--- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java @@ -138,6 +138,11 @@ // 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 @@ -161,7 +166,29 @@ 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); @@ -252,8 +279,13 @@ jbossFactory = (DeploymentFactory) jbossFactories.get(jbossRoot); if ( jbossFactory == null ) { + Version version = JBPluginUtils.getServerVersion(new File(jbossRoot)); URLClassLoader loader = getJBClassLoader(jbossRoot, domainRoot); + 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); } --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java @@ -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; /** * @@ -194,6 +199,18 @@ System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N } + Version version = props.getServerVersion(); + if(version != null && "7".equals(version.getMajorNumber())) { + String host = "localhost"; + int port = 9999; // management-native port + String urlString = System.getProperty("jmx.service.url","service:jmx:remoting-jmx://" + host + ":" + port); + 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); @@ -210,6 +227,7 @@ if (service != null) { profileServiceProxy = new JBoss5ProfileServiceProxy(service); } + } } catch (NameNotFoundException ex) { LOGGER.log(Level.FINE, null, ex); } catch (NamingException ex) { --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBOutputSupport.java @@ -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) { --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java @@ -79,6 +79,7 @@ import org.openide.util.Utilities; import org.openide.util.lookup.Lookups; import org.openide.windows.InputOutput; +import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils.Version; /** * @@ -100,8 +101,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 @@ -316,7 +321,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 ){ @@ -351,13 +356,18 @@ 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) { @@ -414,7 +424,7 @@ String serverLocation = getProperties().getProperty( JBPluginProperties.PROPERTY_ROOT_DIR); String serverRunFileName = serverLocation + - (Utilities.isWindows() ? STARTUP_BAT : STARTUP_SH); + (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); --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java @@ -71,6 +71,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; @@ -237,8 +238,18 @@ result = false; } - Object serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig"); //NOI18N - Object serverHome = Util.getMBeanParameter(dm, "ServerHomeLocation", "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 @@ -254,7 +265,7 @@ } 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; --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStopRunnable.java @@ -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; @@ -89,6 +91,11 @@ this.startServer = startServer; } + private boolean isJBoss7() { + JBPluginUtils.Version serverVersion = dm.getProperties().getServerVersion(); + return serverVersion!=null && "7".equals(serverVersion.getMajorNumber()); + } + private String[] createEnvironment() { JBProperties properties = dm.getProperties(); @@ -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()){ @@ -131,6 +138,10 @@ JBProperties properties = dm.getProperties(); StringBuilder additionalParams = new StringBuilder(32); int jnpPort = JBPluginUtils.getJnpPortNumber(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)); + NbProcessDescriptor pd; + if(isJBoss7()) { + pd = new NbProcessDescriptor(serverStopFileName, "--connect --command=:shutdown"); // NOI18N + } else { if (dm.getProperties().getServerVersion().compareTo(JBPluginUtils.JBOSS_6_0_0) < 0) { additionalParams.append(" -s jnp://localhost:").append(jnpPort); // NOI18N } else { @@ -150,9 +161,9 @@ /* 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( + pd = new NbProcessDescriptor( serverStopFileName, "--shutdown " + additionalParams); // NOI18N - + } Process stoppingProcess = null; try { String envp[] = createEnvironment(); --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties @@ -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 --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBInstantiatingIterator.java @@ -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); --- j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java +++ j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java @@ -98,6 +98,8 @@ public static final String LIB = "lib" + File.separator; + public static final String MODULES = "modules" + File.separator; + public static final String CLIENT = "client" + File.separator; public static final String COMMON = "common" + File.separator; @@ -195,6 +197,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; @@ -249,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--------------------------- /** * returns Hashmap @@ -262,14 +291,22 @@ File serverDirectory = new File(serverLocation); if (isGoodJBServerLocation(serverDirectory)) { - File file = new File(serverLocation + File.separator + "server"); // NOI18N - - String[] files = file.list(new FilenameFilter(){ + 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 +416,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 +486,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,9 +714,28 @@ 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) { if (!systemJarFile.exists()) { return null;