View | Details | Raw Unified | Return to bug 200132 | Differences between
and this patch

Collapse All | Expand All

(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JB7Deployer.java (+140 lines)
Added Link Here 
1
package org.netbeans.modules.j2ee.jboss4;
2
3
import java.io.File;
4
import java.net.MalformedURLException;
5
import java.net.URL;
6
import java.util.MissingResourceException;
7
import java.util.logging.Level;
8
import java.util.logging.Logger;
9
import javax.enterprise.deploy.shared.ActionType;
10
import javax.enterprise.deploy.shared.CommandType;
11
import javax.enterprise.deploy.shared.ModuleType;
12
import javax.enterprise.deploy.shared.StateType;
13
import javax.enterprise.deploy.spi.Target;
14
import javax.enterprise.deploy.spi.TargetModuleID;
15
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
16
import org.netbeans.modules.j2ee.jboss4.ide.JBDeploymentStatus;
17
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
18
import org.openide.filesystems.FileObject;
19
import org.openide.filesystems.FileUtil;
20
import org.openide.util.NbBundle;
21
22
/**
23
 *
24
 * @author Pragalathan M
25
 */
26
public class JB7Deployer extends JBDeployer {
27
28
    private static final Logger LOGGER = Logger.getLogger(JB7Deployer.class.getName());
29
    protected TargetModuleID deployedModuleID;
30
31
    public JB7Deployer(String serverUri, JBDeploymentManager dm) {
32
        super(serverUri, dm);
33
    }
34
35
    @Override
36
    public void run() {
37
        if (dm == null) {
38
            return;
39
        }
40
        final String deployDir = InstanceProperties.getInstanceProperties(uri).getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
41
        FileObject foIn = FileUtil.toFileObject(file);
42
        FileObject foDestDir = FileUtil.toFileObject(new File(deployDir));
43
        String fileName = file.getName();
44
45
        File toDeploy = new File(deployDir + File.separator + fileName);
46
        if (toDeploy.exists()) {
47
            toDeploy.delete();
48
        }
49
50
        fileName = fileName.substring(0, fileName.lastIndexOf('.'));
51
        String msg = NbBundle.getMessage(JBDeployer.class, "MSG_DEPLOYING", file.getAbsolutePath());
52
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, msg));
53
54
        try {
55
            FileUtil.copyFile(foIn, foDestDir, fileName);
56
            String webUrl = mainModuleID.getWebURL();
57
            if (webUrl == null) {
58
                TargetModuleID[] ch = mainModuleID.getChildTargetModuleID();
59
                if (ch != null) {
60
                    for (int i = 0; i < ch.length; i++) {
61
                        webUrl = ch[i].getWebURL();
62
                        if (webUrl != null) {
63
                            break;
64
                        }
65
                    }
66
                }
67
68
            }
69
            //Deploy file
70
            dm.invokeRemoteAction(new JB7RemoteAction<Void>() {
71
72
                @Override
73
                public Void execute() throws Exception {
74
                    File statusFile = new File(deployDir, file.getName() + ".deployed");
75
76
                    for (int i = 0, limit = (int) TIMEOUT / POLLING_INTERVAL; i < limit && !statusFile.exists(); i++) {
77
                        Thread.sleep(POLLING_INTERVAL);
78
                    }
79
80
                    Target[] targets = dm.getTargets();
81
                    ModuleType moduleType = getModuleType(file.getName().substring(file.getName().lastIndexOf(".") + 1));
82
                    TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
83
                    for (TargetModuleID targetModuleID : modules) {
84
                        if (targetModuleID.getModuleID().equals(mainModuleID.getModuleID())) {
85
                            deployedModuleID = targetModuleID;
86
                            break;
87
                        }
88
                    }
89
                    return null;
90
                }
91
            });
92
93
            if (webUrl != null) {
94
                URL url = new URL(webUrl);
95
                String waitingMsg = NbBundle.getMessage(JBDeployer.class, "MSG_Waiting_For_Url", url);
96
                fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, waitingMsg));
97
            }
98
        } catch (MalformedURLException ex) {
99
            LOGGER.log(Level.INFO, null, ex);
100
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
101
        } catch (MissingResourceException ex) {
102
            LOGGER.log(Level.INFO, null, ex);
103
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
104
        } catch (Exception ex) {
105
            LOGGER.log(Level.INFO, null, ex);
106
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
107
        }
108
109
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.COMPLETED, "Applicaton Deployed"));
110
    }
111
112
    private ModuleType getModuleType(String extension) {
113
        if (extension.equals("war")) {
114
            return ModuleType.WAR;
115
        }
116
117
        if (extension.equals("ear")) {
118
            return ModuleType.EAR;
119
        }
120
121
        if (extension.equals("car")) {
122
            return ModuleType.CAR;
123
        }
124
125
        if (extension.equals("ejb")) {
126
            return ModuleType.EJB;
127
        }
128
129
        if (extension.equals("rar")) {
130
            return ModuleType.RAR;
131
        }
132
        return null;
133
    }
134
135
    @Override
136
    public TargetModuleID[] getResultTargetModuleIDs() {
137
//        return new TargetModuleID[]{mainModuleID};
138
        return new TargetModuleID[]{deployedModuleID};
139
    }
140
}
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeployer.java (-6 / +6 lines)
 Lines 89-105    Link Here 
89
 */
89
 */
90
public class JBDeployer implements ProgressObject, Runnable {
90
public class JBDeployer implements ProgressObject, Runnable {
91
    /** timeout for waiting for URL connection */
91
    /** timeout for waiting for URL connection */
92
    private static final int TIMEOUT = 60000;
92
    protected static final int TIMEOUT = 60000;
93
93
94
    private static final int POLLING_INTERVAL = 1000;
94
    protected  static final int POLLING_INTERVAL = 1000;
95
95
96
    private static final Logger LOGGER = Logger.getLogger(JBDeployer.class.getName());
96
    private static final Logger LOGGER = Logger.getLogger(JBDeployer.class.getName());
97
97
98
    private final JBDeploymentManager dm;
98
    protected final JBDeploymentManager dm;
99
99
100
    private File file;
100
    protected File file;
101
    private String uri;
101
    protected String uri;
102
    private JBTargetModuleID mainModuleID;
102
    protected JBTargetModuleID mainModuleID;
103
103
104
    /** Creates a new instance of JBDeployer */
104
    /** Creates a new instance of JBDeployer */
105
    public JBDeployer(String serverUri, JBDeploymentManager dm) {
105
    public JBDeployer(String serverUri, JBDeploymentManager dm) {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java (-4 / +40 lines)
 Lines 81-87    Link Here 
81
public class JBDeploymentFactory implements DeploymentFactory {
81
public class JBDeploymentFactory implements DeploymentFactory {
82
82
83
    public static final String URI_PREFIX = "jboss-deployer:"; // NOI18N
83
    public static final String URI_PREFIX = "jboss-deployer:"; // NOI18N
84
84
    
85
    private static final String DISCONNECTED_URI = "jboss-deployer:http://localhost:8080&"; // NOI18N
85
    private static final String DISCONNECTED_URI = "jboss-deployer:http://localhost:8080&"; // NOI18N
86
86
87
    private static final Logger LOGGER = Logger.getLogger(JBDeploymentFactory.class.getName());
87
    private static final Logger LOGGER = Logger.getLogger(JBDeploymentFactory.class.getName());
 Lines 156-161    Link Here 
156
                // dom4j.jar library for JBoss Application Server 4.0.5
156
                // dom4j.jar library for JBoss Application Server 4.0.5
157
                domFile = new File(domainRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
157
                domFile = new File(domainRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
158
            }
158
            }
159
160
            String sep = File.separator;
161
            if (!domFile.exists() && "7".equals(JBVer.getMajorNumber())) {
162
                domFile = new File(serverRoot, JBPluginUtils.MODULES + "org" + sep + "dom4j" + sep + "main" + sep + "dom4j-1.6.1.jar"); // NOI18N
163
            }
159
            if (!domFile.exists()) {
164
            if (!domFile.exists()) {
160
                domFile = null;
165
                domFile = null;
161
                LOGGER.log(Level.INFO, "No dom4j.jar availabale on classpath"); // NOI18N
166
                LOGGER.log(Level.INFO, "No dom4j.jar availabale on classpath"); // NOI18N
 Lines 179-185    Link Here 
179
                urlList.add(domFile.toURI().toURL());
184
                urlList.add(domFile.toURI().toURL());
180
            }
185
            }
181
186
182
            if  (version5Above) {
187
            if ("7".equals(JBVer.getMajorNumber())) {
188
                File org = new File(serverRoot, JBPluginUtils.MODULES + "org");
189
                File jboss = new File(org, "jboss");
190
                File as = new File(jboss, "as");
191
                String versionString = JBVer.getMajorNumber()+"."+JBVer.getMinorNumber()+"."+JBVer.getMicroNumber()+"."+JBVer.getUpdate();
192
                
193
                if (domFile.exists()) {
194
                    urlList.add(domFile.toURI().toURL());
195
                }
196
                
197
                urlList.add(new File(serverRoot, "jboss-modules.jar").toURI().toURL());
198
                urlList.add(new File(serverRoot, "bin"+sep+"client"+sep+"jboss-client.jar").toURI().toURL());
199
                urlList.add(new File(jboss, "logging" + sep + "main" + sep + "jboss-logging-3.1.0.GA.jar").toURI().toURL());
200
                urlList.add(new File(jboss, "threads" + sep + "main" + sep + "jboss-threads-2.0.0.GA.jar").toURI().toURL());
201
                urlList.add(new File(jboss, "remoting3" + sep + "main" + sep + "jboss-remoting-3.2.3.GA.jar").toURI().toURL());
202
                urlList.add(new File(jboss, "xnio" + sep + "main" + sep + "xnio-api-3.0.3.GA.jar").toURI().toURL());
203
                urlList.add(new File(jboss, "xnio" + sep + "nio" + sep + "main" + sep + "xnio-nio-3.0.3.GA.jar").toURI().toURL());
204
                urlList.add(new File(jboss, "dmr" + sep + "main"+ sep + "jboss-dmr-1.1.1.Final.jar").toURI().toURL());
205
                urlList.add(new File(jboss, "msc" + sep + "main" + sep + "jboss-msc-1.0.2.GA.jar").toURI().toURL());
206
                urlList.add(new File(jboss, "common-core" + sep + "main" + sep + "jboss-common-core-2.2.17.GA.jar").toURI().toURL());
207
                urlList.add(new File(as, "ee" + sep + "deployment" + sep + "main" + sep + "jboss-as-ee-deployment-" + versionString + ".jar").toURI().toURL());
208
                urlList.add(new File(as, "naming" + sep + "main" + sep + "jboss-as-naming-" + versionString + ".jar").toURI().toURL());
209
                urlList.add(new File(as, "controller-client" + sep + "main" + sep + "jboss-as-controller-client-" + versionString + ".jar").toURI().toURL());
210
                urlList.add(new File(as, "protocol" + sep + "main" + sep + "jboss-as-protocol-" + versionString + ".jar").toURI().toURL());
211
            } else if (version5Above) {
183
                // get lient class path for Jboss 5.0
212
                // get lient class path for Jboss 5.0
184
                List<URL> clientClassUrls = JBPluginUtils.getJB5ClientClasspath(
213
                List<URL> clientClassUrls = JBPluginUtils.getJB5ClientClasspath(
185
                        serverRoot);
214
                        serverRoot);
 Lines 274-282    Link Here 
274
                    jbossFactory = (DeploymentFactory) FACTORIES_CACHE.get(ip);
303
                    jbossFactory = (DeploymentFactory) FACTORIES_CACHE.get(ip);
275
                }
304
                }
276
                if (jbossFactory == null) {
305
                if (jbossFactory == null) {
306
                    Version version = JBPluginUtils.getServerVersion(new File(jbossRoot));
277
                    URLClassLoader loader = (ip != null) ? getJBClassLoader(ip) : createJBClassLoader(jbossRoot, domainRoot);
307
                    URLClassLoader loader = (ip != null) ? getJBClassLoader(ip) : createJBClassLoader(jbossRoot, domainRoot);
278
                    jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N
308
                    if(version!= null && "7".equals(version.getMajorNumber())) {
279
309
                        Class<?> c = loader.loadClass("org.jboss.as.ee.deployment.spi.factories.DeploymentFactoryImpl");
310
                        c.getMethod("register").invoke(null);
311
                        jbossFactory = (DeploymentFactory) c.newInstance();//NOI18N
312
                    } else {
313
                        jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N
314
                    }
315
                    
280
                    
316
                    
281
                    if (ip != null) {
317
                    if (ip != null) {
282
                        FACTORIES_CACHE.put(ip, jbossFactory);
318
                        FACTORIES_CACHE.put(ip, jbossFactory);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java (-13 / +77 lines)
 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 94-107    Link Here 
94
95
95
    private InstanceProperties instanceProperties;
96
    private InstanceProperties instanceProperties;
96
    private boolean needsRestart;
97
    private boolean needsRestart;
97
98
    private Boolean as7;
98
    /**
99
    /**
99
     * Stores information about running instances. instance is represented by its InstanceProperties,
100
     * Stores information about running instances. instance is represented by its InstanceProperties,
100
     *  running state by Boolean.TRUE, stopped state Boolean.FALSE.
101
     *  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.
102
     * WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance.
102
     */
103
     */
103
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
104
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
104
    
105
105
    /** Creates a new instance of JBDeploymentManager */
106
    /** Creates a new instance of JBDeploymentManager */
106
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
107
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
107
        realUri = uri;
108
        realUri = uri;
 Lines 139-144    Link Here 
139
        return instanceProperties;
140
        return instanceProperties;
140
    }
141
    }
141
142
143
    /**
144
     * This is a handy method to execute the any {@code action} within JBoss's class loader.
145
     *
146
     * @param action the action to be executed
147
     * @return T
148
     * @throws ExecutionException
149
     */
150
    public <T> T invokeRemoteAction(JB7RemoteAction<T> action) throws Exception {
151
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
152
        try {
153
            InstanceProperties ip = getInstanceProperties();
154
            URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip);
155
            Thread.currentThread().setContextClassLoader(loader);
156
            return action.execute();
157
        } finally {
158
            Thread.currentThread().setContextClassLoader(oldLoader);
159
        }
160
    }
161
142
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
162
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
143
163
144
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
164
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
 Lines 177-184    Link Here 
177
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
197
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
178
            }
198
            }
179
199
180
            // Gets naming context
200
            if (!props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
181
            ctx = new InitialContext(env);
201
                // Gets naming context
202
                ctx = new InitialContext(env);
203
            }
182
204
183
            //restore java.security.auth.login.config system property
205
            //restore java.security.auth.login.config system property
184
            if (oldAuthConf != null) {
206
            if (oldAuthConf != null) {
 Lines 189-211    Link Here 
189
211
190
            MBeanServerConnection rmiServer = null;
212
            MBeanServerConnection rmiServer = null;
191
            try {
213
            try {
192
                conn = JMXConnectorFactory.connect(new JMXServiceURL(
214
                JMXServiceURL url;
193
                        "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"));
215
                if (props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
216
                    // using management-native port
217
                    url = new JMXServiceURL(
218
                            System.getProperty("jmx.service.url", "service:jmx:remoting-jmx://localhost:9999")); // NOI18N
219
                } else {
220
                    url = new JMXServiceURL(
221
                            "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"); // NOI18N
222
                }
223
                conn = JMXConnectorFactory.connect(url);
194
224
195
                rmiServer = conn.getMBeanServerConnection();
225
                rmiServer = conn.getMBeanServerConnection();
196
            } catch (IOException ex) {
226
            } catch (IOException ex) {
197
                LOGGER.log(Level.FINE, null, ex);
227
                LOGGER.log(Level.FINE, null, ex);
198
            }
228
            }
199
229
200
            if (rmiServer == null) {
230
            if (rmiServer == null && ctx != null) {
201
                // Lookup RMI Adaptor
231
                // Lookup RMI Adaptor
202
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
232
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
203
            }
233
            }
204
234
205
            JBoss5ProfileServiceProxy profileService = null;
235
            JBoss5ProfileServiceProxy profileService = null;
206
            Object service = ctx.lookup("ProfileService"); // NOI18N
236
            if (ctx != null) {
207
            if (service != null) {
237
                Object service = ctx.lookup("ProfileService"); // NOI18N
208
                profileService = new JBoss5ProfileServiceProxy(service);
238
                if (service != null) {
239
                    profileService = new JBoss5ProfileServiceProxy(service);
240
                }
209
            }
241
            }
210
242
211
            return action.action(rmiServer, profileService);
243
            return action.action(rmiServer, profileService);
 Lines 257-269    Link Here 
257
        propertiesToIsRunning.put(ip, isRunning);
289
        propertiesToIsRunning.put(ip, isRunning);
258
    }
290
    }
259
291
292
    boolean isAs7() {
293
        if (as7 == null) {
294
            as7 = getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
295
        }
296
        return as7;
297
    }
260
    ////////////////////////////////////////////////////////////////////////////
298
    ////////////////////////////////////////////////////////////////////////////
261
    // DeploymentManager Implementation
299
    // DeploymentManager Implementation
262
    ////////////////////////////////////////////////////////////////////////////
300
    ////////////////////////////////////////////////////////////////////////////
263
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
301
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
302
        if (isAs7()) {
303
            return new JB7Deployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
304
        }
264
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
305
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
265
    }
306
    }
266
307
308
    public ProgressObject distributeTarget(Target[] target, File file, File file2) throws IllegalStateException {
309
        return dm.distribute(target, file, file2);
310
    }
311
267
    public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException {
312
    public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException {
268
        throw new RuntimeException("This method should never be called."); // NOI18N
313
        throw new RuntimeException("This method should never be called."); // NOI18N
269
    }
314
    }
 Lines 288-294    Link Here 
288
        return dm.stop(targetModuleID);
333
        return dm.stop(targetModuleID);
289
    }
334
    }
290
335
291
    public ProgressObject start(TargetModuleID[] targetModuleID) throws IllegalStateException {
336
    public ProgressObject start(final TargetModuleID[] targetModuleID) throws IllegalStateException {
337
        if (isAs7()) {
338
            ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
339
            try {
340
                InstanceProperties ip = getInstanceProperties();
341
                URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip);
342
                Thread.currentThread().setContextClassLoader(loader);
343
                return dm.start(targetModuleID);
344
            } finally {
345
                Thread.currentThread().setContextClassLoader(oldLoader);
346
            }
347
        }
348
292
        return dm.start(targetModuleID);
349
        return dm.start(targetModuleID);
293
    }
350
    }
294
351
 Lines 301-312    Link Here 
301
    }
358
    }
302
359
303
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
360
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
304
        //return dm.getAvailableModules(moduleType, target);
361
        if (isAs7()) {
362
            return dm.getAvailableModules(moduleType, target);
363
        }
305
        return new TargetModuleID[]{};
364
        return new TargetModuleID[]{};
306
    }
365
    }
307
366
308
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
367
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
309
        //return dm.getNonRunningModules(moduleType, target);
368
        if (isAs7()) {
369
            return dm.getAvailableModules(moduleType, target);
370
        }
310
        return new TargetModuleID[]{};
371
        return new TargetModuleID[]{};
311
    }
372
    }
312
373
 Lines 315-320    Link Here 
315
    }
376
    }
316
377
317
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
378
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
379
        if (isAs7()) {
380
            return new JB7Deployer(realUri, this).redeploy(targetModuleID, file, file2);
381
        }
318
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
382
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
319
    }
383
    }
320
384
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java (-2 / +3 lines)
 Lines 309-318    Link Here 
309
                    || line.indexOf("Starting JBossAS") > -1) { // JBoss 6.0 message // NOI18N
309
                    || line.indexOf("Starting JBossAS") > -1) { // JBoss 6.0 message // NOI18N
310
                LOGGER.log(Level.FINER, "STARTING message fired"); // NOI18N
310
                LOGGER.log(Level.FINER, "STARTING message fired"); // NOI18N
311
                //fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N
311
                //fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N
312
            } else if ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N
312
            } else if ( ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N
313
                    || line.indexOf("JBoss (Microcontainer)") > -1 // JBoss 5.0 message // NOI18N
313
                    || line.indexOf("JBoss (Microcontainer)") > -1 // JBoss 5.0 message // NOI18N
314
                    || line.indexOf("JBossAS") > -1) // JBoss 6.0 message // NOI18N
314
                    || line.indexOf("JBossAS") > -1) // JBoss 6.0 message // NOI18N
315
                    && line.indexOf("Started in") > -1) { // NOI18N
315
                    && line.indexOf("Started in") > -1) 
316
                    || line.indexOf("JBoss AS") > -1 && line.indexOf("started in") > -1) { // NOI18N
316
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
317
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
317
318
318
                synchronized (JBOutputSupport.this) {
319
                synchronized (JBOutputSupport.this) {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java (-3 / +11 lines)
 Lines 100-107    Link Here 
100
100
101
    private final static String STARTUP_SH = File.separator + 
101
    private final static String STARTUP_SH = File.separator + 
102
            "bin" + File.separator + "run.sh";          // NOI18N
102
            "bin" + File.separator + "run.sh";          // NOI18N
103
    private final static String STANDALONE_SH = File.separator + 
104
            "bin" + File.separator + "standalone.sh";          // NOI18N
103
    private final static String STARTUP_BAT = File.separator + 
105
    private final static String STARTUP_BAT = File.separator + 
104
            "bin" + File.separator + RUN_FILE_NAME;     // NOI18N
106
            "bin" + File.separator + RUN_FILE_NAME;     // NOI18N
107
    private final static String STANDALONE_BAT = File.separator + 
108
            "bin" + File.separator + "standalone.bat";     // NOI18N
105
                             
109
                             
106
    private final static String CONF_BAT = File.separator + 
110
    private final static String CONF_BAT = File.separator + 
107
            "bin" + File.separator + CONF_FILE_NAME;    // NOI18N
111
            "bin" + File.separator + CONF_FILE_NAME;    // NOI18N
 Lines 316-322    Link Here 
316
320
317
        final String instanceName = ip.getProperty(JBPluginProperties.PROPERTY_SERVER);
321
        final String instanceName = ip.getProperty(JBPluginProperties.PROPERTY_SERVER);
318
        String args = ("all".equals(instanceName) ? "-b 127.0.0.1 " : "") + "-c " + instanceName; // NOI18N
322
        String args = ("all".equals(instanceName) ? "-b 127.0.0.1 " : "") + "-c " + instanceName; // NOI18N
319
        return new NbProcessDescriptor(serverRunFileName, args);
323
        return new NbProcessDescriptor(serverRunFileName, isJBoss7()? "" : args);
320
    }
324
    }
321
    
325
    
322
    private String getRunFileName( InstanceProperties ip, String[] envp ){
326
    private String getRunFileName( InstanceProperties ip, String[] envp ){
 Lines 351-363    Link Here 
351
            Logger.getLogger("global").log(Level.INFO, null, ioe);
355
            Logger.getLogger("global").log(Level.INFO, null, ioe);
352
356
353
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
357
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
354
            final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
358
            final String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
355
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
359
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
356
360
357
            return null;
361
            return null;
358
        }
362
        }
359
    }
363
    }
360
    
364
    
365
    private boolean isJBoss7() {
366
        return dm.getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
367
    }
368
    
361
    private InputOutput openConsole() {
369
    private InputOutput openConsole() {
362
        InputOutput io = UISupport.getServerIO(dm.getUrl());
370
        InputOutput io = UISupport.getServerIO(dm.getUrl());
363
        if (io == null) {
371
        if (io == null) {
 Lines 414-420    Link Here 
414
            String serverLocation = getProperties().getProperty(
422
            String serverLocation = getProperties().getProperty(
415
                    JBPluginProperties.PROPERTY_ROOT_DIR);
423
                    JBPluginProperties.PROPERTY_ROOT_DIR);
416
            String serverRunFileName = serverLocation + 
424
            String serverRunFileName = serverLocation + 
417
                (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
425
                    (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
418
            if ( needChange ){
426
            if ( needChange ){
419
                String contentRun = readFile(serverRunFileName);
427
                String contentRun = readFile(serverRunFileName);
420
                String contentConf = readFile(serverLocation + CONF_BAT);
428
                String contentConf = readFile(serverLocation + CONF_BAT);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java (-14 / +26 lines)
 Lines 75-80    Link Here 
75
import javax.management.MBeanServerConnection;
75
import javax.management.MBeanServerConnection;
76
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
76
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
77
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
77
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
78
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
79
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version;
78
import org.openide.util.NbBundle;
80
import org.openide.util.NbBundle;
79
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
81
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
80
82
 Lines 249-270    Link Here 
249
251
250
                        @Override
252
                        @Override
251
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
253
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
252
                            Object serverName = Util.getMBeanParameter(connection, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
254
                            Object serverName = null;
253
                            Object serverHome = Util.getMBeanParameter(connection, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
255
                            Object serverHome = null;
254
                            boolean isJBoss6 = serverHome != null;
256
                            if (dm.getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0)) {
255
                            if (!isJBoss6) {
257
                                serverHome = Util.getMBeanParameter(connection, "baseDir", "jboss.as:core-service=server-environment"); //NOI18N
256
                                serverHome = Util.getMBeanParameter(connection, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
258
                                serverName = Util.getMBeanParameter(connection, "launchType", "jboss.as:core-service=server-environment"); //NOI18N
257
                            }
259
                                if (serverName != null) {
258
                            try {
260
                                    serverName = serverName.toString().toLowerCase();
259
                                if (serverHome != null) {
261
                                }
260
                                    if (isJBoss6) {
262
                            } else {
261
                                        serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
263
                                serverName = Util.getMBeanParameter(connection, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
262
                                    } else {
264
                                serverHome = Util.getMBeanParameter(connection, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
263
                                        serverHome = ((File) serverHome).getAbsolutePath();
265
                                boolean isJBoss6 = serverHome != null;
266
                                if (!isJBoss6) {
267
                                    serverHome = Util.getMBeanParameter(connection, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
268
                                }
269
                                try {
270
                                    if (serverHome != null) {
271
                                        if (isJBoss6) {
272
                                            serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
273
                                        } else {
274
                                            serverHome = ((File) serverHome).getAbsolutePath();
275
                                        }
264
                                    }
276
                                    }
277
                                } catch (URISyntaxException use) {
278
                                    LOGGER.log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
265
                                }
279
                                }
266
                            } catch (URISyntaxException use) {
267
                                LOGGER.log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
268
                            }
280
                            }
269
281
270
                            if (serverName == null || serverHome == null) {
282
                            if (serverName == null || serverHome == null) {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java (-3 / +13 lines)
 Lines 77-83    Link Here 
77
    private static final Logger LOGGER = Logger.getLogger(JBStopRunnable.class.getName());
77
    private static final Logger LOGGER = Logger.getLogger(JBStopRunnable.class.getName());
78
    
78
    
79
    private static final String SHUTDOWN_SH = "/bin/shutdown.sh"; // NOI18N
79
    private static final String SHUTDOWN_SH = "/bin/shutdown.sh"; // NOI18N
80
    private static final String JBOSS_CLI_SH = "/bin/jboss-cli.sh"; // NOI18N
80
    private static final String SHUTDOWN_BAT = "/bin/shutdown.bat"; // NOI18N
81
    private static final String SHUTDOWN_BAT = "/bin/shutdown.bat"; // NOI18N
82
    private static final String JBOSS_CLI_BAT = "/bin/jboss-cli.bat"; // NOI18N
81
83
82
    private static final int TIMEOUT = 300000;
84
    private static final int TIMEOUT = 300000;
83
    
85
    
 Lines 89-94    Link Here 
89
        this.startServer = startServer;
91
        this.startServer = startServer;
90
    }
92
    }
91
    
93
    
94
    private boolean isJBoss7() {
95
        return dm.getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
96
    }
97
    
92
    private String[] createEnvironment() {
98
    private String[] createEnvironment() {
93
        
99
        
94
        JBProperties properties = dm.getProperties();
100
        JBProperties properties = dm.getProperties();
 Lines 120-126    Link Here 
120
        String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
126
        String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
121
127
122
        String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
128
        String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
123
        String serverStopFileName = serverLocation + (Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH);
129
        String serverStopFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? JBOSS_CLI_BAT : JBOSS_CLI_SH :Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH);
124
130
125
        File serverStopFile = new File(serverStopFileName);
131
        File serverStopFile = new File(serverStopFileName);
126
        if (!serverStopFile.exists()){
132
        if (!serverStopFile.exists()){
 Lines 131-136    Link Here 
131
        JBProperties properties = dm.getProperties();
137
        JBProperties properties = dm.getProperties();
132
        StringBuilder additionalParams = new StringBuilder(32);
138
        StringBuilder additionalParams = new StringBuilder(32);
133
        int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR));  
139
        int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR));  
140
        NbProcessDescriptor pd;
141
        if(isJBoss7()) {
142
            pd = new NbProcessDescriptor(serverStopFileName, "--connect --command=:shutdown"); // NOI18N
143
        } else {
134
        if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) {
144
        if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) {
135
            additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N
145
            additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N
136
        } else {
146
        } else {
 Lines 150-158    Link Here 
150
160
151
        /* 2008-09-10 The usage of --halt doesn't solve the problem on Windows; it even creates another problem
161
        /* 2008-09-10 The usage of --halt doesn't solve the problem on Windows; it even creates another problem
152
                        of NB Profiler not being notified about the fact that the server was stopped */
162
                        of NB Profiler not being notified about the fact that the server was stopped */
153
        NbProcessDescriptor pd = new NbProcessDescriptor(
163
            pd = new NbProcessDescriptor(
154
                serverStopFileName, "--shutdown " + additionalParams); // NOI18N
164
                serverStopFileName, "--shutdown " + additionalParams); // NOI18N
155
165
        }
156
        Process stoppingProcess = null;
166
        Process stoppingProcess = null;
157
        try {
167
        try {
158
            String envp[] = createEnvironment();
168
            String envp[] = createEnvironment();
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties (-2 / +2 lines)
 Lines 56-64    Link Here 
56
56
57
LBL_BrowseButton=Br&owse...
57
LBL_BrowseButton=Br&owse...
58
58
59
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 6, 5 or 4 Location
59
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 7, 6, 5 or 4 Location
60
60
61
MSG_SpecifyServerLocation=Please specify JBoss Application Server 6, 5 or 4 Location
61
MSG_SpecifyServerLocation=Please specify JBoss Application Server 7, 6, 5 or 4 Location
62
62
63
LBL_ChooserName=Choose JBoss Server Location
63
LBL_ChooserName=Choose JBoss Server Location
64
64
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java (-4 / +14 lines)
 Lines 146-160    Link Here 
146
        Set result = new HashSet();
146
        Set result = new HashSet();
147
        
147
        
148
        String displayName =  (String)wizard.getProperty(PROP_DISPLAY_NAME);
148
        String displayName =  (String)wizard.getProperty(PROP_DISPLAY_NAME);
149
        
149
        JBPluginUtils.Version version = JBPluginUtils.getServerVersion(new File(installLocation));
150
        String url = JBDeploymentFactory.URI_PREFIX + host + ":" + port;    // NOI18N
150
        String url = JBDeploymentFactory.URI_PREFIX;
151
        if(version != null && "7".equals(version.getMajorNumber())){
152
            url += "//"+host + ":" + port+"?targetType=as7&serverPort="+port;    // NOI18N
153
        } else {
154
            url += host + ":" + port;    // NOI18N
155
        }
151
        if (server != null && !server.equals(""))                           // NOI18N
156
        if (server != null && !server.equals(""))                           // NOI18N
152
            url += "#" + server;                                            // NOI18N
157
            url += "#" + server;                                            // NOI18N
153
        url += "&"+ installLocation;                                        // NOI18N
158
        url += "&"+ installLocation;                                        // NOI18N
154
      
159
      
155
        try {
160
        try {
156
            JBPluginUtils.Version version = JBPluginUtils.getServerVersion(new File(installLocation));
157
158
            Map<String, String> initialProperties = new HashMap<String, String>();
161
            Map<String, String> initialProperties = new HashMap<String, String>();
159
            initialProperties.put(JBPluginProperties.PROPERTY_SERVER, server);
162
            initialProperties.put(JBPluginProperties.PROPERTY_SERVER, server);
160
            initialProperties.put(JBPluginProperties.PROPERTY_DEPLOY_DIR, deployDir);
163
            initialProperties.put(JBPluginProperties.PROPERTY_DEPLOY_DIR, deployDir);
 Lines 286-291    Link Here 
286
    private String deployDir;
289
    private String deployDir;
287
    private String serverPath;
290
    private String serverPath;
288
    
291
    
292
    public void setPassword(String password) {
293
        this.password = password;
294
    }
295
296
    public void setUserName(String userName) {
297
        this.userName = userName;
298
    }
289
    
299
    
290
    public void setHost(String host){
300
    public void setHost(String host){
291
        this.host = host.trim();
301
        this.host = host.trim();
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java (-15 / +91 lines)
 Lines 91-96    Link Here 
91
    public static final Version JBOSS_5_0_1 = new Version("5.0.1"); // NOI18N
91
    public static final Version JBOSS_5_0_1 = new Version("5.0.1"); // NOI18N
92
92
93
    public static final Version JBOSS_6_0_0 = new Version("6.0.0"); // NOI18N
93
    public static final Version JBOSS_6_0_0 = new Version("6.0.0"); // NOI18N
94
95
    public static final Version JBOSS_7_0_0 = new Version("7.0.0"); // NOI18N
94
    
96
    
95
    private static final Logger LOGGER = Logger.getLogger(JBPluginUtils.class.getName());
97
    private static final Logger LOGGER = Logger.getLogger(JBPluginUtils.class.getName());
96
98
 Lines 98-103    Link Here 
98
100
99
    public static final String LIB = "lib" + File.separator;
101
    public static final String LIB = "lib" + File.separator;
100
102
103
    public static final String MODULES = "modules" + File.separator;
104
101
    public static final String CLIENT = "client" + File.separator;
105
    public static final String CLIENT = "client" + File.separator;
102
106
103
    public static final String COMMON = "common" + File.separator;
107
    public static final String COMMON = "common" + File.separator;
 Lines 195-200    Link Here 
195
        return domainRequirements6x;
199
        return domainRequirements6x;
196
    }
200
    }
197
201
202
    private static List<String> domainRequirements7x;
203
204
    private static synchronized List<String> getDomainRequirements7x() {
205
        if (domainRequirements7x == null) {
206
            domainRequirements7x = new ArrayList<String>(11);
207
            Collections.addAll(domainRequirements7x,
208
                    "configuration", // NOI18N
209
                    "deployments", // NOI18N
210
                    "lib" // NOI18N
211
                    );
212
        }
213
        return domainRequirements7x;
214
    }
215
216
198
    //--------------- checking for possible server directory -------------
217
    //--------------- checking for possible server directory -------------
199
    private static List<String> serverRequirements4x;
218
    private static List<String> serverRequirements4x;
200
219
 Lines 249-254    Link Here 
249
        return serverRequirements5And6x;
268
        return serverRequirements5And6x;
250
    }
269
    }
251
270
271
    private static List<String> serverRequirements7x;
272
    private static synchronized List<String> getServerRequirements7x() {
273
        if (serverRequirements7x == null) {
274
            serverRequirements7x = new ArrayList<String>(6);
275
            Collections.addAll(serverRequirements7x,
276
                    "bin", // NOI18N
277
                    "modules", // NOI18N
278
                    "jboss-modules.jar"); // NOI18N
279
        }
280
        return serverRequirements7x;
281
    }
282
252
    //------------  getting exists servers---------------------------
283
    //------------  getting exists servers---------------------------
253
    /**
284
    /**
254
     * returns Hashmap
285
     * returns Hashmap
 Lines 262-275    Link Here 
262
        File serverDirectory = new File(serverLocation);
293
        File serverDirectory = new File(serverLocation);
263
294
264
        if (isGoodJBServerLocation(serverDirectory)) {
295
        if (isGoodJBServerLocation(serverDirectory)) {
265
           File file = new File(serverLocation + File.separator + "server");  // NOI18N
296
            Version version = getServerVersion(serverDirectory);            
266
297
            File file;
267
            String[] files = file.list(new FilenameFilter(){
298
            String[] files;
268
                public boolean accept(File dir, String name){
299
            if("7".equals(version.getMajorNumber())) {
269
                    if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true;
300
                files = new String[]{"standalone", "domain"};
270
                    return false;
301
                file = serverDirectory;
271
                }
302
            } else {
272
            });
303
                file = new File(serverLocation + File.separator + "server");  // NOI18N
304
                files = file.list(new FilenameFilter(){
305
                    @Override
306
                    public boolean accept(File dir, String name){
307
                        if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true;
308
                        return false;
309
                    }
310
                });
311
            }
273
312
274
            for(int i = 0; i<files.length; i++) {
313
            for(int i = 0; i<files.length; i++) {
275
                String path = file.getAbsolutePath() + File.separator + files[i];
314
                String path = file.getAbsolutePath() + File.separator + files[i];
 Lines 319-337    Link Here 
319
        return isGoodJBInstanceLocation(candidate, getDomainRequirements6x());
358
        return isGoodJBInstanceLocation(candidate, getDomainRequirements6x());
320
    }
359
    }
321
360
361
    private static boolean isGoodJBInstanceLocation7x(File serverDir, File candidate){
362
        return isGoodJBInstanceLocation(candidate, getDomainRequirements7x());
363
    }
364
322
    public static boolean isGoodJBInstanceLocation(File serverDir, File candidate){
365
    public static boolean isGoodJBInstanceLocation(File serverDir, File candidate){
323
        Version version = getServerVersion(serverDir);
366
        Version version = getServerVersion(serverDir);
324
        if (version == null || (!"4".equals(version.getMajorNumber())
367
        if (version == null || (!"4".equals(version.getMajorNumber())
325
                && !"5".equals(version.getMajorNumber()) // NOI18N
368
                && !"5".equals(version.getMajorNumber()) // NOI18N
326
                && !"6".equals(version.getMajorNumber()))) { // NOI18N
369
                && !"6".equals(version.getMajorNumber()) // NOI18N
370
                && !"7".equals(version.getMajorNumber()))) { // NOI18N
327
            return JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)
371
            return JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)
328
                    || JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)
372
                    || JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)
329
                    || JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate);
373
                    || JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)
374
                    || JBPluginUtils.isGoodJBInstanceLocation7x(serverDir, candidate);
330
        }
375
        }
331
376
332
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)) // NOI18N
377
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)) // NOI18N
333
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)) // NOI18N
378
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)) // NOI18N
334
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)); // NOI18N
379
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)) // NOI18N
380
                || ("7".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation7x(serverDir, candidate)); // NOI18N
335
    }
381
    }
336
382
337
    private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){
383
    private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){
 Lines 372-390    Link Here 
372
        return isGoodJBServerLocation(candidate, getServerRequirements5And6x());
418
        return isGoodJBServerLocation(candidate, getServerRequirements5And6x());
373
    }
419
    }
374
420
421
    private static boolean isGoodJBServerLocation7x(File candidate){
422
        return isGoodJBServerLocation(candidate, getServerRequirements7x());
423
    }
424
375
    public static boolean isGoodJBServerLocation(File candidate) {
425
    public static boolean isGoodJBServerLocation(File candidate) {
376
        Version version = getServerVersion(candidate);
426
        Version version = getServerVersion(candidate);
377
        if (version == null || (!"4".equals(version.getMajorNumber())
427
        if (version == null || (!"4".equals(version.getMajorNumber())
378
                && !"5".equals(version.getMajorNumber())
428
                && !"5".equals(version.getMajorNumber())
379
                && !"6".equals(version.getMajorNumber()))) { // NOI18N
429
                && !"6".equals(version.getMajorNumber())
430
                && !"7".equals(version.getMajorNumber()))) { // NOI18N
380
            return JBPluginUtils.isGoodJBServerLocation4x(candidate)
431
            return JBPluginUtils.isGoodJBServerLocation4x(candidate)
381
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
432
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
382
                    || JBPluginUtils.isGoodJBServerLocation6x(candidate);
433
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
434
                    || JBPluginUtils.isGoodJBServerLocation7x(candidate);
383
        }
435
        }
384
436
385
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation4x(candidate)) // NOI18n
437
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation4x(candidate)) // NOI18n
386
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation5x(candidate)) // NOI18N
438
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation5x(candidate)) // NOI18N
387
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)); // NOI18N
439
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)) // NOI18N
440
                || ("7".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation7x(candidate)); // NOI18N
388
    }
441
    }
389
442
390
    public static boolean isJB4(JBDeploymentManager dm) {
443
    public static boolean isJB4(JBDeploymentManager dm) {
 Lines 435-440    Link Here 
435
     *
488
     *
436
     */
489
     */
437
    public static String getDeployDir(String domainDir){
490
    public static String getDeployDir(String domainDir){
491
        Version version = JBPluginUtils.getServerVersion(new File(JBPluginProperties.getInstance().getInstallLocation()));
492
        if("7".equals(version.getMajorNumber())) {
493
            return domainDir + File.separator + "deployments"; //NOI18N
494
        }
438
        return domainDir + File.separator + "deploy"; //NOI18N
495
        return domainDir + File.separator + "deploy"; //NOI18N
439
        //todo: get real deploy path
496
        //todo: get real deploy path
440
    }
497
    }
 Lines 659-665    Link Here 
659
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
716
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
660
717
661
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
718
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
662
        return getVersion(systemJarFile);
719
        Version version = getVersion(systemJarFile);
720
        if(version == null) {
721
            // check for JBoss AS 7
722
            File serverDir = new File(serverPath, "modules/org/jboss/as/server/main");
723
            for (File jarFile : serverDir.listFiles(new JarFileFilter())) {
724
                version = getVersion(jarFile);
725
                if(version != null) {
726
                    break;
727
    }
728
            }
729
        }
730
        return version;
731
    }
732
733
    static class JarFileFilter implements FilenameFilter {
734
735
        @Override
736
        public boolean accept(File dir, String name) {
737
            return name.endsWith(".jar");
738
        }
663
    }
739
    }
664
740
665
    private static Version getVersion(File systemJarFile) {
741
    private static Version getVersion(File systemJarFile) {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBAbilitiesSupport.java (-2 / +12 lines)
 Lines 44-50    Link Here 
44
 *
44
 *
45
 * @author Petr Hejl
45
 * @author Petr Hejl
46
 */
46
 */
47
class JBAbilitiesSupport {
47
public class JBAbilitiesSupport {
48
48
49
    private final Lookup lookup;
49
    private final Lookup lookup;
50
50
 Lines 54-59    Link Here 
54
    
54
    
55
    private Boolean isJB6x = null;
55
    private Boolean isJB6x = null;
56
56
57
    private Boolean isJB7x= null;
58
    
57
    /**
59
    /**
58
     * Constructs the JBAbilitiesSupport.
60
     * Constructs the JBAbilitiesSupport.
59
     *
61
     *
 Lines 101-106    Link Here 
101
            isJB6x = version != null && JBPluginUtils.JBOSS_6_0_0.compareTo(version) <= 0;
103
            isJB6x = version != null && JBPluginUtils.JBOSS_6_0_0.compareTo(version) <= 0;
102
        }
104
        }
103
        return isJB6x;
105
        return isJB6x;
106
    }  
107
    
108
    public boolean isJB7x() {
109
        if (isJB7x == null) {
110
            JBDeploymentManager dm = lookup.lookup(JBDeploymentManager.class);
111
            Version version = dm.getProperties().getServerVersion();
112
            isJB7x = version != null && JBPluginUtils.JBOSS_7_0_0.compareTo(version) <= 0;
113
        }
114
        return isJB7x;
104
    }    
115
    }    
105
106
}
116
}
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBEarApplicationsChildren.java (-50 / +100 lines)
 Lines 45-66    Link Here 
45
package org.netbeans.modules.j2ee.jboss4.nodes;
45
package org.netbeans.modules.j2ee.jboss4.nodes;
46
46
47
import java.lang.reflect.Method;
47
import java.lang.reflect.Method;
48
import java.util.Iterator;
48
import java.util.*;
49
import java.util.Set;
50
import java.util.Vector;
51
import java.util.concurrent.ExecutionException;
49
import java.util.concurrent.ExecutionException;
52
import java.util.logging.Level;
50
import java.util.logging.Level;
53
import java.util.logging.Logger;
51
import java.util.logging.Logger;
52
import javax.enterprise.deploy.shared.ModuleType;
53
import javax.enterprise.deploy.spi.Target;
54
import javax.enterprise.deploy.spi.TargetModuleID;
55
import javax.enterprise.deploy.spi.exceptions.TargetException;
54
import javax.management.MBeanServerConnection;
56
import javax.management.MBeanServerConnection;
55
import javax.management.ObjectInstance;
57
import javax.management.ObjectInstance;
56
import javax.management.ObjectName;
58
import javax.management.ObjectName;
57
import javax.management.QueryExp;
59
import javax.management.QueryExp;
60
import org.netbeans.modules.j2ee.jboss4.JB7RemoteAction;
58
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
61
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
59
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
62
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
60
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
63
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
61
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
64
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
62
import org.openide.nodes.Children;
65
import org.openide.nodes.Children;
63
import org.openide.nodes.Node;
66
import org.openide.nodes.Node;
67
import org.openide.util.Exceptions;
64
import org.openide.util.Lookup;
68
import org.openide.util.Lookup;
65
import org.openide.util.RequestProcessor;
69
import org.openide.util.RequestProcessor;
66
70
 Lines 83-157    Link Here 
83
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
87
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
84
    }
88
    }
85
89
86
    public void updateKeys(){
90
    @Override
87
        setKeys(new Object[] {Util.WAIT_NODE});
91
    public void updateKeys() {
92
        setKeys(new Object[]{Util.WAIT_NODE});
93
        RequestProcessor.getDefault().post(abilitiesSupport.isJB7x() ? new JBoss7EarApplicationNodeUpdater() : new JBossEarApplicationNodeUpdater(), 0);
94
    }
88
95
89
        RequestProcessor.getDefault().post(new Runnable() {
96
    class JBossEarApplicationNodeUpdater implements Runnable {
90
            Vector keys = new Vector();
91
97
92
            public void run() {
98
        List keys = new ArrayList();
93
                try {
94
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
95
99
96
                        @Override
100
        @Override
97
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
101
        public void run() {
98
                            // Query to the jboss4 server
102
            try {
99
                            ObjectName searchPattern;
103
                lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
100
                            String propertyName;
104
101
                            if (abilitiesSupport.isRemoteManagementSupported()
105
                    @Override
102
                                    && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
106
                    public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
103
                                searchPattern = new ObjectName("jboss.management.local:j2eeType=J2EEApplication,*"); // NOI18N
107
                        // Query to the jboss4 server
104
                                propertyName = "name"; // NOI18N
108
                        ObjectName searchPattern;
105
                            } else {
109
                        String propertyName;
106
                                searchPattern = new ObjectName("jboss.j2ee:service=EARDeployment,*"); // NOI18N
110
                        if (abilitiesSupport.isRemoteManagementSupported()
107
                                propertyName = "url"; // NOI18N
111
                                && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
112
                            searchPattern = new ObjectName("jboss.management.local:j2eeType=J2EEApplication,*"); // NOI18N
113
                            propertyName = "name"; // NOI18N
114
                        } else {
115
                            searchPattern = new ObjectName("jboss.j2ee:service=EARDeployment,*"); // NOI18N
116
                            propertyName = "url"; // NOI18N
117
                        }
118
119
                        Method method = connection.getClass().getMethod("queryMBeans", new Class[] {ObjectName.class, QueryExp.class});
120
                        method = Util.fixJava4071957(method);
121
                        Set managedObj = (Set) method.invoke(connection, new Object[] {searchPattern, null});
122
123
                        // Query results processing
124
                        for (Iterator it = managedObj.iterator(); it.hasNext();) {
125
                            try {
126
                                ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
127
                                String name = elem.getKeyProperty(propertyName);
128
129
                                if (abilitiesSupport.isRemoteManagementSupported()
130
                                        && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
131
                                    if (name.endsWith(".sar") || name.endsWith(".deployer")) { // NOI18N
132
                                        continue;
133
                                    }
134
                                } else {
135
                                    name = name.substring(1, name.length() - 1); // NOI18N
136
                                }
137
138
                                keys.add(new JBEarApplicationNode(name, lookup));
139
                            } catch (Exception ex) {
140
                                LOGGER.log(Level.INFO, null, ex);
108
                            }
141
                            }
142
                        }
143
                        return null;
144
                    }
145
                });
146
            } catch (ExecutionException ex) {
147
                LOGGER.log(Level.INFO, null, ex);
148
            }
109
149
110
                            Method method = connection.getClass().getMethod("queryMBeans", new Class[] {ObjectName.class, QueryExp.class});
150
            setKeys(keys);
111
                            method = Util.fixJava4071957(method);
151
        }
112
                            Set managedObj = (Set) method.invoke(connection, new Object[] {searchPattern, null});
152
    }
113
153
114
                            // Query results processing
154
    class JBoss7EarApplicationNodeUpdater implements Runnable {
115
                            for (Iterator it = managedObj.iterator(); it.hasNext();) {
116
                                try {
117
                                    ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
118
                                    String name = elem.getKeyProperty(propertyName);
119
155
120
                                    if (abilitiesSupport.isRemoteManagementSupported()
156
        List keys = new ArrayList();
121
                                            && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
122
                                        if (name.endsWith(".sar") || name.endsWith(".deployer")) { // NOI18N
123
                                            continue;
124
                                        }
125
                                    } else {
126
                                        name = name.substring(1, name.length() - 1); // NOI18N
127
                                    }
128
157
129
                                    keys.add(new JBEarApplicationNode(name, lookup));
158
        @Override
130
                                } catch (Exception ex) {
159
        public void run() {
131
                                    LOGGER.log(Level.INFO, null, ex);
160
            try {
161
                final JBDeploymentManager dm = (JBDeploymentManager) lookup.lookup(JBDeploymentManager.class);
162
                dm.invokeRemoteAction(new JB7RemoteAction<Void>() {
163
164
                    @Override
165
                    public Void execute() {
166
                        try {
167
                            Target[] targets = dm.getTargets();
168
                            ModuleType moduleType = ModuleType.EAR;
169
170
                            //Get all deployed EAR files.
171
                            TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
172
                            // Module list may be null if nothing is deployed.
173
                            if (modules != null) {
174
                                for (int intModule = 0; intModule < modules.length; intModule++) {
175
                                    keys.add(new JBEarApplicationNode(modules[intModule].getModuleID(), lookup));
132
                                }
176
                                }
133
                            }
177
                            }
134
                            return null;
178
                        } catch (TargetException ex) {
179
                            Exceptions.printStackTrace(ex);
180
                        } catch (IllegalStateException ex) {
181
                            Exceptions.printStackTrace(ex);
135
                        }
182
                        }
136
                    });
183
                        return null;
137
                } catch (ExecutionException ex) {
184
                    }
138
                    LOGGER.log(Level.INFO, null, ex);
185
                });
139
                }
186
            } catch (Exception ex) {
187
                LOGGER.log(Level.INFO, null, ex);
188
            }
140
189
141
                setKeys(keys);
190
            setKeys(keys);
142
            }
191
        }
143
        }, 0);
144
145
    }
192
    }
146
193
194
    @Override
147
    protected void addNotify() {
195
    protected void addNotify() {
148
        updateKeys();
196
        updateKeys();
149
    }
197
    }
150
198
199
    @Override
151
    protected void removeNotify() {
200
    protected void removeNotify() {
152
        setKeys(java.util.Collections.EMPTY_SET);
201
        setKeys(java.util.Collections.EMPTY_SET);
153
    }
202
    }
154
203
204
    @Override
155
    protected org.openide.nodes.Node[] createNodes(Object key) {
205
    protected org.openide.nodes.Node[] createNodes(Object key) {
156
        if (key instanceof JBEarApplicationNode){
206
        if (key instanceof JBEarApplicationNode){
157
            return new Node[]{(JBEarApplicationNode)key};
207
            return new Node[]{(JBEarApplicationNode)key};
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBEjbModulesChildren.java (-6 / +47 lines)
 Lines 45-67    Link Here 
45
package org.netbeans.modules.j2ee.jboss4.nodes;
45
package org.netbeans.modules.j2ee.jboss4.nodes;
46
46
47
import java.lang.reflect.Method;
47
import java.lang.reflect.Method;
48
import java.util.Iterator;
48
import java.util.*;
49
import java.util.LinkedList;
50
import java.util.List;
51
import java.util.Set;
52
import java.util.concurrent.ExecutionException;
49
import java.util.concurrent.ExecutionException;
53
import java.util.logging.Level;
50
import java.util.logging.Level;
54
import java.util.logging.Logger;
51
import java.util.logging.Logger;
52
import javax.enterprise.deploy.shared.ModuleType;
53
import javax.enterprise.deploy.spi.Target;
54
import javax.enterprise.deploy.spi.TargetModuleID;
55
import javax.enterprise.deploy.spi.exceptions.TargetException;
55
import javax.management.MBeanServerConnection;
56
import javax.management.MBeanServerConnection;
56
import javax.management.ObjectInstance;
57
import javax.management.ObjectInstance;
57
import javax.management.ObjectName;
58
import javax.management.ObjectName;
58
import javax.management.QueryExp;
59
import javax.management.QueryExp;
60
import org.netbeans.modules.j2ee.jboss4.JB7RemoteAction;
59
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
61
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
60
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
62
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
61
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
63
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
62
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
64
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
63
import org.openide.nodes.Children;
65
import org.openide.nodes.Children;
64
import org.openide.nodes.Node;
66
import org.openide.nodes.Node;
67
import org.openide.util.Exceptions;
65
import org.openide.util.Lookup;
68
import org.openide.util.Lookup;
66
import org.openide.util.RequestProcessor;
69
import org.openide.util.RequestProcessor;
67
70
 Lines 87-93    Link Here 
87
    public void updateKeys(){
90
    public void updateKeys(){
88
        setKeys(new Object[] {Util.WAIT_NODE});
91
        setKeys(new Object[] {Util.WAIT_NODE});
89
        
92
        
90
        RequestProcessor.getDefault().post(new Runnable() {
93
        RequestProcessor.getDefault().post(abilitiesSupport.isJB7x() ? new JBoss7EjbApplicationNodeUpdater() : new Runnable() {
91
            public void run() {
94
            public void run() {
92
                List keys = new LinkedList();
95
                List keys = new LinkedList();
93
                JBDeploymentManager dm = lookup.lookup(JBDeploymentManager.class);
96
                JBDeploymentManager dm = lookup.lookup(JBDeploymentManager.class);
 Lines 170-176    Link Here 
170
            LOGGER.log(Level.INFO, null, ex);
173
            LOGGER.log(Level.INFO, null, ex);
171
        }
174
        }
172
    }
175
    }
173
    
176
    class  JBoss7EjbApplicationNodeUpdater implements Runnable {
177
178
         List keys = new ArrayList();
179
180
        @Override
181
        public void run() {
182
            try {
183
                final JBDeploymentManager dm = (JBDeploymentManager) lookup.lookup(JBDeploymentManager.class);
184
                dm.invokeRemoteAction(new JB7RemoteAction<Void>() {
185
186
                    @Override
187
                    public Void execute() {
188
                        try {
189
                            Target[] targets = dm.getTargets();
190
                            ModuleType moduleType = ModuleType.EJB;
191
192
                            //Get all deployed EAR files.
193
                            TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
194
                            // Module list may be null if nothing is deployed.
195
                            if (modules != null) {
196
                                for (int intModule = 0; intModule < modules.length; intModule++) {
197
                                    keys.add(new JBEjbModuleNode(modules[intModule].getModuleID(), lookup)); // TODO: how to check ejb3?
198
                                }
199
                            }
200
                        } catch (TargetException ex) {
201
                            Exceptions.printStackTrace(ex);
202
                        } catch (IllegalStateException ex) {
203
                            Exceptions.printStackTrace(ex);
204
                        }
205
                        return null;
206
                    }
207
                });
208
            } catch (Exception ex) {
209
                LOGGER.log(Level.INFO, null, ex);
210
            }
211
212
            setKeys(keys);
213
        }
214
    }
174
    protected void addNotify() {
215
    protected void addNotify() {
175
        updateKeys();
216
        updateKeys();
176
    }
217
    }
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBManagerNode.java (+11 lines)
 Lines 74-79    Link Here 
74
    private static final String ADMIN_URL_60 = "/admin-console/"; //NOI18N
74
    private static final String ADMIN_URL_60 = "/admin-console/"; //NOI18N
75
    private static final String JMX_CONSOLE_URL = "/jmx-console/"; //NOI18N
75
    private static final String JMX_CONSOLE_URL = "/jmx-console/"; //NOI18N
76
    private static final String HTTP_HEADER = "http://";
76
    private static final String HTTP_HEADER = "http://";
77
    private Boolean as7;
77
    
78
    
78
    public JBManagerNode(Children children, Lookup lookup) {
79
    public JBManagerNode(Children children, Lookup lookup) {
79
        super(children);
80
        super(children);
 Lines 199-206    Link Here 
199
        return sheet;
200
        return sheet;
200
    }
201
    }
201
    
202
    
203
    boolean isAs7() {
204
        if (as7 == null) {
205
            as7 = getDeploymentManager().getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
206
        }
207
        return as7;
208
    }
209
        
202
    public Image getIcon(int type) {
210
    public Image getIcon(int type) {
203
        if (type == BeanInfo.ICON_COLOR_16x16) {
211
        if (type == BeanInfo.ICON_COLOR_16x16) {
212
            if (isAs7()) {
213
                return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/as7_16x16.png"); // NOI18N
214
            }
204
            return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/16x16.gif"); // NOI18N
215
            return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/16x16.gif"); // NOI18N
205
        }
216
        }
206
        return super.getIcon(type);
217
        return super.getIcon(type);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBServletsChildren.java (-6 / +39 lines)
 Lines 45-51    Link Here 
45
package org.netbeans.modules.j2ee.jboss4.nodes;
45
package org.netbeans.modules.j2ee.jboss4.nodes;
46
46
47
import java.lang.reflect.Method;
47
import java.lang.reflect.Method;
48
import java.util.ArrayList;
48
import java.util.Iterator;
49
import java.util.Iterator;
50
import java.util.List;
49
import java.util.Set;
51
import java.util.Set;
50
import java.util.Vector;
52
import java.util.Vector;
51
import java.util.concurrent.ExecutionException;
53
import java.util.concurrent.ExecutionException;
 Lines 55-60    Link Here 
55
import javax.management.ObjectInstance;
57
import javax.management.ObjectInstance;
56
import javax.management.ObjectName;
58
import javax.management.ObjectName;
57
import javax.management.QueryExp;
59
import javax.management.QueryExp;
60
import org.netbeans.modules.j2ee.jboss4.JB7RemoteAction;
58
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
61
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
59
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
62
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
60
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
63
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
 Lines 78-96    Link Here 
78
    
81
    
79
    private String name;
82
    private String name;
80
    private Lookup lookup;
83
    private Lookup lookup;
84
    private final JBAbilitiesSupport abilitiesSupport;
81
    
85
    
82
    JBServletsChildren(String name, Lookup lookup) {
86
    JBServletsChildren(String name, Lookup lookup) {
83
        this.lookup = lookup;
87
        this.lookup = lookup;
84
        this.name = name;
88
        this.name = name;
89
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
85
    }
90
    }
86
    
91
    
87
    public void updateKeys(){
92
    public void updateKeys(){
88
        setKeys(new Object[] {WAIT_NODE});
93
        setKeys(new Object[] {WAIT_NODE});
89
        
94
        RequestProcessor.getDefault().post(abilitiesSupport.isJB7x() ? new JB7ServletNodeUpdater() : new JBServletNodeUpdater(), 0);
90
        RequestProcessor.getDefault().post(new Runnable() {
95
    }
91
            Vector keys = new Vector();
96
92
            
97
    class JBServletNodeUpdater implements Runnable {
93
            public void run() {
98
99
        List keys = new ArrayList();
100
101
        @Override
102
        public void run() {
94
                try {
103
                try {
95
                    // Query to the jboss4 server
104
                    // Query to the jboss4 server
96
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
105
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
 Lines 121-127    Link Here 
121
                
130
                
122
                setKeys(keys);
131
                setKeys(keys);
123
            }
132
            }
124
        }, 0);
133
    }
134
    
135
    class JB7ServletNodeUpdater implements Runnable {
136
137
        List keys = new ArrayList();
138
139
        @Override
140
        public void run() {
141
            try {
142
                // Query to the jboss4 server
143
                lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JB7RemoteAction<Void>() {
144
145
                    @Override
146
                    public Void execute() {
147
                        // TODO: add as7 logic here
148
                        return null;
149
                    }
150
                });
151
152
            } catch (Exception ex) {
153
                LOGGER.log(Level.INFO, null, ex);
154
            }
155
156
            setKeys(keys);
157
        }
125
    }
158
    }
126
    
159
    
127
    protected void addNotify() {
160
    protected void addNotify() {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBWebApplicationsChildren.java (-61 / +124 lines)
 Lines 45-74    Link Here 
45
package org.netbeans.modules.j2ee.jboss4.nodes;
45
package org.netbeans.modules.j2ee.jboss4.nodes;
46
46
47
import java.lang.reflect.Method;
47
import java.lang.reflect.Method;
48
import java.util.ArrayList;
48
import java.util.Collections;
49
import java.util.Collections;
49
import java.util.HashSet;
50
import java.util.HashSet;
50
import java.util.Iterator;
51
import java.util.Iterator;
52
import java.util.List;
51
import java.util.Set;
53
import java.util.Set;
52
import java.util.Vector;
53
import java.util.concurrent.ExecutionException;
54
import java.util.concurrent.ExecutionException;
54
import java.util.logging.Level;
55
import java.util.logging.Level;
55
import java.util.logging.Logger;
56
import java.util.logging.Logger;
57
import javax.enterprise.deploy.shared.ModuleType;
58
import javax.enterprise.deploy.spi.Target;
59
import javax.enterprise.deploy.spi.TargetModuleID;
60
import javax.enterprise.deploy.spi.exceptions.TargetException;
56
import javax.management.MBeanServerConnection;
61
import javax.management.MBeanServerConnection;
57
import javax.management.ObjectInstance;
62
import javax.management.ObjectInstance;
58
import javax.management.ObjectName;
63
import javax.management.ObjectName;
59
import javax.management.QueryExp;
64
import javax.management.QueryExp;
65
import org.netbeans.modules.j2ee.jboss4.JB7RemoteAction;
60
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
66
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
61
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
67
import org.netbeans.modules.j2ee.jboss4.JBRemoteAction;
62
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
68
import org.netbeans.modules.j2ee.jboss4.JBoss5ProfileServiceProxy;
63
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
69
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
64
import org.openide.nodes.Children;
70
import org.openide.nodes.Children;
65
import org.openide.nodes.Node;
71
import org.openide.nodes.Node;
72
import org.openide.util.Exceptions;
66
import org.openide.util.Lookup;
73
import org.openide.util.Lookup;
67
import org.openide.util.RequestProcessor;
74
import org.openide.util.RequestProcessor;
68
75
69
/**
76
/**
70
 * It describes children nodes of the Web Applications node. Implements
77
 * It describes children nodes of the Web Applications node. Implements
71
 * Refreshable interface and due to it can be refreshed via ResreshModulesAction.
78
 * Refreshable interface and due to it can be refreshed via
79
 * ResreshModulesAction.
72
 *
80
 *
73
 * @author Michal Mocnak
81
 * @author Michal Mocnak
74
 */
82
 */
 Lines 92-175    Link Here 
92
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
100
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
93
    }
101
    }
94
102
95
    public void updateKeys(){
103
    public void updateKeys() {
96
        setKeys(new Object[] {Util.WAIT_NODE});
104
        setKeys(new Object[]{Util.WAIT_NODE});
105
        RequestProcessor.getDefault().post(abilitiesSupport.isJB7x() ? new JBoss7WebNodeUpdater() : new JBossWebNodeUpdater(), 0);
106
    }
97
107
98
        RequestProcessor.getDefault().post(new Runnable() {
108
    class JBossWebNodeUpdater implements Runnable {
99
            Vector keys = new Vector();
100
109
101
            public void run() {
110
        List keys = new ArrayList();
102
                try {
103
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
104
111
105
                        @Override
112
        @Override
106
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
113
        public void run() {
107
                            // Query to the jboss server
114
            try {
108
                            ObjectName searchPattern;
115
                final JBDeploymentManager dm = (JBDeploymentManager) lookup.lookup(JBDeploymentManager.class);
109
                            if (abilitiesSupport.isRemoteManagementSupported()
116
                dm.invokeRemoteAction(new JBRemoteAction<Void>() {
110
                                    && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
117
111
                                searchPattern = new ObjectName("jboss.management.local:j2eeType=WebModule,J2EEApplication=null,*"); // NOI18N
118
                    @Override
119
                    public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
120
                        // Query to the jboss server
121
                        ObjectName searchPattern;
122
                        if (abilitiesSupport.isRemoteManagementSupported()
123
                                && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
124
                            searchPattern = new ObjectName("jboss.management.local:j2eeType=WebModule,J2EEApplication=null,*"); // NOI18N
112
                            }
125
                            }
113
                            else {
126
                            else {
114
                                searchPattern = new ObjectName("jboss.web:j2eeType=WebModule,J2EEApplication=none,*"); // NOI18N
127
                            searchPattern = new ObjectName("jboss.web:j2eeType=WebModule,J2EEApplication=none,*"); // NOI18N
128
                        }
129
130
                        Method method = connection.getClass().getMethod("queryMBeans", new Class[]  {ObjectName.class, QueryExp.class});
131
                        method = Util.fixJava4071957(method);
132
                        Set managedObj = (Set) method.invoke(connection, new Object[]  {searchPattern, null});
133
134
                        // Query results processing
135
                        for (Iterator it = managedObj.iterator(); it.hasNext();) {
136
                            try {
137
                                ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
138
                                String name = elem.getKeyProperty("name");
139
                                String url = "http://" + dm.getHost() + ":" + dm.getPort();
140
                                String context = null;
141
142
                                if (name.endsWith(".war")) {
143
                                    name = name.substring(0, name.lastIndexOf(".war"));
144
                                }
145
146
                                if (abilitiesSupport.isRemoteManagementSupported()
147
                                        && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
148
                                    if (SYSTEM_WEB_APPLICATIONS.contains(name)) { // Excluding it. It's system package
149
                                        continue;
150
                                    }
151
                                    String descr = (String) Util.getMBeanParameter(connection, "jbossWebDeploymentDescriptor", elem.getCanonicalName()); // NOI18N
152
                                    context = Util.getWebContextRoot(descr, name);
153
                                } else {
154
                                    if (name.startsWith("//localhost/")) { // NOI18N
155
                                        name = name.substring("//localhost/".length()); // NOI18N
156
                                    }
157
                                    if ("".equals(name)) {
158
                                        name = "ROOT"; // NOI18N // consistent with JBoss4
159
                                    }
160
                                    if (SYSTEM_WEB_APPLICATIONS.contains(name)) { // Excluding it. It's system package
161
                                        continue;
162
                                    }
163
164
                                    context = (String) Util.getMBeanParameter(connection, "path", elem.getCanonicalName()); // NOI18N
165
                                }
166
167
                                name += ".war"; // NOI18N
168
                                keys.add(new JBWebModuleNode(name, lookup, (context == null ? null : url + context)));
169
                            } catch (Exception ex) {
170
                                LOGGER.log(Level.INFO, null, ex);
115
                            }
171
                            }
172
                        }
173
                        return null;
174
                    }
175
                });
116
176
117
                            Method method = connection.getClass().getMethod("queryMBeans", new Class[]  {ObjectName.class, QueryExp.class});
177
            } catch (ExecutionException ex) {
118
                            method = Util.fixJava4071957(method);
178
                LOGGER.log(Level.INFO, null, ex);
119
                            Set managedObj = (Set) method.invoke(connection, new Object[]  {searchPattern, null});
179
            }
120
180
121
                            JBDeploymentManager dm = (JBDeploymentManager) lookup.lookup(JBDeploymentManager.class);
181
            setKeys(keys);
182
        }
183
    }
122
184
123
                            // Query results processing
185
    class JBoss7WebNodeUpdater implements Runnable {
124
                            for (Iterator it = managedObj.iterator(); it.hasNext();) {
125
                                try {
126
                                    ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
127
                                    String name = elem.getKeyProperty("name");
128
                                    String url = "http://" + dm.getHost() + ":" + dm.getPort();
129
                                    String context = null;
130
186
187
        List keys = new ArrayList();
188
189
        @Override
190
        public void run() {
191
192
            try {
193
                final JBDeploymentManager dm = (JBDeploymentManager) lookup.lookup(JBDeploymentManager.class);
194
                dm.invokeRemoteAction(new JB7RemoteAction<Void>() {
195
196
                    @Override
197
                    public Void execute() {
198
                        try {
199
                            Target[] targets = dm.getTargets();
200
                            ModuleType moduleType = ModuleType.WAR;
201
202
                            //Get all deployed WAR files.
203
                            TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
204
                            // Module list may be null if nothing is deployed.
205
                            if (modules != null) {
206
                                String url = "http://" + dm.getHost() + ":" + dm.getPort();
207
                                for (int intModule = 0; intModule < modules.length; intModule++) {
208
                                    String name = modules[intModule].getModuleID();
131
                                    if (name.endsWith(".war")) {
209
                                    if (name.endsWith(".war")) {
132
                                        name = name.substring(0, name.lastIndexOf(".war"));
210
                                        name = name.substring(0, name.lastIndexOf(".war"));
133
                                    }
211
                                    }
134
212
                                    if ("".equals(name)) {
135
                                    if (abilitiesSupport.isRemoteManagementSupported()
213
                                        name = "ROOT"; // NOI18N // consistent with JBoss4
136
                                            && (abilitiesSupport.isJB4x() || abilitiesSupport.isJB6x())) {
137
                                        if (SYSTEM_WEB_APPLICATIONS.contains(name)) { // Excluding it. It's system package
138
                                            continue;
139
                                        }
140
                                        String descr = (String) Util.getMBeanParameter(connection, "jbossWebDeploymentDescriptor", elem.getCanonicalName()); // NOI18N
141
                                        context = Util.getWebContextRoot(descr, name);
142
                                    } else {
143
                                        if (name.startsWith("//localhost/")) { // NOI18N
144
                                            name = name.substring("//localhost/".length()); // NOI18N
145
                                        }
146
                                        if ("".equals(name)) {
147
                                            name = "ROOT"; // NOI18N // consistent with JBoss4
148
                                        }
149
                                        if (SYSTEM_WEB_APPLICATIONS.contains(name)) { // Excluding it. It's system package
150
                                            continue;
151
                                        }
152
153
                                        context = (String) Util.getMBeanParameter(connection, "path", elem.getCanonicalName()); // NOI18N
154
                                    }
214
                                    }
155
215
                                    if (SYSTEM_WEB_APPLICATIONS.contains(name)) { // Excluding it. It's system package
216
                                        continue;
217
                                    }
156
                                    name += ".war"; // NOI18N
218
                                    name += ".war"; // NOI18N
157
                                    keys.add(new JBWebModuleNode(name, lookup, (context == null ? null : url + context)));
219
                                    keys.add(new JBWebModuleNode(name, lookup,  url));
158
                                } catch (Exception ex) {
159
                                    LOGGER.log(Level.INFO, null, ex);
160
                                }
220
                                }
161
                            }
221
                            }
162
                            return null;
222
                        } catch (TargetException ex) {
223
                            Exceptions.printStackTrace(ex);
224
                        } catch (IllegalStateException ex) {
225
                            Exceptions.printStackTrace(ex);
163
                        }
226
                        }
164
                    });
227
                        return null;
165
                    
228
                    }
166
                } catch (ExecutionException ex) {
229
                });
167
                    LOGGER.log(Level.INFO, null, ex);
230
            } catch (Exception ex) {
168
                }
231
                LOGGER.log(Level.INFO, null, ex);
232
            }
169
233
170
                setKeys(keys);
234
            setKeys(keys);
171
            }
235
        }
172
        }, 0);
173
    }
236
    }
174
237
175
    protected void addNotify() {
238
    protected void addNotify() {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/actions/UndeployModuleCookieImpl.java (-24 / +39 lines)
 Lines 52-57    Link Here 
52
import org.netbeans.api.progress.ProgressHandleFactory;
52
import org.netbeans.api.progress.ProgressHandleFactory;
53
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
53
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
54
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
54
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
55
import org.netbeans.modules.j2ee.jboss4.nodes.JBAbilitiesSupport;
55
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
56
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
56
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
57
import org.openide.util.NbBundle;
58
import org.openide.util.NbBundle;
 Lines 69-74    Link Here 
69
    private ModuleType type;
70
    private ModuleType type;
70
    private final boolean isEJB3;
71
    private final boolean isEJB3;
71
    private boolean isRunning;
72
    private boolean isRunning;
73
    private final JBAbilitiesSupport abilitiesSupport;
72
    
74
    
73
    public UndeployModuleCookieImpl(String fileName, ModuleType type, Lookup lookup) {
75
    public UndeployModuleCookieImpl(String fileName, ModuleType type, Lookup lookup) {
74
        this(fileName, type, false, lookup);
76
        this(fileName, type, false, lookup);
 Lines 84-89    Link Here 
84
        this.type = type;
86
        this.type = type;
85
        this.isEJB3 = isEJB3;
87
        this.isEJB3 = isEJB3;
86
        this.isRunning = false;
88
        this.isRunning = false;
89
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
87
    }    
90
    }    
88
    
91
    
89
    public Task undeploy() {
92
    public Task undeploy() {
 Lines 100-127    Link Here 
100
                
103
                
101
                if(file.exists() && file.canWrite()) {
104
                if(file.exists() && file.canWrite()) {
102
                    file.delete();
105
                    file.delete();
103
                    
106
                    if(abilitiesSupport.isJB7x()) {
104
                    try {
107
                        File statusFile = new File(file.getAbsolutePath()+File.pathSeparator+ ".undeployed");
105
                        ObjectName searchPattern = null;
106
                        if (Util.isRemoteManagementSupported(lookup) && !isEJB3) {
107
                            searchPattern = new ObjectName("jboss.management.local:"+(!type.equals(ModuleType.EAR) ?
108
                                "J2EEApplication=null," : "")+"j2eeType="+Util.getModuleTypeString(type)+",name=" + fileName + ",*");
109
                        } else {
110
                            if (type.equals(ModuleType.EAR)) {
111
                                searchPattern = new ObjectName("jboss.j2ee:service=EARDeployment,url='" + fileName + "'"); // NOI18N
112
                            }
113
                            else 
114
                            if (type.equals(ModuleType.WAR)) {
115
                                searchPattern = new ObjectName("jboss.web:j2eeType=WebModule,J2EEApplication=none,name=//localhost/" + nameWoExt + ",*"); // NOI18N
116
                            }
117
                            else
118
                            if (type.equals(ModuleType.EJB)) {
119
                                searchPattern = new ObjectName("jboss.j2ee:service=" + (isEJB3 ? "EJB3" : "EjbModule") + ",module=" + fileName); // NOI18N
120
                            }
121
                        }
122
                        
123
                        int time = 0;
108
                        int time = 0;
124
                        while(Util.isObjectDeployed(dm, searchPattern) && time < 30000) {
109
                        while (statusFile.exists() && time < 30000) {
125
                            try {
110
                            try {
126
                                Thread.sleep(2000);
111
                                Thread.sleep(2000);
127
                                time += 2000;
112
                                time += 2000;
 Lines 129-137    Link Here 
129
                                // Nothing to do
114
                                // Nothing to do
130
                            }
115
                            }
131
                        }
116
                        }
132
                    } catch (MalformedObjectNameException ex) {
117
                    } else {
133
                    } catch (NullPointerException ex) {
118
                        try {
134
                        // Nothing to do
119
                            ObjectName searchPattern = null;
120
                            if (Util.isRemoteManagementSupported(lookup) && !isEJB3) {
121
                                searchPattern = new ObjectName("jboss.management.local:"+(!type.equals(ModuleType.EAR) ?
122
                                    "J2EEApplication=null," : "")+"j2eeType="+Util.getModuleTypeString(type)+",name=" + fileName + ",*");
123
                            } else {
124
                                if (type.equals(ModuleType.EAR)) {
125
                                    searchPattern = new ObjectName("jboss.j2ee:service=EARDeployment,url='" + fileName + "'"); // NOI18N
126
                            }
127
                            else 
128
                            if (type.equals(ModuleType.WAR)) {
129
                                    searchPattern = new ObjectName("jboss.web:j2eeType=WebModule,J2EEApplication=none,name=//localhost/" + nameWoExt + ",*"); // NOI18N
130
                            }
131
                            else
132
                            if (type.equals(ModuleType.EJB)) {
133
                                    searchPattern = new ObjectName("jboss.j2ee:service=" + (isEJB3 ? "EJB3" : "EjbModule") + ",module=" + fileName); // NOI18N
134
                                }
135
                            }
136
137
                            int time = 0;
138
                        while(Util.isObjectDeployed(dm, searchPattern) && time < 30000) {
139
                                try {
140
                                    Thread.sleep(2000);
141
                                    time += 2000;
142
                                } catch (InterruptedException ex) {
143
                                    // Nothing to do
144
                                }
145
                            }
146
                        } catch (MalformedObjectNameException ex) {
147
                        } catch (NullPointerException ex) {
148
                            // Nothing to do
149
                        }
135
                    }
150
                    }
136
                }
151
                }
137
                
152
                
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/util/JBProperties.java (-1 / +1 lines)
 Lines 232-238    Link Here 
232
232
233
            addFiles(new File(rootDir, "lib"), list); // NOI18N
233
            addFiles(new File(rootDir, "lib"), list); // NOI18N
234
            addFiles(new File(serverDir, "lib"), list); // NOI18N
234
            addFiles(new File(serverDir, "lib"), list); // NOI18N
235
235
            addFiles(new File(rootDir, "modules"), list); // NOI18N
236
            
236
            
237
            Set<String> commonLibs = new HashSet<String>();
237
            Set<String> commonLibs = new HashSet<String>();
238
    
238
    

Return to bug 200132
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo