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 (+143 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
 * @author Petr Hejl
27
 */
28
public class JB7Deployer extends JBDeployer {
29
30
    private static final Logger LOGGER = Logger.getLogger(JB7Deployer.class.getName());
31
    protected TargetModuleID deployedModuleID;
32
33
    public JB7Deployer(String serverUri, JBDeploymentManager dm) {
34
        super(serverUri, dm);
35
    }
36
37
    @Override
38
    public void run() {
39
        if (dm == null) {
40
            return;
41
        }
42
        final String deployDir = InstanceProperties.getInstanceProperties(uri).getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
43
        FileObject foIn = FileUtil.toFileObject(file);
44
        FileObject foDestDir = FileUtil.toFileObject(new File(deployDir));
45
        String fileName = file.getName();
46
47
        File toDeploy = new File(deployDir + File.separator + fileName);
48
        if (toDeploy.exists()) {
49
            toDeploy.delete();
50
        }
51
52
        fileName = fileName.substring(0, fileName.lastIndexOf('.'));
53
        String msg = NbBundle.getMessage(JBDeployer.class, "MSG_DEPLOYING", file.getAbsolutePath());
54
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, msg));
55
56
        try {
57
            FileUtil.copyFile(foIn, foDestDir, fileName);
58
            String webUrl = mainModuleID.getWebURL();
59
            if (webUrl == null) {
60
                TargetModuleID[] ch = mainModuleID.getChildTargetModuleID();
61
                if (ch != null) {
62
                    for (int i = 0; i < ch.length; i++) {
63
                        webUrl = ch[i].getWebURL();
64
                        if (webUrl != null) {
65
                            break;
66
                        }
67
                    }
68
                }
69
70
            }
71
72
            final String finalWebUrl = webUrl;
73
            //Deploy file
74
            dm.invokeLocalAction(new Callable<Void>() {
75
76
                @Override
77
                public Void call() throws Exception {
78
                    File statusFile = new File(deployDir, file.getName() + ".deployed");
79
80
                    for (int i = 0, limit = (int) TIMEOUT / POLLING_INTERVAL; i < limit && !statusFile.exists(); i++) {
81
                        Thread.sleep(POLLING_INTERVAL);
82
                    }
83
84
                    Target[] targets = dm.getTargets();
85
                    ModuleType moduleType = getModuleType(file.getName().substring(file.getName().lastIndexOf(".") + 1));
86
                    TargetModuleID[] modules = dm.getAvailableModules(moduleType, targets);
87
                    for (TargetModuleID targetModuleID : modules) {
88
                        if (targetModuleID.getModuleID().equals(mainModuleID.getModuleID())) {
89
                            deployedModuleID = new WrappedTargetModuleID(targetModuleID, finalWebUrl, null, null);
90
                            break;
91
                        }
92
                    }
93
                    return null;
94
                }
95
            });
96
97
            if (webUrl != null) {
98
                URL url = new URL(webUrl);
99
                String waitingMsg = NbBundle.getMessage(JBDeployer.class, "MSG_Waiting_For_Url", url);
100
                fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING, waitingMsg));
101
            }
102
        } catch (MalformedURLException ex) {
103
            LOGGER.log(Level.INFO, null, ex);
104
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
105
        } catch (MissingResourceException ex) {
106
            LOGGER.log(Level.INFO, null, ex);
107
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
108
        } catch (Exception ex) {
109
            LOGGER.log(Level.INFO, null, ex);
110
            fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED, "Failed"));
111
        }
112
113
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.COMPLETED, "Applicaton Deployed"));
114
    }
115
116
    private ModuleType getModuleType(String extension) {
117
        if (extension.equals("war")) {
118
            return ModuleType.WAR;
119
        }
120
121
        if (extension.equals("ear")) {
122
            return ModuleType.EAR;
123
        }
124
125
        if (extension.equals("car")) {
126
            return ModuleType.CAR;
127
        }
128
129
        if (extension.equals("ejb")) {
130
            return ModuleType.EJB;
131
        }
132
133
        if (extension.equals("rar")) {
134
            return ModuleType.RAR;
135
        }
136
        return null;
137
    }
138
139
    @Override
140
    public TargetModuleID[] getResultTargetModuleIDs() {
141
        return new TargetModuleID[]{deployedModuleID};
142
    }
143
}
(-)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 (-36 / +157 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 52-60 Link Here
52
import java.io.File;
53
import java.io.File;
53
import java.io.IOException;
54
import java.io.IOException;
54
import java.io.InputStream;
55
import java.io.InputStream;
56
import java.net.MalformedURLException;
55
import java.net.URLClassLoader;
57
import java.net.URLClassLoader;
56
import java.util.Locale;
58
import java.util.Locale;
57
import java.util.Properties;
59
import java.util.Properties;
60
import java.util.concurrent.Callable;
58
import java.util.concurrent.ExecutionException;
61
import java.util.concurrent.ExecutionException;
59
import java.util.logging.Level;
62
import java.util.logging.Level;
60
import java.util.logging.Logger;
63
import java.util.logging.Logger;
Lines 78-83 Link Here
78
import javax.naming.NamingException;
81
import javax.naming.NamingException;
79
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
82
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
80
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
83
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
84
import org.openide.util.Exceptions;
81
85
82
/**
86
/**
83
 *
87
 *
Lines 94-107 Link Here
94
98
95
    private InstanceProperties instanceProperties;
99
    private InstanceProperties instanceProperties;
96
    private boolean needsRestart;
100
    private boolean needsRestart;
97
101
    private Boolean as7;
98
    /**
102
    /**
99
     * Stores information about running instances. instance is represented by its InstanceProperties,
103
     * Stores information about running instances. instance is represented by its InstanceProperties,
100
     *  running state by Boolean.TRUE, stopped state Boolean.FALSE.
104
     *  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.
105
     * WeakHashMap should guarantee erasing of an unregistered server instance bcs instance properties are also removed along with instance.
102
     */
106
     */
103
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
107
    private static final Map<InstanceProperties, Boolean> propertiesToIsRunning = Collections.synchronizedMap(new WeakHashMap());
104
    
108
105
    /** Creates a new instance of JBDeploymentManager */
109
    /** Creates a new instance of JBDeploymentManager */
106
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
110
    public JBDeploymentManager(DeploymentManager dm, String uri, String username, String password) {
107
        realUri = uri;
111
        realUri = uri;
Lines 139-144 Link Here
139
        return instanceProperties;
143
        return instanceProperties;
140
    }
144
    }
141
145
146
    /**
147
     * This is a handy method to execute the any {@code action} within JBoss's class loader.
148
     *
149
     * @param action the action to be executed
150
     * @return T
151
     * @throws ExecutionException
152
     */
153
    public <T> T invokeLocalAction(Callable<T> action) throws Exception {
154
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
155
        try {
156
            InstanceProperties ip = getInstanceProperties();
157
            URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip);
158
            Thread.currentThread().setContextClassLoader(loader);
159
            return action.call();
160
        } finally {
161
            Thread.currentThread().setContextClassLoader(oldLoader);
162
        }
163
    }
164
142
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
165
    public <T> T invokeRemoteAction(JBRemoteAction<T> action) throws ExecutionException {
143
166
144
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
167
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
Lines 177-184 Link Here
177
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
200
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
178
            }
201
            }
179
202
180
            // Gets naming context
203
            if (!props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
181
            ctx = new InitialContext(env);
204
                // Gets naming context
205
                ctx = new InitialContext(env);
206
            }
182
207
183
            //restore java.security.auth.login.config system property
208
            //restore java.security.auth.login.config system property
184
            if (oldAuthConf != null) {
209
            if (oldAuthConf != null) {
Lines 189-218 Link Here
189
214
190
            MBeanServerConnection rmiServer = null;
215
            MBeanServerConnection rmiServer = null;
191
            try {
216
            try {
192
                conn = JMXConnectorFactory.connect(new JMXServiceURL(
217
                JMXServiceURL url;
193
                        "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"));
218
                if (props.isVersion(JBPluginUtils.JBOSS_7_0_0)) {
219
                    // using management-native port
220
                    url = new JMXServiceURL(
221
                            System.getProperty("jmx.service.url", "service:jmx:remoting-jmx://localhost:9999")); // NOI18N
222
                } else {
223
                    url = new JMXServiceURL(
224
                            "service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"); // NOI18N
225
                }
226
                conn = JMXConnectorFactory.connect(url);
194
227
195
                rmiServer = conn.getMBeanServerConnection();
228
                rmiServer = conn.getMBeanServerConnection();
196
            } catch (IOException ex) {
229
            } catch (IOException ex) {
197
                LOGGER.log(Level.FINE, null, ex);
230
                LOGGER.log(Level.FINE, null, ex);
198
            }
231
            }
199
232
200
            if (rmiServer == null) {
233
            if (rmiServer == null && ctx != null) {
201
                // Lookup RMI Adaptor
234
                // Lookup RMI Adaptor
202
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
235
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); // NOI18N
203
            }
236
            }
204
237
205
            JBoss5ProfileServiceProxy profileService = null;
238
            JBoss5ProfileServiceProxy profileService = null;
206
            try {
239
            try {
207
                Object service = ctx.lookup("ProfileService"); // NOI18N
240
                if (ctx != null) {
208
                if (service != null) {
241
                    Object service = ctx.lookup("ProfileService"); // NOI18N
209
                    profileService = new JBoss5ProfileServiceProxy(service);
242
                    if (service != null) {
243
                        profileService = new JBoss5ProfileServiceProxy(service);
244
                    }
210
                }
245
                }
211
            } catch (NameNotFoundException ex) {
246
            } catch (NameNotFoundException ex) {
212
                LOGGER.log(Level.FINE, null, ex);
247
                LOGGER.log(Level.FINE, null, ex);
213
            }
248
            }
214
249
215
            return action.action(rmiServer, profileService);
250
            if (rmiServer != null) {
251
                return action.action(rmiServer, profileService);
252
            } else {
253
                throw new IllegalStateException("No rmi server acquired for " + realUri);
254
            }
216
        } catch (NameNotFoundException ex) {
255
        } catch (NameNotFoundException ex) {
217
            LOGGER.log(Level.FINE, null, ex);
256
            LOGGER.log(Level.FINE, null, ex);
218
            throw new ExecutionException(ex);
257
            throw new ExecutionException(ex);
Lines 261-270 Link Here
261
        propertiesToIsRunning.put(ip, isRunning);
300
        propertiesToIsRunning.put(ip, isRunning);
262
    }
301
    }
263
302
303
    boolean isAs7() {
304
        if (as7 == null) {
305
            as7 = getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
306
        }
307
        return as7;
308
    }
264
    ////////////////////////////////////////////////////////////////////////////
309
    ////////////////////////////////////////////////////////////////////////////
265
    // DeploymentManager Implementation
310
    // DeploymentManager Implementation
266
    ////////////////////////////////////////////////////////////////////////////
311
    ////////////////////////////////////////////////////////////////////////////
267
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
312
    public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException {
313
        if (isAs7()) {
314
            return new JB7Deployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
315
        }
268
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
316
        return new JBDeployer(realUri, this).deploy(target, file, file2, getHost(), getPort());
269
    }
317
    }
270
318
Lines 273-290 Link Here
273
    }
321
    }
274
322
275
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, InputStream inputStream, InputStream inputStream2) throws UnsupportedOperationException, IllegalStateException {
323
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, InputStream inputStream, InputStream inputStream2) throws UnsupportedOperationException, IllegalStateException {
324
        if (isAs7()) {
325
            return dm.redeploy(translateForUndeploy(targetModuleID), inputStream, inputStream2);
326
        }
276
        return dm.redeploy(targetModuleID, inputStream, inputStream2);
327
        return dm.redeploy(targetModuleID, inputStream, inputStream2);
277
    }
328
    }
278
329
279
    public ProgressObject distribute(Target[] target, InputStream inputStream, InputStream inputStream2) throws IllegalStateException {
330
    public ProgressObject distribute(Target[] target, InputStream inputStream, InputStream inputStream2) throws IllegalStateException {
280
        return dm.distribute(target, inputStream, inputStream2);
331
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
281
    }
332
    }
282
333
283
    public ProgressObject distribute(Target[] target, ModuleType moduleType, InputStream inputStream, InputStream inputStream0) throws IllegalStateException {
334
    public ProgressObject distribute(Target[] target, ModuleType moduleType, InputStream inputStream, InputStream inputStream0) throws IllegalStateException {
284
        return distribute(target, inputStream, inputStream0);
335
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
285
    }
336
    }
286
337
287
    public ProgressObject undeploy(TargetModuleID[] targetModuleID) throws IllegalStateException {
338
    public ProgressObject undeploy(TargetModuleID[] targetModuleID) throws IllegalStateException {
339
        if (isAs7()) {
340
            return dm.undeploy(translateForUndeploy(targetModuleID));
341
        }
288
        return dm.undeploy(targetModuleID);
342
        return dm.undeploy(targetModuleID);
289
    }
343
    }
290
344
Lines 292-316 Link Here
292
        return dm.stop(targetModuleID);
346
        return dm.stop(targetModuleID);
293
    }
347
    }
294
348
295
    public ProgressObject start(TargetModuleID[] targetModuleID) throws IllegalStateException {
349
    public ProgressObject start(final TargetModuleID[] targetModuleID) throws IllegalStateException {
350
        if (isAs7()) {
351
            try {
352
                return invokeLocalAction(new Callable<ProgressObject>() {
353
354
                    @Override
355
                    public ProgressObject call() {
356
                        return dm.start(unwrap(targetModuleID));
357
                    }
358
                });
359
            } catch (Exception ex) {
360
                LOGGER.log(Level.INFO, null, ex);
361
            }
362
        }
363
296
        return dm.start(targetModuleID);
364
        return dm.start(targetModuleID);
297
    }
365
    }
298
366
299
    public void setLocale(Locale locale) throws UnsupportedOperationException {
300
        dm.setLocale(locale);
301
    }
302
303
    public boolean isLocaleSupported(Locale locale) {
304
        return dm.isLocaleSupported(locale);
305
    }
306
307
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
367
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
308
        //return dm.getAvailableModules(moduleType, target);
368
        if (isAs7()) {
369
            TargetModuleID[] ids = dm.getAvailableModules(moduleType, target);
370
            if (ids != null) {
371
                return ids;
372
            }
373
        }
309
        return new TargetModuleID[]{};
374
        return new TargetModuleID[]{};
310
    }
375
    }
311
376
312
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
377
    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException {
313
        //return dm.getNonRunningModules(moduleType, target);
378
        if (isAs7()) {
379
            return dm.getAvailableModules(moduleType, target);
380
        }
314
        return new TargetModuleID[]{};
381
        return new TargetModuleID[]{};
315
    }
382
    }
316
383
Lines 319-335 Link Here
319
    }
386
    }
320
387
321
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
388
    public ProgressObject redeploy(TargetModuleID[] targetModuleID, File file, File file2) throws UnsupportedOperationException, IllegalStateException {
389
        if (isAs7()) {
390
            return new JB7Deployer(realUri, this).redeploy(targetModuleID, file, file2);
391
        }
322
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
392
        return new JBDeployer(realUri, this).redeploy(targetModuleID, file, file2);
323
    }
393
    }
324
394
325
    public void setDConfigBeanVersion(DConfigBeanVersionType dConfigBeanVersionType) throws DConfigBeanVersionUnsupportedException {
326
        dm.setDConfigBeanVersion(dConfigBeanVersionType);
327
    }
328
329
    public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType dConfigBeanVersionType) {
330
        return dm.isDConfigBeanVersionSupported(dConfigBeanVersionType);
331
    }
332
333
    public void release() {
395
    public void release() {
334
        if (dm != null) {
396
        if (dm != null) {
335
            dm.release();
397
            dm.release();
Lines 340-359 Link Here
340
        return dm.isRedeploySupported();
402
        return dm.isRedeploySupported();
341
    }
403
    }
342
404
405
    public void setDConfigBeanVersion(DConfigBeanVersionType dConfigBeanVersionType) throws DConfigBeanVersionUnsupportedException {
406
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
407
    }
408
409
    public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType dConfigBeanVersionType) {
410
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
411
    }
412
413
    public void setLocale(Locale locale) throws UnsupportedOperationException {
414
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
415
    }
416
417
    public boolean isLocaleSupported(Locale locale) {
418
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
419
    }
420
    
343
    public Locale getCurrentLocale() {
421
    public Locale getCurrentLocale() {
344
        return dm.getCurrentLocale();
422
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
345
    }
423
    }
346
424
347
    public DConfigBeanVersionType getDConfigBeanVersion() {
425
    public DConfigBeanVersionType getDConfigBeanVersion() {
348
        return dm.getDConfigBeanVersion();
426
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
349
    }
427
    }
350
428
351
    public Locale getDefaultLocale() {
429
    public Locale getDefaultLocale() {
352
        return dm.getDefaultLocale();
430
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
353
    }
431
    }
354
432
355
    public Locale[] getSupportedLocales() {
433
    public Locale[] getSupportedLocales() {
356
        return dm.getSupportedLocales();
434
        throw new UnsupportedOperationException("This method should never be called!"); // NOI18N
357
    }
435
    }
358
436
359
    public Target[] getTargets() throws IllegalStateException {
437
    public Target[] getTargets() throws IllegalStateException {
Lines 388-391 Link Here
388
    public synchronized boolean getNeedsRestart() {
466
    public synchronized boolean getNeedsRestart() {
389
        return needsRestart;
467
        return needsRestart;
390
    }
468
    }
469
470
    // we are doing this because undeployment/redeployment as implemented
471
    // in current AS7 expect URL as module ID, though the server seturned IDs
472
    // are just filenames
473
    private TargetModuleID[] translateForUndeploy(TargetModuleID[] ids) {
474
        final String deployDir = getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
475
        if (deployDir != null) {
476
            TargetModuleID[] ret = new TargetModuleID[ids.length];
477
            for (int i = 0; i < ids.length; i++) {
478
                File testFile = new File(deployDir, ids[i].getModuleID());
479
                if (testFile.exists()) {
480
                    // XXX is this needed ?
481
                    File markFile = new File(deployDir, ids[i].getModuleID() + ".deployed"); // NOI18N
482
                    if (markFile.isFile()) {
483
                        try {
484
                            ret[i] = new WrappedTargetModuleID(ids[i], null, testFile.toURI().toURL().toString(), null);
485
                            continue;
486
                        } catch (MalformedURLException ex) {
487
                            LOGGER.log(Level.FINE, null, ex);
488
                        }
489
                    }
490
                }
491
                ret[i] = ids[i];
492
            }
493
            return ret;
494
        }
495
        return ids;
496
    }
497
    
498
    private static TargetModuleID[] unwrap(TargetModuleID[] ids) {
499
        if (ids == null || ids.length == 0) {
500
            return ids;
501
        }
502
        TargetModuleID[] ret = new TargetModuleID[ids.length];
503
        for (int i = 0; i < ids.length; i++) {
504
            if (ids[i] instanceof WrappedTargetModuleID) {
505
                ret[i] = ((WrappedTargetModuleID) ids[i]).getOriginal();
506
            } else {
507
                ret[i] = ids[i];
508
            }
509
        }
510
        return ret;
511
    }
391
}
512
}
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/WrappedTargetModuleID.java (+119 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.j2ee.jboss4;
43
44
import javax.enterprise.deploy.spi.Target;
45
import javax.enterprise.deploy.spi.TargetModuleID;
46
47
/**
48
 *
49
 * @author Petr Hejl
50
 */
51
public class WrappedTargetModuleID implements TargetModuleID {
52
53
    private final TargetModuleID original;
54
55
    private final String webUrl;
56
57
    private final String moduleId;
58
59
    private final TargetModuleID parent;
60
61
    public WrappedTargetModuleID(TargetModuleID original, String webUrl,
62
            String moduleId, TargetModuleID parent) {
63
        this.original = original;
64
        this.webUrl = webUrl;
65
        this.moduleId = moduleId;
66
        this.parent = parent;
67
    }
68
69
    @Override
70
    public Target getTarget() {
71
        return original.getTarget();
72
    }
73
74
    @Override
75
    public String getModuleID() {
76
        if (moduleId != null) {
77
            return moduleId;
78
        }
79
        return original.getModuleID();
80
    }
81
82
    @Override
83
    public String getWebURL() {
84
        if (webUrl != null) {
85
            return webUrl;
86
        }
87
        return original.getWebURL();
88
    }
89
90
    @Override
91
    public String toString() {
92
        return original.toString();
93
    }
94
95
    @Override
96
    public TargetModuleID getParentTargetModuleID() {
97
        if (parent != null) {
98
            return parent;
99
        }
100
        return original.getParentTargetModuleID();
101
    }
102
103
    @Override
104
    public TargetModuleID[] getChildTargetModuleID() {
105
        TargetModuleID[] ids = original.getChildTargetModuleID();
106
        if (ids == null) {
107
            return null;
108
        }
109
        TargetModuleID[] ret = new TargetModuleID[ids.length];
110
        for (int i = 0; i < ids.length; i++) {
111
            ret[i] = new WrappedTargetModuleID(ids[i], webUrl, null, this);
112
        }
113
        return ret;
114
    }
115
116
    public TargetModuleID getOriginal() {
117
        return original;
118
    }
119
}
(-)a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java (-3 / +6 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("JBoss AS") > -1)// JBoss 7.0 message // NOI18N
316
                    && (line.indexOf("Started in") > -1) // NOI18N
317
                        || line.indexOf("started in") > -1 // NOI18N
318
                        || line.indexOf("started (with errors) in") > -1)) { // JBoss 7 with some errors (include wrong deployments) // NOI18N
316
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
319
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
317
320
318
                synchronized (JBOutputSupport.this) {
321
                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 (-2 / +16 lines)
Lines 72-79 Link Here
72
    private Lookup lookup;
72
    private Lookup lookup;
73
    private static final String ADMIN_URL = "/web-console/"; //NOI18N
73
    private static final String ADMIN_URL = "/web-console/"; //NOI18N
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 ADMIN_URL_70 = "/console"; //NOI18N
75
    private static final String JMX_CONSOLE_URL = "/jmx-console/"; //NOI18N
76
    private static final String JMX_CONSOLE_URL = "/jmx-console/"; //NOI18N
76
    private static final String HTTP_HEADER = "http://";
77
    private static final String HTTP_HEADER = "http://";
78
    private Boolean as7;
77
    
79
    
78
    public JBManagerNode(Children children, Lookup lookup) {
80
    public JBManagerNode(Children children, Lookup lookup) {
79
        super(children);
81
        super(children);
Lines 96-104 Link Here
96
    
98
    
97
    public String  getAdminURL() {
99
    public String  getAdminURL() {
98
        Version version = getDeploymentManager().getProperties().getServerVersion();
100
        Version version = getDeploymentManager().getProperties().getServerVersion();
99
        if (version != null && JBPluginUtils.JBOSS_6_0_0.compareTo(version) <= 0) {
101
        if (version != null && JBPluginUtils.JBOSS_7_0_0.compareTo(version) <= 0) {
102
            return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL_70;
103
        } else if (version != null && JBPluginUtils.JBOSS_6_0_0.compareTo(version) <= 0) {
100
            return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL_60;
104
            return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL_60;
101
        }
105
        } 
102
        return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL;
106
        return HTTP_HEADER+getDeploymentManager().getHost()+":"+getDeploymentManager().getPort()+ ADMIN_URL;
103
    }
107
    }
104
    
108
    
Lines 199-206 Link Here
199
        return sheet;
203
        return sheet;
200
    }
204
    }
201
    
205
    
206
    boolean isAs7() {
207
        if (as7 == null) {
208
            as7 = getDeploymentManager().getProperties().isVersion(JBPluginUtils.JBOSS_7_0_0);
209
        }
210
        return as7;
211
    }
212
        
202
    public Image getIcon(int type) {
213
    public Image getIcon(int type) {
203
        if (type == BeanInfo.ICON_COLOR_16x16) {
214
        if (type == BeanInfo.ICON_COLOR_16x16) {
215
            if (isAs7()) {
216
                return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/as7_16x16.png"); // NOI18N
217
            }
204
            return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/16x16.gif"); // NOI18N
218
            return ImageUtilities.loadImage("org/netbeans/modules/j2ee/jboss4/resources/16x16.gif"); // NOI18N
205
        }
219
        }
206
        return super.getIcon(type);
220
        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 (-29 / +78 lines)
Lines 46-57 Link Here
46
46
47
import java.io.File;
47
import java.io.File;
48
import javax.enterprise.deploy.shared.ModuleType;
48
import javax.enterprise.deploy.shared.ModuleType;
49
import javax.enterprise.deploy.spi.TargetModuleID;
50
import javax.enterprise.deploy.spi.exceptions.TargetException;
49
import javax.management.MalformedObjectNameException;
51
import javax.management.MalformedObjectNameException;
50
import javax.management.ObjectName;
52
import javax.management.ObjectName;
51
import org.netbeans.api.progress.ProgressHandle;
53
import org.netbeans.api.progress.ProgressHandle;
52
import org.netbeans.api.progress.ProgressHandleFactory;
54
import org.netbeans.api.progress.ProgressHandleFactory;
53
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
55
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
54
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
56
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
57
import org.netbeans.modules.j2ee.jboss4.nodes.JBAbilitiesSupport;
55
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
58
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
56
import org.openide.util.Lookup;
59
import org.openide.util.Lookup;
57
import org.openide.util.NbBundle;
60
import org.openide.util.NbBundle;
Lines 63-74 Link Here
63
 * @author Michal Mocnak
66
 * @author Michal Mocnak
64
 */
67
 */
65
public class UndeployModuleCookieImpl implements UndeployModuleCookie {
68
public class UndeployModuleCookieImpl implements UndeployModuleCookie {
66
    
69
70
    private static final int TIMEOUT = 30000;
71
72
    private static final int POLLING_INTERVAL = 2000;
73
74
    private static final RequestProcessor PROCESSOR = new RequestProcessor ("JBoss undeploy", 1); // NOI18N
75
67
    private String fileName;
76
    private String fileName;
68
    private Lookup lookup;
77
    private Lookup lookup;
69
    private ModuleType type;
78
    private ModuleType type;
70
    private final boolean isEJB3;
79
    private final boolean isEJB3;
71
    private boolean isRunning;
80
    private boolean isRunning;
81
    private final JBAbilitiesSupport abilitiesSupport;
72
    
82
    
73
    public UndeployModuleCookieImpl(String fileName, ModuleType type, Lookup lookup) {
83
    public UndeployModuleCookieImpl(String fileName, ModuleType type, Lookup lookup) {
74
        this(fileName, type, false, lookup);
84
        this(fileName, type, false, lookup);
Lines 84-89 Link Here
84
        this.type = type;
94
        this.type = type;
85
        this.isEJB3 = isEJB3;
95
        this.isEJB3 = isEJB3;
86
        this.isRunning = false;
96
        this.isRunning = false;
97
        this.abilitiesSupport = new JBAbilitiesSupport(lookup);
87
    }    
98
    }    
88
    
99
    
89
    public Task undeploy() {
100
    public Task undeploy() {
Lines 98-137 Link Here
98
                String deployDir = dm.getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
109
                String deployDir = dm.getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_DEPLOY_DIR);
99
                File file = new File(deployDir, fileName);
110
                File file = new File(deployDir, fileName);
100
                
111
                
101
                if(file.exists() && file.canWrite()) {
112
                if (file.exists() && file.canWrite()) {
102
                    file.delete();
113
                    file.delete();
103
                    
114
                    if (abilitiesSupport.isJB7x()) {
104
                    try {
115
                        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;
116
                        int time = 0;
124
                        while(Util.isObjectDeployed(dm, searchPattern) && time < 30000) {
117
                        while (statusFile.exists() && time < TIMEOUT) {
125
                            try {
118
                            try {
126
                                Thread.sleep(2000);
119
                                Thread.sleep(POLLING_INTERVAL);
127
                                time += 2000;
120
                                time += POLLING_INTERVAL;
128
                            } catch (InterruptedException ex) {
121
                            } catch (InterruptedException ex) {
129
                                // Nothing to do
122
                                // Nothing to do
130
                            }
123
                            }
131
                        }
124
                        }
132
                    } catch (MalformedObjectNameException ex) {
125
                        boolean wait = true;
133
                    } catch (NullPointerException ex) {
126
                        while (wait && time < TIMEOUT) {
134
                        // Nothing to do
127
                            try {
128
                                wait = false;
129
                                TargetModuleID[] ids = dm.getAvailableModules(type, dm.getTargets());
130
                                if (ids != null) {
131
                                    for (TargetModuleID id : ids) {
132
                                        if (fileName.equals(id.getModuleID())) {
133
                                            wait = true;
134
                                            break;
135
                                        }
136
                                    }
137
                                }
138
                            } catch (TargetException ex) {
139
                            } catch (IllegalStateException ex) {
140
                                // Nothing to do
141
                            }
142
                            if (wait) {
143
                                try {
144
                                    Thread.sleep(POLLING_INTERVAL);
145
                                    time += POLLING_INTERVAL;
146
                                } catch (InterruptedException ex) {
147
                                    // Nothing to do
148
                                }
149
                            }
150
                        }
151
                    } else {
152
                        try {
153
                            ObjectName searchPattern = null;
154
                            if (Util.isRemoteManagementSupported(lookup) && !isEJB3) {
155
                                searchPattern = new ObjectName("jboss.management.local:"+(!type.equals(ModuleType.EAR) ?
156
                                    "J2EEApplication=null," : "")+"j2eeType="+Util.getModuleTypeString(type)+",name=" + fileName + ",*");
157
                            } else {
158
                                if (type.equals(ModuleType.EAR)) {
159
                                    searchPattern = new ObjectName("jboss.j2ee:service=EARDeployment,url='" + fileName + "'"); // NOI18N
160
                            }
161
                            else 
162
                            if (type.equals(ModuleType.WAR)) {
163
                                    searchPattern = new ObjectName("jboss.web:j2eeType=WebModule,J2EEApplication=none,name=//localhost/" + nameWoExt + ",*"); // NOI18N
164
                            }
165
                            else
166
                            if (type.equals(ModuleType.EJB)) {
167
                                    searchPattern = new ObjectName("jboss.j2ee:service=" + (isEJB3 ? "EJB3" : "EjbModule") + ",module=" + fileName); // NOI18N
168
                                }
169
                            }
170
171
                            int time = 0;
172
                            while(Util.isObjectDeployed(dm, searchPattern) && time < TIMEOUT) {
173
                                    try {
174
                                        Thread.sleep(POLLING_INTERVAL);
175
                                        time += POLLING_INTERVAL;
176
                                    } catch (InterruptedException ex) {
177
                                        // Nothing to do
178
                                    }
179
                                }
180
                            } catch (MalformedObjectNameException ex) {
181
                            } catch (NullPointerException ex) {
182
                                // Nothing to do
183
                            }
135
                    }
184
                    }
136
                }
185
                }
137
                
186
                
Lines 141-147 Link Here
141
        };
190
        };
142
        
191
        
143
        handle.start();
192
        handle.start();
144
        return RequestProcessor.getDefault().post(r);
193
        return PROCESSOR.post(r);
145
    }
194
    }
146
    
195
    
147
    public boolean isRunning() {
196
    public boolean isRunning() {
(-)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(new File(rootDir, "modules"), "javax"), list); // NOI18N
245
            
245
            
246
            Set<String> commonLibs = new HashSet<String>();
246
            Set<String> commonLibs = new HashSet<String>();
247
    
247
    
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/projects/DeploymentTarget.java (+2 lines)
Lines 244-249 Link Here
244
        // prefer the matched
244
        // prefer the matched
245
        if (tmid != null) {
245
        if (tmid != null) {
246
            urlString = tmid.getWebURL();
246
            urlString = tmid.getWebURL();
247
        } else if (children == null || children.length == 0) {
248
            urlString = module.getWebURL();
247
        }
249
        }
248
        
250
        
249
        return urlString;
251
        return urlString;

Return to bug 200132