Author: rob.stryker(a)jboss.com
Date: 2010-10-20 02:24:30 -0400 (Wed, 20 Oct 2010)
New Revision: 25927
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/
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
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.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
Log:
JBIDE-7370 - updating server bean loader stuff
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2010-10-20
05:15:50 UTC (rev 25926)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF 2010-10-20
06:24:30 UTC (rev 25927)
@@ -32,6 +32,7 @@
org.jboss.ide.eclipse.as.core.modules,
org.jboss.ide.eclipse.as.core.publishers,
org.jboss.ide.eclipse.as.core.server,
+ org.jboss.ide.eclipse.as.core.server.bean,
org.jboss.ide.eclipse.as.core.server.internal,
org.jboss.ide.eclipse.as.core.server.internal.launch,
org.jboss.ide.eclipse.as.core.server.xpl,
Added:
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
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/JBossServerType.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.bean;
+
+import java.io.File;
+
+import org.jboss.ide.eclipse.as.core.util.IJBossRuntimeResourceConstants;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+
+public class JBossServerType implements IJBossToolingConstants {
+
+ private static final String JBOSS_AS_PATH = "jboss-as"; //$NON-NLS-1$
+ private static final String BIN_PATH = "bin"; //$NON-NLS-1$
+ private static final String TWIDDLE_JAR_NAME = "twiddle.jar"; //$NON-NLS-1$
+ private static final String RUN_JAR_NAME = "run.jar"; //$NON-NLS-1$
+ private static final String JBOSS_ESB_PATH = "jboss-esb"; //$NON-NLS-1$
+ private static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl"; //$NON-NLS-1$
+ private static final String JBOSS_AS_WEB_PATH = "jboss-as-web"; //$NON-NLS-1$
+ private static final String JBOSS_PORTLETBRIDGE_PATH = "portletbridge";
//$NON-NLS-1$
+ private static final String JBOSS_PORTAL_SAR = "jboss-portal.sar";
//$NON-NLS-1$
+ private static final String UNKNOWN_STR = "UNKNOWN"; //$NON-NLS-1$
+
+ private String name;
+ private String jbossSystemJarPath;
+ private String[] versions = new String[0];
+
+ private JBossServerType.Condition condition = null;
+ private String id=UNKNOWN_STR;
+
+ protected JBossServerType(String id, String name, String jbossSystemJarPath, String[]
versions, Condition condition) {
+ this.id = id;
+ this.name = name;
+ this.jbossSystemJarPath = jbossSystemJarPath;
+ this.versions = versions;
+ this.condition = condition;
+ }
+
+ public static final JBossServerType AS = new JBossServerType(
+ "AS", //$NON-NLS-1$
+ "Application Server", //$NON-NLS-1$
+ BIN_PATH+File.separatorChar + TWIDDLE_JAR_NAME,
+ new String[]{V6_0,V5_1, V5_0, V4_2, V4_0, V3_2}, new ASServerTypeCondition());
+
+ public static final JBossServerType EAP = new JBossServerType(
+ "EAP",//$NON-NLS-1$
+ "Enterprise Application Platform",//$NON-NLS-1$
+ JBOSS_AS_PATH + File.separatorChar + BIN_PATH+ File.separatorChar + TWIDDLE_JAR_NAME,
+ new String[]{V4_2,V4_3,V5_0,V5_1}, new EAPServerTypeCondition());
+
+ public static final JBossServerType SOAP = new JBossServerType(
+ "SOA-P",//$NON-NLS-1$
+ "SOA Platform",//$NON-NLS-1$
+ JBOSS_AS_PATH + File.separatorChar + BIN_PATH+ File.separatorChar + TWIDDLE_JAR_NAME,
+ new String[]{V4_3, V5_0 }, new SOAPServerTypeCondition());
+
+ public static final JBossServerType SOAP_STD = new JBossServerType(
+ "SOA-P-STD",//$NON-NLS-1$
+ "SOA Platform Standalone",//$NON-NLS-1$
+ JBOSS_ESB_PATH + File.separatorChar + BIN_PATH+ File.separatorChar + RUN_JAR_NAME,
+ new String[]{V4_3, V5_0 }, new SOAPStandaloneServerTypeCondition());
+
+ public static final JBossServerType EWP = new JBossServerType(
+ "EWP",//$NON-NLS-1$
+ "Enterprise Web Platform",//$NON-NLS-1$
+ JBOSS_AS_WEB_PATH + File.separatorChar + BIN_PATH + File.separatorChar +
RUN_JAR_NAME,
+ new String[]{V5_0 }, new EWPTypeCondition());
+
+ public static final JBossServerType EPP = new JBossServerType(
+ "EPP",//$NON-NLS-1$
+ "Enterprise Portal Platform",//$NON-NLS-1$
+ JBOSS_AS_PATH + File.separatorChar + BIN_PATH + File.separatorChar + RUN_JAR_NAME,
+ new String[]{V4_3, V5_0}, new EPPTypeCondition());
+
+ public static final JBossServerType UNKNOWN = new JBossServerType(
+ UNKNOWN_STR,
+ UNKNOWN_STR,
+ "",//$NON-NLS-1$
+ new String[]{V6_0, V5_1, V5_0, V4_3, V4_2, V4_0, V3_2}, null);
+
+ public String toString() {
+ return id;
+ }
+
+ public static JBossServerType getType(String name) {
+ if(AS.name.equals(name)) {
+ return AS;
+ } else if(EAP.name.equals(name)) {
+ return EAP;
+ } else if(SOAP.name.equals(name)) {
+ return SOAP;
+ } else if(SOAP_STD.name.equals(name)) {
+ return SOAP_STD;
+ } else if(EWP.name.equals(name)) {
+ return EWP;
+ } else if(EPP.name.equals(name)) {
+ return EPP;
+ }
+ // TODO externalize
+ throw new IllegalArgumentException("Name '" + name + "' cannot
be converted to ServerType"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String[] getVersions() {
+ return versions;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSystemJarPath() {
+ return jbossSystemJarPath;
+ }
+
+ public boolean isServerRoot(File location) {
+ return this.condition.isServerRoot(location);
+ }
+
+ public static final JBossServerType[] KNOWN_TYPES = {AS, EAP, SOAP, SOAP_STD, EWP,
EPP};
+
+ static interface Condition {
+ public boolean isServerRoot(File location);
+ }
+
+
+ public static class EAPServerTypeCondition implements Condition {
+ public boolean isServerRoot(File location) {
+ File asSystemJar = new File(location, JBossServerType.EAP.getSystemJarPath());
+ return asSystemJar.exists() && asSystemJar.isFile();
+ }
+ }
+
+ public static class ASServerTypeCondition implements Condition {
+
+ public boolean isServerRoot(File location) {
+ File asSystemJar = new File(location, JBossServerType.AS.getSystemJarPath());
+ return asSystemJar.exists() && asSystemJar.isFile();
+ }
+ }
+
+ public static class SOAPServerTypeCondition extends EAPServerTypeCondition{
+
+ public boolean isServerRoot(File location) {
+ File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
+ return super.isServerRoot(location) && jbpmFolder.exists() &&
jbpmFolder.isDirectory();
+ }
+ }
+
+ public static class SOAPStandaloneServerTypeCondition implements Condition {
+
+ public boolean isServerRoot(File location) {
+ File jbpmFolder = new File(location, SOAP_JBPM_JPDL_PATH);
+ File soaStdSystemJar = new File(location,JBOSS_ESB_PATH + File.separatorChar +
BIN_PATH + File.separatorChar + RUN_JAR_NAME);
+ return
+ jbpmFolder.exists() && jbpmFolder.isDirectory()
+ &&
+ soaStdSystemJar.exists() && soaStdSystemJar.isFile();
+ }
+ }
+
+ public static class EWPTypeCondition implements Condition {
+ 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 boolean isServerRoot(File location) {
+ 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 );
+ File asStdSystemJar = new File(location,JBOSS_AS_PATH + File.separatorChar + BIN_PATH
+ File.separatorChar + RUN_JAR_NAME);
+ return
+ (portletBridgeFolder.exists() && portletBridgeFolder.isDirectory()
+ ||
+ portlalSarFolder.exists() && portlalSarFolder.isDirectory())
+ &&
+ asStdSystemJar.exists() && asStdSystemJar.isFile();
+ }
+ }
+
+ public String getId() {
+ return id;
+ }
+}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBean.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.ide.eclipse.as.core.server.bean;
+
+
+public class ServerBean {
+
+ public static final String EMPTY = ""; //$NON-NLS-1$
+
+ public ServerBean() {
+
+ }
+
+ public ServerBean(String location, String name, JBossServerType type,
+ String version) {
+ super();
+ this.location = location;
+ this.name = name;
+ this.type = type;
+ this.version = version;
+ }
+
+ public ServerBean(ServerBean bean) {
+ this(bean.getLocation(),bean.getName(), bean.getType(),bean.getVersion());
+ }
+
+ private String location=EMPTY;
+ private JBossServerType type = JBossServerType.UNKNOWN;
+ private String name = EMPTY;
+ private String version = EMPTY;
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public JBossServerType getType() {
+ return type;
+ }
+
+ public void setType(JBossServerType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String toString() {
+ return name + "," + type + "," + version + "," +
location; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == null) return false;
+ if(this == obj) return true;
+ return this.toString().equals(obj.toString());
+ }
+}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/bean/ServerBeanLoader.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.ide.eclipse.as.core.server.bean;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ServerBeanLoader {
+
+ public static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl";//$NON-NLS-1$
+
+ public ServerBean loadFromLocation(File location) {
+ JBossServerType type = getServerType(location);
+ String version = getServerVersion(getFullServerVersion(new
File(location,type.getSystemJarPath())));
+ ServerBean server = new ServerBean(location.getPath(),getName(location),type,version);
+ return server;
+ }
+
+ public JBossServerType getServerType(File location) {
+ if(JBossServerType.AS.isServerRoot(location)) {
+ return JBossServerType.AS;
+ } 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;
+ }
+ return JBossServerType.UNKNOWN;
+ }
+
+ public String getName(File location) {
+ return location.getName();
+ }
+
+ public String getFullServerVersion(File systemJarFile) {
+ String version = null;
+ if(systemJarFile.canRead()) {
+ try {
+ ZipFile jar = new ZipFile(systemJarFile);
+ ZipEntry manifest = jar.getEntry("META-INF/MANIFEST.MF");//$NON-NLS-1$
+ Properties props = new Properties();
+ props.load(jar.getInputStream(manifest));
+ version = (String)props.get("Specification-Version");//$NON-NLS-1$
+ } catch (IOException e) {
+ // version = ""
+ }
+ }
+ return version;
+ }
+
+ public String getServerVersion(String version) {
+ if(version==null) return "";//$NON-NLS-1$
+ String[] versions = JBossServerType.UNKNOWN.getVersions();
+ String adapterVersion = "";//$NON-NLS-1$
+ // trying to match adapter version by X.X version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.replace(".", "\\.") +
".*";//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+
+ if("".equals(adapterVersion)) {//$NON-NLS-1$
+ // trying to match by major version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.substring(0, 2).replace(".",
"\\.") + ".*";//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+ }
+ return adapterVersion;
+ }
+
+ public String getAdapterVersion(String version) {
+ String[] versions = JBossServerType.UNKNOWN.getVersions();
+ String adapterVersion = "";//$NON-NLS-1$
+ // trying to match adapter version by X.X version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.replace(".", "\\.") +
".*";//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+
+ if("".equals(adapterVersion)) { //$NON-NLS-1$
+ // trying to match by major version
+ for (String currentVersion : versions) {
+ String pattern = currentVersion.substring(0, 2).replace(".",
"\\.") + ".*";//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if(version.matches(pattern)) {
+ adapterVersion = currentVersion;
+ break;
+ }
+ }
+ }
+ return adapterVersion;
+ }
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-10-20
05:15:50 UTC (rev 25926)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -42,6 +42,7 @@
public static final String V3_2 = "3.2"; //$NON-NLS-1$
public static final String V4_0 = "4.0"; //$NON-NLS-1$
public static final String V4_2 = "4.2"; //$NON-NLS-1$
+ public static final String V4_3 = "4.3"; //$NON-NLS-1$
public static final String V5_0 = "5.0"; //$NON-NLS-1$
public static final String V5_1 = "5.1"; //$NON-NLS-1$
public static final String V6_0 = "6.0"; //$NON-NLS-1$
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java 2010-10-20
05:15:50 UTC (rev 25926)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/JBossServerType.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.core.util;
-
-import java.io.File;
-
-import org.eclipse.osgi.util.NLS;
-import org.jboss.ide.eclipse.as.core.Messages;
-
-public class JBossServerType {
-
- private static final String SYSTEM_JAR_NAME = "twiddle.jar"; //$NON-NLS-1$
- private String type;
- private String jbossSystemJarPath;
- private String[] versions = new String[0];
-
- private JBossServerType(String type, String jbossSystemJarPath, String[] versions) {
- this.type = type;
- this.jbossSystemJarPath = jbossSystemJarPath;
- this.versions = versions;
- }
-
- public static final JBossServerType AS = new JBossServerType(
- "AS", //$NON-NLS-1$
- "bin"+File.separatorChar + SYSTEM_JAR_NAME, //$NON-NLS-1$
- new String[]{"6.0", "5.0", "4.2", "4.0",
"3.2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- public static final JBossServerType EAP = new JBossServerType(
- "EAP", //$NON-NLS-1$
- "jboss-as" + File.separatorChar + "bin"+ File.separatorChar +
SYSTEM_JAR_NAME, //$NON-NLS-1$ //$NON-NLS-2$
- new String[]{"4.2","4.3"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static final JBossServerType SOAP = new JBossServerType(
- "SOA-P", //$NON-NLS-1$
- "jboss-as" + File.separatorChar + "bin"+ File.separatorChar +
SYSTEM_JAR_NAME, //$NON-NLS-1$ //$NON-NLS-2$
- new String[]{"4.3"}); //$NON-NLS-1$
-
- public static final JBossServerType UNKNOWN = new JBossServerType(
- "UNKNOWN", //$NON-NLS-1$
- "", //$NON-NLS-1$
- new String[]{"5.0", "4.3", "4.2", "4.0",
"3.2"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- public String toString() {
- return type;
- }
-
- public static JBossServerType getType(String name) {
- if(AS.type.equals(name)) {
- return AS;
- } else if(EAP.type.equals(name)) {
- return EAP;
- } else if(SOAP.type.equals(name)) {
- return SOAP;
- }
- throw new IllegalArgumentException(
- NLS.bind(Messages.ServerTypeDiscovererFail, name));
- }
-
- public String[] getVersions() {
- return versions;
- }
-
- public String getType() {
- return type;
- }
-
- public String getSystemJarPath() {
- return jbossSystemJarPath;
- }
-
- public static final JBossServerType[] KNOWN_TYPES = {AS, EAP, SOAP};
-
-}
\ No newline at end of file
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java 2010-10-20
05:15:50 UTC (rev 25926)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ServerBeanLoader.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.ide.eclipse.as.core.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-/**
- * @author eskimo
- *
- */
-public class ServerBeanLoader {
-
- public static final String SOAP_JBPM_JPDL_PATH = "jbpm-jpdl"; //$NON-NLS-1$
-
- public JBossServerType getServerType(File location) {
- File asSystemJar = new File(location, JBossServerType.AS.getSystemJarPath());
- if(asSystemJar.exists() && asSystemJar.isFile()) {
- return JBossServerType.AS;
- } else {
- File eapSystemJar = new File(location, JBossServerType.EAP.getSystemJarPath());
- File jbpmJpdlFolder = new File(location, this.SOAP_JBPM_JPDL_PATH);
- if(eapSystemJar.exists() && eapSystemJar.isFile()) {
- if(jbpmJpdlFolder.exists() && jbpmJpdlFolder.isDirectory()) {
- return JBossServerType.SOAP;
- } else {
- return JBossServerType.EAP;
- }
- }
- }
- return JBossServerType.UNKNOWN;
- }
-
- public String getName(File location) {
- return location.getName();
- }
-
- public String getFullServerVersion(File systemJarFile) {
- String version = null;
- if(systemJarFile.canRead()) {
- try {
- ZipFile jar = new ZipFile(systemJarFile);
- ZipEntry manifest = jar.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
- Properties props = new Properties();
- props.load(jar.getInputStream(manifest));
- version = (String)props.get("Specification-Version"); //$NON-NLS-1$
- } catch (IOException e) {
- // version = ""
- }
- }
- return version;
- }
-
- public String getServerVersion(String version) {
- if(version==null) return ""; //$NON-NLS-1$
- String[] versions = JBossServerType.UNKNOWN.getVersions();
- String adapterVersion = ""; //$NON-NLS-1$
- // trying to match adapter version by X.X version
- for (String currentVersion : versions) {
- String pattern = currentVersion.replace(".", "\\.") +
".*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if(version.matches(pattern)) {
- adapterVersion = currentVersion;
- break;
- }
- }
-
- if("".equals(adapterVersion)) { //$NON-NLS-1$
- // trying to match by major version
- for (String currentVersion : versions) {
- String pattern = currentVersion.substring(0, 2).replace(".",
"\\.") + ".*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if(version.matches(pattern)) {
- adapterVersion = currentVersion;
- break;
- }
- }
- }
- return adapterVersion;
- }
-
- public String getAdapterVersion(String version) {
- String[] versions = JBossServerType.UNKNOWN.getVersions();
- String adapterVersion = ""; //$NON-NLS-1$
- // trying to match adapter version by X.X version
- for (String currentVersion : versions) {
- String pattern = currentVersion.replace(".", "\\.") +
".*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if(version.matches(pattern)) {
- adapterVersion = currentVersion;
- break;
- }
- }
-
- if("".equals(adapterVersion)) { //$NON-NLS-1$
- // trying to match by major version
- for (String currentVersion : versions) {
- String pattern = currentVersion.substring(0, 2).replace(".",
"\\.") + ".*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if(version.matches(pattern)) {
- adapterVersion = currentVersion;
- break;
- }
- }
- }
- return adapterVersion;
- }
-}
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 2010-10-20
05:15:50 UTC (rev 25926)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeLocator.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -38,10 +38,10 @@
import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment;
import org.eclipse.wst.server.ui.wizard.WizardFragment;
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.JBossServerType;
-import org.jboss.ide.eclipse.as.core.util.ServerBeanLoader;
public class JBossRuntimeLocator extends RuntimeLocatorDelegate {
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 2010-10-20
05:15:50 UTC (rev 25926)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2010-10-20
06:24:30 UTC (rev 25927)
@@ -79,11 +79,11 @@
import org.eclipse.wst.server.ui.wizard.WizardFragment;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
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.LocalJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IConstants;
-import org.jboss.ide.eclipse.as.core.util.JBossServerType;
-import org.jboss.ide.eclipse.as.core.util.ServerBeanLoader;
import org.jboss.ide.eclipse.as.ui.IPreferenceKeys;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.jboss.ide.eclipse.as.ui.JBossServerUISharedImages;