Author: rob.stryker(a)jboss.com
Date: 2012-01-30 15:12:47 -0500 (Mon, 30 Jan 2012)
New Revision: 38299
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
Log:
JBIDE-10688 - fixing up the server bean loader and cleaning the api slightly
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -11,11 +11,14 @@
package org.jboss.ide.eclipse.as.core.server.bean;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.core.util.IWTPConstants;
@@ -156,6 +159,16 @@
return this.condition.isServerRoot(location);
}
+ public String getFullVersion(File root) {
+ if( this.condition == null )
+ return null;
+ return this.condition.getFullVersion(root, new File(root, getSystemJarPath()));
+ }
+
+ public String getServerAdapterTypeId(String version) {
+ return this.condition.getServerTypeId(version);
+ }
+
private static final String IMPLEMENTATION_TITLE = "Implementation-Title";
//$NON-NLS-1$
private static final String JBEAP_RELEASE_VERSION =
"JBossEAP-Release-Version"; //$NON-NLS-1$
private static final String JBAS7_RELEASE_VERSION = "JBossAS-Release-Version";
//$NON-NLS-1$
@@ -200,24 +213,102 @@
public static final JBossServerType[] KNOWN_TYPES = {AS, EAP, SOAP, SOAP_STD, EWP,
EPP};
static interface Condition {
+ /**
+ * Is this location the root of an installation?
+ * @param location
+ * @return
+ */
public boolean isServerRoot(File location);
+
+ /**
+ * Get the full version of this server. Provide the system jar / reference file
+ * as a hint.
+ *
+ * @param serverRoot
+ * @param systemFile
+ * @return
+ */
+ public String getFullVersion(File serverRoot, File systemFile);
+
+ /**
+ * Get the ServerType id associated with this installation
+ *
+ * @param serverRoot
+ * @param systemFile
+ * @return
+ */
+ public String getServerTypeId(String version);
+
}
+ public static abstract class AbstractCondition implements Condition {
+ public String getFullVersion(File location, File systemFile) {
+ return ServerBeanLoader.getFullServerVersionFromZip(systemFile);
+ }
+ }
+
+ public static abstract class AbstractEAPTypeCondition extends AbstractCondition {
+ public String getServerTypeId(String version) {
+ // V4_2,V4_3,V5_0,V5_1
+ if( V4_2.equals(version)) return IJBossToolingConstants.SERVER_EAP_43;
+ if( V4_3.equals(version)) return IJBossToolingConstants.SERVER_EAP_43;
+ if( V5_0.equals(version)) return IJBossToolingConstants.SERVER_EAP_50;
+ if( V5_1.equals(version)) return IJBossToolingConstants.SERVER_EAP_50;
+ if( V6_0.equals(version)) return IJBossToolingConstants.SERVER_EAP_60;
+ return null;
+ }
+ }
- public static class EAPServerTypeCondition implements Condition {
+ public static class EAPServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.EAP.getSystemJarPath());
return asSystemJar.exists() && asSystemJar.isFile();
}
}
- public static class EAP6ServerTypeCondition implements Condition {
+ public static class EAP6ServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
- return checkAS7EAP6Version(location, JBEAP_RELEASE_VERSION, "6.");
//$NON-NLS-1$
+ return getEAP6Version(location, "6.") != null; //$NON-NLS-1$
}
+ public String getFullVersion(File location, File systemJarFile) {
+ return getEAP6Version(location, "6."); //$NON-NLS-1$
+ }
}
+
+ /**
+ * Get the eap6-style version string, or null if not found
+ * @param location
+ * @param versionPrefix
+ * @return
+ */
+ protected static String getEAP6Version(File location, String versionPrefix) {
+ IPath rootPath = new Path(location.getAbsolutePath());
+ IPath productConf = rootPath.append("bin/product.conf"); //$NON-NLS-1$
+ if( productConf.toFile().exists()) {
+ try {
+ Properties p = new Properties();
+ p.load(new FileInputStream(productConf.toFile()));
+ String product = (String) p.get("slot"); //$NON-NLS-1$
+ if("eap".equals(product)) { //$NON-NLS-1$
+ IPath eapDir =
rootPath.append("modules/org/jboss/as/product/eap/dir/META-INF"); //$NON-NLS-1$
+ if( eapDir.toFile().exists()) {
+ IPath manifest = eapDir.append("MANIFEST.MF"); //$NON-NLS-1$
+ Properties p2 = new Properties();
+ p2.load(new FileInputStream(manifest.toFile()));
+ String type = p2.getProperty("JBoss-Product-Release-Name");
//$NON-NLS-1$
+ String version = p2.getProperty("JBoss-Product-Release-Version");
//$NON-NLS-1$
+ if( "EAP".equals(type) && version.startsWith(versionPrefix))
//$NON-NLS-1$
+ return version;
+ }
+ }
+ } catch(IOException ioe) {
+
+ }
+ }
+ return null;
+ }
- public static class EAPStandaloneServerTypeCondition implements Condition {
+ public static class EAPStandaloneServerTypeCondition extends AbstractEAPTypeCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.EAP_STD.getSystemJarPath());
if (asSystemJar.exists() && asSystemJar.isFile()) {
@@ -227,8 +318,7 @@
}
}
- public static class ASServerTypeCondition implements Condition {
-
+ public static class ASServerTypeCondition extends AbstractCondition {
public boolean isServerRoot(File location) {
File asSystemJar = new File(location, JBossServerType.AS.getSystemJarPath());
if (asSystemJar.exists() && asSystemJar.isFile()) {
@@ -236,25 +326,36 @@
}
return false;
}
+
+ @Override
+ public String getServerTypeId(String version) {
+ // V6_0, V6_1, V5_1, V5_0, V4_2, V4_0, V3_2
+ if( version.equals(V3_2)) return IJBossToolingConstants.SERVER_AS_32;
+ if( version.equals(V4_0)) return IJBossToolingConstants.SERVER_AS_40;
+ if( version.equals(V4_2)) return IJBossToolingConstants.SERVER_AS_42;
+ if( version.equals(V5_0)) return IJBossToolingConstants.SERVER_AS_50;
+ if( version.equals(V5_1)) return IJBossToolingConstants.SERVER_AS_51;
+ if( version.equals(V6_0)) return IJBossToolingConstants.SERVER_AS_60;
+ if( version.equals(V6_1)) return IJBossToolingConstants.SERVER_AS_60;
+ return null;
+ }
}
- public static class AS7ServerTypeCondition implements Condition {
+ public static class AS7ServerTypeCondition extends AbstractCondition {
public boolean isServerRoot(File location) {
- return checkAS7EAP6Version(location, JBAS7_RELEASE_VERSION, "7.");
//$NON-NLS-1$
+ return checkAS7Version(location, JBAS7_RELEASE_VERSION, "7.");
//$NON-NLS-1$
}
+
+ public String getServerTypeId(String version) {
+ if( version.equals(V7_0)) return IJBossToolingConstants.SERVER_AS_70;
+ if( version.equals(V7_1)) return IJBossToolingConstants.SERVER_AS_71;
+ return null;
+ }
}
- protected static boolean checkAS7EAP6Version(File location, String property, String
propPrefix) {
- String mainFolder = new StringBuilder(location.getAbsolutePath())
- .append(File.separator)
- .append("modules").append(File.separator) //$NON-NLS-1$
- .append("org").append(File.separator) //$NON-NLS-1$
- .append("jboss").append(File.separator) //$NON-NLS-1$
- .append("as").append(File.separator) //$NON-NLS-1$
- .append("server").append(File.separator) //$NON-NLS-1$
- .append("main").append(File.separator) //$NON-NLS-1$
- .toString();
- File f = new File(mainFolder);
+ protected static boolean checkAS7Version(File location, String property, String
propPrefix) {
+ String mainFolder = JBossServerType.AS7.jbossSystemJarPath;
+ File f = new File(location, mainFolder);
if( f.exists() ) {
File[] children = f.listFiles();
for( int i = 0; i < children.length; i++ ) {
@@ -275,9 +376,21 @@
File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
return super.isServerRoot(location) && jbpmFolder.exists() &&
jbpmFolder.isDirectory();
}
+
+ public String getFullVersion(File location, File systemFile) {
+ String fullVersion = ServerBeanLoader.getFullServerVersionFromZip(location);
+ if (fullVersion != null && fullVersion.startsWith("5.1.1")) {
//$NON-NLS-1$
+ // SOA-P 5.2
+ String runJar = JBossServerType.JBOSS_AS_PATH + File.separatorChar +
+ JBossServerType.BIN_PATH+ File.separatorChar + JBossServerType.RUN_JAR_NAME;
+ fullVersion = ServerBeanLoader.getFullServerVersionFromZip(new File(location,
runJar));
+ }
+ return fullVersion;
+ }
+
}
- public static class SOAPStandaloneServerTypeCondition implements Condition {
+ public static class SOAPStandaloneServerTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
@@ -289,15 +402,18 @@
}
}
- public static class EWPTypeCondition implements Condition {
+ public static class EWPTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
File ewpSystemJar = new File(location,JBossServerType.EWP.getSystemJarPath());
return ewpSystemJar.exists() && ewpSystemJar.isFile();
}
}
- public static class EPPTypeCondition implements Condition {
+ public static class EPPTypeCondition extends EAPServerTypeCondition {
public boolean isServerRoot(File location) {
+ if( !super.isServerRoot(location))
+ return false;
+
File portletBridgeFolder = new File(location, JBOSS_PORTLETBRIDGE_PATH);
IJBossRuntimeResourceConstants CONSTANTS = new IJBossRuntimeResourceConstants(){};
File portlalSarFolder = new File(location, JBOSS_AS_PATH + File.separatorChar +
CONSTANTS.SERVER + File.separatorChar + CONSTANTS.DEFAULT_CONFIGURATION +
File.separatorChar + CONSTANTS.DEPLOY + File.separatorChar + JBOSS_PORTAL_SAR );
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2010 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -24,53 +24,68 @@
*/
public class ServerBeanLoader {
- public static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl";//$NON-NLS-1$
+ private static JBossServerType[] typesInOrder = {
+ JBossServerType.AS, JBossServerType.EAP6, JBossServerType.AS7, JBossServerType.EAP_STD,
+ JBossServerType.SOAP, JBossServerType.SOAP_STD, JBossServerType.EPP,
JBossServerType.EAP,
+ JBossServerType.EWP
+ };
- public ServerBean loadFromLocation(File location) {
- JBossServerType type = getServerType(location);
+ private ServerBean bean = null;
+ private File rootLocation = null;
+
+ public ServerBeanLoader(File location) {
+ rootLocation = location;
+ }
+
+ public ServerBean getServerBean() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean;
+ }
+
+ public JBossServerType getServerType() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean == null ? JBossServerType.UNKNOWN : bean.getType();
+ }
+
+ private void loadBeanInternal() {
+ JBossServerType type = loadTypeInternal(rootLocation);
String version = null;
if (!JBossServerType.UNKNOWN.equals(type)) {
- String fullVersion = getFullServerVersion(new
File(location,type.getSystemJarPath()));
- if (fullVersion != null && fullVersion.startsWith("5.1.1")
&& JBossServerType.SOAP.equals(type)) { //$NON-NLS-1$
- // SOA-P 5.2
- String runJar = JBossServerType.JBOSS_AS_PATH + File.separatorChar +
- JBossServerType.BIN_PATH+ File.separatorChar + JBossServerType.RUN_JAR_NAME;
- fullVersion = getFullServerVersion(new File(location, runJar));
- }
+ String fullVersion = type.getFullVersion(rootLocation);
version = getServerVersion(fullVersion);
}
- ServerBean server = new ServerBean(location.getPath(),getName(location),type,version);
- return server;
+ ServerBean server = new
ServerBean(rootLocation.getPath(),getName(rootLocation),type,version);
+ this.bean = server;
}
- public JBossServerType getServerType(File location) {
- if(JBossServerType.AS.isServerRoot(location)) {
- return JBossServerType.AS;
- } else if(JBossServerType.EAP6.isServerRoot(location)) {
- return JBossServerType.EAP6;
- } else if(JBossServerType.AS7.isServerRoot(location)) {
- return JBossServerType.AS7;
- } else if(JBossServerType.EAP_STD.isServerRoot(location)) {
- return JBossServerType.EAP_STD;
- } else if(JBossServerType.EAP.isServerRoot(location) &&
JBossServerType.SOAP.isServerRoot(location)) {
- return JBossServerType.SOAP;
- } else if(JBossServerType.SOAP_STD.isServerRoot(location)) {
- return JBossServerType.SOAP_STD;
- } else if(JBossServerType.EAP.isServerRoot(location) &&
JBossServerType.EPP.isServerRoot(location)) {
- return JBossServerType.EPP;
- } else if(JBossServerType.EAP.isServerRoot(location)) {
- return JBossServerType.EAP;
- } else if(JBossServerType.EWP.isServerRoot(location)) {
- return JBossServerType.EWP;
+ private JBossServerType loadTypeInternal(File location) {
+ for( int i = 0; i < typesInOrder.length; i++ ) {
+ if( typesInOrder[i].isServerRoot(location))
+ return typesInOrder[i];
}
return JBossServerType.UNKNOWN;
+
}
public String getName(File location) {
return location.getName();
}
- public String getFullServerVersion(File systemJarFile) {
+ public String getFullServerVersion() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean.getType().getFullVersion(rootLocation);
+ }
+
+ public String getServerAdapterId() {
+ if( bean == null )
+ loadBeanInternal();
+ return bean.getType().getServerAdapterTypeId(bean.getVersion());
+ }
+
+ public static String getFullServerVersionFromZip(File systemJarFile) {
if (systemJarFile.isDirectory()) {
File[] files = systemJarFile.listFiles(new FilenameFilter() {
@@ -111,7 +126,7 @@
return version;
}
- public String getServerVersion(String version) {
+ public static String getServerVersion(String version) {
if(version==null) return "";//$NON-NLS-1$
String[] versions = JBossServerType.UNKNOWN.getVersions();
String adapterVersion = "";//$NON-NLS-1$
@@ -137,7 +152,7 @@
return adapterVersion;
}
- public String getAdapterVersion(String version) {
+ public static String getAdapterVersion(String version) {
String[] versions = JBossServerType.UNKNOWN.getVersions();
String adapterVersion = "";//$NON-NLS-1$
// trying to match adapter version by X.X version
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossServerRuntime.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -14,8 +14,10 @@
import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.DEFAULT_MEM_ARGS_AS50;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.ENDORSED_DIRS;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.EQ;
+import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.FILE_COLON;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.JAVA_LIB_PATH;
import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.JAVA_PREFER_IP4_ARG;
+import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.LOGGING_CONFIG_PROP;
import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.PROGRAM_NAME_ARG;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.QUOTE;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.SERVER_ARG;
@@ -27,13 +29,10 @@
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.BIN;
import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.ENDORSED;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LIB;
+import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LOGGING_PROPERTIES;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.NATIVE;
import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.SERVER;
-import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants.LOGGING_PROPERTIES;
-import static org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.FILE_COLON;
-import static
org.jboss.ide.eclipse.as.core.util.IJBossRuntimeConstants.LOGGING_CONFIG_PROP;
-import java.io.File;
import java.util.HashMap;
import org.eclipse.core.runtime.IPath;
@@ -43,16 +42,13 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
-import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
public class LocalJBossServerRuntime extends AbstractLocalJBossServerRuntime implements
IJBossServerRuntime {
@@ -124,8 +120,7 @@
@Override
public String getDefaultRunVMArgs(IPath serverHome) {
- File sysJar = new File(serverHome.toFile(), JBossServerType.AS.getSystemJarPath());
- String version = new ServerBeanLoader().getFullServerVersion(sysJar);
+ String version = new ServerBeanLoader(serverHome.toFile()).getFullServerVersion();
String name = getRuntime().getName();
String ret = QUOTE + SYSPROP + PROGRAM_NAME_ARG + EQ +
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -36,8 +36,8 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.TaskModel;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.bean.JBossServerType;
+import org.jboss.ide.eclipse.as.core.server.bean.ServerBeanLoader;
import org.jboss.ide.eclipse.as.core.server.internal.v7.LocalJBoss7ServerRuntime;
import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
@@ -214,8 +214,7 @@
}
// Forced error strings for as7.0 and 7.1 incompatabilities.
- File loc = new File(homeDir, getSystemJarPath() );
- String version = getVersionString(loc);
+ String version = getVersionString(new File(homeDir));
IRuntime rt = (IRuntime) getTaskModel().getObject(
TaskModel.TASK_RUNTIME);
String adapterVersion = rt.getRuntimeType().getVersion();
@@ -238,6 +237,8 @@
}
private boolean standaloneScriptExists() {
+ ServerBeanLoader loader = new ServerBeanLoader(new File(homeDir));
+ String version = loader.getFullServerVersion();
String s = JBossServerType.AS7.getSystemJarPath();
IPath p = new Path(homeDir).append(s);
return p.toFile().exists();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -52,17 +52,16 @@
@Override
public void searchForRuntimes(IPath path, IRuntimeSearchListener listener,
IProgressMonitor monitor) {
- ServerBeanLoader loader = new ServerBeanLoader();
- IRuntimeWorkingCopy wc = searchForRuntimes(path, loader, monitor);
+ IRuntimeWorkingCopy wc = searchForRuntimes(path, monitor);
if( wc != null )
listener.runtimeFound(wc);
}
- public IRuntimeWorkingCopy searchForRuntimes(IPath path, ServerBeanLoader loader,
IProgressMonitor monitor) {
+ public IRuntimeWorkingCopy searchForRuntimes(IPath path, IProgressMonitor monitor) {
if( monitor.isCanceled())
return null;
-
- if( loader.getServerType(path.toFile()) != JBossServerType.UNKNOWN) {
+ ServerBeanLoader loader = new ServerBeanLoader(path.toFile());
+ if( loader.getServerType() != JBossServerType.UNKNOWN) {
// return found
IRuntimeWorkingCopy wc = createRuntime(path, loader);
if( wc == null )
@@ -76,7 +75,7 @@
for( int i = 0; i < children.length; i++ ) {
if( children[i].isDirectory()) {
SubProgressMonitor newMon = new SubProgressMonitor(monitor, 1);
- IRuntimeWorkingCopy wc = searchForRuntimes(path.append(children[i].getName()),
loader, newMon);
+ IRuntimeWorkingCopy wc = searchForRuntimes(path.append(children[i].getName()),
newMon);
if( wc != null ) {
monitor.done();
return wc;
@@ -91,11 +90,11 @@
}
public static IRuntimeWorkingCopy createRuntime(IPath path) {
- return createRuntime(path, new ServerBeanLoader());
+ return createRuntime(path, new ServerBeanLoader(path.toFile()));
}
public static IRuntimeWorkingCopy createRuntime(IPath path, ServerBeanLoader loader) {
- JBossServerType type = loader.getServerType(path.toFile());
+ JBossServerType type = loader.getServerType();
if( type == JBossServerType.AS)
return createASRuntime(path, loader);
if( type == JBossServerType.AS7)
@@ -110,7 +109,7 @@
}
private static IRuntimeWorkingCopy createAS7Runtime(IPath path, ServerBeanLoader loader)
{
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(),
JBossServerType.AS7.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId;
if( version.startsWith(IJBossToolingConstants.V7_0))
runtimeTypeId = IJBossToolingConstants.AS_70;
@@ -136,7 +135,7 @@
}
private static IRuntimeWorkingCopy createASRuntime(IPath path, ServerBeanLoader loader)
{
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(),
JBossServerType.AS.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId = null;
if( version.compareTo("4.0") < 0 ) //$NON-NLS-1$
runtimeTypeId=IJBossToolingConstants.AS_32;
@@ -160,7 +159,7 @@
return null;
}
private static IRuntimeWorkingCopy createEAPRuntime(IPath path, ServerBeanLoader loader)
{
- String version = new ServerBeanLoader().getFullServerVersion(new File(path.toFile(),
JBossServerType.EAP.getSystemJarPath()));
+ String version = loader.getFullServerVersion();
String runtimeTypeId = null;
if( version.compareTo("5.0") < 0 ) //$NON-NLS-1$
runtimeTypeId=IJBossToolingConstants.EAP_43;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -650,7 +650,7 @@
}
protected String getVersionString(File loc) {
- String version = new ServerBeanLoader().getFullServerVersion(loc);
+ String version = new ServerBeanLoader(loc).getFullServerVersion();
return version;
}
@@ -659,7 +659,7 @@
}
protected String getHomeVersionWarning() {
- File loc = new File(homeDir, getSystemJarPath() );
+ File loc = new File(homeDir);
String version = getVersionString(loc);
IRuntime rt = (IRuntime) getTaskModel().getObject(
TaskModel.TASK_RUNTIME);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/ServerBeanLoaderTest.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -1,7 +1,5 @@
package org.jboss.ide.eclipse.as.test.server;
-import java.io.File;
-
import junit.framework.TestCase;
import org.eclipse.core.runtime.IPath;
@@ -40,28 +38,43 @@
serverBeanLoaderTestAS6AndBelow("serverEAP5/jbossas",
IJBossToolingConstants.SERVER_EAP_50,
JBossServerType.EAP_STD,IJBossToolingConstants.V5_0);
}
public void testEAP60() {
- serverBeanLoaderTestAS7Style("serverEap6",
IJBossToolingConstants.SERVER_EAP_60, JBossServerType.EAP6,IJBossToolingConstants.V6_0);
+ serverBeanLoaderTestEAP6Style("serverEap6",
IJBossToolingConstants.SERVER_EAP_60, JBossServerType.EAP6,IJBossToolingConstants.V6_0);
}
private void serverBeanLoaderTestAS6AndBelow(String name, String serverTypeId,
JBossServerType expected, String actualVersionPrefix) {
IPath serverDir = ServerRuntimeUtils.createAS6AndBelowMockServerDirectory(
name, ServerRuntimeUtils.asSystemJar.get(serverTypeId), "default");
- ServerBeanLoader loader = new ServerBeanLoader();
- JBossServerType type = loader.getServerType(serverDir.toFile());
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
assertTrue(type.equals(expected));
- String fullVersion = loader.getFullServerVersion(new File(serverDir.toFile(),
type.getSystemJarPath()));
+ String fullVersion = loader.getFullServerVersion();
assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
}
private void serverBeanLoaderTestAS7Style(String name, String serverTypeId,
JBossServerType expected, String actualVersionPrefix) {
IPath serverDir = ServerRuntimeUtils.createAS7StyleMockServerDirectory(
name, serverTypeId, ServerRuntimeUtils.asSystemJar.get(serverTypeId));
- ServerBeanLoader loader = new ServerBeanLoader();
- JBossServerType type = loader.getServerType(serverDir.toFile());
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
assertTrue(type.equals(expected));
- String fullVersion = loader.getFullServerVersion(new File(serverDir.toFile(),
type.getSystemJarPath()));
+ String fullVersion = loader.getFullServerVersion();
assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
}
+
+ private void serverBeanLoaderTestEAP6Style(String name, String serverTypeId,
+ JBossServerType expected, String actualVersionPrefix) {
+ IPath serverDir = ServerRuntimeUtils.createEAP6StyleMockServerDirectory(
+ name, serverTypeId, ServerRuntimeUtils.asSystemJar.get(serverTypeId));
+ ServerBeanLoader loader = new ServerBeanLoader(serverDir.toFile());
+ JBossServerType type = loader.getServerType();
+ assertTrue(type.equals(expected));
+ String fullVersion = loader.getFullServerVersion();
+ assertTrue(fullVersion.startsWith(actualVersionPrefix));
+ assertEquals(loader.getServerAdapterId(), serverTypeId);
+ }
+
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -18,6 +18,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -28,6 +29,25 @@
import org.jboss.tools.test.util.JobUtils;
public class IOUtil {
+
+ public static void setContents(File file, String contents) throws IOException,
CoreException {
+ byte[] buffer = new byte[65536];
+ InputStream in = new ByteArrayInputStream(contents.getBytes());
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ int avail = in.read(buffer);
+ while (avail > 0) {
+ out.write(buffer, 0, avail);
+ avail = in.read(buffer);
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
public static String getContents(IFile file) throws IOException, CoreException {
return getContents(file.getLocation().toFile());
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -275,6 +275,27 @@
return loc;
}
+ public static IPath createEAP6StyleMockServerDirectory(String name, String serverTypeId,
String serverJar) {
+ IPath loc = mockedServers.append(name);
+ try {
+ loc.toFile().mkdirs();
+ IPath productConf = loc.append("bin/product.conf");
+ loc.append("bin").toFile().mkdirs();
+ IOUtil.setContents(productConf.toFile(), "slot=eap");
+ loc.append("modules/org/jboss/as/product/eap/dir/META-INF").toFile().mkdirs();
+ IPath manifest =
loc.append("modules/org/jboss/as/product/eap/dir/META-INF/MANIFEST.MF");
+ String manString = "JBoss-Product-Release-Name:
EAP\nJBoss-Product-Release-Version: 6.0.0.Alpha\nJBoss-Product-Console-Slot: eap";
+ IOUtil.setContents(manifest.toFile(), manString);
+ } catch(CoreException ce) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ } catch(IOException ioe) {
+ FileUtil.completeDelete(loc.toFile());
+ return null;
+ }
+ return loc;
+ }
+
// Find a file in our bundle
protected static File getFileLocation(String path) throws CoreException {
Modified:
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java
===================================================================
---
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-01-30
19:30:30 UTC (rev 38298)
+++
trunk/runtime/plugins/org.jboss.tools.runtime.as.detector/src/org/jboss/tools/runtime/handlers/JBossASHandler.java 2012-01-30
20:12:47 UTC (rev 38299)
@@ -143,9 +143,9 @@
String ver = serverDefinition.getVersion();
String fullVersion;
if (EAP.equals(type) && "6.0".equals(ver)) {
- fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation,
JBossServerType.EAP6.getSystemJarPath()));
+ fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
} else {
- fullVersion = new ServerBeanLoader().getFullServerVersion(new File(asLocation,
JBossServerType.AS.getSystemJarPath()));
+ fullVersion = new ServerBeanLoader(asLocation).getFullServerVersion();
}
if(fullVersion != null ) {
String version = fullVersion.substring(0, 3);
@@ -332,8 +332,8 @@
if (monitor.isCanceled() || root == null || !isEnabled()) {
return null;
}
- ServerBeanLoader loader = new ServerBeanLoader();
- ServerBean serverBean = loader.loadFromLocation(root);
+ ServerBeanLoader loader = new ServerBeanLoader(root);
+ ServerBean serverBean = loader.getServerBean();
if (!JBossServerType.UNKNOWN.equals(serverBean.getType())) {
ServerDefinition serverDefinition = new ServerDefinition(serverBean.getName(),