Author: tom.baeyens(a)jboss.com
Date: 2009-04-06 03:08:56 -0400 (Mon, 06 Apr 2009)
New Revision: 4444
Added:
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentClassLoader.java
Modified:
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.eventlisteners.xml
jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.jpdl.eventlisteners.xml
jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.jpdl.eventlisteners.xml
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.eventlisteners.xml
jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.jpdl.eventlisteners.xml
Log:
classloading
Modified:
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.eventlisteners.xml
===================================================================
---
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.eventlisteners.xml 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/distro/src/main/resources/config-tool/jbpm/jbpm.jpdl.eventlisteners.xml 2009-04-06
07:08:56 UTC (rev 4444)
@@ -1,3 +1,4 @@
<eventlisteners>
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding"
/>
+ <eventlistener
binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
</eventlisteners>
Modified:
jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.jpdl.eventlisteners.xml
===================================================================
---
jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/examples/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
07:08:56 UTC (rev 4444)
@@ -1,3 +1,4 @@
<eventlisteners>
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding"
/>
+ <eventlistener
binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
</eventlisteners>
Added:
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
===================================================================
---
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
(rev 0)
+++
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java 2009-04-06
07:08:56 UTC (rev 4444)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EventListenerBinding extends JpdlBinding {
+
+ public EventListenerBinding() {
+ super("event-listener");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ Descriptor descriptor = JpdlParser.parseObjectDescriptor(element, parse);
+ return null;
+ }
+
+}
Property changes on:
jbpm4/branches/tbaeyens/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.jpdl.eventlisteners.xml
===================================================================
---
jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/jpdl/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
07:08:56 UTC (rev 4444)
@@ -1,3 +1,4 @@
<eventlisteners>
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding"
/>
+ <eventlistener
binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
</eventlisteners>
Added:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentClassLoader.java
===================================================================
---
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentClassLoader.java
(rev 0)
+++
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentClassLoader.java 2009-04-06
07:08:56 UTC (rev 4444)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.repository;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.jbpm.JbpmException;
+import org.jbpm.pvm.internal.util.IoUtil;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeploymentClassLoader extends ClassLoader {
+
+ private DeploymentImpl deployment = null;
+
+ public DeploymentClassLoader(ClassLoader parent, DeploymentImpl deployment ) {
+ super(parent);
+ this.deployment = deployment;
+ }
+
+ public URL findResource(String name) {
+ URL url = null;
+ InputStream inputStream = deployment.getResourceAsStream(name);
+ if (inputStream!=null) {
+ try {
+ url = new URL(null, "jbpm://"+deployment.getDbid()+"/"+name,
new BytesUrlStreamHandler(inputStream));
+ } catch (MalformedURLException e) {
+ throw new JbpmException("couldn't create url", e);
+ }
+ }
+ return url;
+ }
+
+ public static class BytesUrlStreamHandler extends URLStreamHandler {
+ InputStream inputStream;
+ public BytesUrlStreamHandler(InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+ protected URLConnection openConnection(URL u) throws IOException {
+ return new BytesUrlConnection(inputStream, u);
+ }
+ }
+
+ public static class BytesUrlConnection extends URLConnection {
+ InputStream inputStream;
+ public BytesUrlConnection(InputStream inputStream, URL url) {
+ super(url);
+ this.inputStream = inputStream;
+ }
+ public void connect() throws IOException {
+ }
+ public InputStream getInputStream() throws IOException {
+ return inputStream;
+ }
+ }
+
+ public Class findClass(String name) throws ClassNotFoundException {
+ Class clazz = null;
+
+ String fileName = name.replace( '.', '/' ) + ".class";
+ InputStream inputStream = deployment.getResourceAsStream(fileName);
+ if (inputStream!=null) {
+ try {
+ byte[] classBytes = IoUtil.readBytes(inputStream);
+ clazz = defineClass(name, classBytes, 0, classBytes.length);
+
+ // Add the package information
+ final int packageIndex = name.lastIndexOf('.');
+ if (packageIndex != -1) {
+ final String packageName = name.substring(0, packageIndex);
+ final Package classPackage = getPackage(packageName);
+ if (classPackage == null) {
+ definePackage(packageName, null, null, null, null, null, null, null);
+ }
+ }
+
+ } catch (JbpmException e) {
+ clazz = null;
+ }
+ }
+
+ if (clazz==null) {
+ throw new ClassNotFoundException("class '"+name+"' could not
be found in jbpm "+deployment);
+ }
+
+ return clazz;
+ }
+}
Property changes on:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentClassLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
---
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-04-06
07:08:56 UTC (rev 4444)
@@ -70,6 +70,10 @@
this.commandService = commandService;
}
+ public String toString() {
+ return "deployment("+dbid+")";
+ }
+
public long deploy() {
return commandService.execute(new DeployCmd(this));
}
Modified:
jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.eventlisteners.xml
===================================================================
---
jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/pvm/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
07:08:56 UTC (rev 4444)
@@ -1,3 +1,4 @@
<eventlisteners>
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding"
/>
+ <eventlistener
binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
</eventlisteners>
Modified:
jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.jpdl.eventlisteners.xml
===================================================================
---
jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
02:38:32 UTC (rev 4443)
+++
jbpm4/branches/tbaeyens/modules/test-db/src/test/resources/jbpm.jpdl.eventlisteners.xml 2009-04-06
07:08:56 UTC (rev 4444)
@@ -1,3 +1,4 @@
<eventlisteners>
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding"
/>
+ <eventlistener
binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
</eventlisteners>