1 package org.codehaus.mojo.jboss;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Iterator;
23
24 import org.apache.maven.plugin.MojoExecutionException;
25
26 /**
27 * ReDeploys a directory or file to JBoss via JMX.
28 *
29 * @author <a href="mailto:jgenender@apache.org">Jeff Genender</a>
30 * @goal redeploy
31 */
32 public class ReDeployMojo
33 extends AbstractJBossDeployerMojo
34 {
35
36 public static final String DEFAULT_REDEPLOY_URL = "/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=redeploy&argType=java.net.URL&arg0=";
37
38 /**
39 * The redeployment URL.
40 *
41 * @parameter
42 */
43 protected String redeployUrlPath;
44
45 /**
46 * Main plugin execution.
47 *
48 * @throws MojoExecutionException
49 */
50 public void doExecute()
51 throws MojoExecutionException
52 {
53
54 // Note: the url path is set here instead of in the parameter default-value because of a parse error
55 // when generating the project site.
56 if ( redeployUrlPath == null )
57 {
58 redeployUrlPath = DEFAULT_REDEPLOY_URL;
59 }
60
61 Iterator iter = fileNames.iterator();
62 while ( iter.hasNext() )
63 {
64 String fileName = (String) iter.next();
65 String fixedFile = null;
66 if ( fileName.toLowerCase().endsWith( "ejb" ) )
67 {
68 // Fix the ejb packaging to a jar
69 fixedFile = fileName.substring( 0, fileName.length() - 3 ) + "jar";
70 }
71 else
72 {
73 fixedFile = fileName;
74 }
75
76 getLog().info( "Reploying " + fixedFile + " to JBoss." );
77 String url = "http://" + hostName + ":" + port + redeployUrlPath + fixedFile;
78 doURL( url );
79 }
80 }
81 }