Author: dennyxu
Date: 2008-09-02 03:14:58 -0400 (Tue, 02 Sep 2008)
New Revision: 10017
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath
trunk/esb/plugins/org.jboss.tools.esb.project.core/.project
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties
trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
Log:
Initial import. Add ESB project facet and wizard
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath 2008-09-02 07:14:58 UTC
(rev 10017)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/.project
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/.project
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/.project 2008-09-02 07:14:58 UTC
(rev 10017)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.esb.project.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,7 @@
+#Wed Aug 27 16:17:18 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %PLUGIN_NAME
+Bundle-SymbolicName: org.jboss.tools.esb.project.core;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.esb.core.ESBCorePlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.core.resources,
+ org.eclipse.jst.ws,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jst.jsf.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jst.jsf.ui,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jst.ws.consumption.ui,
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.200",
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0"
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %PLUGIN_PROVIDER
+Export-Package: org.jboss.tools.esb.core,
+ org.jboss.tools.esb.core.facet,
+ org.jboss.tools.esb.core.messages,
+ org.jboss.tools.esb.core.runtime
+
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
(rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml 2008-09-02 07:14:58 UTC
(rev 10017)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.facets">
+ <project-facet
+ id="jst.jboss.esb">
+ <label>
+ JBoss ESB
+ </label>
+ </project-facet>
+ <project-facet-version
+ facet="jst.jboss.esb"
+ version="4.2">
+ </project-facet-version>
+ <action
+ facet="jst.jboss.esb"
+ id="jst.jboss.esb.install"
+ type="install">
+ <delegate
+
class="org.jboss.tools.esb.core.facet.JBossESBFacetInstallationDelegate">
+ </delegate>
+ <config-factory
+
class="org.jboss.tools.esb.core.facet.JBossESBFacetDataModelProvider">
+ </config-factory>
+ </action>
+ <project-facet-version
+ facet="jst.jboss.esb"
+ version="4.3">
+ </project-facet-version>
+ <template
+ id="template.jst.jboss.esb">
+ <label>
+ label body text
+ </label>
+ <fixed
+ facet="jst.java">
+ </fixed>
+ <fixed
+ facet="jst.jboss.esb">
+ </fixed>
+ </template>
+ </extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <supported>
+ <facet
+ id="jst.jboss.esb"
+ version="4.2,4.3">
+ </facet>
+ <runtime-component
+ id="org.jboss.ide.eclipse.as.runtime.component"
+ version="4.2">
+ </runtime-component>
+ </supported>
+ </extension>
+ <extension
+ id="ESBNature"
+ name="JBoss ESB Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+
class="org.jboss.tools.esb.project.nature.JBossESBProjectNature">
+ </run>
+ </runtime>
+ <requires-nature
+ id="org.eclipse.wst.common.project.facet.core.nature">
+ </requires-nature>
+ </extension>
+ <extension
+ point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
+
class="org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer"
+ id="org.jboss.esb.runtime.classpath">
+ </classpathContainerInitializer>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.moduleTypes">
+ <moduleType
+ id="jst.jboss.esb"
+ name="JBoss ESB Module">
+ </moduleType>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.moduleFactories">
+ <moduleFactory
+ class="org.jboss.tools.esb.core.module.JBossESBModuleFactory"
+ id="org.jboss.tools.esb.project.core.moduleFactory"
+ projects="true">
+ <moduleType
+ types="jst.jboss.esb"
+ versions="4.2,4.3,4.4">
+ </moduleType>
+ </moduleFactory>
+ </extension>
+</plugin>
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,50 @@
+package org.jboss.tools.esb.core;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ESBCorePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.core";
+
+ // The shared instance
+ private static ESBCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ESBCorePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ESBCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,10 @@
+package org.jboss.tools.esb.core;
+
+public class ESBProjectUtilities {
+
+ public final static String ESB_PROJECT_FACET = "jst.jboss.esb";
+ public final static String ESB_PROJECT_FACET_TEMPLATE =
"template.jst.jboss.esb";
+ public final static String BUILD_CLASSES = "build/classes";
+
+ public final static String ESB_PROJECT_NATURE =
"org.jboss.tools.esb.project.ESBNature";
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+
+public class StatusUtils
+{
+ public static IStatus errorStatus( String errorMessage )
+ {
+ return new Status( IStatus.ERROR, "id", 0, errorMessage, null );
+ }
+
+ public static IStatus errorStatus( Throwable exc )
+ {
+ String message = exc.getMessage();
+
+ return new Status( IStatus.ERROR, "id", 0, message == null ? "" :
message, exc );
+ }
+
+ public static IStatus errorStatus( String message, Throwable exc )
+ {
+ return new Status( IStatus.ERROR, "id", 0, message, exc );
+ }
+
+ public static MultiStatus multiStatus( String message, IStatus[] children, Throwable
exc )
+ {
+ return new MultiStatus( "id", 0, children, message, exc );
+ }
+
+ public static MultiStatus multiStatus( String message, IStatus[] children )
+ {
+ return new MultiStatus( "id", 0, children, message, null );
+ }
+
+ public static IStatus warningStatus( String warningMessage )
+ {
+ return new Status( IStatus.WARNING, "id", 0, warningMessage, null );
+ }
+
+ public static IStatus warningStatus( String warningMessage, Throwable exc )
+ {
+ return new Status( IStatus.WARNING, "id", 0, warningMessage, exc );
+ }
+
+ public static IStatus infoStatus( String infoMessage )
+ {
+ return new Status( IStatus.INFO, "id", 0, infoMessage, null );
+ }
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,37 @@
+package org.jboss.tools.esb.core.facet;
+
+import org.eclipse.core.runtime.QualifiedName;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+
+public interface IJBossESBFacetDataModelProperties extends
IFacetProjectCreationDataModelProperties {
+
+ public static final String USER_DEFINED_LOCATION =
"IProjectCreationPropertiesNew.USER_DEFINED_LOCATION"; //$NON-NLS-1$
+ public static final String DEFAULT_LOCATION =
"IProjectCreationPropertiesNew.DEFAULT_LOCATION"; //$NON-NLS-1$
+ public static final String USE_DEFAULT_LOCATION =
"IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION"; //$NON-NLS-1$
+ public static final String PROJECT_LOCATION =
"IProjectCreationPropertiesNew.PROJECT_LOCATION";
+
+ public static final String ESB_CONTENT_FOLDER =
"JBoss.Project.Content_Folder";
+ public static final String ESB_SOURCE_FOLDER = "JBoss.Project.Src_Folder";
+
+ public static final QualifiedName QNAME_ESB_CONTENT_FOLDER = new
QualifiedName("jboss", ESB_CONTENT_FOLDER);
+ public static final QualifiedName QNAME_ESB_SRC_FOLDER = new
QualifiedName("jboss", ESB_SOURCE_FOLDER);
+
+
+
+ public static final String JBOSS_ESB_FACET_ID = "jst.jboss.esb";
+ public static final String RUNTIME_DEPLOY = "jboss.deploy";
+ public static final String QUALIFIEDNAME_IDENTIFIER = "jboss.tools";
+ public static final String RUNTIME_IS_SERVER_SUPPLIED =
"jboss.is.server.supplied";
+ public static final String RUNTIME_ID = "jboss.runtime_id";
+
+ public static final String PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME =
"is.server.supplied.runtime";
+ public static final String RUNTIME_HOME = "jboss.runtime.home";
+ public static final String DEFAULT_VALUE_IS_SERVER_SUPPLIED = "1";
+ static QualifiedName PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME = new
QualifiedName(QUALIFIEDNAME_IDENTIFIER,
+ RUNTIME_ID);
+ static QualifiedName PERSISTENCE_PROPERTY_RNTIME_LOCATION = new
QualifiedName(QUALIFIEDNAME_IDENTIFIER,
+ RUNTIME_HOME);
+ static QualifiedName PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME = new QualifiedName(
+ QUALIFIEDNAME_IDENTIFIER,
+ PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME);
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.facet;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossClassPathCommand extends AbstractDataModelOperation {
+
+ IProject project;
+ private IDataModel model;
+
+ public JBossClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ this.model = model;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ // store runtime name and runtime location to the project
+
+ String runtimeName = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_ID);
+ String runtimeLocation = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_HOME);
+ String esbcontentFolder =
model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ project
+ .setPersistentProperty(
+ IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
+ runtimeName);
+ project
+ .setPersistentProperty(
+ IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
+ runtimeLocation);
+ project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER,
esbcontentFolder);
+ status = addClassPath(project, runtimeName);
+
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossFacetCoreMessages.Error_Add_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus addClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IClasspathEntry newClasspath;
+ IJavaProject javaProject = JavaCore.create(project);
+
+ newClasspath = JavaCore
+ .newContainerEntry(new Path(
+ JBossRuntimeClassPathInitializer.JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)
+ .append(segment));
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ newClasspath.getPath())) {
+ isFolderInClassPathAlready = true;
+ break;
+ }
+ }
+
+ if (!isFolderInClassPathAlready) {
+
+ IClasspathEntry[] newClasspathEntries = new
IClasspathEntry[oldClasspathEntries.length + 1];
+ for (int i = 0; i < oldClasspathEntries.length; i++) {
+ newClasspathEntries[i] = oldClasspathEntries[i];
+ }
+ newClasspathEntries[oldClasspathEntries.length] = newClasspath;
+ javaProject.setRawClasspath(newClasspathEntries,
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossFacetCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,64 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class JBossESBFacetDataModelProvider extends
J2EEModuleFacetInstallDataModelProvider implements IJBossESBFacetDataModelProperties{
+
+ private static final String JBOSSESB_PROJECT_FACET = "jst.jboss.esb";
+
+ public Set getPropertyNames() {
+ Set names = super.getPropertyNames();
+ names.add(CONFIG_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ names.add(RUNTIME_ID);
+ names.add(RUNTIME_HOME);
+ return names;
+ }
+
+ public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(FACET_ID)) {
+ return JBOSSESB_PROJECT_FACET;
+ }
+ else if(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER.equals(propertyName)){
+ return "esbcontent";
+ }
+ else if(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER.equals(propertyName)){
+ return "src";
+ }
+ else if(propertyName.equals(RUNTIME_ID)){
+ return "";
+ }else if(propertyName.equals(FACET_ID)){
+ return IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID;
+ }
+ return super.getDefaultProperty(propertyName);
+ }
+
+ protected int convertFacetVersionToJ2EEVersion(IProjectFacetVersion version) {
+ return J2EEVersionConstants.J2EE_1_4_ID;
+ }
+
+ public boolean isPropertyEnabled(String propertyName) {
+ return super.isPropertyEnabled(propertyName);
+ }
+
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ boolean status = false;
+ status = super.propertySet(propertyName, propertyValue);
+ return status;
+ }
+
+ public IStatus validate(String propertyName) {
+ return OK_STATUS;
+ }
+
+
+
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,127 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.common.project.facet.WtpUtils;
+import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class JBossESBFacetInstallationDelegate implements IDelegate {
+
+
+ private IDataModel model;
+ public static final String ESB_NATURE =
"org.jboss.tools.esb.project.core.ESBNature";
+
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ model = (IDataModel) config;
+
+ createProjectStructure(project);
+
+ final IJavaProject jproj = JavaCore.create(project);
+
+ // Add WTP natures.
+ WtpUtils.addNatures(project);
+
+ // Setup the flexible project structure.
+ final IVirtualComponent c = ComponentCore.createComponent(project);
+ c.create(0, null);
+ String esbContent =
model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ c.setMetaProperty("java-output-path", "/" + esbContent +
"/build/classes/");
+
+ final IVirtualFolder jbiRoot = c.getRootFolder();
+
+ // Create directory structure
+ String srcFolder = null;
+ srcFolder = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ jbiRoot.createLink(new Path("/" + srcFolder), 0, null);
+ String resourcesFolder = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ jbiRoot.createLink(new Path("/" + resourcesFolder), 0, null);
+
+
+
+ //addESBNature(project);
+
+ String runtimeId = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_ID);
+ if (runtimeId != null && !runtimeId.equals("")) {
+ JBossClassPathCommand command = new JBossClassPathCommand(project,
+ model);
+ IStatus status = command.executeOverride(monitor);
+ if (!status.equals(Status.OK_STATUS)) {
+ throw new CoreException(status);
+ }
+ }
+
+ ClasspathHelper.removeClasspathEntries(project, fv);
+ ClasspathHelper.addClasspathEntries(project, fv);
+
+ //String prjName =
model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
+ //IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
+
+
+ }
+
+ private IFile createJBossESBXML(IFolder folder) throws CoreException{
+ StringBuffer emptyESB = new StringBuffer();
+ emptyESB.append("<?xml version = \"1.0\" encoding =
\"UTF-8\"?>");
+ emptyESB.append("\n");
+ emptyESB.append("<jbossesb
xmlns=\"http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/et...
parameterReloadSecs=\"5\">");
+ emptyESB.append("\n");
+ emptyESB.append("</jbossesb>");
+ IFile esbfile = folder.getFile("jboss-esb.xml");
+ esbfile.create(new ByteArrayInputStream(emptyESB.toString().getBytes()), true, null);
+
+ return esbfile;
+ }
+
+
+
+
+ private void createProjectStructure(IProject project) throws CoreException{
+ IFile esbFile = null;
+ String strContentFolder =
model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER,
strContentFolder);
+ IFolder esbContent = project.getFolder(strContentFolder);
+ if(!esbContent.exists()) {
+ esbContent.create(true, true, null);
+ }
+
+ esbContent.getFolder("lib").create(true, true, null);
+ esbContent.getFolder("META-INF").create(true, true, null);
+ esbFile = createJBossESBXML(esbContent.getFolder("META-INF"));
+
+ project.refreshLocal(IResource.DEPTH_ZERO, null);
+ }
+
+ private static void addESBNature(IProject project) throws CoreException{
+ IProjectDescription desc = project.getDescription();
+ final String[] current = desc.getNatureIds();
+ final String[] replacement = new String[ current.length + 1 ];
+ System.arraycopy( current, 0, replacement, 1, current.length );
+ replacement[ 0 ] = ESB_NATURE;
+ desc.setNatureIds( replacement );
+ project.setDescription( desc, null );
+
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,102 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer;
+
+public class UninstallJBossClassPathCommand {
+ IProject project;
+
+ public UninstallJBossClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = Boolean
+ .getBoolean(project
+ .getPersistentProperty(IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
+ if (isServerSupplied) {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ } else {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String runtimeName = project
+ .getPersistentProperty(IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+
+ status = removeClassPath(project, runtimeName);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossFacetCoreMessages.Error_Remove_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus removeClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ List<IClasspathEntry> classpathEntries = new
ArrayList<IClasspathEntry>();
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (!oldClasspathEntries[i].getPath().equals(
+ new
Path(JBossRuntimeClassPathInitializer.JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)
+ .append(segment))) {
+ classpathEntries.add(oldClasspathEntries[i]);
+ }
+ }
+ if (classpathEntries.size() < oldClasspathEntries.length) {
+ javaProject.setRawClasspath(classpathEntries
+ .toArray(new IClasspathEntry[classpathEntries.size()]),
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossFacetCoreMessages.Error_Remove_Facet_JBossWS,
+ new String[] { e.getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,14 @@
+Progress_Install_JBossWS_Runtime=JBoss ESB Runtime
+Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss ESB Runtime
+Dir_Lib=lib
+Dir_Client=client
+Dir_Web_Inf=WEB-INF
+Dir_Web_Content=WebContent
+Error_Copy=Exception while copy runtime jars
+ESB_Location=jbossesbruntimelocation
+JBossWS_Runtime=JBoss ESB Runtime
+JBossAS=JBOSS
+Error_WS_Location=The JBoss ESB Runtime Location is NULL
+Error_WS_Classpath=A error comes up when create JBoss ESB runtime Classpath
+Error_Add_Facet_JBossWS=Exception while install JBoss ESB facet
+Error_Remove_Facet_JBossWS=Exception while uninstall JBoss ESB facet
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossFacetCoreMessages {
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.esb.core.messages.JBossFacetCore"; //$NON-NLS-1$
+
+ private JBossFacetCoreMessages() {
+ // Do not instantiate
+ }
+
+ public static String Progress_Install_JBossWS_Runtime;
+ public static String Progress_UnInstall_JBossWS_Runtime;
+ public static String Dir_Lib;
+ public static String Dir_Client;
+ public static String Dir_Web_Inf;
+ public static String Dir_Web_Content;
+ public static String Error_Copy;
+ public static String ESB_Location;
+ public static String JBossWS_Runtime;
+ public static String JBossAS;
+ public static String Error_WS_Location;
+ public static String Error_WS_Classpath;
+ public static String Error_Add_Facet_JBossWS;
+ public static String Error_Remove_Facet_JBossWS;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossFacetCoreMessages.class);
+ }
+}
\ No newline at end of file
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,73 @@
+package org.jboss.tools.esb.core.module;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ModuleFactory;
+import org.eclipse.wst.server.core.internal.ModuleType;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class JBossESBModule implements IModule{
+
+ private IProject project;
+ private ModuleFactoryDelegate factory;
+ private String factoryId;
+ public JBossESBModule(IProject project, ModuleFactoryDelegate factory, String
factoryId){
+ this.project = project;
+ this.factory = factory;
+ this.factoryId = factoryId;
+
+ }
+ public Object getAdapter(Class adapter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getId() {
+ return factoryId + ":" + project.getName();
+ }
+
+ public IModuleType getModuleType() {
+ IFacetedProject facetPrj;
+ try {
+ facetPrj = ProjectFacetsManager.create(project);
+ final IProjectFacet esbfacet =
ProjectFacetsManager.getProjectFacet(ESBProjectUtilities.ESB_PROJECT_FACET);
+ final IProjectFacetVersion fv = facetPrj.getInstalledVersion(esbfacet);
+ return ModuleType.getModuleType(esbfacet.getId(), fv.getVersionString());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public String getName() {
+ return project.getName();
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public boolean isExternal() {
+ return false;
+ }
+
+ public Object loadAdapter(Class adapter, IProgressMonitor monitor) {
+ ModuleDelegate delegate = factory.getModuleDelegate(this);
+ if(adapter.isInstance(delegate))
+ return delegate;
+ return null;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,85 @@
+package org.jboss.tools.esb.core.module;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.internal.ModuleResourceDelta;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
+import org.eclipse.wst.server.core.util.ModuleFolder;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+
+public class JBossESBModuleDelegate extends ProjectModule {
+
+ public JBossESBModuleDelegate(IProject project){
+ super(project);
+ }
+ @Override
+ public IModule[] getChildModules() {
+ return null;
+ }
+
+ public IModuleResource[] members() throws CoreException {
+ IProject project = getProject();
+ String esbFolder =
(String)project.getPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER);
+ IFolder configFolder = project.getFolder(esbFolder);
+ IJavaProject javaPrj = JavaCore.create(project);
+ IPath output = javaPrj.getOutputLocation();
+ IModuleResource[] esbContent = getModuleResources(Path.EMPTY, configFolder);
+ IModuleResource[] classes = getModuleResources(Path.EMPTY,
project.getWorkspace().getRoot().getFolder(output));
+ IModuleResource[] allResource = new IModuleResource[esbContent.length +
classes.length];
+ System.arraycopy(esbContent, 0, allResource, 0, esbContent.length);
+ System.arraycopy(classes, 0, allResource, esbContent.length, classes.length);
+ return allResource;
+ }
+
+ @Override
+ public IStatus validate() {
+ return null;
+ }
+
+ @Override
+ protected IModuleResource[] getModuleResources(IPath path, IContainer container) throws
CoreException {
+
+ IResource[] resources = container.members();
+ if (resources != null) {
+ int size = resources.length;
+ List<IModuleResource> list = new ArrayList<IModuleResource>(size);
+ for (int i = 0; i < size; i++) {
+ IResource resource = resources[i];
+ if (resource != null && resource.exists()) {
+ String name = resource.getName();
+ if (resource instanceof IContainer) {
+ IContainer container2 = (IContainer) resource;
+ ModuleFolder mf = new ModuleFolder(container2, name, path);
+ mf.setMembers(getModuleResources(path.append(name), container2));
+ list.add(mf);
+ } else if (resource instanceof IFile) {
+ list.add(new ModuleFile((IFile) resource, name, path));
+ }
+ }
+ }
+ IModuleResource[] moduleResources = new IModuleResource[list.size()];
+ list.toArray(moduleResources);
+ return moduleResources;
+ }
+ return new IModuleResource[0];
+ }
+
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,44 @@
+package org.jboss.tools.esb.core.module;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class JBossESBModuleFactory extends ProjectModuleFactoryDelegate {
+
+ public JBossESBModuleFactory() {
+ }
+
+ @Override
+ public ModuleDelegate getModuleDelegate(IModule module) {
+ if(module instanceof JBossESBModule){
+ IProject project = module.getProject();
+ return new JBossESBModuleDelegate(project);
+ }
+ return null;
+ }
+
+ protected IModule[] createModules(IProject project) {
+ IFacetedProject facetProject;
+ try {
+ facetProject = ProjectFacetsManager.create(project);
+ IProjectFacet esbFacet =
ProjectFacetsManager.getProjectFacet(ESBProjectUtilities.ESB_PROJECT_FACET);
+ if(facetProject.hasProjectFacet(esbFacet)){
+ JBossESBModule module = new JBossESBModule(project, this, this.getId());
+ return new IModule[]{ module };
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntime {
+
+ String name = null;
+
+ String homeDir = null;
+
+ String version = null;
+
+ boolean defaultRt = false;
+
+ List<String> libraries;
+
+ private boolean userConfigClasspath;
+
+ /**
+ * Default constructor
+ */
+ public JBossRuntime() {
+ libraries = new ArrayList<String>();
+ }
+
+ /**
+ * Get JBossWSRuntime name
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get path to home directory
+ *
+ * @return home directory path as string
+ */
+ public String getHomeDir() {
+ return homeDir;
+ }
+
+ /**
+ * Set JBossWSRuntime name
+ *
+ * @param name
+ * new JBossWSRuntime name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set home directory
+ *
+ * @param homeDir
+ * new JBossWSRuntime's home directory
+ */
+ public void setHomeDir(String homeDir) {
+ this.homeDir = homeDir;
+ }
+
+ /**
+ * Mark runtime as default
+ *
+ * @param b
+ * new value for default property
+ */
+ public void setDefault(boolean b) {
+ this.defaultRt = b;
+ }
+
+ /**
+ * Get default flag
+ *
+ * @return default property
+ */
+ public boolean isDefault() {
+ return defaultRt;
+ }
+
+ public List<String> getLibraries(){
+
+ return this.libraries;
+ }
+
+ public void setLibraries(List<String> libraries){
+ this.libraries = libraries;
+ }
+
+ public boolean isUserConfigClasspath(){
+ return this.userConfigClasspath;
+ }
+
+ public void setUserConfigClasspath(boolean userConfigClasspath){
+ this.userConfigClasspath = userConfigClasspath;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeClassPathInitializer extends
+ ClasspathContainerInitializer {
+
+ public final static String JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID =
"org.jboss.esb.runtime.classpath";
+ public JBossRuntimeClassPathInitializer() {
+ }
+
+ private String segment;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+
+ if (containerPath.segment(0).equals(
+ JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)) {
+ JBossRuntimeClasspathContainer container = new JBossRuntimeClasspathContainer(
+ containerPath);
+ segment = containerPath.segment(1);
+ JavaCore.setClasspathContainer(containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
+ }
+ }
+
+ public IClasspathEntry[] getEntries(IPath path) {
+ return new JBossRuntimeClasspathContainer(path).getClasspathEntries();
+ }
+
+ public class JBossRuntimeClasspathContainer implements
+ IClasspathContainer {
+ private IPath path;
+ private IClasspathEntry[] entries = null;
+
+ public JBossRuntimeClasspathContainer(IPath path) {
+ this.path = path;
+ }
+
+ public String getDescription() {
+ return JBossFacetCoreMessages.JBossWS_Runtime;
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ public IClasspathEntry[] getClasspathEntries() {
+ if (entries == null) {
+ ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
+ JBossRuntime jbws = JBossRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ if (jbws != null) {
+
+ List<String> jars =
JBossRuntimeManager.getInstance().getAllRuntimeJars(jbws);
+ for (String jar : jars) {
+ entryList.add(getEntry(new Path(jar)));
+ }
+ entries = entryList.toArray(new IClasspathEntry[entryList.size()]);
+ if (entries == null)
+ return new IClasspathEntry[0];
+ }
+ }
+ return entries;
+ }
+
+ protected IClasspathEntry getEntry(IPath path) {
+ return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
+ .getClasspathEntry();
+ }
+
+ public void removeEntry(String jarName) {
+ if (entries == null) {
+ return;
+ }
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
+ }
+ }
+ entries = newEntries;
+ }
+
+ }
+
+ public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
+ for (IClasspathEntry entry : list) {
+ if (entry.getPath().lastSegment().equals(jarName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,141 @@
+package org.jboss.tools.esb.core.runtime;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+public class JBossRuntimeListConverter {
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String LIBRARY_SEPARATOR = ";";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String HOME_DIR = "homeDir";
+ private static final String VERSION = "version";
+ private static final String NAME = "name";
+ private static final String USER_CONFIG_CLASSPATH = "userConfig";
+ private static final String LIBRARY = "libraries";
+
+ /**
+ * Load String to JBossWSRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, JBossWSRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, JBossRuntime> getMap(String input) {
+
+ Map<String, JBossRuntime> result = new HashMap<String, JBossRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
+ return result;
+ }
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
+ while (runtimes.hasMoreTokens()) {
+ String runtime = runtimes.nextToken();
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
+ JBossRuntime rt = new JBossRuntime();
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
+ String name = map[i];
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
+ rt.setName(value);
+ } else if (HOME_DIR.equals(name)) {
+ rt.setHomeDir(value);
+ } else if (VERSION.equals(name)) {
+ rt.setVersion(value);
+ } else if (DEFAULT.equals(name)) {
+ rt.setDefault(Boolean.parseBoolean(value));
+ }else if(USER_CONFIG_CLASSPATH.equals(name)){
+ rt.setUserConfigClasspath(Boolean.parseBoolean(value));
+ }else if(LIBRARY.equals(name)){
+ if(value != null && !EMPTY_STRING.equals(value)){
+ rt.setLibraries(getLibrariesFromString(value));
+ }
+ }
+
+ }
+ result.put(rt.getName(), rt);
+ }
+
+ return result;
+ }
+
+ private List<String> getLibrariesFromString(String strLibraries){
+ List<String> libraries = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
+ while(st.hasMoreTokens()){
+ String library = st.nextToken();
+ if(!libraries.contains(library)){
+ libraries.add(library);
+ }
+ }
+ return libraries;
+
+ }
+
+ private String convertListToString(List<String> libraries){
+ String strLib = "";
+ for(String library: libraries){
+ if("".equals(strLib)){
+ strLib = library;
+ }else{
+ strLib = strLib + LIBRARY_SEPARATOR + library;
+ }
+ }
+ return strLib;
+ }
+
+ /**
+ * Convert map String to JBossWSRUntime to string representation
+ * @param runtimeMap
+ * Map<String, JBossWSRuntime> - map of String to JBossWS Runtime to
convert
+ * in String
+ * @return
+ * String representation of String to JBossWS Runtime map
+ */
+ public String getString(Map<String, JBossRuntime> runtimeMap) {
+ StringBuffer buffer = new StringBuffer();
+ JBossRuntime[] runtimes = runtimeMap.values().toArray(
+ new JBossRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getName());
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getVersion());
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getHomeDir());
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isDefault());
+ buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isUserConfigClasspath());
+ buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
+ buffer.append(convertListToString(runtimes[i].getLibraries()));
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java 2008-09-02
07:14:58 UTC (rev 10017)
@@ -0,0 +1,393 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.runtime;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.esb.core.ESBCorePlugin;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeManager {
+
+ private static JBossRuntimeListConverter converter = new JBossRuntimeListConverter();
+
+ private Map<String, JBossRuntime> runtimes = new HashMap<String,
JBossRuntime>();
+
+ private final static String JBOSSESB_ESB = "jbossesb.esb";
+ private final static String JBOSSESB_SAR = "jbossesb.sar";
+
+ /**
+ * Private constructor
+ */
+ private JBossRuntimeManager() {
+ load();
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ */
+ static class JBossRuntimeManagerHolder {
+ private static final JBossRuntimeManager INSTANCE = new JBossRuntimeManager();
+ }
+
+ /**
+ * Return JBossWSRuntimeManaher instance
+ *
+ * @return JBossWSRuntimeManager instance
+ */
+ public static JBossRuntimeManager getInstance() {
+ return JBossRuntimeManagerHolder.INSTANCE;
+ }
+
+ /**
+ * Return Array of configured JBossWSRuntimes
+ *
+ * @return JBossWSRuntime[]
+ */
+ public JBossRuntime[] getRuntimes() {
+ Collection<JBossRuntime> c = runtimes.values();
+ return c.toArray(new JBossRuntime[runtimes.size()]);
+ }
+
+ /**
+ * Add new JBossWSRuntime
+ *
+ * @param runtime
+ * JBossWSRuntime
+ */
+ public void addRuntime(JBossRuntime runtime) {
+ if (runtimes.size() == 0) {
+ runtime.setDefault(true);
+ }
+
+ JBossRuntime oldDefaultRuntime = getDefaultRuntime();
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ save();
+ }
+
+ /**
+ * Add new JBossWSRuntime with given parameters
+ *
+ * @param name
+ * String - runtime name
+ * @param path
+ * String - runtime home folder
+ * @param version
+ * String - string representation of version number
+ * @param defaultRt
+ * boolean - default flag
+ */
+ public void addRuntime(String name, String path, String version,
+ boolean defaultRt) {
+ JBossRuntime jbossWSRt = new JBossRuntime();
+ jbossWSRt.setHomeDir(path);
+ jbossWSRt.setName(name);
+ jbossWSRt.setVersion(version);
+ jbossWSRt.setDefault(defaultRt);
+ addRuntime(jbossWSRt);
+ }
+
+ /**
+ * Return JBossWSRuntime by given name
+ *
+ * @param name
+ * String - JBossWSRuntime name
+ * @return JBossWSRuntime - found JBossWSRuntime instance or null
+ */
+ public JBossRuntime findRuntimeByName(String name) {
+ for (JBossRuntime jbossWSRuntime : runtimes.values()) {
+ if (jbossWSRuntime.getName().equals(name)) {
+ return jbossWSRuntime;
+ }
+ }
+ return null;
+ }
+
+ public List<String> getAllRuntimeJars(JBossRuntime rt){
+ List<String> jarList = new ArrayList<String>();
+ if (rt != null) {
+ if (rt.isUserConfigClasspath()) {
+ jarList.addAll(rt.getLibraries());
+
+ } else {
+
+ IPath rtHome = new Path(rt.getHomeDir());
+ IPath deployPath =
rtHome.append("server").append("default").append("deploy");
+
+ IPath esbPath = deployPath.append(JBOSSESB_ESB);
+ IPath sarPath = deployPath.append(JBOSSESB_SAR);
+
+ IPath libPath = rtHome.append("lib");
+
+ if (!esbPath.toFile().exists() || !sarPath.toFile().exists()) {
+ esbPath = libPath.append(JBOSSESB_ESB);
+ sarPath = libPath.append(JBOSSESB_SAR);
+
+ }
+
+ List<File> esblibs = getJarsOfFolder(esbPath.toFile());
+ IPath sarLibPath = sarPath.append("lib");
+ List<File> sarJars = getJarsOfFolder(sarLibPath.toFile());
+ ///List<File> commonLibs = getJarsOfFolder(libPath.toFile());
+ //List<File> tmpLibs = mergeTwoFileList(esblibs, sarJars);
+ //libs.addAll(commonLibs);
+
+ jarList = mergeTwoList(esblibs, sarJars);
+
+ }
+
+ }
+ return jarList;
+ }
+
+
+
+ private List<File> getJarsOfFolder(File folder){
+ List<File> jars = new ArrayList<File>();
+ if(folder.isDirectory()){
+ for(File file: folder.listFiles()){
+ if(file.isFile() && (file.getName().endsWith(".jar") ||
file.getName().endsWith(".zip"))){
+ jars.add(file);
+ }else if (folder.isDirectory()){
+ jars.addAll(getJarsOfFolder(file));
+ }
+ }
+ }
+
+ return jars;
+ }
+
+ // if two folders have the same jar file, one of them will be ignored.
+ private List<String> mergeTwoList(List<File> jarList1, List<File>
jarList2){
+ List<String> rtList = new ArrayList<String>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ }
+
+ return rtList;
+
+ }
+
+ private List<File> mergeTwoFileList(List<File> jarList1, List<File>
jarList2){
+ List<File> rtList = new ArrayList<File>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile);
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile);
+ }
+ }
+
+ return rtList;
+
+ }
+
+ /**
+ * Remove given JBossWSRuntime from manager
+ *
+ * @param rt
+ * JBossWSRuntime
+ */
+ public void removeRuntime(JBossRuntime rt) {
+ runtimes.remove(rt.getName());
+ }
+
+ /**
+ * Save preference value and force save changes to disk
+ */
+ public void save() {
+ ESBCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossFacetCoreMessages.ESB_Location, converter.getString(runtimes));
+ IPreferenceStore store = ESBCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Marks this runtime as default. Marks other runtimes with the same version
+ * as not default.
+ *
+ * @param runtime
+ */
+ public void setDefaultRuntime(JBossRuntime runtime) {
+ JBossRuntime[] runtimes = getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
+ * Return first default JBossWSRuntime
+ *
+ * @return JBossWSRuntime
+ */
+ public JBossRuntime getDefaultRuntime() {
+ for (JBossRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return list of available JBossWSRuntime names
+ *
+ * @return List<String>
+ */
+ public List<String> getRuntimeNames() {
+ JBossRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * Return a list of all runtime names
+ *
+ * @return List of all runtime names
+ */
+ public List<String> getAllRuntimeNames() {
+ JBossRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
+ public void changeRuntimeName(String oldName, String newName) {
+ JBossRuntime o = findRuntimeByName(oldName);
+ if (o == null) {
+ return;
+ }
+ o.setName(newName);
+ onRuntimeNameChanged(oldName, newName);
+ }
+
+ private void onRuntimeNameChanged(String oldName, String newName) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet(IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID);
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName =
IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ String name = null;
+ try {
+ name = facetedProject.getProject().getPersistentProperty(
+ qRuntimeName);
+ if (name != null && name.equals(oldName)) {
+ facetedProject.getProject().setPersistentProperty(
+ qRuntimeName, newName);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public static boolean isRuntimeUsed(String name) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet(IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID);
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName =
IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ try {
+ if (name.equals(facetedProject.getProject()
+ .getPersistentProperty(qRuntimeName))) {
+ return true;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ public void load() {
+ IPreferenceStore ps = ESBCorePlugin.getDefault()
+ .getPreferenceStore();
+
+ String runtimeListString = ps
+ .getString(JBossFacetCoreMessages.ESB_Location);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+}
\ No newline at end of file