diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java Fri Apr 06 18:59:45 2012 +0530 @@ -116,28 +116,33 @@ return p; } - public Enumeration getResources(String name) throws IOException { - // get rid of annoying warnings - if (name.indexOf("jndi.properties") != -1) {// || name.indexOf("i18n_user.properties") != -1) { // NOI18N - return Collections.enumeration(Collections.emptyList()); - } + public Enumeration getResources(String name) throws IOException { + // get rid of annoying warnings + if (name.indexOf("jndi.properties") != -1) {// || name.indexOf("i18n_user.properties") != -1) { // NOI18N + return Collections.enumeration(Collections.emptyList()); + } - return super.getResources(name); - } + return super.getResources(name); + } } public static URLClassLoader getJBClassLoader(String serverRoot, String domainRoot) { try { - Version JBVer = JBPluginUtils.getServerVersion(new File (serverRoot)); + Version JBVer = JBPluginUtils.getServerVersion(new File(serverRoot)); boolean version5Above = (JBVer != null && JBVer.compareToIgnoreUpdate(JBPluginUtils.JBOSS_5_0_0) >= 0); // dom4j.jar library for JBoss Application Server 4.0.4 and lower and JBoss Application Server 5.0 - File domFile = new File(serverRoot , JBPluginUtils.LIB + "dom4j.jar"); // NOI18N + File domFile = new File(serverRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N if (!domFile.exists()) { // dom4j.jar library for JBoss Application Server 4.0.5 domFile = new File(domainRoot, JBPluginUtils.LIB + "dom4j.jar"); // NOI18N } + + String sep = File.separator; + if (!domFile.exists() && "7".equals(JBVer.getMajorNumber())) { + domFile = new File(serverRoot, JBPluginUtils.MODULES + "org" + sep + "dom4j" + sep + "main" + sep + "dom4j-1.6.1.jar"); // NOI18N + } if (!domFile.exists()) { domFile = null; LOGGER.log(Level.INFO, "No dom4j.jar availabale on classpath"); // NOI18N @@ -157,18 +162,40 @@ List urlList = new ArrayList(); - if (domFile != null) { + if (domFile != null) { urlList.add(domFile.toURI().toURL()); } - if (version5Above) { + if ("7".equals(JBVer.getMajorNumber())) { + + File org = new File(serverRoot, JBPluginUtils.MODULES + "org"); + File jboss = new File(org, "jboss"); + File as = new File(jboss, "as"); + String versionString = JBVer.getMajorNumber()+"."+JBVer.getMinorNumber()+"."+JBVer.getMicroNumber()+"."+JBVer.getUpdate(); + + if (domFile.exists()) { + urlList.add(domFile.toURI().toURL()); + } + + urlList.add(new File(serverRoot, "jboss-modules.jar").toURI().toURL()); + urlList.add(new File(serverRoot, "bin"+sep+"client"+sep+"jboss-client.jar").toURI().toURL()); + urlList.add(new File(jboss, "logging" + sep + "main" + sep + "jboss-logging-3.1.0.GA.jar").toURI().toURL()); + urlList.add(new File(jboss, "threads" + sep + "main" + sep + "jboss-threads-2.0.0.GA.jar").toURI().toURL()); + urlList.add(new File(jboss, "remoting3" + sep + "main" + sep + "jboss-remoting-3.2.3.GA.jar").toURI().toURL()); + urlList.add(new File(jboss, "xnio" + sep + "main" + sep + "xnio-api-3.0.3.GA.jar").toURI().toURL()); + urlList.add(new File(jboss, "msc" + sep + "main" + sep + "jboss-msc-1.0.2.GA.jar").toURI().toURL()); + urlList.add(new File(as, "ee" + sep + "deployment" + sep + "main" + sep + "jboss-as-ee-deployment-" + versionString + ".jar").toURI().toURL()); + urlList.add(new File(as, "naming" + sep + "main" + sep + "jboss-as-naming-" + versionString + ".jar").toURI().toURL()); + urlList.add(new File(as, "controller-client" + sep + "main" + sep + "jboss-as-controller-client-" + versionString + ".jar").toURI().toURL()); + urlList.add(new File(as, "protocol" + sep + "main" + sep + "jboss-as-protocol-" + versionString + ".jar").toURI().toURL()); + } else if (version5Above) { // get lient class path for Jboss 5.0 List clientClassUrls = JBPluginUtils.getJB5ClientClasspath( serverRoot); urlList.addAll(clientClassUrls); File runFile = new File(serverRoot, "bin" + File.separator + "run.jar"); // NOI18N - if ( runFile.exists()) { + if (runFile.exists()) { urlList.add(runFile.toURI().toURL()); } @@ -181,7 +208,7 @@ + "lib" + File.separator + "jboss-profileservice.jar"); // NOI18N if (profileFile.exists()) { urlList.add(profileFile.toURI().toURL()); - } + } File managedFile = new File(serverRoot, "lib" + File.separator + "jboss-managed.jar"); // NOI18N if (managedFile.exists()) { urlList.add(managedFile.toURI().toURL()); @@ -189,17 +216,17 @@ File metaFile = new File(serverRoot, "lib" + File.separator + "jboss-metatype.jar"); // NOI18N if (metaFile.exists()) { urlList.add(metaFile.toURI().toURL()); - } + } } else { // version < 5.0 urlList.add( - new File(serverRoot , JBPluginUtils.CLIENT + "jbossall-client.jar").toURI().toURL()); //NOI18N + new File(serverRoot, JBPluginUtils.CLIENT + "jbossall-client.jar").toURI().toURL()); //NOI18N urlList.add( - new File(serverRoot , JBPluginUtils.CLIENT + "jboss-deployment.jar").toURI().toURL()); //NOI18N + new File(serverRoot, JBPluginUtils.CLIENT + "jboss-deployment.jar").toURI().toURL()); //NOI18N urlList.add( new File(serverRoot, JBPluginUtils.CLIENT + "jnp-client.jar").toURI().toURL()); //NOI18N // jboss-common-client.jar JBoss Application Server 4.x - File client40 = new File(serverRoot , JBPluginUtils.CLIENT + "jboss-common-client.jar"); // NOI18N + File client40 = new File(serverRoot, JBPluginUtils.CLIENT + "jboss-common-client.jar"); // NOI18N if (client40.exists()) { urlList.add(client40.toURI().toURL()); } @@ -221,7 +248,7 @@ // urlList.add(logging50.toURI().toURL()); // } - URLClassLoader loader = new JBClassLoader(urlList.toArray(new URL[] {}), JBDeploymentFactory.class.getClassLoader()); + URLClassLoader loader = new JBClassLoader(urlList.toArray(new URL[]{}), JBDeploymentFactory.class.getClassLoader()); return loader; } catch (Exception e) { LOGGER.log(Level.WARNING, null, e); @@ -233,10 +260,10 @@ DeploymentFactory jbossFactory = null; try { String jbossRoot = InstanceProperties.getInstanceProperties(instanceURL). - getProperty(JBPluginProperties.PROPERTY_ROOT_DIR); + getProperty(JBPluginProperties.PROPERTY_ROOT_DIR); String domainRoot = InstanceProperties.getInstanceProperties(instanceURL). - getProperty(JBPluginProperties.PROPERTY_SERVER_DIR); + getProperty(JBPluginProperties.PROPERTY_SERVER_DIR); // if jbossRoot is null, then we are in a server instance registration process, thus this call // is made from InstanceProperties creation -> JBPluginProperties singleton contains @@ -251,9 +278,14 @@ domainRoot = JBPluginProperties.getInstance().getDomainLocation(); jbossFactory = (DeploymentFactory) jbossFactories.get(jbossRoot); - if ( jbossFactory == null ) { + if (jbossFactory == null) { + Version version = JBPluginUtils.getServerVersion(new File(jbossRoot)); URLClassLoader loader = getJBClassLoader(jbossRoot, domainRoot); - jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N + if(version!= null && "7".equals(version.getMajorNumber())) { + jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.as.ee.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N + } else { + jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N + } jbossFactories.put(jbossRoot, jbossFactory); } @@ -337,7 +369,7 @@ public String getProductVersion() { - return NbBundle.getMessage (JBDeploymentFactory.class, "LBL_JBossFactoryVersion"); + return NbBundle.getMessage(JBDeploymentFactory.class, "LBL_JBossFactoryVersion"); } public String getDisplayName() { @@ -379,7 +411,7 @@ private static boolean isAlreadyRegistered(FileObject serverInstanceDir, String domainLocation) throws IOException { String domainLocationCan = new File(domainLocation).getCanonicalPath(); for (FileObject instanceFO : serverInstanceDir.getChildren()) { - String installedLocation = (String)instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR); + String installedLocation = (String) instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR); if (installedLocation != null) { String installedLocationCan = new File(installedLocation).getCanonicalPath(); if (domainLocationCan.equals(installedLocationCan)) { @@ -394,11 +426,11 @@ private static void setRemovability(FileObject serverInstanceDir, String domainLocation) throws IOException { String domainLocationCan = new File(domainLocation).getCanonicalPath(); for (FileObject instanceFO : serverInstanceDir.getChildren()) { - String url = (String)instanceFO.getAttribute(InstanceProperties.URL_ATTR); + String url = (String) instanceFO.getAttribute(InstanceProperties.URL_ATTR); if (url == null) { // can occur if some unxpected file is in the directory LOGGER.log(Level.INFO, "No server URL in " + FileUtil.getFileDisplayName(instanceFO)); } else if (url.startsWith(URI_PREFIX)) { // it's JBoss instance - String installedLocation = (String)instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR); + String installedLocation = (String) instanceFO.getAttribute(JBPluginProperties.PROPERTY_SERVER_DIR); String installedLocationCan = new File(installedLocation).getCanonicalPath(); if (domainLocationCan.equals(installedLocationCan)) { instanceFO.setAttribute(InstanceProperties.REMOVE_FORBIDDEN, Boolean.TRUE); @@ -448,7 +480,7 @@ Set registeredInstances = getServerInstancesNames(serverInstanceDir); while (registeredInstances.contains(instanceName.toUpperCase())) { - instanceName = serverName + " (" + String.valueOf(counter++) + ")"; + instanceName = serverName + " (" + String.valueOf(counter++) + ")"; } return instanceName; @@ -457,7 +489,7 @@ private static Set getServerInstancesNames(FileObject serverInstanceDir) { Set names = new HashSet(); for (FileObject instanceFO : serverInstanceDir.getChildren()) { - String instanceName = (String)instanceFO.getAttribute(InstanceProperties.DISPLAY_NAME_ATTR); + String instanceName = (String) instanceFO.getAttribute(InstanceProperties.DISPLAY_NAME_ATTR); names.add(instanceName.toUpperCase()); } diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java Fri Apr 06 18:59:45 2012 +0530 @@ -53,6 +53,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URLClassLoader; +import java.util.HashMap; import java.util.Locale; import java.util.Properties; import java.util.logging.Level; @@ -73,11 +74,15 @@ import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.ReflectionException; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils; +import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version; /** * @@ -161,7 +166,7 @@ private void init() { ClassLoader oldLoader = null; - + try { oldLoader = Thread.currentThread().getContextClassLoader(); InstanceProperties ip = this.getInstanceProperties(); @@ -171,7 +176,7 @@ JBProperties props = getProperties(); Properties env = new Properties(); - + // Sets the jboss naming environment String jnpPort = Integer.toString( JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR))); @@ -193,22 +198,39 @@ env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory"); System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N } + + Version version = props.getServerVersion(); + if(version != null && "7".equals(version.getMajorNumber())) { +// env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory"); + String host = "localhost"; + int port = 9999; // management-native port + // int port = 1099; + String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port); - // Gets naming context - InitialContext ctx = new InitialContext(env); + // String urlString = System.getProperty("jmx.service.url", "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"); + JMXServiceURL serviceURL = new JMXServiceURL(urlString); + Map environment = new HashMap(); + environment.put(Context.SECURITY_PRINCIPAL, props.getUsername()); + environment.put(Context.SECURITY_CREDENTIALS, props.getPassword()); + JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, environment); + rmiServer = jmxConnector.getMBeanServerConnection(); + } else { + // Gets naming context + InitialContext ctx = new InitialContext(env); - //restore java.security.auth.login.config system property - if (oldAuthConf != null) { - System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf); - } else { - System.clearProperty(JAVA_SEC_AUTH_LOGIN_CONF); - } + //restore java.security.auth.login.config system property + if (oldAuthConf != null) { + System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf); + } else { + System.clearProperty(JAVA_SEC_AUTH_LOGIN_CONF); + } - // Lookup RMI Adaptor - rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); - Object service = ctx.lookup("ProfileService"); - if (service != null) { - profileServiceProxy = new JBoss5ProfileServiceProxy(service); + // Lookup RMI Adaptor + rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor"); + Object service = ctx.lookup("ProfileService"); + if (service != null) { + profileServiceProxy = new JBoss5ProfileServiceProxy(service); + } } } catch (NameNotFoundException ex) { LOGGER.log(Level.FINE, null, ex); diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java Fri Apr 06 18:59:45 2012 +0530 @@ -309,10 +309,11 @@ || line.indexOf("Starting JBossAS") > -1) { // JBoss 6.0 message // NOI18N LOGGER.log(Level.FINER, "STARTING message fired"); // NOI18N //fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N - } else if ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N + } else if ( ((line.indexOf("JBoss (MX MicroKernel)") > -1 // JBoss 4.x message // NOI18N || line.indexOf("JBoss (Microcontainer)") > -1 // JBoss 5.0 message // NOI18N || line.indexOf("JBossAS") > -1) // JBoss 6.0 message // NOI18N - && line.indexOf("Started in") > -1) { // NOI18N + && line.indexOf("Started in") > -1) + || line.indexOf("JBoss AS") > -1 && line.indexOf("started in") > -1) { // NOI18N LOGGER.log(Level.FINER, "STARTED message fired"); // NOI18N synchronized (JBOutputSupport.this) { diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java Fri Apr 06 18:59:45 2012 +0530 @@ -62,13 +62,13 @@ import javax.enterprise.deploy.shared.CommandType; import javax.enterprise.deploy.shared.StateType; import org.netbeans.api.java.platform.JavaPlatform; -import org.netbeans.api.extexecution.startup.StartupExtender; -import org.netbeans.modules.j2ee.deployment.plugins.api.CommonServerBridge; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport; +import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils; +import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version; import org.netbeans.modules.j2ee.jboss4.util.JBProperties; import org.openide.execution.NbProcessDescriptor; import org.openide.filesystems.FileObject; @@ -77,7 +77,6 @@ import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.Utilities; -import org.openide.util.lookup.Lookups; import org.openide.windows.InputOutput; /** @@ -100,8 +99,12 @@ private final static String STARTUP_SH = File.separator + "bin" + File.separator + "run.sh"; // NOI18N + private final static String STANDALONE_SH = File.separator + + "bin" + File.separator + "standalone.sh"; // NOI18N private final static String STARTUP_BAT = File.separator + "bin" + File.separator + RUN_FILE_NAME; // NOI18N + private final static String STANDALONE_BAT = File.separator + + "bin" + File.separator + "standalone.bat"; // NOI18N private final static String CONF_BAT = File.separator + "bin" + File.separator + CONF_FILE_NAME; // NOI18N @@ -122,11 +125,13 @@ private JBDeploymentManager dm; private String instanceName; private JBStartServer startServer; + private ProfilerServerSettings profilerSettings; - JBStartRunnable(JBDeploymentManager dm, JBStartServer startServer) { + JBStartRunnable(ProfilerServerSettings profilerSettings, JBDeploymentManager dm, JBStartServer startServer) { this.dm = dm; this.instanceName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR); this.startServer = startServer; + this.profilerSettings = profilerSettings; } public void run() { @@ -205,7 +210,7 @@ } // get Java platform that will run the server - JavaPlatform platform = properties.getJavaPlatform(); + JavaPlatform platform = (startServer.getMode() != JBStartServer.MODE.PROFILE ? properties.getJavaPlatform() : profilerSettings.getJavaPlatform()); if (startServer.getMode() == JBStartServer.MODE.DEBUG && javaOptsBuilder.toString().indexOf("-Xdebug") == -1) { // NOI18N // if in debug mode and the debug options not specified manually @@ -217,19 +222,18 @@ append(",server=y,suspend=n"); // NOI18N } else if (startServer.getMode() == JBStartServer.MODE.PROFILE) { + + // get JVM arguments used for starting the server + String[] profJvmArgs = profilerSettings.getJvmArgs(); + for (int i = 0; i < profJvmArgs.length; i++) { + javaOptsBuilder.append(" ").append(profJvmArgs[i]); // NOI18N + } if (properties.isVersion(JBPluginUtils.JBOSS_6_0_0)) { javaOptsBuilder.append(" ").append("-Djboss.platform.mbeanserver") .append(" ").append("-Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"); } } - for (StartupExtender args : StartupExtender.getExtenders( - Lookups.singleton(CommonServerBridge.getCommonInstance(ip.getProperty("url"))), getMode(startServer.getMode()))) { - for (String singleArg : args.getArguments()) { - javaOptsBuilder.append(' ').append(singleArg); - } - } - // create new environment for server javaOpts = javaOptsBuilder.toString(); String javaHome = getJavaHome(platform); @@ -242,17 +246,7 @@ }; return envp; } - - private static StartupExtender.StartMode getMode(JBStartServer.MODE jbMode) { - if (JBStartServer.MODE.PROFILE.equals(jbMode)) { - return StartupExtender.StartMode.PROFILE; - } else if (JBStartServer.MODE.DEBUG.equals(jbMode)) { - return StartupExtender.StartMode.DEBUG; - } else { - return StartupExtender.StartMode.NORMAL; - } - } - + private boolean checkPorts(final InstanceProperties ip) { try { @@ -316,7 +310,7 @@ final String instanceName = ip.getProperty(JBPluginProperties.PROPERTY_SERVER); String args = ("all".equals(instanceName) ? "-b 127.0.0.1 " : "") + "-c " + instanceName; // NOI18N - return new NbProcessDescriptor(serverRunFileName, args); + return new NbProcessDescriptor(serverRunFileName, isJBoss7()? "" : args); } private String getRunFileName( InstanceProperties ip, String[] envp ){ @@ -346,18 +340,23 @@ } try { - return pd.exec(null, envp, true, null ); + return pd.exec(null, envp, true, null); } catch (java.io.IOException ioe) { Logger.getLogger("global").log(Level.INFO, null, ioe); final String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR); - final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH); + final String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH); fireStartProgressEvent(StateType.FAILED, createProgressMessage("MSG_START_SERVER_FAILED_PD", serverRunFileName)); return null; } } + private boolean isJBoss7() { + Version serverVersion = dm.getProperties().getServerVersion(); + return serverVersion!=null && "7".equals(serverVersion.getMajorNumber()); + } + private InputOutput openConsole() { InputOutput io = UISupport.getServerIO(dm.getUrl()); if (io == null) { @@ -413,8 +412,7 @@ String getRunFileName(){ String serverLocation = getProperties().getProperty( JBPluginProperties.PROPERTY_ROOT_DIR); - String serverRunFileName = serverLocation + - (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH); + String serverRunFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? STANDALONE_BAT : STANDALONE_SH : Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH); if ( needChange ){ String contentRun = readFile(serverRunFileName); String contentConf = readFile(serverLocation + CONF_BAT); diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java Fri Apr 06 18:59:45 2012 +0530 @@ -45,6 +45,7 @@ import java.net.URISyntaxException; import java.util.Collections; +import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings; import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; import java.io.IOException; @@ -71,6 +72,7 @@ import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException; import javax.enterprise.deploy.spi.status.ClientConfiguration; import javax.enterprise.deploy.spi.status.DeploymentStatus; +import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version; import org.openide.util.NbBundle; import org.netbeans.modules.j2ee.jboss4.nodes.Util; @@ -78,49 +80,51 @@ * * @author Kirill Sorokin */ -public class JBStartServer extends StartServer implements ProgressObject{ - - static enum MODE { RUN, DEBUG, PROFILE }; - - static enum ACTION_STATUS { SUCCESS, FAILURE, UNKNOWN }; - +public class JBStartServer extends StartServer implements ProgressObject { + + static enum MODE { + + RUN, DEBUG, PROFILE + }; + + static enum ACTION_STATUS { + + SUCCESS, FAILURE, UNKNOWN + }; private static final int AVERAGE_SERVER_INSTANCES = 2; - private MODE mode; - private final JBDeploymentManager dm; - private static Set isDebugModeUri = Collections.synchronizedSet( new HashSet(AVERAGE_SERVER_INSTANCES)); - + public JBStartServer(DeploymentManager dm) { if (!(dm instanceof JBDeploymentManager)) { throw new IllegalArgumentException("Not an instance of JBDeploymentManager"); // NOI18N } this.dm = (JBDeploymentManager) dm; } - + private void addDebugModeUri() { isDebugModeUri.add(dm.getUrl()); } - + private void removeDebugModeUri() { isDebugModeUri.remove(dm.getUrl()); } - + private boolean existsDebugModeUri() { return isDebugModeUri.contains(dm.getUrl()); } - + public ProgressObject startDebugging(Target target) { String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR); fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName))); //NOI18N mode = MODE.DEBUG; - RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY); + RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY); addDebugModeUri(); return this; } - + public boolean isDebuggable(Target target) { if (!existsDebugModeUri()) { return false; @@ -130,36 +134,35 @@ } return true; } - + public boolean supportsStartDebugging(Target target) { return true; } - + public boolean supportsStartProfiling(Target target) { return true; } - + public boolean isAlsoTargetServer(Target target) { return true; } - + public ServerDebugInfo getDebugInfo(Target target) { return new ServerDebugInfo("localhost", dm.getDebuggingPort()); } - + /** * Starts the server in profiling mode. */ - public ProgressObject startProfiling(Target target) { + public ProgressObject startProfiling(Target target, ProfilerServerSettings settings) { String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR); fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_PROFILED_SERVER_IN_PROGRESS", serverName))); //NOI18N mode = MODE.PROFILE; - RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY); + RequestProcessor.getDefault().post(new JBStartRunnable(settings, dm, this), 0, Thread.NORM_PRIORITY); removeDebugModeUri(); return this; } - - + /** * Indicates whether this server supports start/stop. * @@ -168,7 +171,7 @@ public boolean supportsStartDeploymentManager() { return true; } - + /** * Stops the server. */ @@ -179,7 +182,7 @@ removeDebugModeUri(); return this; } - + /** * Starts the server */ @@ -187,24 +190,23 @@ String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR); fireHandleProgressEvent(null, new JBDeploymentStatus(ActionType.EXECUTE, CommandType.START, StateType.RUNNING, NbBundle.getMessage(JBStartServer.class, "MSG_START_SERVER_IN_PROGRESS", serverName)));//NOI18N mode = MODE.RUN; - RequestProcessor.getDefault().post(new JBStartRunnable(dm, this), 0, Thread.NORM_PRIORITY); + RequestProcessor.getDefault().post(new JBStartRunnable(null, dm, this), 0, Thread.NORM_PRIORITY); removeDebugModeUri(); return this; } - - + public boolean needsStartForTargetList() { return false; } - + public boolean needsStartForConfigure() { return false; } - + public boolean needsStartForAdminConfig() { return false; } - + private boolean isReallyRunning() { final InstanceProperties ip = dm.getInstanceProperties(); if (ip == null) { @@ -237,49 +239,64 @@ result = false; } - Object serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N - Object serverHome = Util.getMBeanParameter(dm, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N - boolean isJBoss6 = serverHome != null; - if (!isJBoss6) { - serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N + Object serverName; + Object serverHome; + Version version = dm.getProperties().getServerVersion(); + if(version != null && "7".equals(version.getMajorNumber())) { + serverHome = Util.getMBeanParameter(dm, "baseDir", "jboss.as:core-service=server-environment"); //NOI18N + serverName = Util.getMBeanParameter(dm, "launchType", "jboss.as:core-service=server-environment"); //NOI18N + if (serverName != null) { + serverName = serverName.toString().toLowerCase(); + } + }else { + serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N + serverHome = Util.getMBeanParameter(dm, "ServerHomeLocation", "jboss.system:type=ServerConfig"); //NOI18N + boolean isJBoss6 = serverHome != null; + if (!isJBoss6) { + serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig"); //NOI18N + } + try { + if (serverHome != null) { + if (isJBoss6) { + serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath(); + } else { + serverHome = ((File) serverHome).getAbsolutePath(); + } + } + } catch (URISyntaxException use) { + Logger.getLogger(JBStartServer.class.getName()).log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N + } } - try { - if (serverHome != null) { - if (isJBoss6) { - serverHome = new File(((URL) serverHome).toURI()).getAbsolutePath(); - } else { - serverHome = ((File) serverHome).getAbsolutePath(); - } - } - } catch (URISyntaxException use) { - Logger.getLogger(JBStartServer.class.getName()).log(Level.WARNING, "error getting file from URI: " + serverHome, use); //NOI18N - } - if (serverName == null || serverHome == null) { result = false; return; } if (checkingConfigName.equals(serverName) && checkingServerDir.equals(serverHome)) { result = true; - } + } } }; - + return safeTrueTest(test, 10000); } - - /** Safe true/false test useful. */ + + /** + * Safe true/false test useful. + */ private abstract static class SafeTrueTest implements Runnable { + protected boolean result = false; - + public abstract void run(); - + public final boolean result() { return result; } }; - - /** Return the result of the test or false if the given time-out ran out. */ + + /** + * Return the result of the test or false if the given time-out ran out. + */ private boolean safeTrueTest(SafeTrueTest test, int timeout) { try { new RequestProcessor().post(test).waitFinished(timeout); @@ -288,79 +305,80 @@ } return test.result(); } - + public boolean isRunning() { - + InstanceProperties ip = dm.getInstanceProperties(); if (ip == null) { return false; // finish, it looks like this server instance has been unregistered } - - if (!isReallyRunning()){ + + if (!isReallyRunning()) { dm.setRunningLastCheck(ip, Boolean.FALSE); return false; } - + dm.setRunningLastCheck(ip, Boolean.TRUE); return true; } - // ---------- Implementation of ProgressObject interface private Vector listeners = new Vector(); private DeploymentStatus deploymentStatus; - + public void addProgressListener(ProgressListener pl) { listeners.add(pl); } - + public void removeProgressListener(ProgressListener pl) { listeners.remove(pl); } - + public void stop() throws OperationUnsupportedException { throw new OperationUnsupportedException(""); } - + public boolean isStopSupported() { return false; } - + public void cancel() throws OperationUnsupportedException { throw new OperationUnsupportedException(""); } - + public boolean isCancelSupported() { return false; } - + public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) { return null; } - + public TargetModuleID[] getResultTargetModuleIDs() { return new TargetModuleID[]{}; } - + public DeploymentStatus getDeploymentStatus() { return deploymentStatus; } - - /** Report event to any registered listeners. */ + + /** + * Report event to any registered listeners. + */ public void fireHandleProgressEvent(TargetModuleID targetModuleID, DeploymentStatus deploymentStatus) { ProgressEvent evt = new ProgressEvent(this, targetModuleID, deploymentStatus); - + this.deploymentStatus = deploymentStatus; - + java.util.Vector targets = null; synchronized (this) { if (listeners != null) { targets = (java.util.Vector) listeners.clone(); } } - + if (targets != null) { for (int i = 0; i < targets.size(); i++) { - ProgressListener target = (ProgressListener)targets.elementAt(i); + ProgressListener target = (ProgressListener) targets.elementAt(i); target.handleProgressEvent(evt); } } @@ -369,6 +387,4 @@ MODE getMode() { return mode; } - - } diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java Fri Apr 06 18:59:45 2012 +0530 @@ -77,7 +77,9 @@ private static final Logger LOGGER = Logger.getLogger(JBStopRunnable.class.getName()); private static final String SHUTDOWN_SH = "/bin/shutdown.sh"; // NOI18N + private static final String JBOSS_CLI_SH = "/bin/jboss-cli.sh"; // NOI18N private static final String SHUTDOWN_BAT = "/bin/shutdown.bat"; // NOI18N + private static final String JBOSS_CLI_BAT = "/bin/jboss-cli.bat"; // NOI18N private static final int TIMEOUT = 300000; @@ -88,6 +90,11 @@ this.dm = dm; this.startServer = startServer; } + + private boolean isJBoss7() { + JBPluginUtils.Version serverVersion = dm.getProperties().getServerVersion(); + return serverVersion!=null && "7".equals(serverVersion.getMajorNumber()); + } private String[] createEnvironment() { @@ -120,7 +127,7 @@ String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR); String serverLocation = ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR); - String serverStopFileName = serverLocation + (Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH); + String serverStopFileName = serverLocation + (isJBoss7() ? Utilities.isWindows() ? JBOSS_CLI_BAT : JBOSS_CLI_SH :Utilities.isWindows() ? SHUTDOWN_BAT : SHUTDOWN_SH); File serverStopFile = new File(serverStopFileName); if (!serverStopFile.exists()){ @@ -130,29 +137,33 @@ JBProperties properties = dm.getProperties(); StringBuilder additionalParams = new StringBuilder(32); - int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)); - if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) { - additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N + int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)); + NbProcessDescriptor pd; + if(isJBoss7()) { + pd = new NbProcessDescriptor(serverStopFileName, "--connect --command=:shutdown"); // NOI18N } else { - // FIXME changed for JBoss 6 - // see http://community.jboss.org/message/546904 - // and http://community.jboss.org/wiki/StartStopJBoss + if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) { + additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N + } else { + // FIXME changed for JBoss 6 + // see http://community.jboss.org/message/546904 + // and http://community.jboss.org/wiki/StartStopJBoss + } + + additionalParams.append(" -u ").append(properties.getUsername()); // NOI18N + additionalParams.append(" -p ").append(properties.getPassword()); // NOI18N + + // Currently there is a problem stopping JBoss when Profiler agent is loaded. + // As a workaround for now, --halt parameter has to be used for stopping the server. + // NbProcessDescriptor pd = (startServer.getMode() == JBStartServer.MODE.PROFILE ? + // new NbProcessDescriptor(serverStopFileName, "--halt=0 " + credentialsParams) : // NOI18N + // new NbProcessDescriptor(serverStopFileName, "--shutdown " + credentialsParams)); // NOI18N + + /* 2008-09-10 The usage of --halt doesn't solve the problem on Windows; it even creates another problem + of NB Profiler not being notified about the fact that the server was stopped */ + pd = new NbProcessDescriptor( + serverStopFileName, "--shutdown " + additionalParams); // NOI18N } - - additionalParams.append(" -u ").append(properties.getUsername()); // NOI18N - additionalParams.append(" -p ").append(properties.getPassword()); // NOI18N - - // Currently there is a problem stopping JBoss when Profiler agent is loaded. - // As a workaround for now, --halt parameter has to be used for stopping the server. -// NbProcessDescriptor pd = (startServer.getMode() == JBStartServer.MODE.PROFILE ? -// new NbProcessDescriptor(serverStopFileName, "--halt=0 " + credentialsParams) : // NOI18N -// new NbProcessDescriptor(serverStopFileName, "--shutdown " + credentialsParams)); // NOI18N - - /* 2008-09-10 The usage of --halt doesn't solve the problem on Windows; it even creates another problem - of NB Profiler not being notified about the fact that the server was stopped */ - NbProcessDescriptor pd = new NbProcessDescriptor( - serverStopFileName, "--shutdown " + additionalParams); // NOI18N - Process stoppingProcess = null; try { String envp[] = createEnvironment(); diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties Fri Apr 06 18:59:45 2012 +0530 @@ -56,9 +56,9 @@ LBL_BrowseButton=Br&owse... -MSG_InvalidServerLocation=Provide a valid JBoss Application Server 6, 5 or 4 Location +MSG_InvalidServerLocation=Provide a valid JBoss Application Server 7, 6, 5 or 4 Location -MSG_SpecifyServerLocation=Please specify JBoss Application Server 6, 5 or 4 Location +MSG_SpecifyServerLocation=Please specify JBoss Application Server 7, 6, 5 or 4 Location LBL_ChooserName=Choose JBoss Server Location diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java Fri Apr 06 18:59:45 2012 +0530 @@ -146,15 +146,18 @@ Set result = new HashSet(); String displayName = (String)wizard.getProperty(PROP_DISPLAY_NAME); - - String url = JBDeploymentFactory.URI_PREFIX + host + ":" + port; // NOI18N + JBPluginUtils.Version version = JBPluginUtils.getServerVersion(new File(installLocation)); + String url = JBDeploymentFactory.URI_PREFIX; + if(version != null && "7".equals(version.getMajorNumber())){ + url += "//"+host + ":" + port+"?targetType=as7&serverPort="+port; // NOI18N + } else { + url += host + ":" + port; // NOI18N + } if (server != null && !server.equals("")) // NOI18N url += "#" + server; // NOI18N url += "&"+ installLocation; // NOI18N try { - JBPluginUtils.Version version = JBPluginUtils.getServerVersion(new File(installLocation)); - Map initialProperties = new HashMap(); initialProperties.put(JBPluginProperties.PROPERTY_SERVER, server); initialProperties.put(JBPluginProperties.PROPERTY_DEPLOY_DIR, deployDir); diff -r 25467438bd5b j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java --- a/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java Mon Mar 19 12:07:00 2012 +0000 +++ b/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java Fri Apr 06 18:59:45 2012 +0530 @@ -53,6 +53,7 @@ import java.net.ServerSocket; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Hashtable; import java.util.List; @@ -97,6 +98,8 @@ private static final Version DOM4J_SERVER = new Version("4.0.4"); // NOI18N public static final String LIB = "lib" + File.separator; + + public static final String MODULES = "modules" + File.separator; public static final String CLIENT = "client" + File.separator; @@ -195,6 +198,21 @@ return domainRequirements6x; } + private static List domainRequirements7x; + + private static synchronized List getDomainRequirements7x() { + if (domainRequirements7x == null) { + domainRequirements7x = new ArrayList(11); + Collections.addAll(domainRequirements7x, + "configuration", // NOI18N + "deployments", // NOI18N + "lib" // NOI18N + ); + } + return domainRequirements7x; + } + + //--------------- checking for possible server directory ------------- private static List serverRequirements4x; @@ -248,6 +266,18 @@ } return serverRequirements5And6x; } + + private static List serverRequirements7x; + private static synchronized List getServerRequirements7x() { + if (serverRequirements7x == null) { + serverRequirements7x = new ArrayList(6); + Collections.addAll(serverRequirements7x, + "bin", // NOI18N + "modules", // NOI18N + "jboss-modules.jar"); // NOI18N + } + return serverRequirements7x; + } //------------ getting exists servers--------------------------- /** @@ -262,14 +292,22 @@ File serverDirectory = new File(serverLocation); if (isGoodJBServerLocation(serverDirectory)) { - File file = new File(serverLocation + File.separator + "server"); // NOI18N - - String[] files = file.list(new FilenameFilter(){ - public boolean accept(File dir, String name){ - if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true; - return false; - } - }); + Version version = getServerVersion(serverDirectory); + File file; + String[] files; + if("7".equals(version.getMajorNumber())) { + files = new String[]{"standalone", "domain"}; + file = serverDirectory; + } else { + file = new File(serverLocation + File.separator + "server"); // NOI18N + files = file.list(new FilenameFilter(){ + @Override + public boolean accept(File dir, String name){ + if ((new File(dir.getAbsolutePath()+File.separator+name)).isDirectory()) return true; + return false; + } + }); + } for(int i = 0; i requirements){ @@ -372,19 +417,26 @@ return isGoodJBServerLocation(candidate, getServerRequirements5And6x()); } + private static boolean isGoodJBServerLocation7x(File candidate){ + return isGoodJBServerLocation(candidate, getServerRequirements7x()); + } + public static boolean isGoodJBServerLocation(File candidate) { Version version = getServerVersion(candidate); if (version == null || (!"4".equals(version.getMajorNumber()) && !"5".equals(version.getMajorNumber()) - && !"6".equals(version.getMajorNumber()))) { // NOI18N + && !"6".equals(version.getMajorNumber()) + && !"7".equals(version.getMajorNumber()))) { // NOI18N return JBPluginUtils.isGoodJBServerLocation4x(candidate) || JBPluginUtils.isGoodJBServerLocation5x(candidate) - || JBPluginUtils.isGoodJBServerLocation6x(candidate); + || JBPluginUtils.isGoodJBServerLocation5x(candidate) + || JBPluginUtils.isGoodJBServerLocation7x(candidate); } return ("4".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation4x(candidate)) // NOI18n || ("5".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation5x(candidate)) // NOI18N - || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)); // NOI18N + || ("6".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation6x(candidate)) // NOI18N + || ("7".equals(version.getMajorNumber()) && JBPluginUtils.isGoodJBServerLocation7x(candidate)); // NOI18N } public static boolean isJB4(JBDeploymentManager dm) { @@ -435,6 +487,10 @@ * */ public static String getDeployDir(String domainDir){ + Version version = JBPluginUtils.getServerVersion(new File(JBPluginProperties.getInstance().getInstallLocation())); + if("7".equals(version.getMajorNumber())) { + return domainDir + File.separator + "deployments"; //NOI18N + } return domainDir + File.separator + "deploy"; //NOI18N //todo: get real deploy path } @@ -659,7 +715,26 @@ assert serverPath != null : "Can't determine version with null server path"; // NOI18N File systemJarFile = new File(serverPath, "lib/jboss-system.jar"); // NOI18N - return getVersion(systemJarFile); + Version version = getVersion(systemJarFile); + if(version == null) { + // check for JBoss AS 7 + File serverDir = new File(serverPath, "modules/org/jboss/as/server/main"); + for (File jarFile : serverDir.listFiles(new JarFileFilter())) { + version = getVersion(jarFile); + if(version != null) { + break; + } + } + } + return version; + } + + static class JarFileFilter implements FilenameFilter { + + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".jar"); + } } private static Version getVersion(File systemJarFile) {