This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 200132
Collapse All | Expand All

(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JB7Deployer.java (+141 lines)
Line 0 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.concurrent.Callable;
8
import java.util.logging.Level;
9
import java.util.logging.Logger;
10
import javax.enterprise.deploy.shared.ActionType;
11
import javax.enterprise.deploy.shared.CommandType;
12
import javax.enterprise.deploy.shared.ModuleType;
13
import javax.enterprise.deploy.shared.StateType;
14
import javax.enterprise.deploy.spi.Target;
15
import javax.enterprise.deploy.spi.TargetModuleID;
16
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
17
import org.netbeans.modules.j2ee.jboss4.ide.JBDeploymentStatus;
18
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
19
import org.openide.filesystems.FileObject;
20
import org.openide.filesystems.FileUtil;
21
import org.openide.util.NbBundle;
22
23
/**
24
 *
25
 * @author Pragalathan M
26
 */
27
public class JB7Deployer extends JBDeployer {
28
29
    private static final Logger LOGGER = Logger.getLogger(JB7Deployer.class.getName());
30
    protected TargetModuleID deployedModuleID;
31
32
    public JB7Deployer(String serverUri, JBDeploymentManager dm) {
33
        super(serverUri, dm);
34
    }
35
36
    @Override
37
    public void run() {
38
        if (dm == null) {
39
            return;
40
        }
41
        final String deployDir = InstanceProperties.getInstanceProperties(uri).getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
42
        FileObject foIn = FileUtil.toFileObject(file);
43
        FileObject foDestDir = FileUtil.toFileObject(new File(deployDir));
44
        String fileName = file.getName();
45
46
        File toDeploy = new File(deployDir + File.separator + fileName);
47
        if (toDeploy.exists()) {
48
            toDeploy.delete();
49
        }
50
51
        fileName = fileName.substring(0, fileName.lastIndexOf('.'));
52
        String msg = NbBundle.getMessage(JBDeployer.class, "MSG_DEPLOYING", file.getAbsolutePath());
53
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, msg));
54
55
        try {
56
            FileUtil.copyFile(foIn, foDestDir, fileName);
57
            String webUrl = mainModuleID.getWebURL();
58
            if (webUrl == null) {
59
                TargetModuleID[] ch = mainModuleID.getChildTargetModuleID();
60
                if (ch != null) {
61
                    for (int i = 0; i < ch.length; i++) {
62
                        webUrl = ch[i].getWebURL();
63
                        if (webUrl != null) {
64
                            break;
65
                        }
66
                    }
67
                }
68
69
            }
70
            //Deploy file
71
            dm.invokeLocalAction(new Callable<Void>() {
72
73
                @Override
74
                public Void call() throws Exception {
75
                    File statusFile = new File(deployDir, file.getName() + ".deployed");
76
77
                    for (int i = 0, limit = (int) TIMEOUT / POLLING_INTERVAL; i < limit && !statusFile.exists(); i++) {
78
                        Thread.sleep(POLLING_INTERVAL);
79
                    }
80
81
                    Target[] targets = dm.getTargets();
82
                    ModuleType moduleType = getModuleType(file.getName().substring(file.getName().lastIndexOf(".") + 1));
83
                    TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
84
                    for (TargetModuleID targetModuleID : modules) {
85
                        if (targetModuleID.getModuleID().equals(mainModuleID.getModuleID())) {
86
                            deployedModuleID = targetModuleID;
87
                            break;
88
                        }
89
                    }
90
                    return null;
91
                }
92
            });
93
94
            if (webUrl != null) {
95
                URL url = new URL(webUrl);
96
                String waitingMsg = NbBundle.getMessage(JBDeployer.class, "MSG_Waiting_For_Url", url);
97
                fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, waitingMsg));
98
            }
99
        } catch (MalformedURLException ex) {
100
            LOGGER.log(Level.INFO, null, ex);
101
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
102
        } catch (MissingResourceException ex) {
103
            LOGGER.log(Level.INFO, null, ex);
104
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
105
        } catch (Exception ex) {
106
            LOGGER.log(Level.INFO, null, ex);
107
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
108
        }
109
110
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.COMPLETED, "Applicaton Deployed"));
111
    }
112
113
    private ModuleType getModuleType(String extension) {
114
        if (extension.equals("war")) {
115
            return ModuleType.WAR;
116
        }
117
118
        if (extension.equals("ear")) {
119
            return ModuleType.EAR;
120
        }
121
122
        if (extension.equals("car")) {
123
            return ModuleType.CAR;
124
        }
125
126
        if (extension.equals("ejb")) {
127
            return ModuleType.EJB;
128
        }
129
130
        if (extension.equals("rar")) {
131
            return ModuleType.RAR;
132
        }
133
        return null;
134
    }
135
136
    @Override
137
    public TargetModuleID[] getResultTargetModuleIDs() {
138
//        return new TargetModuleID[]{mainModuleID};
139
        return new TargetModuleID[]{deployedModuleID};
140
    }
141
}
(-)a/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) {
(-)a/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);
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java (-14 / +83 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 55-60 Link Here
55
import java.net.URLClassLoader;
56
import java.net.URLClassLoader;
56
import java.util.Locale;
57
import java.util.Locale;
57
import java.util.Properties;
58
import java.util.Properties;
59
import java.util.concurrent.Callable;
58
import java.util.concurrent.ExecutionException;
60
import java.util.concurrent.ExecutionException;
59
import java.util.logging.Level;
61
import java.util.logging.Level;
60
import java.util.logging.Logger;
62
import java.util.logging.Logger;
Lines 94-107 Link Here
94
96
95
    private InstanceProperties instanceProperties;
97
    private InstanceProperties instanceProperties;
96
    private boolean needsRestart;
98
    private boolean needsRestart;
97
99
    private Boolean as7;
98
    /**
100
    /**
99
     * Stores information about running instances. instance is represented by its InstanceProperties,
101
     * Stores information about running instances. instance is represented by its InstanceProperties,
100
     *  running state by Boolean.TRUE, stopped state Boolean.FALSE.
102
     *  running state by Boolean.TRUE, stopped state Boolean.FALSE.
101
     * WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance.
103
     * WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance.
102
     */
104
     */
103
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
105
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
104
    
106
105
    /** Creates a new instance of JBDeploymentManager */
107
    /** Creates a new instance of JBDeploymentManager */
106
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
108
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
107
        realUri = uri;
109
        realUri = uri;
Lines 139-144 Link Here
139
        return instanceProperties;
141
        return instanceProperties;
140
    }
142
    }
141
143
144
    /**
145
     * This is a handy method to execute the any {@code action} within JBoss's class loader.
146
     *
147
     * @param action the action to be executed
148
     * @return T
149
     * @throws ExecutionException
150
     */
151
    public <T> T invokeLocalAction(Callable<T> action) throws Exception {
152
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
153
        try {
154
            InstanceProperties ip = getInstanceProperties();
155
            URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip);
156
            Thread.currentThread().setContextClassLoader(loader);
157
            return action.call();
158
        } finally {
159
            Thread.currentThread().setContextClassLoader(oldLoader);
160
        }
161
    }
162
142
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
163
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
143
164
144
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
165
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Lines 177-184 Link Here
177
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
198
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
178
            }
199
            }
179
200
180
            // Gets naming context
201
            if (!props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
181
            ctx = new InitialContext(env);
202
                // Gets naming context
203
                ctx = new InitialContext(env);
204
            }
182
205
183
            //restore java.security.auth.login.config system property
206
            //restore java.security.auth.login.config system property
184
            if (oldAuthConf != null) {
207
            if (oldAuthConf != null) {
Lines 189-218 Link Here
189
212
190
            MBeanServerConnection rmiServer = null;
213
            MBeanServerConnection rmiServer = null;
191
            try {
214
            try {
192
                conn = JMXConnectorFactory.connect(new JMXServiceURL(
215
                JMXServiceURL url;
193
                        "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"));
216
                if (props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
217
                    // using management-native port
218
                    url = new JMXServiceURL(
219
                            System.getProperty("jmx.service.url", "service:jmx:remoting-jmx://localhost:9999")); // NOI18N
220
                } else {
221
                    url = new JMXServiceURL(
222
                            "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"); // NOI18N
223
                }
224
                conn = JMXConnectorFactory.connect(url);
194
225
195
                rmiServer = conn.getMBeanServerConnection();
226
                rmiServer = conn.getMBeanServerConnection();
196
            } catch (IOException ex) {
227
            } catch (IOException ex) {
197
                LOGGER.log(Level.FINE, null, ex);
228
                LOGGER.log(Level.FINE, null, ex);
198
            }
229
            }
199
230
200
            if (rmiServer == null) {
231
            if (rmiServer == null && ctx != null) {
201
                // Lookup RMI Adaptor
232
                // Lookup RMI Adaptor
202
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
233
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
203
            }
234
            }
204
235
205
            JBoss5ProfileServiceProxy profileService = null;
236
            JBoss5ProfileServiceProxy profileService = null;
206
            try {
237
            try {
207
                Object service = ctx.lookup("ProfileService"); // NOI18N
238
                if (ctx != null) {
208
                if (service != null) {
239
                    Object service = ctx.lookup("ProfileService"); // NOI18N
209
                    profileService = new JBoss5ProfileServiceProxy(service);
240
                    if (service != null) {
241
                        profileService = new JBoss5ProfileServiceProxy(service);
242
                    }
210
                }
243
                }
211
            } catch (NameNotFoundException ex) {
244
            } catch (NameNotFoundException ex) {
212
                LOGGER.log(Level.FINE, null, ex);
245
                LOGGER.log(Level.FINE, null, ex);
213
            }
246
            }
214
247
215
            return action.action(rmiServer, profileService);
248
            if (rmiServer != null) {
249
                return action.action(rmiServer, profileService);
250
            } else {
251
                throw new IllegalStateException("No rmi server acquired for " + realUri);
252
            }
216
        } catch (NameNotFoundException ex) {
253
        } catch (NameNotFoundException ex) {
217
            LOGGER.log(Level.FINE, null, ex);
254
            LOGGER.log(Level.FINE, null, ex);
218
            throw new ExecutionException(ex);
255
            throw new ExecutionException(ex);
Lines 261-273 Link Here
261
        propertiesToIsRunning.put(ip, isRunning);
298
        propertiesToIsRunning.put(ip, isRunning);
262
    }
299
    }
263
300
301
    boolean isAs7() {
302
        if (as7 == null) {
303
            as7 = getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
304
        }
305
        return as7;
306
    }
264
    ////////////////////////////////////////////////////////////////////////////
307
    ////////////////////////////////////////////////////////////////////////////
265
    // DeploymentManager Implementation
308
    // DeploymentManager Implementation
266
    ////////////////////////////////////////////////////////////////////////////
309
    ////////////////////////////////////////////////////////////////////////////
267
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
310
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
311
        if (isAs7()) {
312
            return new JB7Deployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
313
        }
268
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
314
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
269
    }
315
    }
270
316
317
    public ProgressObject distributeTarget(Target[] target, File file, File file2) throws IllegalStateException {
318
        return dm.distribute(target, file, file2);
319
    }
320
271
    public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException {
321
    public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException {
272
        throw new RuntimeException("This method should never be called."); // NOI18N
322
        throw new RuntimeException("This method should never be called."); // NOI18N
273
    }
323
    }
Lines 292-298 Link Here
292
        return dm.stop(targetModuleID);
342
        return dm.stop(targetModuleID);
293
    }
343
    }
294
344
295
    public ProgressObject start(TargetModuleID[] targetModuleID) throws IllegalStateException {
345
    public ProgressObject start(final TargetModuleID[] targetModuleID) throws IllegalStateException {
346
        if (isAs7()) {
347
            ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
348
            try {
349
                InstanceProperties ip = getInstanceProperties();
350
                URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip);
351
                Thread.currentThread().setContextClassLoader(loader);
352
                return dm.start(targetModuleID);
353
            } finally {
354
                Thread.currentThread().setContextClassLoader(oldLoader);
355
            }
356
        }
357
296
        return dm.start(targetModuleID);
358
        return dm.start(targetModuleID);
297
    }
359
    }
298
360
Lines 305-316 Link Here
305
    }
367
    }
306
368
307
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
369
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
308
        //return dm.getAvailableModules(moduleType, target);
370
        if (isAs7()) {
371
            return dm.getAvailableModules(moduleType, target);
372
        }
309
        return new TargetModuleID[]{};
373
        return new TargetModuleID[]{};
310
    }
374
    }
311
375
312
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
376
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
313
        //return dm.getNonRunningModules(moduleType, target);
377
        if (isAs7()) {
378
            return dm.getAvailableModules(moduleType, target);
379
        }
314
        return new TargetModuleID[]{};
380
        return new TargetModuleID[]{};
315
    }
381
    }
316
382
Lines 319-324 Link Here
319
    }
385
    }
320
386
321
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
387
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
388
        if (isAs7()) {
389
            return new JB7Deployer(realUri, this).redeploy(targetModuleID, file, file2);
390
        }
322
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
391
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
323
    }
392
    }
324
393
(-)a/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) {
(-)a/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 359-371 Link Here
359
            Logger.getLogger("global").log(Level.INFO, null, ioe);
363
            Logger.getLogger("global").log(Level.INFO, null, ioe);
360
364
361
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
365
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
362
            final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
366
            final String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
363
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
367
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
364
368
365
            return null;
369
            return null;
366
        }
370
        }
367
    }
371
    }
368
    
372
    
373
    private boolean isJBoss7() {
374
        return dm.getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
375
    }
376
    
369
    private InputOutput openConsole() {
377
    private InputOutput openConsole() {
370
        InputOutput io = UISupport.getServerIO(dm.getUrl());
378
        InputOutput io = UISupport.getServerIO(dm.getUrl());
371
        if (io == null) {
379
        if (io == null) {
Lines 422-428 Link Here
422
            String serverLocation = getProperties().getProperty(
430
            String serverLocation = getProperties().getProperty(
423
                    JBPluginProperties.PROPERTY_ROOT_DIR);
431
                    JBPluginProperties.PROPERTY_ROOT_DIR);
424
            String serverRunFileName = serverLocation + 
432
            String serverRunFileName = serverLocation + 
425
                (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
433
                    (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
426
            if ( needChange ){
434
            if ( needChange ){
427
                String contentRun = readFile(serverRunFileName);
435
                String contentRun = readFile(serverRunFileName);
428
                String contentConf = readFile(serverLocation + CONF_BAT);
436
                String contentConf = readFile(serverLocation + CONF_BAT);
(-)a/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 252-273 Link Here
252
254
253
                        @Override
255
                        @Override
254
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
256
                        public Void action(MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService) throws Exception {
255
                            Object serverName = Util.getMBeanParameter(connection, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
257
                            Object serverName = null;
256
                            Object serverHome = Util.getMBeanParameter(connection, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
258
                            Object serverHome = null;
257
                            boolean isJBoss6 = serverHome != null;
259
                            if (dm.getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0)) {
258
                            if (!isJBoss6) {
260
                                serverHome = Util.getMBeanParameter(connection, "baseDir", "jboss.as:core-service=server-environment"); //NOI18N
259
                                serverHome = Util.getMBeanParameter(connection, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
261
                                serverName = Util.getMBeanParameter(connection, "launchType", "jboss.as:core-service=server-environment"); //NOI18N
260
                            }
262
                                if (serverName != null) {
261
                            try {
263
                                    serverName = serverName.toString().toLowerCase();
262
                                if (serverHome != null) {
264
                                }
263
                                    if (isJBoss6) {
265
                            } else {
264
                                        serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
266
                                serverName = Util.getMBeanParameter(connection, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
265
                                    } else {
267
                                serverHome = Util.getMBeanParameter(connection, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
266
                                        serverHome = ((File) serverHome).getAbsolutePath();
268
                                boolean isJBoss6 = serverHome != null;
269
                                if (!isJBoss6) {
270
                                    serverHome = Util.getMBeanParameter(connection, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
271
                                }
272
                                try {
273
                                    if (serverHome != null) {
274
                                        if (isJBoss6) {
275
                                            serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
276
                                        } else {
277
                                            serverHome = ((File) serverHome).getAbsolutePath();
278
                                        }
267
                                    }
279
                                    }
280
                                } catch (URISyntaxException use) {
281
                                    LOGGER.log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
268
                                }
282
                                }
269
                            } catch (URISyntaxException use) {
270
                                LOGGER.log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
271
                            }
283
                            }
272
284
273
                            if (serverName == null || serverHome == null) {
285
                            if (serverName == null || serverHome == null) {
(-)a/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();
(-)a/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
(-)a/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();
(-)a/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 675-681 Link Here
675
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
732
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
676
733
677
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
734
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
678
        return getVersion(systemJarFile);
735
        Version version = getVersion(systemJarFile);
736
        if(version == null) {
737
            // check for JBoss AS 7
738
            File serverDir = new File(serverPath, "modules/org/jboss/as/server/main");
739
            for (File jarFile : serverDir.listFiles(new JarFileFilter())) {
740
                version = getVersion(jarFile);
741
                if(version != null) {
742
                    break;
743
    }
744
            }
745
        }
746
        return version;
747
    }
748
749
    static class JarFileFilter implements FilenameFilter {
750
751
        @Override
752
        public boolean accept(File dir, String name) {
753
            return name.endsWith(".jar");
754
        }
679
    }
755
    }
680
756
681
    private static Version getVersion(File systemJarFile) {
757
    private static Version getVersion(File systemJarFile) {
(-)a/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
}
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBEarApplicationsChildren.java (-50 / +100 lines)
Lines 45-56 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;
49
import java.util.concurrent.Callable;
50
import java.util.Vector;
51
import java.util.concurrent.ExecutionException;
50
import java.util.concurrent.ExecutionException;
52
import java.util.logging.Level;
51
import java.util.logging.Level;
53
import java.util.logging.Logger;
52
import java.util.logging.Logger;
53
import javax.enterprise.deploy.shared.ModuleType;
54
import javax.enterprise.deploy.spi.Target;
55
import javax.enterprise.deploy.spi.TargetModuleID;
56
import javax.enterprise.deploy.spi.exceptions.TargetException;
54
import javax.management.MBeanServerConnection;
57
import javax.management.MBeanServerConnection;
55
import javax.management.ObjectInstance;
58
import javax.management.ObjectInstance;
56
import javax.management.ObjectName;
59
import javax.management.ObjectName;
Lines 61-66 Link Here
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.invokeLocalAction(new Callable<Void>() {
163
164
                    @Override
165
                    public Void call() {
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};
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBEjbModulesChildren.java (-6 / +47 lines)
Lines 45-57 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;
49
import java.util.concurrent.Callable;
50
import java.util.List;
51
import java.util.Set;
52
import java.util.concurrent.ExecutionException;
50
import java.util.concurrent.ExecutionException;
53
import java.util.logging.Level;
51
import java.util.logging.Level;
54
import java.util.logging.Logger;
52
import java.util.logging.Logger;
53
import javax.enterprise.deploy.shared.ModuleType;
54
import javax.enterprise.deploy.spi.Target;
55
import javax.enterprise.deploy.spi.TargetModuleID;
56
import javax.enterprise.deploy.spi.exceptions.TargetException;
55
import javax.management.MBeanServerConnection;
57
import javax.management.MBeanServerConnection;
56
import javax.management.ObjectInstance;
58
import javax.management.ObjectInstance;
57
import javax.management.ObjectName;
59
import javax.management.ObjectName;
Lines 62-67 Link Here
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.invokeLocalAction(new Callable<Void>() {
185
186
                    @Override
187
                    public Void call() {
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
    }
(-)a/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);
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBServletsChildren.java (-7 / +39 lines)
Lines 45-53 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.concurrent.Callable;
51
import java.util.concurrent.ExecutionException;
53
import java.util.concurrent.ExecutionException;
52
import java.util.logging.Level;
54
import java.util.logging.Level;
53
import java.util.logging.Logger;
55
import java.util.logging.Logger;
Lines 78-96 Link Here
78
    
80
    
79
    private String name;
81
    private String name;
80
    private Lookup lookup;
82
    private Lookup lookup;
83
    private final JBAbilitiesSupport abilitiesSupport;
81
    
84
    
82
    JBServletsChildren(String name, Lookup lookup) {
85
    JBServletsChildren(String name, Lookup lookup) {
83
        this.lookup = lookup;
86
        this.lookup = lookup;
84
        this.name = name;
87
        this.name = name;
88
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
85
    }
89
    }
86
    
90
    
87
    public void updateKeys(){
91
    public void updateKeys(){
88
        setKeys(new Object[] {WAIT_NODE});
92
        setKeys(new Object[] {WAIT_NODE});
89
        
93
        RequestProcessor.getDefault().post(abilitiesSupport.isJB7x() ? new JB7ServletNodeUpdater() : new JBServletNodeUpdater(), 0);
90
        RequestProcessor.getDefault().post(new Runnable() {
94
    }
91
            Vector keys = new Vector();
95
92
            
96
    class JBServletNodeUpdater implements Runnable {
93
            public void run() {
97
98
        List keys = new ArrayList();
99
100
        @Override
101
        public void run() {
94
                try {
102
                try {
95
                    // Query to the jboss4 server
103
                    // Query to the jboss4 server
96
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
104
                    lookup.lookup(JBDeploymentManager.class).invokeRemoteAction(new JBRemoteAction<Void>() {
Lines 121-127 Link Here
121
                
129
                
122
                setKeys(keys);
130
                setKeys(keys);
123
            }
131
            }
124
        }, 0);
132
    }
133
    
134
    class JB7ServletNodeUpdater implements Runnable {
135
136
        List keys = new ArrayList();
137
138
        @Override
139
        public void run() {
140
            try {
141
                // Query to the jboss4 server
142
                lookup.lookup(JBDeploymentManager.class).invokeLocalAction(new Callable<Void>() {
143
144
                    @Override
145
                    public Void call() {
146
                        // TODO: add as7 logic here
147
                        return null;
148
                    }
149
                });
150
151
            } catch (Exception ex) {
152
                LOGGER.log(Level.INFO, null, ex);
153
            }
154
155
            setKeys(keys);
156
        }
125
    }
157
    }
126
    
158
    
127
    protected void addNotify() {
159
    protected void addNotify() {
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/nodes/JBWebApplicationsChildren.java (-61 / +124 lines)
Lines 45-58 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;
54
import java.util.concurrent.Callable;
53
import java.util.concurrent.ExecutionException;
55
import java.util.concurrent.ExecutionException;
54
import java.util.logging.Level;
56
import java.util.logging.Level;
55
import java.util.logging.Logger;
57
import java.util.logging.Logger;
58
import javax.enterprise.deploy.shared.ModuleType;
59
import javax.enterprise.deploy.spi.Target;
60
import javax.enterprise.deploy.spi.TargetModuleID;
61
import javax.enterprise.deploy.spi.exceptions.TargetException;
56
import javax.management.MBeanServerConnection;
62
import javax.management.MBeanServerConnection;
57
import javax.management.ObjectInstance;
63
import javax.management.ObjectInstance;
58
import javax.management.ObjectName;
64
import javax.management.ObjectName;
Lines 63-74 Link Here
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.invokeLocalAction(new Callable<Void>() {
195
196
                    @Override
197
                    public Void call() {
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() {
(-)a/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
                
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/util/JBProperties.java (-1 / +1 lines)
Lines 241-247 Link Here
241
241
242
            addFiles(new File(rootDir, "lib"), list); // NOI18N
242
            addFiles(new File(rootDir, "lib"), list); // NOI18N
243
            addFiles(new File(serverDir, "lib"), list); // NOI18N
243
            addFiles(new File(serverDir, "lib"), list); // NOI18N
244
244
            addFiles(new File(rootDir, "modules"), list); // NOI18N
245
            
245
            
246
            Set<String> commonLibs = new HashSet<String>();
246
            Set<String> commonLibs = new HashSet<String>();
247
    
247
    

Return to bug 200132