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

Collapse All | Expand All

(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java (-28 / +60 lines)
 Lines 116-143    Link Here 
116
            return p;
116
            return p;
117
        }
117
        }
118
118
119
       public Enumeration<URL> getResources(String name) throws IOException {
119
        public Enumeration<URL> getResources(String name) throws IOException {
120
           // get rid of annoying warnings
120
            // get rid of annoying warnings
121
           if (name.indexOf("jndi.properties") != -1) {// || name.indexOf("i18n_user.properties") != -1) { // NOI18N
121
            if (name.indexOf("jndi.properties") != -1) {// || name.indexOf("i18n_user.properties") != -1) { // NOI18N
122
               return Collections.enumeration(Collections.<URL>emptyList());
122
                return Collections.enumeration(Collections.<URL>emptyList());
123
           }
123
            }
124
124
125
           return super.getResources(name);
125
            return super.getResources(name);
126
       }
126
        }
127
    }
127
    }
128
128
129
    public static URLClassLoader getJBClassLoader(String serverRoot, String domainRoot) {
129
    public static URLClassLoader getJBClassLoader(String serverRoot, String domainRoot) {
130
        try {
130
        try {
131
131
132
            Version JBVer = JBPluginUtils.getServerVersion(new File (serverRoot));
132
            Version JBVer = JBPluginUtils.getServerVersion(new File(serverRoot));
133
            boolean version5Above = (JBVer != null && JBVer.compareToIgnoreUpdate(JBPluginUtils.JBOSS_5_0_0) >= 0);
133
            boolean version5Above = (JBVer != null && JBVer.compareToIgnoreUpdate(JBPluginUtils.JBOSS_5_0_0) >= 0);
134
134
135
            // dom4j.jar library for JBoss Application Server 4.0.4 and lower and JBoss Application Server 5.0
135
            // dom4j.jar library for JBoss Application Server 4.0.4 and lower and JBoss Application Server 5.0
136
            File domFile = new File(serverRoot , JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
136
            File domFile = new File(serverRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
137
            if (!domFile.exists()) {
137
            if (!domFile.exists()) {
138
                // dom4j.jar library for JBoss Application Server 4.0.5
138
                // dom4j.jar library for JBoss Application Server 4.0.5
139
                domFile = new File(domainRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
139
                domFile = new File(domainRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N
140
            }
140
            }
141
142
            String sep = File.separator;
143
            if (!domFile.exists() && "7".equals(JBVer.getMajorNumber())) {
144
                domFile = new File(serverRoot, JBPluginUtils.MODULES + "org" + sep + "dom4j" + sep + "main" + sep + "dom4j-1.6.1.jar"); // NOI18N
145
            }
141
            if (!domFile.exists()) {
146
            if (!domFile.exists()) {
142
                domFile = null;
147
                domFile = null;
143
                LOGGER.log(Level.INFO, "No dom4j.jar availabale on classpath"); // NOI18N
148
                LOGGER.log(Level.INFO, "No dom4j.jar availabale on classpath"); // NOI18N
 Lines 157-174    Link Here 
157
162
158
            List<URL> urlList = new ArrayList<URL>();
163
            List<URL> urlList = new ArrayList<URL>();
159
164
160
              if (domFile != null) {
165
            if (domFile != null) {
161
                urlList.add(domFile.toURI().toURL());
166
                urlList.add(domFile.toURI().toURL());
162
            }
167
            }
163
168
164
            if  (version5Above) {
169
            if ("7".equals(JBVer.getMajorNumber())) {
170
               
171
                File org = new File(serverRoot, JBPluginUtils.MODULES + "org");
172
                File jboss = new File(org, "jboss");
173
                File as = new File(jboss, "as");
174
                String versionString = JBVer.getMajorNumber()+"."+JBVer.getMinorNumber()+"."+JBVer.getMicroNumber()+"."+JBVer.getUpdate();
175
                
176
                if (domFile.exists()) {
177
                    urlList.add(domFile.toURI().toURL());
178
                }
179
                
180
                urlList.add(new File(serverRoot, "jboss-modules.jar").toURI().toURL());
181
                urlList.add(new File(serverRoot, "bin"+sep+"client"+sep+"jboss-client.jar").toURI().toURL());
182
                urlList.add(new File(jboss, "logging" + sep + "main" + sep + "jboss-logging-3.1.0.GA.jar").toURI().toURL());
183
                urlList.add(new File(jboss, "threads" + sep + "main" + sep + "jboss-threads-2.0.0.GA.jar").toURI().toURL());
184
                urlList.add(new File(jboss, "remoting3" + sep + "main" + sep + "jboss-remoting-3.2.3.GA.jar").toURI().toURL());
185
                urlList.add(new File(jboss, "xnio" + sep + "main" + sep + "xnio-api-3.0.3.GA.jar").toURI().toURL());
186
                urlList.add(new File(jboss, "msc" + sep + "main" + sep + "jboss-msc-1.0.2.GA.jar").toURI().toURL());
187
                urlList.add(new File(as, "ee" + sep + "deployment" + sep + "main" + sep + "jboss-as-ee-deployment-" + versionString + ".jar").toURI().toURL());
188
                urlList.add(new File(as, "naming" + sep + "main" + sep + "jboss-as-naming-" + versionString + ".jar").toURI().toURL());
189
                urlList.add(new File(as, "controller-client" + sep + "main" + sep + "jboss-as-controller-client-" + versionString + ".jar").toURI().toURL());
190
                urlList.add(new File(as, "protocol" + sep + "main" + sep + "jboss-as-protocol-" + versionString + ".jar").toURI().toURL());
191
            } else if (version5Above) {
165
                // get lient class path for Jboss 5.0
192
                // get lient class path for Jboss 5.0
166
                List<URL> clientClassUrls = JBPluginUtils.getJB5ClientClasspath(
193
                List<URL> clientClassUrls = JBPluginUtils.getJB5ClientClasspath(
167
                        serverRoot);
194
                        serverRoot);
168
                urlList.addAll(clientClassUrls);
195
                urlList.addAll(clientClassUrls);
169
196
170
                File runFile = new File(serverRoot, "bin" + File.separator + "run.jar"); // NOI18N
197
                File runFile = new File(serverRoot, "bin" + File.separator + "run.jar"); // NOI18N
171
                if ( runFile.exists()) {
198
                if (runFile.exists()) {
172
                    urlList.add(runFile.toURI().toURL());
199
                    urlList.add(runFile.toURI().toURL());
173
                }
200
                }
174
201
 Lines 181-187    Link Here 
181
                        + "lib" + File.separator + "jboss-profileservice.jar"); // NOI18N
208
                        + "lib" + File.separator + "jboss-profileservice.jar"); // NOI18N
182
                if (profileFile.exists()) {
209
                if (profileFile.exists()) {
183
                    urlList.add(profileFile.toURI().toURL());
210
                    urlList.add(profileFile.toURI().toURL());
184
                }                
211
                }
185
                File managedFile = new File(serverRoot, "lib" + File.separator + "jboss-managed.jar"); // NOI18N
212
                File managedFile = new File(serverRoot, "lib" + File.separator + "jboss-managed.jar"); // NOI18N
186
                if (managedFile.exists()) {
213
                if (managedFile.exists()) {
187
                    urlList.add(managedFile.toURI().toURL());
214
                    urlList.add(managedFile.toURI().toURL());
 Lines 189-205    Link Here 
189
                File metaFile = new File(serverRoot, "lib" + File.separator + "jboss-metatype.jar"); // NOI18N
216
                File metaFile = new File(serverRoot, "lib" + File.separator + "jboss-metatype.jar"); // NOI18N
190
                if (metaFile.exists()) {
217
                if (metaFile.exists()) {
191
                    urlList.add(metaFile.toURI().toURL());
218
                    urlList.add(metaFile.toURI().toURL());
192
                }                 
219
                }
193
            } else {  // version < 5.0
220
            } else {  // version < 5.0
194
                urlList.add(
221
                urlList.add(
195
                        new File(serverRoot , JBPluginUtils.CLIENT + "jbossall-client.jar").toURI().toURL());      //NOI18N
222
                        new File(serverRoot, JBPluginUtils.CLIENT + "jbossall-client.jar").toURI().toURL());      //NOI18N
196
                urlList.add(
223
                urlList.add(
197
                        new File(serverRoot , JBPluginUtils.CLIENT + "jboss-deployment.jar").toURI().toURL());     //NOI18N
224
                        new File(serverRoot, JBPluginUtils.CLIENT + "jboss-deployment.jar").toURI().toURL());     //NOI18N
198
                urlList.add(
225
                urlList.add(
199
                        new File(serverRoot, JBPluginUtils.CLIENT + "jnp-client.jar").toURI().toURL());           //NOI18N
226
                        new File(serverRoot, JBPluginUtils.CLIENT + "jnp-client.jar").toURI().toURL());           //NOI18N
200
227
201
                // jboss-common-client.jar JBoss Application Server 4.x
228
                // jboss-common-client.jar JBoss Application Server 4.x
202
                File client40 = new File(serverRoot , JBPluginUtils.CLIENT + "jboss-common-client.jar"); // NOI18N
229
                File client40 = new File(serverRoot, JBPluginUtils.CLIENT + "jboss-common-client.jar"); // NOI18N
203
                if (client40.exists()) {
230
                if (client40.exists()) {
204
                    urlList.add(client40.toURI().toURL());
231
                    urlList.add(client40.toURI().toURL());
205
                }
232
                }
 Lines 221-227    Link Here 
221
//                urlList.add(logging50.toURI().toURL());
248
//                urlList.add(logging50.toURI().toURL());
222
//            }
249
//            }
223
250
224
            URLClassLoader loader = new JBClassLoader(urlList.toArray(new URL[] {}), JBDeploymentFactory.class.getClassLoader());
251
            URLClassLoader loader = new JBClassLoader(urlList.toArray(new URL[]{}), JBDeploymentFactory.class.getClassLoader());
225
            return loader;
252
            return loader;
226
        } catch (Exception e) {
253
        } catch (Exception e) {
227
            LOGGER.log(Level.WARNING, null, e);
254
            LOGGER.log(Level.WARNING, null, e);
 Lines 233-242    Link Here 
233
        DeploymentFactory jbossFactory = null;
260
        DeploymentFactory jbossFactory = null;
234
        try {
261
        try {
235
            String jbossRoot = InstanceProperties.getInstanceProperties(instanceURL).
262
            String jbossRoot = InstanceProperties.getInstanceProperties(instanceURL).
236
                                    getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
263
                    getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
237
264
238
            String domainRoot = InstanceProperties.getInstanceProperties(instanceURL).
265
            String domainRoot = InstanceProperties.getInstanceProperties(instanceURL).
239
                                    getProperty(JBPluginProperties.PROPERTY_SERVER_DIR);
266
                    getProperty(JBPluginProperties.PROPERTY_SERVER_DIR);
240
267
241
            // if jbossRoot is null, then we are in a server instance registration process, thus this call
268
            // if jbossRoot is null, then we are in a server instance registration process, thus this call
242
            // is made from InstanceProperties creation -> JBPluginProperties singleton contains
269
            // is made from InstanceProperties creation -> JBPluginProperties singleton contains
 Lines 251-259    Link Here 
251
                domainRoot = JBPluginProperties.getInstance().getDomainLocation();
278
                domainRoot = JBPluginProperties.getInstance().getDomainLocation();
252
279
253
            jbossFactory = (DeploymentFactory) jbossFactories.get(jbossRoot);
280
            jbossFactory = (DeploymentFactory) jbossFactories.get(jbossRoot);
254
            if ( jbossFactory == null ) {
281
            if (jbossFactory == null) {
282
                Version version = JBPluginUtils.getServerVersion(new File(jbossRoot));
255
                URLClassLoader loader = getJBClassLoader(jbossRoot, domainRoot);
283
                URLClassLoader loader = getJBClassLoader(jbossRoot, domainRoot);
256
                jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N
284
                if(version!= null && "7".equals(version.getMajorNumber())) {
285
                    jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.as.ee.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N
286
                } else {
287
                    jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N
288
                }
257
289
258
                jbossFactories.put(jbossRoot, jbossFactory);
290
                jbossFactories.put(jbossRoot, jbossFactory);
259
            }
291
            }
 Lines 337-343    Link Here 
337
369
338
    public String getProductVersion() {
370
    public String getProductVersion() {
339
371
340
        return NbBundle.getMessage (JBDeploymentFactory.class, "LBL_JBossFactoryVersion");
372
        return NbBundle.getMessage(JBDeploymentFactory.class, "LBL_JBossFactoryVersion");
341
    }
373
    }
342
374
343
    public String getDisplayName() {
375
    public String getDisplayName() {
 Lines 379-385    Link Here 
379
    private static boolean isAlreadyRegistered(FileObject serverInstanceDir, String domainLocation) throws IOException {
411
    private static boolean isAlreadyRegistered(FileObject serverInstanceDir, String domainLocation) throws IOException {
380
        String domainLocationCan = new File(domainLocation).getCanonicalPath();
412
        String domainLocationCan = new File(domainLocation).getCanonicalPath();
381
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
413
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
382
            String installedLocation = (String)instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR);
414
            String installedLocation = (String) instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR);
383
            if (installedLocation != null) {
415
            if (installedLocation != null) {
384
                String installedLocationCan = new File(installedLocation).getCanonicalPath();
416
                String installedLocationCan = new File(installedLocation).getCanonicalPath();
385
                if (domainLocationCan.equals(installedLocationCan)) {
417
                if (domainLocationCan.equals(installedLocationCan)) {
 Lines 394-404    Link Here 
394
    private static void setRemovability(FileObject serverInstanceDir, String domainLocation) throws IOException {
426
    private static void setRemovability(FileObject serverInstanceDir, String domainLocation) throws IOException {
395
        String domainLocationCan = new File(domainLocation).getCanonicalPath();
427
        String domainLocationCan = new File(domainLocation).getCanonicalPath();
396
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
428
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
397
            String url = (String)instanceFO.getAttribute(InstanceProperties.URL_ATTR);
429
            String url = (String) instanceFO.getAttribute(InstanceProperties.URL_ATTR);
398
            if (url == null) { // can occur if some unxpected file is in the directory
430
            if (url == null) { // can occur if some unxpected file is in the directory
399
                LOGGER.log(Level.INFO, "No server URL in " + FileUtil.getFileDisplayName(instanceFO));
431
                LOGGER.log(Level.INFO, "No server URL in " + FileUtil.getFileDisplayName(instanceFO));
400
            } else if (url.startsWith(URI_PREFIX)) { // it's JBoss instance
432
            } else if (url.startsWith(URI_PREFIX)) { // it's JBoss instance
401
                String installedLocation = (String)instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR);
433
                String installedLocation = (String) instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR);
402
                String installedLocationCan = new File(installedLocation).getCanonicalPath();
434
                String installedLocationCan = new File(installedLocation).getCanonicalPath();
403
                if (domainLocationCan.equals(installedLocationCan)) {
435
                if (domainLocationCan.equals(installedLocationCan)) {
404
                    instanceFO.setAttribute(InstanceProperties.REMOVE_FORBIDDEN, Boolean.TRUE);
436
                    instanceFO.setAttribute(InstanceProperties.REMOVE_FORBIDDEN, Boolean.TRUE);
 Lines 448-454    Link Here 
448
        Set<String> registeredInstances = getServerInstancesNames(serverInstanceDir);
480
        Set<String> registeredInstances = getServerInstancesNames(serverInstanceDir);
449
481
450
        while (registeredInstances.contains(instanceName.toUpperCase())) {
482
        while (registeredInstances.contains(instanceName.toUpperCase())) {
451
            instanceName = serverName  + " (" + String.valueOf(counter++) + ")";
483
            instanceName = serverName + " (" + String.valueOf(counter++) + ")";
452
        }
484
        }
453
485
454
        return instanceName;
486
        return instanceName;
 Lines 457-463    Link Here 
457
    private static Set<String> getServerInstancesNames(FileObject serverInstanceDir) {
489
    private static Set<String> getServerInstancesNames(FileObject serverInstanceDir) {
458
        Set<String> names = new HashSet<String>();
490
        Set<String> names = new HashSet<String>();
459
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
491
        for (FileObject instanceFO : serverInstanceDir.getChildren()) {
460
            String instanceName = (String)instanceFO.getAttribute(InstanceProperties.DISPLAY_NAME_ATTR);
492
            String instanceName = (String) instanceFO.getAttribute(InstanceProperties.DISPLAY_NAME_ATTR);
461
            names.add(instanceName.toUpperCase());
493
            names.add(instanceName.toUpperCase());
462
        }
494
        }
463
495
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java (-15 / +37 lines)
 Lines 53-58    Link Here 
53
import java.io.IOException;
53
import java.io.IOException;
54
import java.io.InputStream;
54
import java.io.InputStream;
55
import java.net.URLClassLoader;
55
import java.net.URLClassLoader;
56
import java.util.HashMap;
56
import java.util.Locale;
57
import java.util.Locale;
57
import java.util.Properties;
58
import java.util.Properties;
58
import java.util.logging.Level;
59
import java.util.logging.Level;
 Lines 73-83    Link Here 
73
import javax.management.MBeanServerConnection;
74
import javax.management.MBeanServerConnection;
74
import javax.management.ObjectName;
75
import javax.management.ObjectName;
75
import javax.management.ReflectionException;
76
import javax.management.ReflectionException;
77
import javax.management.remote.JMXConnector;
78
import javax.management.remote.JMXConnectorFactory;
79
import javax.management.remote.JMXServiceURL;
76
import javax.naming.Context;
80
import javax.naming.Context;
77
import javax.naming.InitialContext;
81
import javax.naming.InitialContext;
78
import javax.naming.NamingException;
82
import javax.naming.NamingException;
79
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
83
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
80
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
84
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
85
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version;
81
86
82
/**
87
/**
83
 *
88
 *
 Lines 161-167    Link Here 
161
    
166
    
162
    private void init() {
167
    private void init() {
163
        ClassLoader oldLoader = null;
168
        ClassLoader oldLoader = null;
164
169
        
165
        try {
170
        try {
166
            oldLoader = Thread.currentThread().getContextClassLoader();
171
            oldLoader = Thread.currentThread().getContextClassLoader();
167
            InstanceProperties ip = this.getInstanceProperties();
172
            InstanceProperties ip = this.getInstanceProperties();
 Lines 171-177    Link Here 
171
176
172
            JBProperties props = getProperties();
177
            JBProperties props = getProperties();
173
            Properties env = new Properties();
178
            Properties env = new Properties();
174
179
            
175
            // Sets the jboss naming environment
180
            // Sets the jboss naming environment
176
            String jnpPort = Integer.toString(
181
            String jnpPort = Integer.toString(
177
                    JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)));
182
                    JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)));
 Lines 193-214    Link Here 
193
                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
198
                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
194
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
199
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
195
            }
200
            }
201
            
202
            Version version = props.getServerVersion();
203
            if(version != null && "7".equals(version.getMajorNumber())) {
204
//                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
205
                String host = "localhost";
206
                int port = 9999;  // management-native port
207
    //            int port = 1099;
208
                String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port);
196
209
197
            // Gets naming context
210
    //        String urlString = System.getProperty("jmx.service.url", "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi");
198
            InitialContext ctx = new InitialContext(env);
211
                JMXServiceURL serviceURL = new JMXServiceURL(urlString);
212
                Map environment = new HashMap();
213
                environment.put(Context.SECURITY_PRINCIPAL, props.getUsername());
214
                environment.put(Context.SECURITY_CREDENTIALS, props.getPassword());
215
                JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, environment);
216
                rmiServer = jmxConnector.getMBeanServerConnection();
217
            } else {
218
                // Gets naming context
219
                InitialContext ctx = new InitialContext(env);
199
220
200
            //restore java.security.auth.login.config system property
221
                //restore java.security.auth.login.config system property
201
            if (oldAuthConf != null) {
222
                if (oldAuthConf != null) {
202
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf);
223
                    System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf);
203
            } else {
224
                } else {
204
                System.clearProperty(JAVA_SEC_AUTH_LOGIN_CONF);
225
                    System.clearProperty(JAVA_SEC_AUTH_LOGIN_CONF);
205
            }
226
                }
206
227
207
            // Lookup RMI Adaptor
228
                // Lookup RMI Adaptor
208
            rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor");
229
                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor");
209
            Object service = ctx.lookup("ProfileService");
230
                Object service = ctx.lookup("ProfileService");
210
            if (service != null) {
231
                if (service != null) {
211
                profileServiceProxy = new JBoss5ProfileServiceProxy(service);
232
                    profileServiceProxy = new JBoss5ProfileServiceProxy(service);
233
                }
212
            }
234
            }
213
        } catch (NameNotFoundException ex) {
235
        } catch (NameNotFoundException ex) {
214
            LOGGER.log(Level.FINE, null, ex);
236
            LOGGER.log(Level.FINE, null, ex);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java (-2 / +3 lines)
 Lines 309-318    Link Here 
309
                    || line.indexOf("Starting JBossAS") > -1) { // JBoss 6.0 message // NOI18N
309
                    || line.indexOf("Starting JBossAS") > -1) { // JBoss 6.0 message // NOI18N
310
                LOGGER.log(Level.FINER, "STARTING message fired"); // NOI18N
310
                LOGGER.log(Level.FINER, "STARTING message fired"); // NOI18N
311
                //fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N
311
                //fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N
312
            } else if ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N
312
            } else if ( ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N
313
                    || line.indexOf("JBoss (Microcontainer)") > -1 // JBoss 5.0 message // NOI18N
313
                    || line.indexOf("JBoss (Microcontainer)") > -1 // JBoss 5.0 message // NOI18N
314
                    || line.indexOf("JBossAS") > -1) // JBoss 6.0 message // NOI18N
314
                    || line.indexOf("JBossAS") > -1) // JBoss 6.0 message // NOI18N
315
                    && line.indexOf("Started in") > -1) { // NOI18N
315
                    && line.indexOf("Started in") > -1) 
316
                    || line.indexOf("JBoss AS") > -1 && line.indexOf("started in") > -1) { // NOI18N
316
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
317
                LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N
317
318
318
                synchronized (JBOutputSupport.this) {
319
                synchronized (JBOutputSupport.this) {
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java (-28 / +26 lines)
 Lines 62-74    Link Here 
62
import javax.enterprise.deploy.shared.CommandType;
62
import javax.enterprise.deploy.shared.CommandType;
63
import javax.enterprise.deploy.shared.StateType;
63
import javax.enterprise.deploy.shared.StateType;
64
import org.netbeans.api.java.platform.JavaPlatform;
64
import org.netbeans.api.java.platform.JavaPlatform;
65
import org.netbeans.api.extexecution.startup.StartupExtender;
66
import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge;
67
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
65
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
68
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
66
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
67
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
69
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
68
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
70
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
69
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
71
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
70
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
71
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version;
72
import org.netbeans.modules.j2ee.jboss4.util.JBProperties;
72
import org.netbeans.modules.j2ee.jboss4.util.JBProperties;
73
import org.openide.execution.NbProcessDescriptor;
73
import org.openide.execution.NbProcessDescriptor;
74
import org.openide.filesystems.FileObject;
74
import org.openide.filesystems.FileObject;
 Lines 77-83    Link Here 
77
import org.openide.util.Exceptions;
77
import org.openide.util.Exceptions;
78
import org.openide.util.NbBundle;
78
import org.openide.util.NbBundle;
79
import org.openide.util.Utilities;
79
import org.openide.util.Utilities;
80
import org.openide.util.lookup.Lookups;
81
import org.openide.windows.InputOutput;
80
import org.openide.windows.InputOutput;
82
81
83
/**
82
/**
 Lines 100-107    Link Here 
100
99
101
    private final static String STARTUP_SH = File.separator + 
100
    private final static String STARTUP_SH = File.separator + 
102
            "bin" + File.separator + "run.sh";          // NOI18N
101
            "bin" + File.separator + "run.sh";          // NOI18N
102
    private final static String STANDALONE_SH = File.separator + 
103
            "bin" + File.separator + "standalone.sh";          // NOI18N
103
    private final static String STARTUP_BAT = File.separator + 
104
    private final static String STARTUP_BAT = File.separator + 
104
            "bin" + File.separator + RUN_FILE_NAME;     // NOI18N
105
            "bin" + File.separator + RUN_FILE_NAME;     // NOI18N
106
    private final static String STANDALONE_BAT = File.separator + 
107
            "bin" + File.separator + "standalone.bat";     // NOI18N
105
                             
108
                             
106
    private final static String CONF_BAT = File.separator + 
109
    private final static String CONF_BAT = File.separator + 
107
            "bin" + File.separator + CONF_FILE_NAME;    // NOI18N
110
            "bin" + File.separator + CONF_FILE_NAME;    // NOI18N
 Lines 122-132    Link Here 
122
    private JBDeploymentManager dm;
125
    private JBDeploymentManager dm;
123
    private String instanceName;
126
    private String instanceName;
124
    private JBStartServer startServer;
127
    private JBStartServer startServer;
128
    private ProfilerServerSettings profilerSettings;
125
129
126
    JBStartRunnable(JBDeploymentManager dm, JBStartServer startServer) {
130
    JBStartRunnable(ProfilerServerSettings profilerSettings, JBDeploymentManager dm, JBStartServer startServer) {
127
        this.dm = dm;
131
        this.dm = dm;
128
        this.instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
132
        this.instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
129
        this.startServer = startServer;
133
        this.startServer = startServer;
134
        this.profilerSettings = profilerSettings;
130
    }
135
    }
131
136
132
    public void run() {
137
    public void run() {
 Lines 205-211    Link Here 
205
        }
210
        }
206
211
207
        // get Java platform that will run the server
212
        // get Java platform that will run the server
208
        JavaPlatform platform = properties.getJavaPlatform();
213
        JavaPlatform platform = (startServer.getMode() != JBStartServer.MODE.PROFILE ? properties.getJavaPlatform() : profilerSettings.getJavaPlatform());
209
214
210
        if (startServer.getMode() == JBStartServer.MODE.DEBUG && javaOptsBuilder.toString().indexOf("-Xdebug") == -1) { // NOI18N
215
        if (startServer.getMode() == JBStartServer.MODE.DEBUG && javaOptsBuilder.toString().indexOf("-Xdebug") == -1) { // NOI18N
211
            // if in debug mode and the debug options not specified manually
216
            // if in debug mode and the debug options not specified manually
 Lines 217-235    Link Here 
217
                            append(",server=y,suspend=n"); // NOI18N
222
                            append(",server=y,suspend=n"); // NOI18N
218
223
219
        } else if (startServer.getMode() == JBStartServer.MODE.PROFILE) {
224
        } else if (startServer.getMode() == JBStartServer.MODE.PROFILE) {
225
226
            // get JVM arguments used for starting the server
227
            String[] profJvmArgs = profilerSettings.getJvmArgs();
228
            for (int i = 0; i < profJvmArgs.length; i++) {
229
                javaOptsBuilder.append(" ").append(profJvmArgs[i]); // NOI18N
230
            }
220
            if (properties.isVersion(JBPluginUtils.JBOSS_6_0_0)) {
231
            if (properties.isVersion(JBPluginUtils.JBOSS_6_0_0)) {
221
                javaOptsBuilder.append(" ").append("-Djboss.platform.mbeanserver")
232
                javaOptsBuilder.append(" ").append("-Djboss.platform.mbeanserver")
222
                        .append(" ").append("-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl");
233
                        .append(" ").append("-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl");
223
            }
234
            }
224
        }
235
        }
225
236
226
        for (StartupExtender args : StartupExtender.getExtenders(
227
                Lookups.singleton(CommonServerBridge.getCommonInstance(ip.getProperty("url"))), getMode(startServer.getMode()))) {
228
            for (String singleArg : args.getArguments()) {
229
                javaOptsBuilder.append(' ').append(singleArg);
230
            }
231
        }
232
233
        // create new environment for server
237
        // create new environment for server
234
        javaOpts = javaOptsBuilder.toString();
238
        javaOpts = javaOptsBuilder.toString();
235
        String javaHome = getJavaHome(platform);
239
        String javaHome = getJavaHome(platform);
 Lines 242-258    Link Here 
242
        };
246
        };
243
        return envp;
247
        return envp;
244
    }
248
    }
245
249
    
246
    private static StartupExtender.StartMode getMode(JBStartServer.MODE jbMode) {
247
        if (JBStartServer.MODE.PROFILE.equals(jbMode)) {
248
            return StartupExtender.StartMode.PROFILE;
249
        } else if (JBStartServer.MODE.DEBUG.equals(jbMode)) {
250
            return StartupExtender.StartMode.DEBUG;
251
        } else {
252
            return StartupExtender.StartMode.NORMAL;
253
        }
254
    }
255
256
    private boolean checkPorts(final InstanceProperties ip) {
250
    private boolean checkPorts(final InstanceProperties ip) {
257
251
258
        try {
252
        try {
 Lines 316-322    Link Here 
316
310
317
        final String instanceName = ip.getProperty(JBPluginProperties.PROPERTY_SERVER);
311
        final String instanceName = ip.getProperty(JBPluginProperties.PROPERTY_SERVER);
318
        String args = ("all".equals(instanceName) ? "-b 127.0.0.1 " : "") + "-c " + instanceName; // NOI18N
312
        String args = ("all".equals(instanceName) ? "-b 127.0.0.1 " : "") + "-c " + instanceName; // NOI18N
319
        return new NbProcessDescriptor(serverRunFileName, args);
313
        return new NbProcessDescriptor(serverRunFileName, isJBoss7()? "" : args);
320
    }
314
    }
321
    
315
    
322
    private String getRunFileName( InstanceProperties ip, String[] envp ){
316
    private String getRunFileName( InstanceProperties ip, String[] envp ){
 Lines 346-363    Link Here 
346
        }
340
        }
347
341
348
        try {
342
        try {
349
            return pd.exec(null, envp, true, null );
343
            return pd.exec(null, envp, true, null);
350
        } catch (java.io.IOException ioe) {
344
        } catch (java.io.IOException ioe) {
351
            Logger.getLogger("global").log(Level.INFO, null, ioe);
345
            Logger.getLogger("global").log(Level.INFO, null, ioe);
352
346
353
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
347
            final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
354
            final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
348
            final String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
355
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
349
            fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName));
356
350
357
            return null;
351
            return null;
358
        }
352
        }
359
    }
353
    }
360
    
354
    
355
    private boolean isJBoss7() {
356
        Version serverVersion = dm.getProperties().getServerVersion();
357
        return serverVersion!=null && "7".equals(serverVersion.getMajorNumber());
358
    }
359
    
361
    private InputOutput openConsole() {
360
    private InputOutput openConsole() {
362
        InputOutput io = UISupport.getServerIO(dm.getUrl());
361
        InputOutput io = UISupport.getServerIO(dm.getUrl());
363
        if (io == null) {
362
        if (io == null) {
 Lines 413-420    Link Here 
413
        String getRunFileName(){
412
        String getRunFileName(){
414
            String serverLocation = getProperties().getProperty(
413
            String serverLocation = getProperties().getProperty(
415
                    JBPluginProperties.PROPERTY_ROOT_DIR);
414
                    JBPluginProperties.PROPERTY_ROOT_DIR);
416
            String serverRunFileName = serverLocation + 
415
            String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
417
                (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH);
418
            if ( needChange ){
416
            if ( needChange ){
419
                String contentRun = readFile(serverRunFileName);
417
                String contentRun = readFile(serverRunFileName);
420
                String contentConf = readFile(serverLocation + CONF_BAT);
418
                String contentConf = readFile(serverLocation + CONF_BAT);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java (-81 / +97 lines)
 Lines 45-50    Link Here 
45
45
46
import java.net.URISyntaxException;
46
import java.net.URISyntaxException;
47
import java.util.Collections;
47
import java.util.Collections;
48
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
48
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
49
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
49
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
50
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
50
import java.io.IOException;
51
import java.io.IOException;
 Lines 71-76    Link Here 
71
import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
72
import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException;
72
import javax.enterprise.deploy.spi.status.ClientConfiguration;
73
import javax.enterprise.deploy.spi.status.ClientConfiguration;
73
import javax.enterprise.deploy.spi.status.DeploymentStatus;
74
import javax.enterprise.deploy.spi.status.DeploymentStatus;
75
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version;
74
import org.openide.util.NbBundle;
76
import org.openide.util.NbBundle;
75
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
77
import org.netbeans.modules.j2ee.jboss4.nodes.Util;
76
78
 Lines 78-126    Link Here 
78
 *
80
 *
79
 * @author Kirill Sorokin
81
 * @author Kirill Sorokin
80
 */
82
 */
81
public class JBStartServer extends StartServer implements ProgressObject{
83
public class JBStartServer extends StartServer implements ProgressObject {
82
    
84
83
    static enum MODE { RUN, DEBUG, PROFILE };
85
    static enum MODE {
84
    
86
85
    static enum ACTION_STATUS { SUCCESS, FAILURE, UNKNOWN };
87
        RUN, DEBUG, PROFILE
86
    
88
    };
89
90
    static enum ACTION_STATUS {
91
92
        SUCCESS, FAILURE, UNKNOWN
93
    };
87
    private static final int AVERAGE_SERVER_INSTANCES = 2;
94
    private static final int AVERAGE_SERVER_INSTANCES = 2;
88
    
89
    private MODE mode;
95
    private MODE mode;
90
    
91
    private final JBDeploymentManager dm;
96
    private final JBDeploymentManager dm;
92
93
    private static Set<String> isDebugModeUri = Collections.synchronizedSet(
97
    private static Set<String> isDebugModeUri = Collections.synchronizedSet(
94
            new HashSet<String>(AVERAGE_SERVER_INSTANCES));
98
            new HashSet<String>(AVERAGE_SERVER_INSTANCES));
95
    
99
96
    public JBStartServer(DeploymentManager dm) {
100
    public JBStartServer(DeploymentManager dm) {
97
        if (!(dm instanceof JBDeploymentManager)) {
101
        if (!(dm instanceof JBDeploymentManager)) {
98
            throw new IllegalArgumentException("Not an instance of JBDeploymentManager"); // NOI18N
102
            throw new IllegalArgumentException("Not an instance of JBDeploymentManager"); // NOI18N
99
        }
103
        }
100
        this.dm = (JBDeploymentManager) dm;
104
        this.dm = (JBDeploymentManager) dm;
101
    }
105
    }
102
    
106
103
    private void addDebugModeUri() {
107
    private void addDebugModeUri() {
104
        isDebugModeUri.add(dm.getUrl());
108
        isDebugModeUri.add(dm.getUrl());
105
    }
109
    }
106
    
110
107
    private void removeDebugModeUri() {
111
    private void removeDebugModeUri() {
108
        isDebugModeUri.remove(dm.getUrl());
112
        isDebugModeUri.remove(dm.getUrl());
109
    }
113
    }
110
    
114
111
    private boolean existsDebugModeUri() {
115
    private boolean existsDebugModeUri() {
112
        return isDebugModeUri.contains(dm.getUrl());
116
        return isDebugModeUri.contains(dm.getUrl());
113
    }
117
    }
114
    
118
115
    public ProgressObject startDebugging(Target target) {
119
    public ProgressObject startDebugging(Target target) {
116
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
120
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
117
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName))); //NOI18N
121
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName))); //NOI18N
118
        mode = MODE.DEBUG;
122
        mode = MODE.DEBUG;
119
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
123
        RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY);
120
        addDebugModeUri();
124
        addDebugModeUri();
121
        return this;
125
        return this;
122
    }
126
    }
123
    
127
124
    public boolean isDebuggable(Target target) {
128
    public boolean isDebuggable(Target target) {
125
        if (!existsDebugModeUri()) {
129
        if (!existsDebugModeUri()) {
126
            return false;
130
            return false;
 Lines 130-165    Link Here 
130
        }
134
        }
131
        return true;
135
        return true;
132
    }
136
    }
133
    
137
134
    public boolean supportsStartDebugging(Target target) {
138
    public boolean supportsStartDebugging(Target target) {
135
        return true;
139
        return true;
136
    }
140
    }
137
    
141
138
    public boolean supportsStartProfiling(Target target) {
142
    public boolean supportsStartProfiling(Target target) {
139
        return true;
143
        return true;
140
    }
144
    }
141
    
145
142
    public boolean isAlsoTargetServer(Target target) {
146
    public boolean isAlsoTargetServer(Target target) {
143
        return true;
147
        return true;
144
    }
148
    }
145
    
149
146
    public ServerDebugInfo getDebugInfo(Target target) {
150
    public ServerDebugInfo getDebugInfo(Target target) {
147
        return new ServerDebugInfo("localhost", dm.getDebuggingPort());
151
        return new ServerDebugInfo("localhost", dm.getDebuggingPort());
148
    }
152
    }
149
    
153
150
    /**
154
    /**
151
     * Starts the server in profiling mode.
155
     * Starts the server in profiling mode.
152
     */
156
     */
153
    public ProgressObject startProfiling(Target target) {
157
    public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) {
154
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
158
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
155
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_PROFILED_SERVER_IN_PROGRESS", serverName))); //NOI18N
159
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_PROFILED_SERVER_IN_PROGRESS", serverName))); //NOI18N
156
        mode = MODE.PROFILE;
160
        mode = MODE.PROFILE;
157
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
161
        RequestProcessor.getDefault().post(new JBStartRunnable(settings, dm, this), 0, Thread.NORM_PRIORITY);
158
        removeDebugModeUri();
162
        removeDebugModeUri();
159
        return this;
163
        return this;
160
    }
164
    }
161
    
165
162
    
163
    /**
166
    /**
164
     * Indicates whether this server supports start/stop.
167
     * Indicates whether this server supports start/stop.
165
     *
168
     *
 Lines 168-174    Link Here 
168
    public boolean supportsStartDeploymentManager() {
171
    public boolean supportsStartDeploymentManager() {
169
        return true;
172
        return true;
170
    }
173
    }
171
    
174
172
    /**
175
    /**
173
     * Stops the server.
176
     * Stops the server.
174
     */
177
     */
 Lines 179-185    Link Here 
179
        removeDebugModeUri();
182
        removeDebugModeUri();
180
        return this;
183
        return this;
181
    }
184
    }
182
    
185
183
    /**
186
    /**
184
     * Starts the server
187
     * Starts the server
185
     */
188
     */
 Lines 187-210    Link Here 
187
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
190
        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
188
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName)));//NOI18N
191
        fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName)));//NOI18N
189
        mode = MODE.RUN;
192
        mode = MODE.RUN;
190
        RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY);
193
        RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY);
191
        removeDebugModeUri();
194
        removeDebugModeUri();
192
        return this;
195
        return this;
193
    }
196
    }
194
    
197
195
    
196
    public boolean needsStartForTargetList() {
198
    public boolean needsStartForTargetList() {
197
        return false;
199
        return false;
198
    }
200
    }
199
    
201
200
    public boolean needsStartForConfigure() {
202
    public boolean needsStartForConfigure() {
201
        return false;
203
        return false;
202
    }
204
    }
203
    
205
204
    public boolean needsStartForAdminConfig() {
206
    public boolean needsStartForAdminConfig() {
205
        return false;
207
        return false;
206
    }
208
    }
207
    
209
208
    private boolean isReallyRunning() {
210
    private boolean isReallyRunning() {
209
        final InstanceProperties ip = dm.getInstanceProperties();
211
        final InstanceProperties ip = dm.getInstanceProperties();
210
        if (ip == null) {
212
        if (ip == null) {
 Lines 237-285    Link Here 
237
                    result = false;
239
                    result = false;
238
                }
240
                }
239
241
240
                Object serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
242
                Object serverName;
241
                Object serverHome = Util.getMBeanParameter(dm, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
243
                Object serverHome;
242
                boolean isJBoss6 = serverHome != null;
244
                Version version = dm.getProperties().getServerVersion();
243
                if (!isJBoss6) {
245
                if(version != null && "7".equals(version.getMajorNumber())) {
244
                    serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
246
                    serverHome = Util.getMBeanParameter(dm, "baseDir", "jboss.as:core-service=server-environment"); //NOI18N
247
                    serverName = Util.getMBeanParameter(dm, "launchType", "jboss.as:core-service=server-environment"); //NOI18N
248
                    if (serverName != null) {
249
                        serverName = serverName.toString().toLowerCase();
250
                    }
251
                }else {
252
                    serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N
253
                    serverHome = Util.getMBeanParameter(dm, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N
254
                    boolean isJBoss6 = serverHome != null;
255
                    if (!isJBoss6) {
256
                        serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N
257
                    }
258
                    try {
259
                        if (serverHome != null) {
260
                            if (isJBoss6) {
261
                                serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
262
                            } else {
263
                                serverHome = ((File) serverHome).getAbsolutePath();
264
                            }
265
                        }
266
                    } catch (URISyntaxException use) {
267
                        Logger.getLogger(JBStartServer.class.getName()).log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
268
                    }
245
                }
269
                }
246
                try {
247
                    if (serverHome != null) {
248
                        if (isJBoss6) {
249
                            serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath();
250
                        } else {
251
                            serverHome = ((File) serverHome).getAbsolutePath();
252
                        }
253
                    }
254
                } catch (URISyntaxException use) {
255
                    Logger.getLogger(JBStartServer.class.getName()).log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N
256
                }
257
                
258
                if (serverName == null || serverHome == null) {
270
                if (serverName == null || serverHome == null) {
259
                    result = false;
271
                    result = false;
260
                    return;
272
                    return;
261
                }
273
                }
262
                if (checkingConfigName.equals(serverName) && checkingServerDir.equals(serverHome)) {
274
                if (checkingConfigName.equals(serverName) && checkingServerDir.equals(serverHome)) {
263
                    result = true;
275
                    result = true;
264
            }
276
                }
265
            }
277
            }
266
        };
278
        };
267
        
279
268
        return safeTrueTest(test, 10000);
280
        return safeTrueTest(test, 10000);
269
    }
281
    }
270
    
282
271
    /** Safe true/false test useful. */
283
    /**
284
     * Safe true/false test useful.
285
     */
272
    private abstract static class SafeTrueTest implements Runnable {
286
    private abstract static class SafeTrueTest implements Runnable {
287
273
        protected boolean result = false;
288
        protected boolean result = false;
274
        
289
275
        public abstract void run();
290
        public abstract void run();
276
        
291
277
        public final boolean result() {
292
        public final boolean result() {
278
            return result;
293
            return result;
279
        }
294
        }
280
    };
295
    };
281
    
296
282
    /** Return the result of the test or false if the given time-out ran out. */
297
    /**
298
     * Return the result of the test or false if the given time-out ran out.
299
     */
283
    private boolean safeTrueTest(SafeTrueTest test, int timeout) {
300
    private boolean safeTrueTest(SafeTrueTest test, int timeout) {
284
        try {
301
        try {
285
            new RequestProcessor().post(test).waitFinished(timeout);
302
            new RequestProcessor().post(test).waitFinished(timeout);
 Lines 288-366    Link Here 
288
        }
305
        }
289
        return test.result();
306
        return test.result();
290
    }
307
    }
291
    
308
292
    public boolean isRunning() {
309
    public boolean isRunning() {
293
        
310
294
        InstanceProperties ip = dm.getInstanceProperties();
311
        InstanceProperties ip = dm.getInstanceProperties();
295
        if (ip == null) {
312
        if (ip == null) {
296
            return false; // finish, it looks like this server instance has been unregistered
313
            return false; // finish, it looks like this server instance has been unregistered
297
        }
314
        }
298
        
315
299
        if (!isReallyRunning()){
316
        if (!isReallyRunning()) {
300
            dm.setRunningLastCheck(ip, Boolean.FALSE);
317
            dm.setRunningLastCheck(ip, Boolean.FALSE);
301
            return false;
318
            return false;
302
        }
319
        }
303
        
320
304
        dm.setRunningLastCheck(ip, Boolean.TRUE);
321
        dm.setRunningLastCheck(ip, Boolean.TRUE);
305
        return true;
322
        return true;
306
    }
323
    }
307
    
308
    // ----------  Implementation of ProgressObject interface
324
    // ----------  Implementation of ProgressObject interface
309
    private Vector listeners = new Vector();
325
    private Vector listeners = new Vector();
310
    private DeploymentStatus deploymentStatus;
326
    private DeploymentStatus deploymentStatus;
311
    
327
312
    public void addProgressListener(ProgressListener pl) {
328
    public void addProgressListener(ProgressListener pl) {
313
        listeners.add(pl);
329
        listeners.add(pl);
314
    }
330
    }
315
    
331
316
    public void removeProgressListener(ProgressListener pl) {
332
    public void removeProgressListener(ProgressListener pl) {
317
        listeners.remove(pl);
333
        listeners.remove(pl);
318
    }
334
    }
319
    
335
320
    public void stop() throws OperationUnsupportedException {
336
    public void stop() throws OperationUnsupportedException {
321
        throw new OperationUnsupportedException("");
337
        throw new OperationUnsupportedException("");
322
    }
338
    }
323
    
339
324
    public boolean isStopSupported() {
340
    public boolean isStopSupported() {
325
        return false;
341
        return false;
326
    }
342
    }
327
    
343
328
    public void cancel() throws OperationUnsupportedException {
344
    public void cancel() throws OperationUnsupportedException {
329
        throw new OperationUnsupportedException("");
345
        throw new OperationUnsupportedException("");
330
    }
346
    }
331
    
347
332
    public boolean isCancelSupported() {
348
    public boolean isCancelSupported() {
333
        return false;
349
        return false;
334
    }
350
    }
335
    
351
336
    public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) {
352
    public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) {
337
        return null;
353
        return null;
338
    }
354
    }
339
    
355
340
    public TargetModuleID[] getResultTargetModuleIDs() {
356
    public TargetModuleID[] getResultTargetModuleIDs() {
341
        return new TargetModuleID[]{};
357
        return new TargetModuleID[]{};
342
    }
358
    }
343
    
359
344
    public DeploymentStatus getDeploymentStatus() {
360
    public DeploymentStatus getDeploymentStatus() {
345
        return deploymentStatus;
361
        return deploymentStatus;
346
    }
362
    }
347
    
363
348
    /** Report event to any registered listeners. */
364
    /**
365
     * Report event to any registered listeners.
366
     */
349
    public void fireHandleProgressEvent(TargetModuleID targetModuleID, DeploymentStatus deploymentStatus) {
367
    public void fireHandleProgressEvent(TargetModuleID targetModuleID, DeploymentStatus deploymentStatus) {
350
        ProgressEvent evt = new ProgressEvent(this, targetModuleID, deploymentStatus);
368
        ProgressEvent evt = new ProgressEvent(this, targetModuleID, deploymentStatus);
351
        
369
352
        this.deploymentStatus = deploymentStatus;
370
        this.deploymentStatus = deploymentStatus;
353
        
371
354
        java.util.Vector targets = null;
372
        java.util.Vector targets = null;
355
        synchronized (this) {
373
        synchronized (this) {
356
            if (listeners != null) {
374
            if (listeners != null) {
357
                targets = (java.util.Vector) listeners.clone();
375
                targets = (java.util.Vector) listeners.clone();
358
            }
376
            }
359
        }
377
        }
360
        
378
361
        if (targets != null) {
379
        if (targets != null) {
362
            for (int i = 0; i < targets.size(); i++) {
380
            for (int i = 0; i < targets.size(); i++) {
363
                ProgressListener target = (ProgressListener)targets.elementAt(i);
381
                ProgressListener target = (ProgressListener) targets.elementAt(i);
364
                target.handleProgressEvent(evt);
382
                target.handleProgressEvent(evt);
365
            }
383
            }
366
        }
384
        }
 Lines 369-374    Link Here 
369
    MODE getMode() {
387
    MODE getMode() {
370
        return mode;
388
        return mode;
371
    }
389
    }
372
    
373
    
374
}
390
}
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java (-22 / +33 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 88-93    Link Here 
88
        this.dm = dm;
90
        this.dm = dm;
89
        this.startServer = startServer;
91
        this.startServer = startServer;
90
    }
92
    }
93
        
94
    private boolean isJBoss7() {
95
        JBPluginUtils.Version serverVersion = dm.getProperties().getServerVersion();
96
        return serverVersion!=null && "7".equals(serverVersion.getMajorNumber());
97
    }
91
    
98
    
92
    private String[] createEnvironment() {
99
    private String[] createEnvironment() {
93
        
100
        
 Lines 120-126    Link Here 
120
        String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
127
        String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
121
128
122
        String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
129
        String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
123
        String serverStopFileName = serverLocation + (Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH);
130
        String serverStopFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? JBOSS_CLI_BAT : JBOSS_CLI_SH :Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH);
124
131
125
        File serverStopFile = new File(serverStopFileName);
132
        File serverStopFile = new File(serverStopFileName);
126
        if (!serverStopFile.exists()){
133
        if (!serverStopFile.exists()){
 Lines 130-158    Link Here 
130
        
137
        
131
        JBProperties properties = dm.getProperties();
138
        JBProperties properties = dm.getProperties();
132
        StringBuilder additionalParams = new StringBuilder(32);
139
        StringBuilder additionalParams = new StringBuilder(32);
133
        int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR));  
140
        int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR));
134
        if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) {
141
        NbProcessDescriptor pd;
135
            additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N
142
        if(isJBoss7()) {
143
            pd = new NbProcessDescriptor(serverStopFileName, "--connect --command=:shutdown"); // NOI18N
136
        } else {
144
        } else {
137
            // FIXME changed for JBoss 6
145
            if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) {
138
            // see http://community.jboss.org/message/546904
146
                additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N
139
            // and http://community.jboss.org/wiki/StartStopJBoss
147
            } else {
148
                // FIXME changed for JBoss 6
149
                // see http://community.jboss.org/message/546904
150
                // and http://community.jboss.org/wiki/StartStopJBoss
151
            }
152
153
            additionalParams.append(" -u ").append(properties.getUsername()); // NOI18N
154
            additionalParams.append(" -p ").append(properties.getPassword()); // NOI18N
155
156
            // Currently there is a problem stopping JBoss when Profiler agent is loaded.
157
            // As a workaround for now, --halt parameter has to be used for stopping the server.
158
    //        NbProcessDescriptor pd = (startServer.getMode() == JBStartServer.MODE.PROFILE ?
159
    //                                  new NbProcessDescriptor(serverStopFileName, "--halt=0 " + credentialsParams) :   // NOI18N
160
    //                                  new NbProcessDescriptor(serverStopFileName, "--shutdown " + credentialsParams)); // NOI18N
161
162
            /* 2008-09-10 The usage of --halt doesn't solve the problem on Windows; it even creates another problem
163
                            of NB Profiler not being notified about the fact that the server was stopped */
164
            pd = new NbProcessDescriptor(
165
                    serverStopFileName, "--shutdown " + additionalParams); // NOI18N
140
        }
166
        }
141
        
142
        additionalParams.append(" -u ").append(properties.getUsername()); // NOI18N
143
        additionalParams.append(" -p ").append(properties.getPassword()); // NOI18N
144
        
145
        // Currently there is a problem stopping JBoss when Profiler agent is loaded.
146
        // As a workaround for now, --halt parameter has to be used for stopping the server.
147
//        NbProcessDescriptor pd = (startServer.getMode() == JBStartServer.MODE.PROFILE ?
148
//                                  new NbProcessDescriptor(serverStopFileName, "--halt=0 " + credentialsParams) :   // NOI18N
149
//                                  new NbProcessDescriptor(serverStopFileName, "--shutdown " + credentialsParams)); // NOI18N
150
151
        /* 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 */
153
        NbProcessDescriptor pd = new NbProcessDescriptor(
154
                serverStopFileName, "--shutdown " + additionalParams); // NOI18N
155
156
        Process stoppingProcess = null;
167
        Process stoppingProcess = null;
157
        try {
168
        try {
158
            String envp[] = createEnvironment();
169
            String envp[] = createEnvironment();
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties (-2 / +2 lines)
 Lines 56-64    Link Here 
56
56
57
LBL_BrowseButton=Br&owse...
57
LBL_BrowseButton=Br&owse...
58
58
59
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 6, 5 or 4 Location
59
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 7, 6, 5 or 4 Location
60
60
61
MSG_SpecifyServerLocation=Please specify JBoss Application Server 6, 5 or 4 Location
61
MSG_SpecifyServerLocation=Please specify JBoss Application Server 7, 6, 5 or 4 Location
62
62
63
LBL_ChooserName=Choose JBoss Server Location
63
LBL_ChooserName=Choose JBoss Server Location
64
64
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java (-4 / +7 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);
(-)j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java (-15 / +90 lines)
 Lines 53-58    Link Here 
53
import java.net.ServerSocket;
53
import java.net.ServerSocket;
54
import java.net.URL;
54
import java.net.URL;
55
import java.util.ArrayList;
55
import java.util.ArrayList;
56
import java.util.Arrays;
56
import java.util.Collections;
57
import java.util.Collections;
57
import java.util.Hashtable;
58
import java.util.Hashtable;
58
import java.util.List;
59
import java.util.List;
 Lines 97-102    Link Here 
97
    private static final Version DOM4J_SERVER = new Version("4.0.4"); // NOI18N
98
    private static final Version DOM4J_SERVER = new Version("4.0.4"); // NOI18N
98
99
99
    public static final String LIB = "lib" + File.separator;
100
    public static final String LIB = "lib" + File.separator;
101
    
102
    public static final String MODULES = "modules" + File.separator;
100
103
101
    public static final String CLIENT = "client" + File.separator;
104
    public static final String CLIENT = "client" + File.separator;
102
105
 Lines 195-200    Link Here 
195
        return domainRequirements6x;
198
        return domainRequirements6x;
196
    }
199
    }
197
200
201
    private static List<String> domainRequirements7x;
202
203
    private static synchronized List<String> getDomainRequirements7x() {
204
        if (domainRequirements7x == null) {
205
            domainRequirements7x = new ArrayList<String>(11);
206
            Collections.addAll(domainRequirements7x,
207
                    "configuration", // NOI18N
208
                    "deployments", // NOI18N
209
                    "lib" // NOI18N
210
                    );
211
        }
212
        return domainRequirements7x;
213
    }
214
215
198
    //--------------- checking for possible server directory -------------
216
    //--------------- checking for possible server directory -------------
199
    private static List<String> serverRequirements4x;
217
    private static List<String> serverRequirements4x;
200
218
 Lines 248-253    Link Here 
248
        }
266
        }
249
        return serverRequirements5And6x;
267
        return serverRequirements5And6x;
250
    }
268
    }
269
    
270
    private static List<String> serverRequirements7x;
271
    private static synchronized List<String> getServerRequirements7x() {
272
        if (serverRequirements7x == null) {
273
            serverRequirements7x = new ArrayList<String>(6);
274
            Collections.addAll(serverRequirements7x,
275
                    "bin", // NOI18N
276
                    "modules", // NOI18N
277
                    "jboss-modules.jar"); // NOI18N
278
        }
279
        return serverRequirements7x;
280
    }
251
281
252
    //------------  getting exists servers---------------------------
282
    //------------  getting exists servers---------------------------
253
    /**
283
    /**
 Lines 262-275    Link Here 
262
        File serverDirectory = new File(serverLocation);
292
        File serverDirectory = new File(serverLocation);
263
293
264
        if (isGoodJBServerLocation(serverDirectory)) {
294
        if (isGoodJBServerLocation(serverDirectory)) {
265
           File file = new File(serverLocation + File.separator + "server");  // NOI18N
295
            Version version = getServerVersion(serverDirectory);            
266
296
            File file;
267
            String[] files = file.list(new FilenameFilter(){
297
            String[] files;
268
                public boolean accept(File dir, String name){
298
            if("7".equals(version.getMajorNumber())) {
269
                    if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true;
299
                files = new String[]{"standalone", "domain"};
270
                    return false;
300
                file = serverDirectory;
271
                }
301
            } else {
272
            });
302
                file = new File(serverLocation + File.separator + "server");  // NOI18N
303
                files = file.list(new FilenameFilter(){
304
                    @Override
305
                    public boolean accept(File dir, String name){
306
                        if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true;
307
                        return false;
308
                    }
309
                });
310
            }
273
311
274
            for(int i = 0; i<files.length; i++) {
312
            for(int i = 0; i<files.length; i++) {
275
                String path = file.getAbsolutePath() + File.separator + files[i];
313
                String path = file.getAbsolutePath() + File.separator + files[i];
 Lines 318-337    Link Here 
318
    private static boolean isGoodJBInstanceLocation6x(File serverDir, File candidate){
356
    private static boolean isGoodJBInstanceLocation6x(File serverDir, File candidate){
319
        return isGoodJBInstanceLocation(candidate, getDomainRequirements6x());
357
        return isGoodJBInstanceLocation(candidate, getDomainRequirements6x());
320
    }
358
    }
359
    
360
    private static boolean isGoodJBInstanceLocation7x(File serverDir, File candidate){
361
        return isGoodJBInstanceLocation(candidate, getDomainRequirements7x());
362
    }
321
363
322
    public static boolean isGoodJBInstanceLocation(File serverDir, File candidate){
364
    public static boolean isGoodJBInstanceLocation(File serverDir, File candidate){
323
        Version version = getServerVersion(serverDir);
365
        Version version = getServerVersion(serverDir);
324
        if (version == null || (!"4".equals(version.getMajorNumber())
366
        if (version == null || (!"4".equals(version.getMajorNumber())
325
                && !"5".equals(version.getMajorNumber()) // NOI18N
367
                && !"5".equals(version.getMajorNumber()) // NOI18N
326
                && !"6".equals(version.getMajorNumber()))) { // NOI18N
368
                && !"6".equals(version.getMajorNumber()) // NOI18N
369
                && !"7".equals(version.getMajorNumber()))) { // NOI18N
327
            return JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)
370
            return JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)
328
                    || JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)
371
                    || JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)
329
                    || JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate);
372
                    || JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)
373
                    || JBPluginUtils.isGoodJBInstanceLocation7x(serverDir, candidate);
330
        }
374
        }
331
375
332
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)) // NOI18N
376
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation4x(serverDir, candidate)) // NOI18N
333
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)) // NOI18N
377
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation5x(serverDir, candidate)) // NOI18N
334
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)); // NOI18N
378
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation6x(serverDir, candidate)) // NOI18N
379
                || ("7".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBInstanceLocation7x(serverDir, candidate)); // NOI18N
335
    }
380
    }
336
381
337
    private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){
382
    private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){
 Lines 372-390    Link Here 
372
        return isGoodJBServerLocation(candidate, getServerRequirements5And6x());
417
        return isGoodJBServerLocation(candidate, getServerRequirements5And6x());
373
    }
418
    }
374
419
420
    private static boolean isGoodJBServerLocation7x(File candidate){
421
        return isGoodJBServerLocation(candidate, getServerRequirements7x());
422
    }
423
375
    public static boolean isGoodJBServerLocation(File candidate) {
424
    public static boolean isGoodJBServerLocation(File candidate) {
376
        Version version = getServerVersion(candidate);
425
        Version version = getServerVersion(candidate);
377
        if (version == null || (!"4".equals(version.getMajorNumber())
426
        if (version == null || (!"4".equals(version.getMajorNumber())
378
                && !"5".equals(version.getMajorNumber())
427
                && !"5".equals(version.getMajorNumber())
379
                && !"6".equals(version.getMajorNumber()))) { // NOI18N
428
                && !"6".equals(version.getMajorNumber())
429
                && !"7".equals(version.getMajorNumber()))) { // NOI18N
380
            return JBPluginUtils.isGoodJBServerLocation4x(candidate)
430
            return JBPluginUtils.isGoodJBServerLocation4x(candidate)
381
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
431
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
382
                    || JBPluginUtils.isGoodJBServerLocation6x(candidate);
432
                    || JBPluginUtils.isGoodJBServerLocation5x(candidate)
433
                    || JBPluginUtils.isGoodJBServerLocation7x(candidate);
383
        }
434
        }
384
435
385
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation4x(candidate)) // NOI18n
436
        return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation4x(candidate)) // NOI18n
386
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation5x(candidate)) // NOI18N
437
                || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation5x(candidate)) // NOI18N
387
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)); // NOI18N
438
                || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)) // NOI18N
439
                || ("7".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation7x(candidate)); // NOI18N
388
    }
440
    }
389
441
390
    public static boolean isJB4(JBDeploymentManager dm) {
442
    public static boolean isJB4(JBDeploymentManager dm) {
 Lines 435-440    Link Here 
435
     *
487
     *
436
     */
488
     */
437
    public static String getDeployDir(String domainDir){
489
    public static String getDeployDir(String domainDir){
490
        Version version = JBPluginUtils.getServerVersion(new File(JBPluginProperties.getInstance().getInstallLocation()));
491
        if("7".equals(version.getMajorNumber())) {
492
            return domainDir + File.separator + "deployments"; //NOI18N
493
        }
438
        return domainDir + File.separator + "deploy"; //NOI18N
494
        return domainDir + File.separator + "deploy"; //NOI18N
439
        //todo: get real deploy path
495
        //todo: get real deploy path
440
    }
496
    }
 Lines 659-665    Link Here 
659
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
715
        assert serverPath != null : "Can't determine version with null server path"; // NOI18N
660
716
661
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
717
        File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N
662
        return getVersion(systemJarFile);
718
        Version version = getVersion(systemJarFile);
719
        if(version == null) {
720
            // check for JBoss AS 7
721
            File serverDir = new File(serverPath, "modules/org/jboss/as/server/main");
722
            for (File jarFile : serverDir.listFiles(new JarFileFilter())) {
723
                version = getVersion(jarFile);
724
                if(version != null) {
725
                    break;
726
                }
727
            }
728
        }
729
        return version;
730
    }
731
    
732
    static class JarFileFilter implements FilenameFilter {
733
734
        @Override
735
        public boolean accept(File dir, String name) {
736
            return name.endsWith(".jar");
737
        }
663
    }
738
    }
664
739
665
    private static Version getVersion(File systemJarFile) {
740
    private static Version getVersion(File systemJarFile) {

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