[jbosstools-commits] JBoss Tools SVN: r43457 - in trunk: runtime/plugins/org.jboss.tools.runtime.core/META-INF and 17 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Sep 6 05:28:29 EDT 2012
Author: rob.stryker at jboss.com
Date: 2012-09-06 05:28:28 -0400 (Thu, 06 Sep 2012)
New Revision: 43457
Added:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/InvalidRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeCorePreferences.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetectorDelegate.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IDownloadRuntimes.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetectorDelegate.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/RuntimeJarUtil.java
Removed:
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
trunk/runtime-soa/plugins/org.jboss.tools.runtime.drools.detector/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
trunk/runtime-soa/plugins/org.jboss.tools.runtime.esb.detector/src/org/jboss/tools/runtime/handlers/EsbHandler.java
trunk/runtime-soa/plugins/org.jboss.tools.runtime.jbpm.detector/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
trunk/runtime-soa/tests/org.jboss.tools.runtime.soa.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeDefinition.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java
trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/handlers/TestHandler1.java
trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionFrameworkTest.java
trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java
trunk/seam/tests/org.jboss.tools.runtime.seam.detector.test/src/org/jboss/tools/runtime/seam/detector/test/SeamRuntimeDetectionTest.java
Log:
JBIDE-12549
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesRequirementsPage.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -58,7 +58,7 @@
import org.jboss.tools.project.examples.model.ProjectFix;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.ui.IDownloadRuntimes;
+import org.jboss.tools.runtime.core.model.IDownloadRuntimes;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
import org.jboss.tools.runtime.ui.download.DownloadRuntimeDialog;
import org.osgi.framework.Bundle;
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/META-INF/MANIFEST.MF 2012-09-06 09:28:28 UTC (rev 43457)
@@ -17,5 +17,6 @@
Bundle-Vendor: %BundleVendor
Bundle-Localization: plugin
Export-Package: org.jboss.tools.runtime.core,
+ org.jboss.tools.runtime.core.internal;x-friends:="org.jboss.tools.runtime.test",
org.jboss.tools.runtime.core.model,
org.jboss.tools.runtime.core.util
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/schema/runtimeDetectors.exsd 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,147 +1,147 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.runtime.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.jboss.tools.runtime.core" id="runtimeDetectors" name="Runtime Detectors"/>
- </appinfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="runtimeDetector"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="runtimeDetector">
- <complexType>
- <attribute name="preferenceId" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn="org.jboss.tools.runtime.core.model.AbstractRuntimeDetector:"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="enabled" type="boolean">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="priority" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <extension
- point="org.jboss.tools.runtime.core.runtimeDetectors">
- <runtimeDetector>
- <name>JBoss AS Runtime</name>
- <class>org.jboss.tools.runtime.JBossASRuntimeDetector</class>
- <preferenceId>org.eclipse.wst.server.ui.runtime.preferencePage</preferenceId>
- </runtimeDetector>
-</extension>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.runtime.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.runtime.core" id="runtimeDetectors" name="Runtime Detectors"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="runtimeDetector"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="runtimeDetector">
+ <complexType>
+ <attribute name="preferenceId" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.jboss.tools.runtime.core.model.IRuntimeDetectorDelegate"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="enabled" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ <extension
+ point="org.jboss.tools.runtime.core.runtimeDetectors">
+ <runtimeDetector>
+ <name>JBoss AS Runtime</name>
+ <class>org.jboss.tools.runtime.JBossASRuntimeDetector</class>
+ <preferenceId>org.eclipse.wst.server.ui.runtime.preferencePage</preferenceId>
+ </runtimeDetector>
+</extension>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCoreActivator.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -14,7 +14,10 @@
import java.util.Set;
import org.jboss.tools.common.log.BasePlugin;
+import org.jboss.tools.runtime.core.internal.RuntimeCorePreferences;
+import org.jboss.tools.runtime.core.internal.RuntimeExtensionManager;
import org.jboss.tools.runtime.core.model.DownloadRuntime;
+import org.jboss.tools.runtime.core.model.IDownloadRuntimes;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.osgi.framework.BundleContext;
@@ -27,7 +30,6 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.runtime.core"; //$NON-NLS-1$
- private static final String ESB_DETECTOR_ID = "org.jboss.tools.runtime.handlers.EsbHandler"; //$NON-NLS-1$
// The shared instance
private static RuntimeCoreActivator plugin;
@@ -35,10 +37,10 @@
// Member variables
private Set<IRuntimeDetector> declaredRuntimeDetectors;
private Set<IRuntimeDetector> runtimeDetectors;
- private IRuntimeDetector esbDetector;
private Map<String, DownloadRuntime> downloadRuntimes;
private BundleContext context;
+ private IDownloadRuntimes downloader = null;
/**
* The constructor
@@ -78,15 +80,27 @@
return context;
}
+ public IDownloadRuntimes getDownloader() {
+ return downloader;
+ }
+
+ public void setDownloader(IDownloadRuntimes downloader) {
+ this.downloader = downloader;
+ }
+
+ // TODO figure out a better place for this
+ private static final String ESB_DETECTOR_ID = "org.jboss.tools.runtime.handlers.EsbHandler"; //$NON-NLS-1$
public IRuntimeDetector getEsbDetector() {
- if (esbDetector == null) {
- for (IRuntimeDetector detector:getDeclaredRuntimeDetectors()) {
- if (ESB_DETECTOR_ID.equals(detector.getId())) {
- esbDetector = detector;
- }
+ return findRuntimeDetector(ESB_DETECTOR_ID);
+ }
+
+ public IRuntimeDetector findRuntimeDetector(String id) {
+ for (IRuntimeDetector detector:getDeclaredRuntimeDetectors()) {
+ if (id.equals(detector.getId())) {
+ return detector;
}
}
- return esbDetector;
+ return null;
}
/*
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,58 +0,0 @@
-package org.jboss.tools.runtime.core;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.preferences.ConfigurationScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.osgi.service.prefs.BackingStoreException;
-
-public class RuntimeCorePreferences {
- // Preference key
- private static final String ENABLED_DETECTORS = "enabledDetectors";
- private IEclipsePreferences prefs;
-
- private static RuntimeCorePreferences INSTANCE;
- public static RuntimeCorePreferences getDefault() {
- if( INSTANCE == null )
- INSTANCE = new RuntimeCorePreferences();
- return INSTANCE;
- }
-
- public String[] getEnabledRuntimeDetectors() {
- String enabledDetectors = getPreferences().get(ENABLED_DETECTORS,null);
- return enabledDetectors == null ? null : enabledDetectors.split(",");
- }
-
- public void saveEnabledDetectors() {
- saveEnabledDetectors(RuntimeCoreActivator.getDefault().getDeclaredRuntimeDetectors());
- }
-
- public void saveEnabledDetectors(Set<IRuntimeDetector> allDetectors) {
- StringBuilder builder = new StringBuilder();
- for (IRuntimeDetector detector:allDetectors) {
- if (detector.isEnabled()) {
- builder.append(detector.getId());
- builder.append(",");
- }
- }
- String enabled = builder.toString();
- int index = enabled.lastIndexOf(",");
- if (index != -1) {
- enabled = enabled.substring(0, index);
- }
- getPreferences().put(ENABLED_DETECTORS, enabled);
- try {
- getPreferences().flush();
- } catch (BackingStoreException e) {
- RuntimeCoreActivator.getDefault().logError(e);
- }
- }
-
- IEclipsePreferences getPreferences() {
- if (prefs == null) {
- prefs = ConfigurationScope.INSTANCE.getNode(RuntimeCoreActivator.PLUGIN_ID);
- }
- return prefs;
- }
-}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,307 +0,0 @@
-package org.jboss.tools.runtime.core;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.jboss.tools.common.util.FileUtils;
-import org.jboss.tools.runtime.core.model.DownloadRuntime;
-import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
-import org.jboss.tools.runtime.core.util.ECFTransport;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class RuntimeExtensionManager {
- // Extension points
- private static final String RUNTIME_DETECTOR_EXTENSION_ID = "org.jboss.tools.runtime.core.runtimeDetectors";
- public static final String DOWNLOAD_RUNTIMES_EXTENSION_ID = "org.jboss.tools.runtime.ui.downloadruntimes"; //$NON-NLS-1$
-
- // JBoss Runtime files
- private static final String DOWNLOAD_RUNTIMES_FILE = "download_runtime.xml"; //$NON-NLS-1$
- private static final String JBOSS_RUNTIME_URL_DEFAULT = "http://download.jboss.org/jbosstools/examples/download_runtimes.xml"; //$NON-NLS-1$
- private static final String JBOSS_RUNTIME_DIRECTORY = "jboss.runtime.directory.url"; //$NON-NLS-1$
-
- // Extension point property keys
-
- private static final String URL = "url"; //$NON-NLS-1$
- private static final String DISCLAIMER = "disclaimer"; //$NON-NLS-1$
- private static final String VERSION = "version";
- private static final String NAME = "name";
- private static final String PREFERENCE_ID = "preferenceId";
- private static final String ID = "id";
- private static final String ENABLED = "enabled";
- private static final String PRIORITY = "priority";
-
- private static RuntimeExtensionManager manager = null;
- public static RuntimeExtensionManager getDefault() {
- if( manager == null )
- manager = new RuntimeExtensionManager();
- return manager;
- }
-
- /**
- * This method will load runtime detectors from the extension
- * point, AND set its enablement based on values from the
- * preferences.
- *
- * @return
- */
- public Set<IRuntimeDetector> loadInitializedRuntimeDetectors() {
- Set<IRuntimeDetector> tmp = loadDeclaredRuntimeDetectors();
- initializeRuntimeDetectorEnablement(tmp);
- return tmp;
- }
-
- private void initializeRuntimeDetectorEnablement(Set<IRuntimeDetector> set) {
- String[] enabledDetectors = RuntimeCorePreferences.getDefault().getEnabledRuntimeDetectors();
- boolean allEnabled = false;
- if (enabledDetectors == null) {
- allEnabled = true;
- }
- List<String> enabled = Arrays.asList(enabledDetectors);
- for (IRuntimeDetector detector : set) {
- detector.setEnabled(allEnabled || enabled.contains(detector.getId()));
- }
- }
-
- /**
- * This method will do a full load and actually instantiate the classes
- * It will *NOT* set the enablement for the runtime detectors
- *
- * @return
- */
- public Set<IRuntimeDetector> loadDeclaredRuntimeDetectors() {
- Set<IRuntimeDetector> declared = new TreeSet<IRuntimeDetector>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(RUNTIME_DETECTOR_EXTENSION_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] configurationElements = extension
- .getConfigurationElements();
- for (int j = 0; j < configurationElements.length; j++) {
- IRuntimeDetector dec = loadOneDeclaredRuntimeDetector(configurationElements[j]);
- if( !declared.contains(dec)) {
- declared.add(dec);
- }
- }
- }
- return declared;
- }
-
- // This method will load one detector from a configuration element
- private IRuntimeDetector loadOneDeclaredRuntimeDetector(IConfigurationElement configurationElement) {
- IRuntimeDetector detector;
- try {
- detector = (IRuntimeDetector) configurationElement.createExecutableExtension("class");
- } catch (CoreException e) {
- RuntimeCoreActivator.getDefault().logError(e);
- detector = new InvalidRuntimeDetector();
- detector.setValid(false);
- }
- String name = configurationElement.getAttribute(NAME);
- String preferenceId = configurationElement.getAttribute(PREFERENCE_ID);
- String id = configurationElement.getAttribute(ID);
- detector.setName(name);
- detector.setPreferenceId(preferenceId);
- detector.setId(id);
- String enabled = configurationElement.getAttribute(ENABLED);
- if (enabled == null || new Boolean(enabled).booleanValue()) {
- detector.setEnabled(true);
- } else {
- detector.setEnabled(false);
- }
- String priorityString = configurationElement
- .getAttribute(PRIORITY);
- int priority;
- try {
- priority = Integer.parseInt(priorityString);
- } catch (Exception ex) {
- priority = Integer.MAX_VALUE;
- }
- detector.setPriority(priority);
- return detector;
- }
-
- public Map<String, DownloadRuntime> loadDownloadRuntimes() {
- HashMap<String, DownloadRuntime> tmp = new HashMap<String, DownloadRuntime>();
- loadExtensionDownloadableRuntimes(tmp);
- loadExternalDownloadableRuntimes(tmp);
- return tmp;
- }
-
-
- public String getDownloadRuntimesURL() {
- // use commandline override -Djboss.runtime.directory.url
- String directory = System.getProperty(JBOSS_RUNTIME_DIRECTORY, null);
- if (directory == null) {
- // else use Maven-generated value (or fall back to default)
-// ResourceBundle rb = ResourceBundle.getBundle("org.jboss.tools.project.examples.configurators.discovery"); //$NON-NLS-1$
-// String url = rb.getString("runtime.url").trim(); //$NON-NLS-1$
-// if ("".equals(url) || "${jboss.runtime.directory.url}".equals(url)){ //$NON-NLS-1$//$NON-NLS-2$
-// //was not filtered, fallback to default value
-// return JBOSS_RUNTIME_URL_DEFAULT;
-// } else {
-// return url;
-// }
- // Above code removed when trying to move this downloadable
- // runtime stuff into the runtime component instead of examples / central
- return JBOSS_RUNTIME_URL_DEFAULT;
- }
- return directory;
- }
-
- private File getCacheFile() {
- IPath location = RuntimeCoreActivator.getDefault().getStateLocation();
- File cacheFile = new File(location.toFile(), DOWNLOAD_RUNTIMES_FILE);
- return cacheFile;
- }
-
- private long getCacheModified() {
- long cacheModified = 0;
- // This won't be a regression. First time it will simply fetch from remote
- File f = getCacheFile();
- if (f.isFile()) {
- cacheModified = f.lastModified();
- }
- return cacheModified;
-
- }
- private URL getUrl(String s) {
- try {
- URL url = new URL(s);
- return url;
- } catch(MalformedURLException murle) {
- return null;
- }
- }
- private long getRemoteModified(String urlString) {
- long urlModified = -1;
- try {
- URL url = getUrl(urlString);
- if( url != null )
- urlModified = ECFTransport.getInstance()
- .getLastModified(url);
- } catch (Exception e) {
- RuntimeCoreActivator.getDefault().logError(e);
- urlModified = -1;
- }
- return urlModified;
- }
-
- private void downloadRemoteRuntimeFile(String urlString) throws Exception {
- URL url = getUrl(urlString);
- File tempFile = File.createTempFile(
- "download_runtimes", ".xml"); //$NON-NLS-1$//$NON-NLS-2$
- tempFile.deleteOnExit();
- OutputStream destination = new FileOutputStream(tempFile);
- IStatus status = ECFTransport.getInstance().download(
- DOWNLOAD_RUNTIMES_FILE, urlString, destination,
- new NullProgressMonitor());
- if (status.isOK() && url != null) {
- long cacheModified = ECFTransport.getInstance()
- .getLastModified(url);
- FileUtils.copyFile(tempFile, getCacheFile());
- tempFile.delete();
- getCacheFile().setLastModified(cacheModified);
- } else {
- RuntimeCoreActivator.getDefault().getLog().log(status);
- }
- }
-
- private void loadExtensionDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(DOWNLOAD_RUNTIMES_EXTENSION_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] configurationElements = extension
- .getConfigurationElements();
- for (int j = 0; j < configurationElements.length; j++) {
- IConfigurationElement configurationElement = configurationElements[j];
- String name = configurationElement.getAttribute(NAME);
- String id = configurationElement.getAttribute(ID);
- String version = configurationElement.getAttribute(VERSION);
- String url = configurationElement.getAttribute(URL);
- String disclaimer = configurationElement.getAttribute(DISCLAIMER);
- DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
- if (Boolean.FALSE.toString().equals(disclaimer)) {
- downloadRuntime.setDisclaimer(false);
- }
- map.put(id, downloadRuntime);
- }
- }
- }
- private void loadExternalDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
- try {
- String urlString = getDownloadRuntimesURL();
- if (getCacheModified() == 0 || getRemoteModified(urlString) != getCacheModified()) {
- downloadRemoteRuntimeFile(urlString);
- }
- } catch (Exception e) {
- RuntimeCoreActivator.getDefault().logError(e);
- }
- File cacheFile = getCacheFile();
- if (cacheFile != null && cacheFile.isFile()) {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(cacheFile);
- NodeList runtimes = doc.getElementsByTagName("runtime"); //$NON-NLS-1$
- int len = runtimes.getLength();
- for (int i = 0; i < len; i++) {
- Node node = runtimes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String id = element.getAttribute("id"); //$NON-NLS-1$
- String name = element.getAttribute("name"); //$NON-NLS-1$
- String version = element.getAttribute("version"); //$NON-NLS-1$
- String url = element.getAttribute("url"); //$NON-NLS-1$
- String disclaimer = element.getAttribute("disclaimer"); //$NON-NLS-1$
- if (id == null || name == null || version == null || url == null) {
- IStatus status = new Status(IStatus.WARNING,
- RuntimeCoreActivator.PLUGIN_ID,
- "Invalid runtime: id=" + id + ",name=" +
- name + ",version=" + version + ",url=" + url);
- RuntimeCoreActivator.getDefault().getLog().log(status);
- } else {
- DownloadRuntime runtime = new DownloadRuntime(id, name, version, url);
- runtime.setDisclaimer("true".equals(disclaimer)); //$NON-NLS-1$
- map.put(id, runtime);
- }
- }
- }
- } catch (Exception e) {
- RuntimeCoreActivator.getDefault().logError(e);
- }
- }
- }
-
-}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/InvalidRuntimeDetector.java (from rev 43418, trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/InvalidRuntimeDetector.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/InvalidRuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,34 @@
+/*************************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.internal;
+
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class InvalidRuntimeDetector extends RuntimeDetector {
+ public InvalidRuntimeDetector(String name, String id, String preferenceId,
+ int priority) {
+ super(name, id, preferenceId, priority, null);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return false;
+ }
+
+ // Framework method
+ public void setEnabled(boolean enabled) {
+ // Ignore, invalid cannot be enabled
+ }
+}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeCorePreferences.java (from rev 43419, trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeCorePreferences.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeCorePreferences.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeCorePreferences.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,59 @@
+package org.jboss.tools.runtime.core.internal;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class RuntimeCorePreferences {
+ // Preference key
+ private static final String ENABLED_DETECTORS = "enabledDetectors";
+ private IEclipsePreferences prefs;
+
+ private static RuntimeCorePreferences INSTANCE;
+ public static RuntimeCorePreferences getDefault() {
+ if( INSTANCE == null )
+ INSTANCE = new RuntimeCorePreferences();
+ return INSTANCE;
+ }
+
+ public String[] getEnabledRuntimeDetectors() {
+ String enabledDetectors = getPreferences().get(ENABLED_DETECTORS,null);
+ return enabledDetectors == null ? null : enabledDetectors.split(",");
+ }
+
+ public void saveEnabledDetectors() {
+ saveEnabledDetectors(RuntimeCoreActivator.getDefault().getDeclaredRuntimeDetectors());
+ }
+
+ public void saveEnabledDetectors(Set<IRuntimeDetector> allDetectors) {
+ StringBuilder builder = new StringBuilder();
+ for (IRuntimeDetector detector:allDetectors) {
+ if (detector.isEnabled()) {
+ builder.append(detector.getId());
+ builder.append(",");
+ }
+ }
+ String enabled = builder.toString();
+ int index = enabled.lastIndexOf(",");
+ if (index != -1) {
+ enabled = enabled.substring(0, index);
+ }
+ getPreferences().put(ENABLED_DETECTORS, enabled);
+ try {
+ getPreferences().flush();
+ } catch (BackingStoreException e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ }
+ }
+
+ IEclipsePreferences getPreferences() {
+ if (prefs == null) {
+ prefs = ConfigurationScope.INSTANCE.getNode(RuntimeCoreActivator.PLUGIN_ID);
+ }
+ return prefs;
+ }
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeDetector.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,142 @@
+package org.jboss.tools.runtime.core.internal;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.IRuntimeDetectorDelegate;
+import org.jboss.tools.runtime.core.model.RuntimeDefinition;
+
+public class RuntimeDetector implements IRuntimeDetector {
+
+ private String name, id, preferenceId;
+ private int priority;
+ private IRuntimeDetectorDelegate delegate;
+ private boolean enabled;
+ public RuntimeDetector(String name, String id,
+ String preferenceId, int priority,
+ IRuntimeDetectorDelegate delegate) {
+ this.name = name;
+ this.id = id;
+ this.preferenceId = preferenceId;
+ this.priority = priority;
+ this.delegate = delegate;
+ enabled = true;
+ }
+
+ public IRuntimeDetectorDelegate getDelegate() {
+ return delegate;
+ }
+
+
+ @Override
+ public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) {
+ if( delegate != null )
+ delegate.initializeRuntimes(runtimeDefinitions);
+ }
+
+ @Override
+ public RuntimeDefinition getRuntimeDefinition(File root,
+ IProgressMonitor monitor) {
+ if( delegate != null )
+ return delegate.getRuntimeDefinition(root, monitor);
+ return null;
+ }
+
+ @Override
+ public void computeIncludedRuntimeDefinition(
+ RuntimeDefinition runtimeDefinition) {
+ if( delegate != null )
+ delegate.computeIncludedRuntimeDefinition(runtimeDefinition);
+ }
+
+ @Override
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ if( delegate != null )
+ return delegate.getVersion(runtimeDefinition);
+ return null;
+ }
+
+ @Override
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
+ if( delegate != null)
+ return delegate.exists(runtimeDefinition);
+ return false;
+ }
+
+ @Override
+ public int compareTo(IRuntimeDetector o) {
+ if( this.equals(o))
+ return 0;
+ int p1 = this.getPriority();
+ int p2 = o.getPriority();
+ int dif = p1 - p2;
+ if( dif != 0 )
+ return dif;
+ return getId().compareTo(o.getId());
+ }
+
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getPreferenceId() {
+ return preferenceId;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ // Framework method
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ @Override
+ public int getPriority() {
+ return priority;
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IRuntimeDetector other = (IRuntimeDetector) obj;
+ if (id == null) {
+ if (other.getId() != null)
+ return false;
+ } else if (!id.equals(other.getId()))
+ return false;
+ return true;
+ }
+
+}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java (from rev 43419, trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/RuntimeExtensionManager.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/internal/RuntimeExtensionManager.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,312 @@
+package org.jboss.tools.runtime.core.internal;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.common.util.FileUtils;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.DownloadRuntime;
+import org.jboss.tools.runtime.core.model.IRuntimeDetector;
+import org.jboss.tools.runtime.core.model.IRuntimeDetectorDelegate;
+import org.jboss.tools.runtime.core.util.ECFTransport;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class RuntimeExtensionManager {
+ // Extension points
+ private static final String RUNTIME_DETECTOR_EXTENSION_ID = "org.jboss.tools.runtime.core.runtimeDetectors";
+ public static final String DOWNLOAD_RUNTIMES_EXTENSION_ID = "org.jboss.tools.runtime.ui.downloadruntimes"; //$NON-NLS-1$
+
+ // JBoss Runtime files
+ private static final String DOWNLOAD_RUNTIMES_FILE = "download_runtime.xml"; //$NON-NLS-1$
+ private static final String JBOSS_RUNTIME_URL_DEFAULT = "http://download.jboss.org/jbosstools/examples/download_runtimes.xml"; //$NON-NLS-1$
+ private static final String JBOSS_RUNTIME_DIRECTORY = "jboss.runtime.directory.url"; //$NON-NLS-1$
+
+ // Extension point property keys
+
+ private static final String URL = "url"; //$NON-NLS-1$
+ private static final String DISCLAIMER = "disclaimer"; //$NON-NLS-1$
+ private static final String VERSION = "version";
+ private static final String NAME = "name";
+ private static final String PREFERENCE_ID = "preferenceId";
+ private static final String ID = "id";
+ private static final String ENABLED = "enabled";
+ private static final String PRIORITY = "priority";
+
+ private static RuntimeExtensionManager manager = null;
+ public static RuntimeExtensionManager getDefault() {
+ if( manager == null )
+ manager = new RuntimeExtensionManager();
+ return manager;
+ }
+
+ /**
+ * This method will load runtime detectors from the extension
+ * point, AND set its enablement based on values from the
+ * preferences.
+ *
+ * @return
+ */
+ public Set<IRuntimeDetector> loadInitializedRuntimeDetectors() {
+ Set<IRuntimeDetector> tmp = loadDeclaredRuntimeDetectors();
+ initializeRuntimeDetectorEnablement(tmp);
+ return tmp;
+ }
+
+ private void initializeRuntimeDetectorEnablement(Set<IRuntimeDetector> set) {
+ String[] enabledDetectors = RuntimeCorePreferences.getDefault().getEnabledRuntimeDetectors();
+ boolean allEnabled = false;
+ if (enabledDetectors == null) {
+ allEnabled = true;
+ }
+ List<String> enabled = Arrays.asList(enabledDetectors);
+ for (IRuntimeDetector detector : set) {
+ boolean enableVal = allEnabled || enabled.contains(detector.getId());
+ ((RuntimeDetector)detector).setEnabled(enableVal);
+ }
+ }
+
+ /**
+ * This method will do a full load and actually instantiate the classes
+ * It will *NOT* set the enablement for the runtime detectors
+ *
+ * @return
+ */
+ public Set<IRuntimeDetector> loadDeclaredRuntimeDetectors() {
+ Set<IRuntimeDetector> declared = new TreeSet<IRuntimeDetector>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(RUNTIME_DETECTOR_EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configurationElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IRuntimeDetector dec = loadOneDeclaredRuntimeDetector(configurationElements[j]);
+ if( !declared.contains(dec)) {
+ declared.add(dec);
+ }
+ }
+ }
+ return declared;
+ }
+
+ // This method will load one detector from a configuration element
+ private IRuntimeDetector loadOneDeclaredRuntimeDetector(IConfigurationElement configurationElement) {
+ IRuntimeDetectorDelegate delegate = null;
+ try {
+ delegate = (IRuntimeDetectorDelegate) configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ // TODO
+// detector = new InvalidRuntimeDetector();
+// detector.setValid(false);
+ }
+
+ String name = configurationElement.getAttribute(NAME);
+ String preferenceId = configurationElement.getAttribute(PREFERENCE_ID);
+ String id = configurationElement.getAttribute(ID);
+ String priorityString = configurationElement
+ .getAttribute(PRIORITY);
+ String enabled = configurationElement.getAttribute(ENABLED);
+
+ int priority;
+ try {
+ priority = Integer.parseInt(priorityString);
+ } catch (Exception ex) {
+ priority = Integer.MAX_VALUE;
+ }
+
+ if( delegate != null ) {
+ RuntimeDetector detector = new RuntimeDetector(
+ name, id, preferenceId, priority, delegate);
+ detector.setEnabled(Boolean.parseBoolean(enabled));
+ return detector;
+ }
+
+ // return a new invalid
+ return new InvalidRuntimeDetector(name, id, preferenceId, priority);
+ }
+
+ public Map<String, DownloadRuntime> loadDownloadRuntimes() {
+ HashMap<String, DownloadRuntime> tmp = new HashMap<String, DownloadRuntime>();
+ loadExtensionDownloadableRuntimes(tmp);
+ loadExternalDownloadableRuntimes(tmp);
+ return tmp;
+ }
+
+
+ public String getDownloadRuntimesURL() {
+ // use commandline override -Djboss.runtime.directory.url
+ String directory = System.getProperty(JBOSS_RUNTIME_DIRECTORY, null);
+ if (directory == null) {
+ // else use Maven-generated value (or fall back to default)
+// ResourceBundle rb = ResourceBundle.getBundle("org.jboss.tools.project.examples.configurators.discovery"); //$NON-NLS-1$
+// String url = rb.getString("runtime.url").trim(); //$NON-NLS-1$
+// if ("".equals(url) || "${jboss.runtime.directory.url}".equals(url)){ //$NON-NLS-1$//$NON-NLS-2$
+// //was not filtered, fallback to default value
+// return JBOSS_RUNTIME_URL_DEFAULT;
+// } else {
+// return url;
+// }
+ // Above code removed when trying to move this downloadable
+ // runtime stuff into the runtime component instead of examples / central
+ return JBOSS_RUNTIME_URL_DEFAULT;
+ }
+ return directory;
+ }
+
+ private File getCacheFile() {
+ IPath location = RuntimeCoreActivator.getDefault().getStateLocation();
+ File cacheFile = new File(location.toFile(), DOWNLOAD_RUNTIMES_FILE);
+ return cacheFile;
+ }
+
+ private long getCacheModified() {
+ long cacheModified = 0;
+ // This won't be a regression. First time it will simply fetch from remote
+ File f = getCacheFile();
+ if (f.isFile()) {
+ cacheModified = f.lastModified();
+ }
+ return cacheModified;
+
+ }
+ private URL getUrl(String s) {
+ try {
+ URL url = new URL(s);
+ return url;
+ } catch(MalformedURLException murle) {
+ return null;
+ }
+ }
+ private long getRemoteModified(String urlString) {
+ long urlModified = -1;
+ try {
+ URL url = getUrl(urlString);
+ if( url != null )
+ urlModified = ECFTransport.getInstance()
+ .getLastModified(url);
+ } catch (Exception e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ urlModified = -1;
+ }
+ return urlModified;
+ }
+
+ private void downloadRemoteRuntimeFile(String urlString) throws Exception {
+ URL url = getUrl(urlString);
+ File tempFile = File.createTempFile(
+ "download_runtimes", ".xml"); //$NON-NLS-1$//$NON-NLS-2$
+ tempFile.deleteOnExit();
+ OutputStream destination = new FileOutputStream(tempFile);
+ IStatus status = ECFTransport.getInstance().download(
+ DOWNLOAD_RUNTIMES_FILE, urlString, destination,
+ new NullProgressMonitor());
+ if (status.isOK() && url != null) {
+ long cacheModified = ECFTransport.getInstance()
+ .getLastModified(url);
+ FileUtils.copyFile(tempFile, getCacheFile());
+ tempFile.delete();
+ getCacheFile().setLastModified(cacheModified);
+ } else {
+ RuntimeCoreActivator.getDefault().getLog().log(status);
+ }
+ }
+
+ private void loadExtensionDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(DOWNLOAD_RUNTIMES_EXTENSION_ID);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] configurationElements = extension
+ .getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IConfigurationElement configurationElement = configurationElements[j];
+ String name = configurationElement.getAttribute(NAME);
+ String id = configurationElement.getAttribute(ID);
+ String version = configurationElement.getAttribute(VERSION);
+ String url = configurationElement.getAttribute(URL);
+ String disclaimer = configurationElement.getAttribute(DISCLAIMER);
+ DownloadRuntime downloadRuntime = new DownloadRuntime(id, name, version, url);
+ if (Boolean.FALSE.toString().equals(disclaimer)) {
+ downloadRuntime.setDisclaimer(false);
+ }
+ map.put(id, downloadRuntime);
+ }
+ }
+ }
+ private void loadExternalDownloadableRuntimes(HashMap<String, DownloadRuntime> map) {
+ try {
+ String urlString = getDownloadRuntimesURL();
+ if (getCacheModified() == 0 || getRemoteModified(urlString) != getCacheModified()) {
+ downloadRemoteRuntimeFile(urlString);
+ }
+ } catch (Exception e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ }
+ File cacheFile = getCacheFile();
+ if (cacheFile != null && cacheFile.isFile()) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(cacheFile);
+ NodeList runtimes = doc.getElementsByTagName("runtime"); //$NON-NLS-1$
+ int len = runtimes.getLength();
+ for (int i = 0; i < len; i++) {
+ Node node = runtimes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ String id = element.getAttribute("id"); //$NON-NLS-1$
+ String name = element.getAttribute("name"); //$NON-NLS-1$
+ String version = element.getAttribute("version"); //$NON-NLS-1$
+ String url = element.getAttribute("url"); //$NON-NLS-1$
+ String disclaimer = element.getAttribute("disclaimer"); //$NON-NLS-1$
+ if (id == null || name == null || version == null || url == null) {
+ IStatus status = new Status(IStatus.WARNING,
+ RuntimeCoreActivator.PLUGIN_ID,
+ "Invalid runtime: id=" + id + ",name=" +
+ name + ",version=" + version + ",url=" + url);
+ RuntimeCoreActivator.getDefault().getLog().log(status);
+ } else {
+ DownloadRuntime runtime = new DownloadRuntime(id, name, version, url);
+ runtime.setDisclaimer("true".equals(disclaimer)); //$NON-NLS-1$
+ map.put(id, runtime);
+ }
+ }
+ }
+ } catch (Exception e) {
+ RuntimeCoreActivator.getDefault().logError(e);
+ }
+ }
+ }
+
+}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,150 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.core.model;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-
-/**
- * @author snjeza
- *
- */
-public abstract class AbstractRuntimeDetector implements IRuntimeDetector {
- private String id;
- private String name;
- private String preferenceId;
- private boolean enabled;
- private boolean valid = true;
- private int priority;
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String getPreferenceId() {
- return preferenceId;
- }
-
- @Override
- public void setPreferenceId(String preferenceId) {
- this.preferenceId = preferenceId;
- }
-
- public String getImplementationVersion(File dir, String file) {
- File jarFile = new File(dir, file);
- if(!jarFile.isFile()) {
- return null;
- }
- try {
- JarFile jar = new JarFile(jarFile);
- Attributes attributes = jar.getManifest().getMainAttributes();
- String version = attributes.getValue("Implementation-Version");
- return version;
- } catch (IOException e) {
- return null;
- }
- }
-
- public boolean isEnabled() {
- if (!isValid()) {
- return false;
- }
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- AbstractRuntimeDetector other = (AbstractRuntimeDetector) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- public int getPriority() {
- return priority;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- @Override
- public int compareTo(IRuntimeDetector o) {
- if( this.equals(o))
- return 0;
- int p1 = this.getPriority();
- int p2 = o.getPriority();
- int dif = p1 - p2;
- if( dif != 0 )
- return dif;
- return getId().compareTo(o.getId());
- }
-
- @Override
- public void computeIncludedRuntimeDefinition(
- RuntimeDefinition runtimeDefinition) {
-
- }
-
- public boolean isValid() {
- return valid;
- }
-
- public void setValid(boolean valid) {
- this.valid = valid;
- }
-
- @Override
- public String getVersion(RuntimeDefinition runtimeDefinition) {
- if (runtimeDefinition != null) {
- return runtimeDefinition.getVersion();
- }
- return null;
- }
-}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java (from rev 43418, trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,20 @@
+/*************************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+
+
+/**
+ * @author snjeza
+ * @deprecated
+ */
+public abstract class AbstractRuntimeDetector implements IRuntimeDetectorDelegate {
+}
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetectorDelegate.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetectorDelegate.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/AbstractRuntimeDetectorDelegate.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,68 @@
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.internal.RuntimeDetector;
+
+public abstract class AbstractRuntimeDetectorDelegate implements
+ IRuntimeDetectorDelegate {
+
+ @Override
+ public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) {
+ }
+
+ @Override
+ public RuntimeDefinition getRuntimeDefinition(File root,
+ IProgressMonitor monitor) {
+ return null;
+ }
+
+ @Override
+ public void computeIncludedRuntimeDefinition(
+ RuntimeDefinition runtimeDefinition) {
+ }
+
+ @Override
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ return runtimeDefinition.getVersion();
+ }
+
+ @Override
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
+ return false;
+ }
+
+ /* These methods are only here until I can further
+ * unravel the situation regarding nested runtimes.
+ * They WILL BE removed asap.
+ */
+ @Deprecated
+ protected boolean isEnabled() {
+ IRuntimeDetector d = findMyDetector();
+ return d.isEnabled();
+ }
+
+ @Deprecated
+ protected void setEnabled(boolean enabled) {
+ IRuntimeDetector d = findMyDetector();
+ ((RuntimeDetector)d).setEnabled(enabled);
+ }
+
+ @Deprecated
+ private IRuntimeDetector findMyDetector() {
+ Set<IRuntimeDetector> set = RuntimeCoreActivator.getDefault().getRuntimeDetectors();
+ Iterator<IRuntimeDetector> i = set.iterator();
+ while(i.hasNext()) {
+ IRuntimeDetector d = i.next();
+ IRuntimeDetectorDelegate mightBeMe = ((RuntimeDetector)d).getDelegate();
+ if( mightBeMe == this || this.equals(mightBeMe))
+ return d;
+ }
+ return null;
+ }
+}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,97 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008-2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.core.model;
-
-/**
- *
- * @author snjeza
- *
- */
-public class DownloadRuntime {
- private String name;
- private String id;
- private String version;
- private String url;
- private boolean disclaimer = true;
-
- public DownloadRuntime(String id, String name, String version, String url) {
- super();
- this.id = id;
- this.name = name;
- this.version = version;
- this.url = url;
- }
-
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
- public String getUrl() {
- return url;
- }
- public void setUrl(String url) {
- this.url = url;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- DownloadRuntime other = (DownloadRuntime) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "DownloadRuntime [name=" + name + ", id=" + id + ", version="
- + version + ", url=" + url + "]";
- }
-
- public boolean isDisclaimer() {
- return disclaimer;
- }
-
- public void setDisclaimer(boolean disclaimer) {
- this.disclaimer = disclaimer;
- }
-
-}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java (from rev 43419, trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/DownloadRuntime.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,97 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.runtime.core.model;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class DownloadRuntime {
+ private String name;
+ private String id;
+ private String version;
+ private String url;
+ private boolean disclaimer = true;
+
+ public DownloadRuntime(String id, String name, String version, String url) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.version = version;
+ this.url = url;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getVersion() {
+ return version;
+ }
+ public void setVersion(String version) {
+ this.version = version;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DownloadRuntime other = (DownloadRuntime) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "DownloadRuntime [name=" + name + ", id=" + id + ", version="
+ + version + ", url=" + url + "]";
+ }
+
+ public boolean isDisclaimer() {
+ return disclaimer;
+ }
+
+ public void setDisclaimer(boolean disclaimer) {
+ this.disclaimer = disclaimer;
+ }
+
+}
Copied: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IDownloadRuntimes.java (from rev 43419, trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java)
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IDownloadRuntimes.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IDownloadRuntimes.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,8 @@
+package org.jboss.tools.runtime.core.model;
+
+import java.util.HashMap;
+
+public interface IDownloadRuntimes {
+
+ void execute(HashMap<String, Object> data);
+}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -10,70 +10,24 @@
************************************************************************************/
package org.jboss.tools.runtime.core.model;
-import java.io.File;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-
/**
* @author snjeza
*
*/
-public interface IRuntimeDetector extends Comparable<IRuntimeDetector> {
- /**
- * The framework is asking you to create or otherwise initialize
- * the runtimes provided in this list.
- *
- * @param runtimeDefinitions
- */
- void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions);
+public interface IRuntimeDetector extends IRuntimeDetectorDelegate, Comparable<IRuntimeDetector> {
- /**
- * The framework is asking this detector to search the given folder
- * and return a runtime definition, or null if this folder
- * is not a recognized runtime
- *
- * @param root
- * @param monitor
- * @return
- */
- RuntimeDefinition getRuntimeDefinition(File root, IProgressMonitor monitor);
-
- /**
- * The framework is asking you to check nested folders for
- * additional runtimes that may be provided.
- *
- * @param runtimeDefinition
- */
- void computeIncludedRuntimeDefinition(RuntimeDefinition runtimeDefinition);
-
- void setName(String name);
-
- void setPreferenceId(String preferenceId);
-
- void setId(String id);
-
String getName();
String getPreferenceId();
String getId();
- void setEnabled(boolean enabled);
-
boolean isEnabled();
-
- boolean exists(RuntimeDefinition serverDefinition);
+ void setEnabled(boolean enabled);
int getPriority();
- void setPriority(int priority);
-
-
boolean isValid();
-
- void setValid(boolean valid);
-
- String getVersion(RuntimeDefinition runtimeDefinition);
}
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetectorDelegate.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetectorDelegate.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/IRuntimeDetectorDelegate.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,57 @@
+package org.jboss.tools.runtime.core.model;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IRuntimeDetectorDelegate {
+ /**
+ * The framework is asking you to create or otherwise initialize
+ * the runtimes provided in this list.
+ *
+ * @param runtimeDefinitions
+ */
+ void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions);
+
+ /**
+ * The framework is asking this detector to search the given folder
+ * and return a runtime definition, or null if this folder
+ * is not a recognized runtime
+ *
+ * It can be assumed that the detector is enabled when
+ * this method is called.
+ *
+ * @param root
+ * @param monitor
+ * @return
+ */
+ RuntimeDefinition getRuntimeDefinition(File root, IProgressMonitor monitor);
+
+ /**
+ * The framework is asking you to check nested folders for
+ * additional runtimes that may be provided.
+ *
+ * @param runtimeDefinition
+ */
+ void computeIncludedRuntimeDefinition(RuntimeDefinition runtimeDefinition);
+
+ /**
+ * Standard impl will simply return runtimeDefinition.getVersion(),
+ * but other impls may poll their respective models.
+ *
+ * @param runtimeDefinition
+ * @return
+ */
+ String getVersion(RuntimeDefinition runtimeDefinition);
+
+ /**
+ * Standard impl will simply return runtimeDefinition.exists(),
+ * but other impls may poll their respective models.
+ *
+ * @param runtimeDefinition
+ * @return
+ */
+ boolean exists(RuntimeDefinition runtimeDefinition);
+
+}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/InvalidRuntimeDetector.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,41 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2011 Red Hat, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * JBoss by Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.runtime.core.model;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- *
- * @author snjeza
- *
- */
-public class InvalidRuntimeDetector extends AbstractRuntimeDetector {
-
- @Override
- public void initializeRuntimes(List<RuntimeDefinition> serverDefinitions) {
-
- }
-
- @Override
- public RuntimeDefinition getRuntimeDefinition(File root,
- IProgressMonitor monitor) {
- return null;
- }
-
- @Override
- public boolean exists(RuntimeDefinition serverDefinition) {
- return false;
- }
-
-}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeDefinition.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeDefinition.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/model/RuntimeDefinition.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -30,7 +30,7 @@
private String description;
private boolean enabled = true;
private RuntimePath runtimePath;
- private List<RuntimeDefinition> includedServerDefinitions = new ArrayList<RuntimeDefinition>();
+ private List<RuntimeDefinition> includedRuntimeDefinitions = new ArrayList<RuntimeDefinition>();
private RuntimeDefinition parent;
public RuntimeDefinition(String name, String version,
@@ -118,7 +118,7 @@
@Override
public String toString() {
- return "ServerDefinition [name=" + name + ", version=" + version
+ return "RuntimeDefinition [name=" + name + ", version=" + version
+ ", type=" + type + ", location=" + location + "]";
}
@@ -146,8 +146,8 @@
this.runtimePath = runtimePath;
}
- public List<RuntimeDefinition> getIncludedServerDefinitions() {
- return includedServerDefinitions;
+ public List<RuntimeDefinition> getIncludedRuntimeDefinitions() {
+ return includedRuntimeDefinitions;
}
public RuntimeDefinition getParent() {
Added: trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/RuntimeJarUtil.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/RuntimeJarUtil.java (rev 0)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.core/src/org/jboss/tools/runtime/core/util/RuntimeJarUtil.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -0,0 +1,45 @@
+package org.jboss.tools.runtime.core.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+
+public class RuntimeJarUtil {
+ public static String IMPLEMENTATION_VERSION = "Implementation-Version";
+
+ public static String getImplementationVersion(File dir, String file) {
+ File jarFile = new File(dir, file);
+ return getImplementationVersion(jarFile);
+ }
+
+ public static String getImplementationVersion(File jarFile) {
+ return getImplementationVersion(jarFile, new String[]{IMPLEMENTATION_VERSION});
+ }
+ public static String getImplementationVersion(File jarFile, String[] attributes) {
+ if(!jarFile.isFile()) {
+ return null;
+ }
+ JarFile jar = null;
+ try {
+ jar = new JarFile(jarFile);
+ for( int i = 0; i < attributes.length; i++ ) {
+ Attributes attributes2 = jar.getManifest().getMainAttributes();
+ String version = attributes2.getValue(attributes[i]);
+ if( version != null )
+ return version;
+ }
+ } catch (IOException e) {
+ return null;
+ } finally {
+ try {
+ if( jar != null ) {
+ jar.close();
+ }
+ } catch(IOException ioe) {
+ // ignore
+ }
+ }
+ return null;
+ }
+}
Deleted: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/IDownloadRuntimes.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -1,8 +0,0 @@
-package org.jboss.tools.runtime.ui;
-
-import java.util.HashMap;
-
-public interface IDownloadRuntimes {
-
- void execute(HashMap<String, Object> data);
-}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeContentProvider.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -41,12 +41,12 @@
}
public boolean hasChildren(Object element) {
- return ((RuntimeDefinition) element).getIncludedServerDefinitions().size() > 0;
+ return ((RuntimeDefinition) element).getIncludedRuntimeDefinitions().size() > 0;
}
@Override
public Object[] getChildren(Object parentElement) {
- List<RuntimeDefinition> list = ((RuntimeDefinition) parentElement).getIncludedServerDefinitions();
+ List<RuntimeDefinition> list = ((RuntimeDefinition) parentElement).getIncludedRuntimeDefinitions();
return list.toArray();
}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/RuntimeUIActivator.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -55,6 +55,7 @@
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
import org.jboss.tools.runtime.core.model.RuntimePath;
import org.jboss.tools.runtime.ui.dialogs.SearchRuntimePathDialog;
+import org.jboss.tools.runtime.ui.download.DownloadRuntimes;
import org.jboss.tools.runtime.ui.preferences.RuntimePreferencePage;
import org.osgi.framework.BundleContext;
@@ -138,6 +139,7 @@
plugin = this;
runtimePaths = null;
this.context = context;
+ RuntimeCoreActivator.getDefault().setDownloader(new DownloadRuntimes());
}
/*
@@ -145,6 +147,7 @@
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
+ RuntimeCoreActivator.getDefault().setDownloader(null);
saveRuntimePreferences();
plugin = null;
super.stop(context);
@@ -327,7 +330,7 @@
RuntimeDefinition included = createServerDefinition(includedNode);
included.setRuntimePath(runtimePath);
included.setParent(serverDefinition);
- serverDefinition.getIncludedServerDefinitions().add(
+ serverDefinition.getIncludedRuntimeDefinitions().add(
included);
}
}
@@ -415,7 +418,7 @@
IMemento sdNode = serverDefintionsNode.createChild(SERVER_DEFINITION);
putServerDefinition(serverDefinition, sdNode);
IMemento includedNodes = sdNode.createChild(INCLUDED_DEFINITION);
- for (RuntimeDefinition included:serverDefinition.getIncludedServerDefinitions()) {
+ for (RuntimeDefinition included:serverDefinition.getIncludedRuntimeDefinitions()) {
IMemento includedNode = includedNodes.createChild(SERVER_DEFINITION);
putServerDefinition(included, includedNode);
}
@@ -488,7 +491,7 @@
continue;
}
if (detector.exists(serverDefinition)) {
- List<RuntimeDefinition> includedDefinitions = serverDefinition.getIncludedServerDefinitions();
+ List<RuntimeDefinition> includedDefinitions = serverDefinition.getIncludedRuntimeDefinitions();
boolean includedCreated = true;
for (RuntimeDefinition includedDefinition:includedDefinitions) {
if (!runtimeCreated(includedDefinition)) {
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/dialogs/SearchRuntimePathDialog.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -129,7 +129,7 @@
if (serverDefinition.isEnabled()) {
enableOk = true;
} else {
- for (RuntimeDefinition includedDefinition:serverDefinition.getIncludedServerDefinitions()) {
+ for (RuntimeDefinition includedDefinition:serverDefinition.getIncludedRuntimeDefinitions()) {
if (includedDefinition.isEnabled()) {
enableOk = true;
break;
@@ -232,7 +232,7 @@
treeViewer.setInput(serverDefinitions);
for (RuntimeDefinition definition:serverDefinitions) {
treeViewer.setChecked(definition, definition.isEnabled());
- for (RuntimeDefinition included:definition.getIncludedServerDefinitions()) {
+ for (RuntimeDefinition included:definition.getIncludedRuntimeDefinitions()) {
treeViewer.setChecked(included, included.isEnabled());
}
}
@@ -368,7 +368,7 @@
List<RuntimeDefinition> allDefinitions = new ArrayList<RuntimeDefinition>();
allDefinitions.addAll(runtimePath.getRuntimeDefinitions());
for (RuntimeDefinition serverDefinition : runtimePath.getRuntimeDefinitions()) {
- allDefinitions.addAll(serverDefinition.getIncludedServerDefinitions());
+ allDefinitions.addAll(serverDefinition.getIncludedRuntimeDefinitions());
}
return allDefinitions;
}
@@ -377,7 +377,7 @@
List<RuntimeDefinition> allServerDefinitions = new ArrayList<RuntimeDefinition>();
allServerDefinitions.addAll(RuntimeUIActivator.getDefault().getServerDefinitions());
for (RuntimeDefinition d:RuntimeUIActivator.getDefault().getServerDefinitions()) {
- allServerDefinitions.addAll(d.getIncludedServerDefinitions());
+ allServerDefinitions.addAll(d.getIncludedRuntimeDefinitions());
}
return allServerDefinitions;
}
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeDialog.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -83,7 +83,7 @@
private Button deleteOnExit;
private Text destinationPathText;
private Text pathText;
- private DownloadRuntime downloadRuntime;
+ private DownloadRuntime downloadRuntime;
private String delete;
private ControlDecoration decPathError;
private ControlDecoration decPathReq;
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimeViewerDialog.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -36,7 +36,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.RuntimeExtensionManager;
import org.jboss.tools.runtime.core.model.DownloadRuntime;
import org.jboss.tools.runtime.ui.dialogs.AutoResizeTableLayout;
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/download/DownloadRuntimes.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -4,11 +4,14 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.jboss.tools.runtime.ui.IDownloadRuntimes;
+import org.jboss.tools.runtime.core.model.IDownloadRuntimes;
public class DownloadRuntimes implements IDownloadRuntimes {
public static final String SHELL = "download.runtimes.shell";
- @Override
+
+ public DownloadRuntimes() {
+
+ }
public void execute(HashMap<String, Object> map) {
Object shell = map.get(SHELL);
Shell shell2 = shell == null ? Display.getDefault().getActiveShell() : ((Shell)shell);
Modified: trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java
===================================================================
--- trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/plugins/org.jboss.tools.runtime.ui/src/org/jboss/tools/runtime/ui/preferences/RuntimePreferencePage.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -17,7 +17,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -72,9 +71,10 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.model.IDownloadRuntimes;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
-import org.jboss.tools.runtime.ui.IDownloadRuntimes;
import org.jboss.tools.runtime.ui.IRuntimePathChangeListener;
import org.jboss.tools.runtime.ui.RuntimeSharedImages;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
@@ -82,8 +82,6 @@
import org.jboss.tools.runtime.ui.dialogs.EditRuntimePathDialog;
import org.jboss.tools.runtime.ui.dialogs.RuntimePathEditingSupport;
import org.jboss.tools.runtime.ui.download.DownloadRuntimes;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
/**
* @author snjeza
@@ -473,7 +471,7 @@
}
private IDownloadRuntimes getDownloader() {
- return new DownloadRuntimes();
+ return RuntimeCoreActivator.getDefault().getDownloader();
}
public void init(IWorkbench workbench) {
Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/handlers/TestHandler1.java
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/handlers/TestHandler1.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/handlers/TestHandler1.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -5,10 +5,10 @@
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetectorDelegate;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
-public class TestHandler1 extends AbstractRuntimeDetector {
+public class TestHandler1 extends AbstractRuntimeDetectorDelegate {
private static TestHandler1 ME;
@@ -44,17 +44,26 @@
}
@Override
- public void initializeRuntimes(List<RuntimeDefinition> serverDefinitions) {
- for( int i = 0; i < serverDefinitions.size(); i++ ) {
- String n = serverDefinitions.get(i).getName();
+ public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinition) {
+ for( int i = 0; i < runtimeDefinition.size(); i++ ) {
+ String n = runtimeDefinition.get(i).getName();
addInit(n);
}
}
@Override
- public boolean exists(RuntimeDefinition serverDefinition) {
- // TODO Auto-generated method stub
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
return false;
}
+ @Override
+ public void computeIncludedRuntimeDefinition(
+ RuntimeDefinition runtimeDefinition) {
+ }
+
+ @Override
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ return runtimeDefinition.getVersion();
+ }
+
}
Modified: trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionFrameworkTest.java
===================================================================
--- trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionFrameworkTest.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime/tests/org.jboss.tools.runtime.test/src/org/jboss/tools/runtime/test/RuntimeDetectionFrameworkTest.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -10,21 +10,18 @@
************************************************************************************/
package org.jboss.tools.runtime.test;
-import java.io.File;
import java.util.List;
import java.util.Set;
import junit.framework.TestCase;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.jboss.tools.runtime.core.JBossRuntimeLocator;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.internal.InvalidRuntimeDetector;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
import org.jboss.tools.runtime.core.model.RuntimePath;
import org.jboss.tools.runtime.handlers.TestHandler1;
@@ -42,7 +39,6 @@
*
*/
public class RuntimeDetectionFrameworkTest extends TestCase {
- private final static String seamVersionAttributeName = "Seam-Version";
@BeforeClass
public static void create() {
Modified: trunk/runtime-soa/plugins/org.jboss.tools.runtime.drools.detector/src/org/jboss/tools/runtime/handlers/DroolsHandler.java
===================================================================
--- trunk/runtime-soa/plugins/org.jboss.tools.runtime.drools.detector/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime-soa/plugins/org.jboss.tools.runtime.drools.detector/src/org/jboss/tools/runtime/handlers/DroolsHandler.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -18,16 +18,18 @@
import org.drools.eclipse.util.DroolsRuntime;
import org.drools.eclipse.util.DroolsRuntimeManager;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetectorDelegate;
+import org.jboss.tools.runtime.core.model.IRuntimeDetectorDelegate;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
+import org.jboss.tools.runtime.core.util.RuntimeJarUtil;
-public class DroolsHandler extends AbstractRuntimeDetector {
+public class DroolsHandler extends AbstractRuntimeDetectorDelegate {
private static final String DROOLS = "DROOLS"; // NON-NLS-1$
private static final String SOA_P = "SOA-P"; //$NON-NLS-1$
@Override
- public void initializeRuntimes(List<RuntimeDefinition> serverDefinitions) {
+ public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) {
DroolsRuntime[] existingRuntimes = DroolsRuntimeManager
.getDroolsRuntimes();
List<DroolsRuntime> droolsRuntimes = new ArrayList<DroolsRuntime>();
@@ -36,7 +38,7 @@
droolsRuntimes.add(runtime);
}
}
- initializeInternal(serverDefinitions, droolsRuntimes);
+ initializeInternal(runtimeDefinitions, droolsRuntimes);
if (droolsRuntimes.size() > 0) {
DroolsRuntime[] dra = droolsRuntimes.toArray(new DroolsRuntime[0]);
DroolsRuntimeManager.setDroolsRuntimes(dra);
@@ -53,7 +55,7 @@
File droolsRoot = runtimeDefinition.getLocation(); //$NON-NLS-1$
if (droolsRoot.isDirectory()) {
DroolsRuntime runtime = new DroolsRuntime();
- runtime.setName("Drools " + runtimeDefinition.getVersion() + " - " + serverDefinition.getName()); //$NON-NLS-1$
+ runtime.setName("Drools " + runtimeDefinition.getVersion() + " - " + runtimeDefinition.getName()); //$NON-NLS-1$
runtime.setPath(droolsRoot.getAbsolutePath());
DroolsRuntimeManager.recognizeJars(runtime);
runtime.setDefault(true);
@@ -61,7 +63,7 @@
}
}
}
- initializeInternal(runtimeDefinition.getIncludedServerDefinitions(),
+ initializeInternal(runtimeDefinition.getIncludedRuntimeDefinitions(),
droolsRuntimes);
}
}
@@ -100,7 +102,7 @@
}
});
if (files != null && files.length > 0) {
- String version = getImplementationVersion(root, files[0]);
+ String version = RuntimeJarUtil.getImplementationVersion(root, files[0]);
if (version != null) {
version = version.substring(0, 3);
return new RuntimeDefinition(root.getName(), version, DROOLS,
@@ -121,12 +123,6 @@
@Override
public void computeIncludedRuntimeDefinition(
RuntimeDefinition runtimeDefinition) {
- calculateIncludedServerDefinition(runtimeDefinition);
- }
-
- @Deprecated /* Does this belong here? Static with no callers? */
- public static void calculateIncludedServerDefinition(
- RuntimeDefinition runtimeDefinition) {
if (runtimeDefinition == null
|| !SOA_P.equals(runtimeDefinition.getType())) {
return;
@@ -137,8 +133,7 @@
RuntimeDefinition sd = new RuntimeDefinition(name,
runtimeDefinition.getVersion(), DROOLS, droolsRoot);
sd.setParent(runtimeDefinition);
- runtimeDefinition.getIncludedServerDefinitions().add(sd);
+ runtimeDefinition.getIncludedRuntimeDefinitions().add(sd);
}
}
-
}
Modified: trunk/runtime-soa/plugins/org.jboss.tools.runtime.esb.detector/src/org/jboss/tools/runtime/handlers/EsbHandler.java
===================================================================
--- trunk/runtime-soa/plugins/org.jboss.tools.runtime.esb.detector/src/org/jboss/tools/runtime/handlers/EsbHandler.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime-soa/plugins/org.jboss.tools.runtime.esb.detector/src/org/jboss/tools/runtime/handlers/EsbHandler.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -16,10 +16,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.esb.core.runtime.JBossESBRuntime;
import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetectorDelegate;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
-public class EsbHandler extends AbstractRuntimeDetector {
+public class EsbHandler extends AbstractRuntimeDetectorDelegate {
private static final String DEFAULT_CONFIGURATION = "default";
private static final String ESB = "ESB"; //$NON-NLS-1$
@@ -38,7 +38,7 @@
JBossRuntimeManager.getInstance().addRuntime(runtime);
}
}
- initializeRuntimes(runtimeDefinition.getIncludedServerDefinitions());
+ initializeRuntimes(runtimeDefinition.getIncludedRuntimeDefinitions());
}
}
@@ -57,7 +57,24 @@
return false;
}
- public RuntimeDefinition getServerDefinition(File root,
+ @Override
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
+ if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) {
+ return false;
+ }
+ return esbExists(runtimeDefinition);
+ }
+
+ @Override
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) {
+ return null;
+ }
+ return JBossRuntimeManager.getInstance().getVersion(runtimeDefinition.getLocation().getAbsolutePath(), DEFAULT_CONFIGURATION);
+ }
+
+ @Override
+ public RuntimeDefinition getRuntimeDefinition(File root,
IProgressMonitor monitor) {
if (monitor.isCanceled() || root == null) {
return null;
@@ -67,18 +84,7 @@
}
@Override
- public boolean exists(RuntimeDefinition serverDefinition) {
- if (serverDefinition == null || serverDefinition.getLocation() == null) {
- return false;
- }
- return esbExists(serverDefinition);
+ public void computeIncludedRuntimeDefinition(
+ RuntimeDefinition runtimeDefinition) {
}
-
- @Override
- public String getVersion(RuntimeDefinition serverDefinition) {
- if (serverDefinition == null || serverDefinition.getLocation() == null) {
- return null;
- }
- return JBossRuntimeManager.getInstance().getVersion(serverDefinition.getLocation().getAbsolutePath(), DEFAULT_CONFIGURATION);
- }
}
Modified: trunk/runtime-soa/plugins/org.jboss.tools.runtime.jbpm.detector/src/org/jboss/tools/runtime/handlers/JbpmHandler.java
===================================================================
--- trunk/runtime-soa/plugins/org.jboss.tools.runtime.jbpm.detector/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime-soa/plugins/org.jboss.tools.runtime.jbpm.detector/src/org/jboss/tools/runtime/handlers/JbpmHandler.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -19,10 +19,11 @@
import org.eclipse.core.runtime.Path;
import org.jboss.tools.jbpm.preferences.JbpmInstallation;
import org.jboss.tools.jbpm.preferences.PreferencesManager;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetectorDelegate;
+import org.jboss.tools.runtime.core.model.IRuntimeDetectorDelegate;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
-public class JbpmHandler extends AbstractRuntimeDetector {
+public class JbpmHandler extends AbstractRuntimeDetectorDelegate {
private static final String JBPM3 = "jBPM3"; //$NON-NLS-1$
private static final String JBPM4 = "jBPM4"; //$NON-NLS-1$
@@ -54,7 +55,7 @@
PreferencesManager.getInstance().addJbpmInstallation(runtimeDefinition.getName(), jbpmRoot.getAbsolutePath(), runtimeDefinition.getVersion());
}
}
- initializeRuntimes(runtimeDefinition.getIncludedServerDefinitions());
+ initializeRuntimes(runtimeDefinition.getIncludedRuntimeDefinitions());
}
}
@@ -118,15 +119,15 @@
}
@Override
- public boolean exists(RuntimeDefinition serverDefinition) {
- if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
+ if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) {
return false;
}
- return jbpmExists(serverDefinition);
+ return jbpmExists(runtimeDefinition);
}
- @Deprecated /* Does this belong as static? Nobody calls this */
- public static void calculateIncludedRuntimeDefinition(
+ @Override
+ public void computeIncludedRuntimeDefinition(
RuntimeDefinition runtimeDefinition) {
if (runtimeDefinition == null || !SOA_P.equals(runtimeDefinition.getType())) {
return;
@@ -139,14 +140,12 @@
}
RuntimeDefinition sd = new RuntimeDefinition(runtimeDefinition.getName(), version, JBPM, jbpmRoot);
sd.setParent(runtimeDefinition);
- runtimeDefinition.getIncludedServerDefinitions().add(sd);
+ runtimeDefinition.getIncludedRuntimeDefinitions().add(sd);
}
}
-
+
@Override
- public void computeIncludedRuntimeDefinition(
- RuntimeDefinition runtimeDefinition) {
- calculateIncludedRuntimeDefinition(runtimeDefinition);
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ return runtimeDefinition.getVersion();
}
-
}
Modified: trunk/runtime-soa/tests/org.jboss.tools.runtime.soa.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java
===================================================================
--- trunk/runtime-soa/tests/org.jboss.tools.runtime.soa.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/runtime-soa/tests/org.jboss.tools.runtime.soa.test/src/org/jboss/tools/runtime/test/RuntimeDetectionTest.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -41,8 +41,8 @@
import org.jboss.tools.runtime.as.detector.IJBossRuntimePluginConstants;
import org.jboss.tools.runtime.core.JBossRuntimeLocator;
import org.jboss.tools.runtime.core.RuntimeCoreActivator;
+import org.jboss.tools.runtime.core.internal.InvalidRuntimeDetector;
import org.jboss.tools.runtime.core.model.IRuntimeDetector;
-import org.jboss.tools.runtime.core.model.InvalidRuntimeDetector;
import org.jboss.tools.runtime.core.model.RuntimePath;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
import org.jboss.tools.runtime.ui.RuntimeUIActivator;
@@ -329,8 +329,8 @@
for (RuntimeDefinition serverDefinition:RuntimeUIActivator.getDefault().getServerDefinitions()){
String type = serverDefinition.getType();
if (EAP.equals(type)) {
- assertTrue("EAP has to include server definitions", serverDefinition.getIncludedServerDefinitions().size() > 0);
- for(RuntimeDefinition included:serverDefinition.getIncludedServerDefinitions()) {
+ assertTrue("EAP has to include server definitions", serverDefinition.getIncludedRuntimeDefinitions().size() > 0);
+ for(RuntimeDefinition included:serverDefinition.getIncludedRuntimeDefinitions()) {
assertTrue("Invalid parent definition", included.getParent() == serverDefinition);
}
}
Modified: trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/seam/plugins/org.jboss.tools.runtime.seam.detector/src/org/jboss/tools/runtime/handlers/SeamHandler.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -12,59 +12,57 @@
import java.io.File;
import java.io.FilenameFilter;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.runtime.core.model.AbstractRuntimeDetector;
+import org.jboss.tools.runtime.core.model.AbstractRuntimeDetectorDelegate;
import org.jboss.tools.runtime.core.model.RuntimeDefinition;
+import org.jboss.tools.runtime.core.util.RuntimeJarUtil;
import org.jboss.tools.seam.core.SeamUtil;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
-public class SeamHandler extends AbstractRuntimeDetector {
+public class SeamHandler extends AbstractRuntimeDetectorDelegate {
private final static String seamJarName = "jboss-seam.jar";
private final static String seamVersionAttributeName = "Seam-Version";
private static final String SEAM = "SEAM"; // NON-NLS-1$
- private static File getSeamRoot(RuntimeDefinition serverDefinition) {
- String type = serverDefinition.getType();
+ private static File getSeamRoot(RuntimeDefinition runtimeDefinition) {
+ String type = runtimeDefinition.getType();
if (SEAM.equals(type)) {
- return serverDefinition.getLocation();
+ return runtimeDefinition.getLocation();
}
return null;
}
@Override
- public void initializeRuntimes(List<RuntimeDefinition> serverDefinitions) {
+ public void initializeRuntimes(List<RuntimeDefinition> runtimeDefinitions) {
Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
- for(RuntimeDefinition serverDefinition:serverDefinitions) {
- if (serverDefinition.isEnabled()) {
- String type = serverDefinition.getType();
+ for(RuntimeDefinition runtimeDefinition:runtimeDefinitions) {
+ if (runtimeDefinition.isEnabled()) {
+ String type = runtimeDefinition.getType();
if (SEAM.equals(type)) {
- addSeam(map, serverDefinition,
- serverDefinition.getLocation());
+ addSeam(map, runtimeDefinition,
+ runtimeDefinition.getLocation());
}
}
- initializeRuntimes(serverDefinition.getIncludedServerDefinitions());
+ initializeRuntimes(runtimeDefinition.getIncludedRuntimeDefinitions());
}
SeamRuntimeManager.getInstance().save();
}
private static void addSeam(Map<String, SeamRuntime> map,
- RuntimeDefinition serverDefinition, File seamFile) {
+ RuntimeDefinition runtimeDefinition, File seamFile) {
if (seamFile.exists() && seamFile.canRead() && seamFile.isDirectory()) {
SeamVersion seamVersion = getSeamVersion(seamFile.getAbsolutePath());
if (seamVersion != null) {
- String name = "Seam " + serverDefinition.getName() + " " + seamVersion; //$NON-NLS-1$ //$NON-NLS-2$
+ String name = "Seam " + runtimeDefinition.getName() + " " + seamVersion; //$NON-NLS-1$ //$NON-NLS-2$
addSeam(map, seamFile.getAbsolutePath(), seamVersion, name);
}
}
@@ -154,26 +152,16 @@
return null;
}
}
- try {
- JarFile jar = new JarFile(jarFile);
- Attributes attributes = jar.getManifest().getMainAttributes();
- String version = attributes.getValue(seamVersionAttributeName);
- if (version == null) {
- // Seam 2.3
- version = attributes.getValue("Implementation-Version");
- }
- return version;
- } catch (IOException e) {
- return null;
- }
+ String[] attributes = new String[]{seamVersionAttributeName, RuntimeJarUtil.IMPLEMENTATION_VERSION};
+ return RuntimeJarUtil.getImplementationVersion(jarFile, attributes);
}
@Override
- public boolean exists(RuntimeDefinition serverDefinition) {
- if (serverDefinition == null || serverDefinition.getLocation() == null) {
+ public boolean exists(RuntimeDefinition runtimeDefinition) {
+ if (runtimeDefinition == null || runtimeDefinition.getLocation() == null) {
return false;
}
- File seamRoot = getSeamRoot(serverDefinition);
+ File seamRoot = getSeamRoot(runtimeDefinition);
if (seamRoot == null || !seamRoot.isDirectory()) {
return false;
}
@@ -181,4 +169,14 @@
return seamExists(path);
}
+ @Override
+ public void computeIncludedRuntimeDefinition(
+ RuntimeDefinition runtimeDefinition) {
+ }
+
+ @Override
+ public String getVersion(RuntimeDefinition runtimeDefinition) {
+ return runtimeDefinition.getVersion();
+ }
+
}
Modified: trunk/seam/tests/org.jboss.tools.runtime.seam.detector.test/src/org/jboss/tools/runtime/seam/detector/test/SeamRuntimeDetectionTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.runtime.seam.detector.test/src/org/jboss/tools/runtime/seam/detector/test/SeamRuntimeDetectionTest.java 2012-09-06 09:14:42 UTC (rev 43456)
+++ trunk/seam/tests/org.jboss.tools.runtime.seam.detector.test/src/org/jboss/tools/runtime/seam/detector/test/SeamRuntimeDetectionTest.java 2012-09-06 09:28:28 UTC (rev 43457)
@@ -199,7 +199,7 @@
}
private void setServerDefinitionsEnabledRecurse(RuntimeDefinition def, boolean enabled) {
def.setEnabled(enabled);
- List<RuntimeDefinition> nested = def.getIncludedServerDefinitions();
+ List<RuntimeDefinition> nested = def.getIncludedRuntimeDefinitions();
Iterator<RuntimeDefinition> i = nested.iterator();
while(i.hasNext()) {
setServerDefinitionsEnabledRecurse(i.next(), enabled);
@@ -232,7 +232,7 @@
count = countSeamRuntimesForVersion(version);
assertEquals(1, count);
- List<RuntimeDefinition> nested = def1.getIncludedServerDefinitions();
+ List<RuntimeDefinition> nested = def1.getIncludedRuntimeDefinitions();
System.out.println(nested.size());
}
@@ -347,8 +347,8 @@
for (RuntimeDefinition serverDefinition:RuntimeUIActivator.getDefault().getServerDefinitions()){
String type = serverDefinition.getType();
if (EAP.equals(type)) {
- assertTrue("EAP has to include server definitions", serverDefinition.getIncludedServerDefinitions().size() > 0);
- for(RuntimeDefinition included:serverDefinition.getIncludedServerDefinitions()) {
+ assertTrue("EAP has to include server definitions", serverDefinition.getIncludedRuntimeDefinitions().size() > 0);
+ for(RuntimeDefinition included:serverDefinition.getIncludedRuntimeDefinitions()) {
assertTrue("Invalid parent definition", included.getParent() == serverDefinition);
}
}
More information about the jbosstools-commits
mailing list