Lines 42-47
Link Here
|
42 |
* made subject to such option by the copyright holder. |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
43 |
*/ |
44 |
package org.netbeans.modules.j2ee.jboss4; |
44 |
package org.netbeans.modules.j2ee.jboss4; |
|
|
45 |
|
45 |
import java.util.Collections; |
46 |
import java.util.Collections; |
46 |
import java.util.Map; |
47 |
import java.util.Map; |
47 |
import java.util.WeakHashMap; |
48 |
import java.util.WeakHashMap; |
Lines 55-60
Link Here
|
55 |
import java.net.URLClassLoader; |
56 |
import java.net.URLClassLoader; |
56 |
import java.util.Locale; |
57 |
import java.util.Locale; |
57 |
import java.util.Properties; |
58 |
import java.util.Properties; |
|
|
59 |
import java.util.concurrent.Callable; |
58 |
import java.util.concurrent.ExecutionException; |
60 |
import java.util.concurrent.ExecutionException; |
59 |
import java.util.logging.Level; |
61 |
import java.util.logging.Level; |
60 |
import java.util.logging.Logger; |
62 |
import java.util.logging.Logger; |
Lines 94-107
Link Here
|
94 |
|
96 |
|
95 |
private InstanceProperties instanceProperties; |
97 |
private InstanceProperties instanceProperties; |
96 |
private boolean needsRestart; |
98 |
private boolean needsRestart; |
97 |
|
99 |
private Boolean as7; |
98 |
/** |
100 |
/** |
99 |
* Stores information about running instances. instance is represented by its InstanceProperties, |
101 |
* Stores information about running instances. instance is represented by its InstanceProperties, |
100 |
* running state by Boolean.TRUE, stopped state Boolean.FALSE. |
102 |
* running state by Boolean.TRUE, stopped state Boolean.FALSE. |
101 |
* WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance. |
103 |
* WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance. |
102 |
*/ |
104 |
*/ |
103 |
private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap()); |
105 |
private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap()); |
104 |
|
106 |
|
105 |
/** Creates a new instance of JBDeploymentManager */ |
107 |
/** Creates a new instance of JBDeploymentManager */ |
106 |
public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) { |
108 |
public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) { |
107 |
realUri = uri; |
109 |
realUri = uri; |
Lines 139-144
Link Here
|
139 |
return instanceProperties; |
141 |
return instanceProperties; |
140 |
} |
142 |
} |
141 |
|
143 |
|
|
|
144 |
/** |
145 |
* This is a handy method to execute the any {@code action} within JBoss's class loader. |
146 |
* |
147 |
* @param action the action to be executed |
148 |
* @return T |
149 |
* @throws ExecutionException |
150 |
*/ |
151 |
public <T> T invokeLocalAction(Callable<T> action) throws Exception { |
152 |
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); |
153 |
try { |
154 |
InstanceProperties ip = getInstanceProperties(); |
155 |
URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip); |
156 |
Thread.currentThread().setContextClassLoader(loader); |
157 |
return action.call(); |
158 |
} finally { |
159 |
Thread.currentThread().setContextClassLoader(oldLoader); |
160 |
} |
161 |
} |
162 |
|
142 |
public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException { |
163 |
public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException { |
143 |
|
164 |
|
144 |
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); |
165 |
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); |
Lines 177-184
Link Here
|
177 |
System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N |
198 |
System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N |
178 |
} |
199 |
} |
179 |
|
200 |
|
180 |
// Gets naming context |
201 |
if (!props.isVersion(JBPluginUtils.JBOSS_7_0_0)) { |
181 |
ctx = new InitialContext(env); |
202 |
// Gets naming context |
|
|
203 |
ctx = new InitialContext(env); |
204 |
} |
182 |
|
205 |
|
183 |
//restore java.security.auth.login.config system property |
206 |
//restore java.security.auth.login.config system property |
184 |
if (oldAuthConf != null) { |
207 |
if (oldAuthConf != null) { |
Lines 189-218
Link Here
|
189 |
|
212 |
|
190 |
MBeanServerConnection rmiServer = null; |
213 |
MBeanServerConnection rmiServer = null; |
191 |
try { |
214 |
try { |
192 |
conn = JMXConnectorFactory.connect(new JMXServiceURL( |
215 |
JMXServiceURL url; |
193 |
"service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi")); |
216 |
if (props.isVersion(JBPluginUtils.JBOSS_7_0_0)) { |
|
|
217 |
// using management-native port |
218 |
url = new JMXServiceURL( |
219 |
System.getProperty("jmx.service.url", "service:jmx:remoting-jmx://localhost:9999")); // NOI18N |
220 |
} else { |
221 |
url = new JMXServiceURL( |
222 |
"service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"); // NOI18N |
223 |
} |
224 |
conn = JMXConnectorFactory.connect(url); |
194 |
|
225 |
|
195 |
rmiServer = conn.getMBeanServerConnection(); |
226 |
rmiServer = conn.getMBeanServerConnection(); |
196 |
} catch (IOException ex) { |
227 |
} catch (IOException ex) { |
197 |
LOGGER.log(Level.FINE, null, ex); |
228 |
LOGGER.log(Level.FINE, null, ex); |
198 |
} |
229 |
} |
199 |
|
230 |
|
200 |
if (rmiServer == null) { |
231 |
if (rmiServer == null && ctx != null) { |
201 |
// Lookup RMI Adaptor |
232 |
// Lookup RMI Adaptor |
202 |
rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N |
233 |
rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N |
203 |
} |
234 |
} |
204 |
|
235 |
|
205 |
JBoss5ProfileServiceProxy profileService = null; |
236 |
JBoss5ProfileServiceProxy profileService = null; |
206 |
try { |
237 |
try { |
207 |
Object service = ctx.lookup("ProfileService"); // NOI18N |
238 |
if (ctx != null) { |
208 |
if (service != null) { |
239 |
Object service = ctx.lookup("ProfileService"); // NOI18N |
209 |
profileService = new JBoss5ProfileServiceProxy(service); |
240 |
if (service != null) { |
|
|
241 |
profileService = new JBoss5ProfileServiceProxy(service); |
242 |
} |
210 |
} |
243 |
} |
211 |
} catch (NameNotFoundException ex) { |
244 |
} catch (NameNotFoundException ex) { |
212 |
LOGGER.log(Level.FINE, null, ex); |
245 |
LOGGER.log(Level.FINE, null, ex); |
213 |
} |
246 |
} |
214 |
|
247 |
|
215 |
return action.action(rmiServer, profileService); |
248 |
if (rmiServer != null) { |
|
|
249 |
return action.action(rmiServer, profileService); |
250 |
} else { |
251 |
throw new IllegalStateException("No rmi server acquired for " + realUri); |
252 |
} |
216 |
} catch (NameNotFoundException ex) { |
253 |
} catch (NameNotFoundException ex) { |
217 |
LOGGER.log(Level.FINE, null, ex); |
254 |
LOGGER.log(Level.FINE, null, ex); |
218 |
throw new ExecutionException(ex); |
255 |
throw new ExecutionException(ex); |
Lines 261-273
Link Here
|
261 |
propertiesToIsRunning.put(ip, isRunning); |
298 |
propertiesToIsRunning.put(ip, isRunning); |
262 |
} |
299 |
} |
263 |
|
300 |
|
|
|
301 |
boolean isAs7() { |
302 |
if (as7 == null) { |
303 |
as7 = getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0); |
304 |
} |
305 |
return as7; |
306 |
} |
264 |
//////////////////////////////////////////////////////////////////////////// |
307 |
//////////////////////////////////////////////////////////////////////////// |
265 |
// DeploymentManager Implementation |
308 |
// DeploymentManager Implementation |
266 |
//////////////////////////////////////////////////////////////////////////// |
309 |
//////////////////////////////////////////////////////////////////////////// |
267 |
public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException { |
310 |
public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException { |
|
|
311 |
if (isAs7()) { |
312 |
return new JB7Deployer(realUri, this).deploy(target, file, file2, getHost(), getPort()); |
313 |
} |
268 |
return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort()); |
314 |
return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort()); |
269 |
} |
315 |
} |
270 |
|
316 |
|
|
|
317 |
public ProgressObject distributeTarget(Target[] target, File file, File file2) throws IllegalStateException { |
318 |
return dm.distribute(target, file, file2); |
319 |
} |
320 |
|
271 |
public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException { |
321 |
public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException { |
272 |
throw new RuntimeException("This method should never be called."); // NOI18N |
322 |
throw new RuntimeException("This method should never be called."); // NOI18N |
273 |
} |
323 |
} |
Lines 292-298
Link Here
|
292 |
return dm.stop(targetModuleID); |
342 |
return dm.stop(targetModuleID); |
293 |
} |
343 |
} |
294 |
|
344 |
|
295 |
public ProgressObject start(TargetModuleID[] targetModuleID) throws IllegalStateException { |
345 |
public ProgressObject start(final TargetModuleID[] targetModuleID) throws IllegalStateException { |
|
|
346 |
if (isAs7()) { |
347 |
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); |
348 |
try { |
349 |
InstanceProperties ip = getInstanceProperties(); |
350 |
URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip); |
351 |
Thread.currentThread().setContextClassLoader(loader); |
352 |
return dm.start(targetModuleID); |
353 |
} finally { |
354 |
Thread.currentThread().setContextClassLoader(oldLoader); |
355 |
} |
356 |
} |
357 |
|
296 |
return dm.start(targetModuleID); |
358 |
return dm.start(targetModuleID); |
297 |
} |
359 |
} |
298 |
|
360 |
|
Lines 305-316
Link Here
|
305 |
} |
367 |
} |
306 |
|
368 |
|
307 |
public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { |
369 |
public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { |
308 |
//return dm.getAvailableModules(moduleType, target); |
370 |
if (isAs7()) { |
|
|
371 |
return dm.getAvailableModules(moduleType, target); |
372 |
} |
309 |
return new TargetModuleID[]{}; |
373 |
return new TargetModuleID[]{}; |
310 |
} |
374 |
} |
311 |
|
375 |
|
312 |
public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { |
376 |
public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { |
313 |
//return dm.getNonRunningModules(moduleType, target); |
377 |
if (isAs7()) { |
|
|
378 |
return dm.getAvailableModules(moduleType, target); |
379 |
} |
314 |
return new TargetModuleID[]{}; |
380 |
return new TargetModuleID[]{}; |
315 |
} |
381 |
} |
316 |
|
382 |
|
Lines 319-324
Link Here
|
319 |
} |
385 |
} |
320 |
|
386 |
|
321 |
public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException { |
387 |
public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException { |
|
|
388 |
if (isAs7()) { |
389 |
return new JB7Deployer(realUri, this).redeploy(targetModuleID, file, file2); |
390 |
} |
322 |
return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2); |
391 |
return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2); |
323 |
} |
392 |
} |
324 |
|
393 |
|