Author: dennyxu
Date: 2009-05-06 03:06:41 -0400 (Wed, 06 May 2009)
New Revision: 15037
Added:
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.classpath
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.project
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/META-INF/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/META-INF/MANIFEST.MF
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/bin/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/build.properties
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/definition/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/definition/ode.xml
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/icons/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/icons/obj16/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/icons/obj16/ode.gif
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.properties
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.xml
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/JBossOdeBPELPublisher.java
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdeBPELPublisher.java
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdePlugin.java
Log:
Initial import.
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.classpath
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.classpath
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.classpath 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.project
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.project
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/.project 2009-05-06 07:06:41
UTC (rev 15037)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.bpel.apache.ode.runtime</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: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/META-INF/MANIFEST.MF
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/META-INF/MANIFEST.MF 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Apache ODE Runtime Plug-in
+Bundle-SymbolicName: org.eclipse.bpel.apache.ode.runtime;singleton:=true
+Bundle-Version: 0.4.0
+Bundle-Vendor:
Eclipse.org
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.resources,
+ org.eclipse.wst.server.core,
+ org.eclipse.emf.ecore,
+ org.eclipse.jst.server.generic.core,
+ org.eclipse.wst.wsdl,
+ org.eclipse.bpel.model,
+ org.eclipse.jem.util,
+ org.eclipse.core.runtime,
+ org.eclipse.bpel.runtimes,
+ org.eclipse.jst.server.generic.ui,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.bpel.ui,
+ org.apache.xerces,
+ org.eclipse.xsd,
+ org.eclipse.jst.server.ui,
+ org.eclipse.jst.common.project.facet.core,
+ org.eclipse.jst.server.core,
+ javax.wsdl;bundle-version="[1.4.0,1.5.0)",
+ org.eclipse.bpel.apache.ode.deploy.model
+Bundle-Activator: org.eclipse.bpel.apache.ode.runtime.OdePlugin
+Export-Package: org.eclipse.bpel.apache.ode.runtime
+Eclipse-LazyStart: true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/build.properties
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/build.properties
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/build.properties 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ bin/,\
+ definition/,\
+ icons/,\
+ plugin.properties
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/definition/ode.xml
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/definition/ode.xml
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/definition/ode.xml 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tns:ServerRuntime
+
xmlns:tns="http://eclipse.org/jst/server/generic/ServerTypeDefinitio...
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://eclipse.org/jst/server/generic/ServerType...
ServerTypeDefinitionSchema.xsd "
+ name="Apache ODE" version="v1.x">
+ <property id="ode.home"
+ label="%odeHome"
+ type="directory"
+ context="runtime"
+ default="/your_ode_root/" />
+ <property id="tomcat.home"
+ label="%tomcatHome"
+ type="directory"
+ context="runtime"
+ default="/your_tomcat_root/" />
+
+ <property id="port"
+ label="%port"
+ type="string"
+ context="runtime"
+ default="8080" />
+
+ <port>
+ <no>${port}</no>
+ <name>Http</name>
+ <protocol>http</protocol>
+ </port>
+
+ <module>
+ <type>bpel.module</type>
+ <publishDir>${ode.home}/WEB-INF/processes</publishDir>
+ <publisherReference>org.eclipse.bpel.apache.ode.runtime.publisher</publisherReference>
+ </module>
+
+ <project>
+ <classpathReference>ode.project</classpathReference>
+ </project>
+
+ <start>
+ <mainClass>org.apache.catalina.startup.Bootstrap</mainClass>
+ <workingDirectory>${tomcat.home}</workingDirectory>
+ <programArguments>start</programArguments>
+ <vmParameters>-Dcatalina.home="${tomcat.home}"
-Djava.endorsed.dirs="${tomcat.home}\common\endorsed"</vmParameters>
+ <classpathReference>tomcat</classpathReference>
+ </start>
+
+ <stop>
+ <mainClass>org.apache.catalina.startup.Bootstrap</mainClass>
+ <workingDirectory>${tomcat.home}</workingDirectory>
+ <programArguments>stop</programArguments>
+ <vmParameters>-Dcatalina.home="${tomcat.home}"
-Djava.endorsed.dirs="${tomcat.home}\common\endorsed"</vmParameters>
+ <classpathReference>tomcat</classpathReference>
+ </stop>
+
+ <classpath id="ode">
+ <archive path="${ode.home}/WEB-INF/lib" />
+ </classpath>
+
+ <classpath id="tomcat">
+ <archive path="${tomcat.home}/bin/bootstrap.jar" />
+ </classpath>
+
+</tns:ServerRuntime>
\ No newline at end of file
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/icons/obj16/ode.gif
===================================================================
(Binary files differ)
Property changes on:
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/icons/obj16/ode.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.properties
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.properties
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.properties 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,5 @@
+pluginName = Apache ODE Runtime Adapter
+providerName = Apache Software Foundation
+odeHome = ODE's home directory:
+tomcatHome = Tomcat's home directory:
+port = Port:
\ No newline at end of file
Added: workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.xml
===================================================================
--- workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.xml
(rev 0)
+++ workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/plugin.xml 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.wst.server.core.runtimeTypes">
+ <runtimeType
+ id="org.eclipse.bpel.apache.ode.runtime.rt"
+ name="Apache Ode 1.x Runtime"
+ description="Apache's BPEL 2.0 execution engine - Runtime"
+ vendor="Apache"
+ version="1.0"
+
class="org.eclipse.jst.server.generic.core.internal.GenericServerRuntime">
+ <moduleType
+ types="bpel.module"
+ versions="1.1, 2.0"/>
+ </runtimeType>
+ </extension>
+ <extension point="org.eclipse.wst.server.core.serverTypes">
+ <serverType
+ runtime="true"
+ class="org.eclipse.jst.server.generic.core.internal.GenericServer"
+ id="org.eclipse.bpel.apache.ode.runtime.st"
+ initialState="stopped"
+ supportsRemoteHosts="true"
+ runtimeTypeId="org.eclipse.bpel.apache.ode.runtime.rt"
+ description="Apache's BPEL 2.0 execution engine - Server"
+ launchConfigId="org.eclipse.jst.server.generic.core.launchConfigurationType"
+ behaviourClass="org.eclipse.jst.server.generic.core.internal.GenericServerBehaviour"
+ name="Ode v1.x Server"
+ hasConfiguration="false"
+ startTimeout="480000"
+ stopTimeout="60000"
+ launchModes="run, debug"
+ startBeforePublish="true">
+ </serverType>
+ </extension>
+ <extension point="org.eclipse.wst.server.ui.serverImages">
+ <image
+ id="org.eclipse.jst.server.generic.image"
+ icon="icons/obj16/ode.gif"
+ typeIds="org.eclipse.bpel.apache.ode.runtime.rt"/>
+ <image
+ id="org.eclipse.jst.server.generic.image"
+ icon="icons/obj16/ode.gif"
+ typeIds="org.eclipse.bpel.apache.ode.runtime.st"/>
+ </extension>
+
+ <extension
point="org.eclipse.jst.server.generic.core.genericpublisher">
+ <genericpublisher
+ class="org.eclipse.bpel.apache.ode.runtime.OdeBPELPublisher"
+ id="org.eclipse.bpel.apache.ode.runtime.publisher"/>
+ </extension>
+ <extension
point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <runtime-component-type
+ id="org.eclipse.bpel.apache.ode.runtime.rt"/>
+
+ <runtime-component-version
+ type="org.eclipse.bpel.apache.ode.runtime.rt"
+ version="2.0"/>
+
+ <adapter>
+ <runtime-component
+ id="org.eclipse.bpel.apache.ode.runtime.rt"/>
+ <factory
+ class="org.eclipse.jst.server.core.internal.RuntimeClasspathProvider$Factory"/>
+ <type
+ class="org.eclipse.jst.common.project.facet.core.IClasspathProvider"/>
+ </adapter>
+
+ <supported>
+ <facet
+ id="bpel.facet.core"
+ version="2.0">
+ </facet>
+ <runtime-component
+ id="org.eclipse.bpel.apache.ode.runtime.rt"
+ version="2.0"/>
+ <runtime-component
+ id="org.jboss.ide.eclipse.eap.runtime.component"
+ version="4.3">
+ </runtime-component>
+ </supported>
+ </extension>
+ <extension point="org.eclipse.wst.common.project.facet.ui.images">
+ <image
+ runtime-component-type="org.eclipse.bpel.apache.ode.runtime.rt"
+ path="icons/obj16/ode.gif"/>
+ </extension>
+
+
+ <extension point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <adapter>
+ <runtime-component id="org.eclipse.bpel.apache.ode.runtime.rt"/>
+ <factory
class="org.eclipse.jst.server.ui.internal.RuntimeLabelProvider$Factory"/>
+ <type
class="org.eclipse.wst.common.project.facet.ui.IRuntimeComponentLabelProvider"/>
+ </adapter>
+ </extension>
+
+ <extension point="org.eclipse.jst.server.core.runtimeFacetMappings">
+ <runtimeFacetMapping
+ runtimeTypeId="org.eclipse.bpel.apache.ode.runtime.rt"
+ runtime-component="org.eclipse.bpel.apache.ode.runtime.rt"
+ version="2.0"/>
+ </extension>
+ <extension
point="org.eclipse.jst.server.generic.core.serverdefinition">
+ <serverdefinition id="org.eclipse.bpel.apache.ode.runtime.rt"
definitionfile="definition/ode.xml">
+ </serverdefinition>
+ </extension>
+ <extension point="org.eclipse.wst.server.ui.wizardFragments">
+ <fragment
+ id="org.eclipse.jst.server.generic.runtime"
+ typeIds="org.eclipse.bpel.apache.ode.runtime.rt"
+ class="org.eclipse.jst.server.generic.ui.internal.GenericServerRuntimeWizardFragment"/>
+ <fragment
+ id="org.eclipse.jst.server.generic.server"
+ typeIds="org.eclipse.bpel.apache.ode.runtime.st"
+ class="org.eclipse.jst.server.generic.ui.internal.GenericServerWizardFragment"/>
+ </extension>
+
+</plugin>
Added:
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/JBossOdeBPELPublisher.java
===================================================================
---
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/JBossOdeBPELPublisher.java
(rev 0)
+++
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/JBossOdeBPELPublisher.java 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,239 @@
+package org.eclipse.bpel.apache.ode.runtime;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.bpel.runtimes.publishers.GenericBPELPublisher;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IRuntime;
+
+/**
+ * BPEL publisher for Apache ODE.
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class JBossOdeBPELPublisher extends GenericBPELPublisher {
+
+ public JBossOdeBPELPublisher()
+ {
+ super();
+ }
+
+ @Override
+ public IStatus[] publish(IModuleArtifact[] artifacts, IProgressMonitor monitor) {
+ // resources will always be null for some weird reason :(
+ // therefore we generate a BPELModuleArtifact
+ // the module id value enables us to get BPEL file path relative to its project
+ IModule[] modules = super.getModule();
+ IStatus[] result = new Status[modules.length];
+
+ try {
+ for (int i = 0; i < modules.length; i++) {
+
+ IModule module = modules[i];
+
+ List<IFile> files = getArtifacts(module.getProject());
+
+ if (doesDeploymentDescriptorExist(files)){
+
+ String currentDeployDir = createDeploymentDestination(module);
+
+ for (IFile file : files) {
+
+ if (isFileOfInterest(file)) {
+ copyFileToDeploymentDestination(file, currentDeployDir);
+ }
+ }
+
+ //remove <project>.deployed to kick the redeployment
+ new File(new File(currentDeployDir).getParent(), new
File(currentDeployDir).getName() + ".deployed").delete();
+
+ result[i] = new Status(IStatus.OK, OdePlugin.PLUGIN_ID, 1,
+ "Deployment successful", null);
+ }
+ else {
+ result[i] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 1,
+ "Deployment Descriptor does not exist. Create a ODE Deployment Descriptor and
try again", null);
+ }
+ }
+ } catch (Exception e) {
+ result[0] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 0,
+ "Error during deployment: " + e.getMessage(), e);
+
+ }
+
+ return result;
+ }
+
+ @Override
+ public IStatus[] unpublish(IProgressMonitor monitor) {
+ IModule[] modules = super.getModule();
+ IStatus[] result = new Status[modules.length];
+
+ try {
+ for (int i = 0; i < modules.length; i++) {
+
+ IModule module = modules[i];
+ String currentDeployDir = createDeploymentDestination(module);
+
+ //remove <project>.deployed to kick the redeployment
+ deleteDir(new File(currentDeployDir));
+
+ result[i] = new Status(IStatus.OK, OdePlugin.PLUGIN_ID, 1,
+ "Undeployment successful", null);
+ }
+ } catch (Exception e) {
+ result[0] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 0,
+ "Error during undeployment: " + e.getMessage(), e);
+ }
+
+ return result;
+ }
+
+ protected boolean doesDeploymentDescriptorExist(List<IFile> files){
+
+ for (IFile file : files) {
+
+ if ( file.getName().equalsIgnoreCase("deploy.xml")) { //NON-NLS-1
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected List<IFile> getArtifacts(IProject project) {
+ final List<IFile> files = new ArrayList<IFile>();
+ IResourceVisitor visitor = new IResourceVisitor() {
+ public boolean visit(org.eclipse.core.resources.IResource resource) throws
org.eclipse.core.runtime.CoreException {
+ if (resource.getType() == IResource.FILE) {
+ files.add((IFile)resource);
+ }
+ return true;
+ }
+ };
+ try {
+ project.accept(visitor);
+ }
+ catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return files;
+ }
+
+ protected boolean isFileOfInterest(IFile file) {
+
+ String fileExtension = file.getFileExtension();
+
+ if (fileExtension.equalsIgnoreCase("bpel"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("wsdl"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("xsd"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("soap"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("xml"))
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * This method will create a folder inside the WEB-INF\processes subfolder of the ODE
installation
+ */
+ protected String createDeploymentDestination(IModule module)
+ {
+ String moduleName = module.getName().substring(0,
module.getName().indexOf('/'));
+ String deployAppName = moduleName;
+
+ //get TOMCAT_HOME
+ IRuntime serverDef = getServerRuntime().getRuntime();
+ String tomcatHome = serverDef.getLocation().toOSString();
+
+ //append ODE's Process target Dir tomcatHome
+ String deployTarget = tomcatHome.concat(System.getProperty("file.separator")
+ "webapps" + System.getProperty("file.separator") + "ode" +
System.getProperty("file.separator") + "WEB-INF" +
System.getProperty("file.separator") + "processes" +
System.getProperty("file.separator") + deployAppName );
+
+ File f = new File(deployTarget);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+
+ return deployTarget;
+ }
+
+ private boolean deleteDir(File dir) {
+ if (dir.exists()) {
+ File[] files = dir.listFiles();
+ for (File f : files) {
+ if (f.isDirectory()) {
+ deleteDir(f);
+ } else {
+ f.delete();
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ private void copyFileToDeploymentDestination(IFile ifile, String toDeployDir) {
+
+ String from = ifile.getFullPath().toOSString();
+ String fileName = ifile.getName();
+ String wspath = ifile.getWorkspace().getRoot().getLocation().toOSString();
+
+ File srcFile = new File(wspath + from);
+ File targetFile = new File(toDeployDir + System.getProperty("file.separator")
+ fileName);
+
+ if (srcFile != null && srcFile.exists()) {
+
+ try {
+
+ BufferedInputStream inStream = new BufferedInputStream(new
FileInputStream(srcFile));
+ BufferedOutputStream outStream = new BufferedOutputStream(new
FileOutputStream(targetFile));
+
+ byte[] bytes = new byte[1024];
+
+ int count;
+
+ while ((count = inStream.read(bytes)) != -1) {
+ outStream.write(bytes, 0, count);
+ }
+
+ outStream.close();
+ inStream.close();
+ }
+ catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ }
+ }
+}
Added:
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdeBPELPublisher.java
===================================================================
---
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdeBPELPublisher.java
(rev 0)
+++
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdeBPELPublisher.java 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,239 @@
+package org.eclipse.bpel.apache.ode.runtime;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.bpel.runtimes.publishers.GenericBPELPublisher;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IRuntime;
+
+/**
+ * BPEL publisher for Apache ODE.
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class OdeBPELPublisher extends GenericBPELPublisher {
+
+ public OdeBPELPublisher()
+ {
+ super();
+ }
+
+ @Override
+ public IStatus[] publish(IModuleArtifact[] artifacts, IProgressMonitor monitor) {
+ // resources will always be null for some weird reason :(
+ // therefore we generate a BPELModuleArtifact
+ // the module id value enables us to get BPEL file path relative to its project
+ IModule[] modules = super.getModule();
+ IStatus[] result = new Status[modules.length];
+
+ try {
+ for (int i = 0; i < modules.length; i++) {
+
+ IModule module = modules[i];
+
+ List<IFile> files = getArtifacts(module.getProject());
+
+ if (doesDeploymentDescriptorExist(files)){
+
+ String currentDeployDir = createDeploymentDestination(module);
+
+ for (IFile file : files) {
+
+ if (isFileOfInterest(file)) {
+ copyFileToDeploymentDestination(file, currentDeployDir);
+ }
+ }
+
+ //remove <project>.deployed to kick the redeployment
+ new File(new File(currentDeployDir).getParent(), new
File(currentDeployDir).getName() + ".deployed").delete();
+
+ result[i] = new Status(IStatus.OK, OdePlugin.PLUGIN_ID, 1,
+ "Deployment successful", null);
+ }
+ else {
+ result[i] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 1,
+ "Deployment Descriptor does not exist. Create a ODE Deployment Descriptor and
try again", null);
+ }
+ }
+ } catch (Exception e) {
+ result[0] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 0,
+ "Error during deployment: " + e.getMessage(), e);
+
+ }
+
+ return result;
+ }
+
+ @Override
+ public IStatus[] unpublish(IProgressMonitor monitor) {
+ IModule[] modules = super.getModule();
+ IStatus[] result = new Status[modules.length];
+
+ try {
+ for (int i = 0; i < modules.length; i++) {
+
+ IModule module = modules[i];
+ String currentDeployDir = createDeploymentDestination(module);
+
+ //remove <project>.deployed to kick the redeployment
+ deleteDir(new File(currentDeployDir));
+
+ result[i] = new Status(IStatus.OK, OdePlugin.PLUGIN_ID, 1,
+ "Undeployment successful", null);
+ }
+ } catch (Exception e) {
+ result[0] = new Status(IStatus.ERROR, OdePlugin.PLUGIN_ID, 0,
+ "Error during undeployment: " + e.getMessage(), e);
+ }
+
+ return result;
+ }
+
+ protected boolean doesDeploymentDescriptorExist(List<IFile> files){
+
+ for (IFile file : files) {
+
+ if ( file.getName().equalsIgnoreCase("deploy.xml")) { //NON-NLS-1
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected List<IFile> getArtifacts(IProject project) {
+ final List<IFile> files = new ArrayList<IFile>();
+ IResourceVisitor visitor = new IResourceVisitor() {
+ public boolean visit(org.eclipse.core.resources.IResource resource) throws
org.eclipse.core.runtime.CoreException {
+ if (resource.getType() == IResource.FILE) {
+ files.add((IFile)resource);
+ }
+ return true;
+ }
+ };
+ try {
+ project.accept(visitor);
+ }
+ catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return files;
+ }
+
+ protected boolean isFileOfInterest(IFile file) {
+
+ String fileExtension = file.getFileExtension();
+
+ if (fileExtension.equalsIgnoreCase("bpel"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("wsdl"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("xsd"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("soap"))
+ return true;
+ if (fileExtension.equalsIgnoreCase("xml"))
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * This method will create a folder inside the WEB-INF\processes subfolder of the ODE
installation
+ */
+ protected String createDeploymentDestination(IModule module)
+ {
+ String moduleName = module.getName().substring(0,
module.getName().indexOf('/'));
+ String deployAppName = moduleName;
+
+ //get TOMCAT_HOME
+ IRuntime serverDef = getServerRuntime().getRuntime();
+ String tomcatHome = serverDef.getLocation().toOSString();
+
+ //append ODE's Process target Dir tomcatHome
+ String deployTarget = tomcatHome.concat(System.getProperty("file.separator")
+ "webapps" + System.getProperty("file.separator") + "ode" +
System.getProperty("file.separator") + "WEB-INF" +
System.getProperty("file.separator") + "processes" +
System.getProperty("file.separator") + deployAppName );
+
+ File f = new File(deployTarget);
+ if (!f.exists()) {
+ f.mkdir();
+ }
+
+ return deployTarget;
+ }
+
+ private boolean deleteDir(File dir) {
+ if (dir.exists()) {
+ File[] files = dir.listFiles();
+ for (File f : files) {
+ if (f.isDirectory()) {
+ deleteDir(f);
+ } else {
+ f.delete();
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ private void copyFileToDeploymentDestination(IFile ifile, String toDeployDir) {
+
+ String from = ifile.getFullPath().toOSString();
+ String fileName = ifile.getName();
+ String wspath = ifile.getWorkspace().getRoot().getLocation().toOSString();
+
+ File srcFile = new File(wspath + from);
+ File targetFile = new File(toDeployDir + System.getProperty("file.separator")
+ fileName);
+
+ if (srcFile != null && srcFile.exists()) {
+
+ try {
+
+ BufferedInputStream inStream = new BufferedInputStream(new
FileInputStream(srcFile));
+ BufferedOutputStream outStream = new BufferedOutputStream(new
FileOutputStream(targetFile));
+
+ byte[] bytes = new byte[1024];
+
+ int count;
+
+ while ((count = inStream.read(bytes)) != -1) {
+ outStream.write(bytes, 0, count);
+ }
+
+ outStream.close();
+ inStream.close();
+ }
+ catch (Exception e) {
+
+ e.printStackTrace();
+ }
+ }
+ }
+}
Added:
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdePlugin.java
===================================================================
---
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdePlugin.java
(rev 0)
+++
workspace/Denny/bpel/org.eclipse.bpel.apache.ode.runtime/src/org/eclipse/bpel/apache/ode/runtime/OdePlugin.java 2009-05-06
07:06:41 UTC (rev 15037)
@@ -0,0 +1,41 @@
+package org.eclipse.bpel.apache.ode.runtime;
+
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation, University of Stuttgart (IAAS) 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:
+ * IBM Corporation, University of Stuttgart (IAAS) - initial API and implementation
+ *******************************************************************************/
+
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Runtime contributor for Apache ODE.
+ *
+ * @author Tammo van Lessen (IAAS)
+ * @author Simon Moser (IBM)
+ */
+public class OdePlugin extends AbstractUIPlugin {
+ public static final String PLUGIN_ID = "org.eclipse.bpel.apache.ode.runtime";
+ private static OdePlugin plugin;
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ public static OdePlugin getDefault() {
+ return plugin;
+ }
+
+}