1 /**
2 *
3 * Copyright 2004-2006 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.geronimo.plugins.deployment;
19
20 import java.io.File;
21 import java.io.IOException;
22
23 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
24
25 import javax.enterprise.deploy.spi.DeploymentManager;
26 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
27
28 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
29 import org.apache.geronimo.plugin.MojoSupport;
30
31
32
33
34
35 /**
36 * Support for deployment Mojos.
37 *
38 * @version $Rev: 437248 $ $Date: 2006-08-26 16:39:49 -0700 (Sat, 26 Aug 2006) $
39 */
40 public abstract class AbstractModuleMojo extends MojoSupport {
41
42 /**
43 * The uri to look up the JMXConnector.
44 *
45 * @parameter default-value="jmx:rmi://localhost/jndi/rmi:/JMXConnector"
46 */
47 private String uri;
48
49 /**
50 * @parameter
51 */
52 protected String id;
53
54 /**
55 * The uri to connect to the jmx connector with.
56 *
57 * @parameter default-value="deployer:geronimo:jmx"
58 */
59 private String distributeURI;
60
61 /**
62 * The authentication user name.
63 *
64 * @parameter default-value="system"
65 */
66 private String username;
67
68 /**
69 * The authentication password.
70 *
71 * @parameter default-value="manager"
72 */
73 private String password;
74
75 /**
76 * The time between connect attempts.
77 *
78 * @parameter default-value=0
79 */
80 private long sleepTimer;
81
82 /**
83 * @parameter default-value=100
84 */
85 private int maxTries;
86
87 /**
88 * @parameter default-value=2000
89 */
90 private int retryIntervalMilliseconds;
91
92 /**
93 * @parameter default-value=true
94 */
95 private boolean failOnError;
96
97 /**
98 * @parameter
99 */
100 private File outputDirectory;
101
102 /**
103 * @parameter default-value=null
104 */
105 private File resultsLog;
106
107 /**
108 * @return Returns the maxTries.
109 */
110 public int getMaxTries() {
111 return maxTries;
112 }
113
114 /**
115 * @return Returns the retryIntervalMilliseconds.
116 */
117 public int getRetryIntervalMilliseconds() {
118 return retryIntervalMilliseconds;
119 }
120
121 /**
122 * @return Returns the sleepTimer.
123 */
124 public long getSleepTimer() {
125 return sleepTimer;
126 }
127
128 public String getUri() {
129 return uri;
130 }
131
132 public String getDistributeURI() {
133 return distributeURI;
134 }
135
136 public String getUsername() {
137 return username;
138 }
139
140 public String getPassword() {
141 return password;
142 }
143
144 public boolean isFailOnError() {
145 return failOnError;
146 }
147
148 public File getOutputDirectory() {
149 return outputDirectory;
150 }
151
152 protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException {
153
154
155
156
157
158
159
160 new DeploymentFactoryImpl();
161
162 ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
163 try {
164 Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
165 DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
166 return factoryManager.getDeploymentManager(getDistributeURI(), getUsername(), getPassword());
167 }
168 finally {
169 Thread.currentThread().setContextClassLoader(oldcl);
170 }
171 }
172 }