JBoss JBPM SVN: r2395 - projects.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-26 04:04:59 -0400 (Fri, 26 Sep 2008)
New Revision: 2395
Added:
projects/parent/
Removed:
projects/jbpm-parent/
Log:
Move jbpm-parent to parent
Copied: projects/parent (from rev 2394, projects/jbpm-parent)
17 years, 6 months
JBoss JBPM SVN: r2394 - projects and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-26 04:03:18 -0400 (Fri, 26 Sep 2008)
New Revision: 2394
Added:
projects/docbook-style/
Removed:
jbpm4/docbook-style/
Log:
Move docbook-style to projects
Copied: projects/docbook-style (from rev 2393, jbpm4/docbook-style)
17 years, 6 months
JBoss JBPM SVN: r2393 - jbpm4/trunk/modules/pvm.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-26 03:04:25 -0400 (Fri, 26 Sep 2008)
New Revision: 2393
Modified:
jbpm4/trunk/modules/pvm/pom.xml
Log:
[JBPM-1758] Exclude JobExecutorTest test due to sporadic failure
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2008-09-26 06:48:52 UTC (rev 2392)
+++ jbpm4/trunk/modules/pvm/pom.xml 2008-09-26 07:04:25 UTC (rev 2393)
@@ -197,7 +197,7 @@
<exclude>org/jbpm/pvm/internal/db/langext/*Test.java</exclude>
<exclude>org/jbpm/pvm/internal/db/model/HibernateJobDbSessionTest.java</exclude>
<exclude>org/jbpm/pvm/internal/expr/*Test.java</exclude>
- <exclude>org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java</exclude>
+ <exclude>org/jbpm/pvm/internal/jobexecutor/*Test.java</exclude>
<exclude>org/jbpm/pvm/internal/tx/*Test.java</exclude>
<exclude>org/jbpm/pvm/internal/xml/*Test.java</exclude>
<exclude>org/jbpm/pvm/samples/**/*Test.java</exclude>
17 years, 6 months
JBoss JBPM SVN: r2392 - in jbpm4/branches/tdiesler: modules/api/src/main/java/org/jbpm/api/client and 1 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-26 02:48:52 -0400 (Fri, 26 Sep 2008)
New Revision: 2392
Added:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Deployment.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DeploymentService.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectHandler.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectRegistry.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngineRegistry.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessService.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Service.java
Modified:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/MicrocontainerConfiguration.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processengine/ProcessEngineTest.java
jbpm4/branches/tdiesler/pom.xml
Log:
WIP
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Deployment.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Deployment.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Deployment.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,102 @@
+/*
+ * 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.api.client;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * A deployment, containing all information to create a process that will be deployed to the {@link ProcessService}
+ *
+ * @author Tom Baeyens
+ * @author thomas.diesler(a)jboss.com
+ * @since 25-Sep-2008
+ */
+public class Deployment implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private String procXML;
+
+ public Deployment(String procXML)
+ {
+ if (procXML == null)
+ throw new IllegalArgumentException("Null process definition");
+
+ this.procXML = procXML;
+ }
+
+ public Deployment(URL procURL) throws IOException
+ {
+ if (procURL == null)
+ throw new IllegalArgumentException("Null process definition");
+
+ StringBuilder strBuilder = new StringBuilder();
+ BufferedReader br = new BufferedReader(new InputStreamReader(procURL.openStream()));
+ String line = br.readLine();
+ while (line != null)
+ {
+ strBuilder.append(line);
+ line = br.readLine();
+ }
+ procXML = strBuilder.toString();
+ }
+
+ public String getProcessXML()
+ {
+ return procXML;
+ }
+
+ public URI getNamespaceURI()
+ {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ Document doc;
+ try
+ {
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ doc = db.parse(new ByteArrayInputStream(procXML.getBytes()));
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot parse process descriptor", ex);
+ }
+
+ Element root = doc.getDocumentElement();
+ String nsURI = root.getNamespaceURI();
+ if (nsURI == null)
+ throw new IllegalStateException("Cannot get namespace URI from root element");
+
+ return URI.create(nsURI);
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Deployment.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DeploymentService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DeploymentService.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DeploymentService.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,49 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The marker interface for all Services
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 25-Sep-2008
+ */
+public abstract class DeploymentService implements Service
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(DeploymentService.class);
+
+ /**
+ * Deploy a new process to the process service.
+ */
+ ObjectName deploy(Deployment deployment)
+ {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DeploymentService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectHandler.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectHandler.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,62 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * The DialectHandler converts a supported dialect to the Process model.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Jun-2008
+ */
+public interface DialectHandler
+{
+ URI DEFAULT_NAMESPACE_URI = URI.create("urn:bpm.jboss:pdl-0.1");
+
+ /**
+ * Get the the supported namespace from this dialect.
+ */
+ URI getNamespaceURI();
+
+ /**
+ * Create a {@link Process} from a descriptor.
+ * @param isInclude TODO
+ */
+ Process createProcess(String pXML);
+
+ /**
+ * Create a {@link Process} from a descriptor URL.
+ * @param isInclude TODO
+ */
+ Process createProcess(URL pURL) throws IOException;
+
+ /**
+ * Marshall the process to the given writer
+ */
+ void marshallProcess(Process proc, Writer out) throws IOException;
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectRegistry.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectRegistry.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectRegistry.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,52 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * A registry that maps namespaceURI to a {@link DialectHandler}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Jul-2008
+ */
+public abstract class DialectRegistry
+{
+ // Maps namespaceURI to a DialectHandler
+ protected Map<URI, DialectHandler> dialectHandlers;
+
+ /**
+ * Get the handler for the dialect with the given namespace URI
+ */
+ public DialectHandler getDialectHandler(URI nsURI)
+ {
+ DialectHandler dialectHandler = dialectHandlers.get(nsURI);
+ if (dialectHandler == null)
+ throw new IllegalStateException("No dialect handler registered for: " + nsURI);
+
+ return dialectHandler;
+ }
+
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/DialectRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/MicrocontainerConfiguration.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/MicrocontainerConfiguration.java 2008-09-26 05:26:28 UTC (rev 2391)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/MicrocontainerConfiguration.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -88,7 +88,6 @@
}
ProcessEngine engine = (ProcessEngine)entry.getTarget();
- ProcessEngine.registerProcessEngine(engine);
return engine;
}
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-26 05:26:28 UTC (rev 2391)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -33,7 +33,18 @@
import org.slf4j.LoggerFactory;
/**
- * The process engine is an agregator of various manger objects used by the BPM engine
+ * The process engine is an agregator of various service objects used by the BPM engine.
+ * <p/>
+ * A ProcessEngine is always created via one of the available {@link Configuration} objects. Every implementation of the
+ * API has one default {@link Configuration} which is configured via a resource file with the fully qualified class name
+ * of {@link Configuration}.
+ * <p/>
+ * The API natively supports {@link MicrocontainerConfiguration}. To create and register a ProcessEngine explicitly, you
+ * would do
+ * <pre>
+ * ProcessEngine engine = new MicrocontainerConfiguration(cfgURL).getProcessEngine();
+ * ProcessEngineRegistry.registerProcessEngine(engine);
+ * </pre>
*
* @author thomas.diesler(a)jboss.com
* @since 18-Jun-2008
@@ -43,12 +54,10 @@
// Provide logging
final static Logger log = LoggerFactory.getLogger(ProcessEngine.class);
- // The process engine registry
- private static Map<String, ProcessEngine> engineRegistry = new HashMap<String, ProcessEngine>();
+ // The map of registered services
+ private Map<Class<Service>, Service> services = new HashMap<Class<Service>, Service>();
// The name of this engine
private String name;
- // Flag to indicate that the Engine is shutting down
- private boolean prepareForShutdown;
// Hide public constructor
protected ProcessEngine()
@@ -56,8 +65,20 @@
}
/**
- * Get registered the default ProcessEngine
+ * Get the instance of the registered service
*
+ * @return null if there is no service registered for the given class
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getService(Class<T> clazz)
+ {
+ return (T)services.get(clazz);
+ }
+
+ /**
+ * Get the registered default ProcessEngine <p/> If there is no ProcessEngine registered, a call to this method will
+ * register the default engine automatically.
+ *
* @return The configured instance of a process engine
*/
public static ProcessEngine getProcessEngine()
@@ -68,14 +89,16 @@
/**
* Get a registered ProcessEngine
*
- * @return null, if there is no registered by this name
+ * @return null, if there is no ProcessEngine registered by this name
*/
public static ProcessEngine getProcessEngine(String name)
{
+ Map<String, ProcessEngine> engineRegistry = ProcessEngineRegistry.engineRegistry;
+
if (engineRegistry.size() == 0)
loadDefaultEngine();
-
- ProcessEngine pe = null;
+
+ ProcessEngine pe = null;
if (name == null && engineRegistry.size() == 1)
{
pe = engineRegistry.values().iterator().next();
@@ -86,7 +109,7 @@
}
return pe;
}
-
+
/**
* Get the name of this engine
*/
@@ -100,53 +123,14 @@
{
this.name = name;
}
-
- public static void registerProcessEngine(ProcessEngine pe)
- {
- log.debug("Register: " + pe);
- engineRegistry.put(pe.getName(), pe);
- }
- public static ProcessEngine unregisterProcessEngine(String name)
- {
- ProcessEngine pe = engineRegistry.remove(name);
- log.debug("Unregister: " + name + "=" + pe);
- return pe;
- }
-
- /**
- * Prepare the engine for shutdown. During shutdown the creation of new processes is disallowed.
- */
- public void prepareForShutdown()
- {
- log.debug("prepareForShutdown");
- prepareForShutdown = true;
- }
-
- /**
- * True, if engine is preparing for shutdown.
- */
- public boolean isPrepareForShutdown()
- {
- return prepareForShutdown;
- }
-
- /**
- * Cancel the prepare for shutdown request
- */
- public void cancelShutdown()
- {
- log.debug("cancelShutdown");
- prepareForShutdown = false;
- }
-
private static void loadDefaultEngine()
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
InputStream instream = ctxLoader.getResourceAsStream(Configuration.class.getName());
if (instream == null)
throw new IllegalStateException("Cannot find resource: " + Configuration.class.getName());
-
+
Configuration configuration = null;
try
{
@@ -159,12 +143,12 @@
{
throw new IllegalStateException("Cannot obtain configuration", ex);
}
-
+
ProcessEngine pe = configuration.getProcessEngine();
if (pe == null)
throw new IllegalStateException("Cannot obtain engine from configuration: " + configuration);
-
- registerProcessEngine(pe);
+
+ ProcessEngineRegistry.registerProcessEngine(pe);
}
@Override
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngineRegistry.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngineRegistry.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngineRegistry.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,84 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A registry of ProcessEngine instances per VM
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 25-Sep-2008
+ */
+public final class ProcessEngineRegistry
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(ProcessEngineRegistry.class);
+
+ // The process engine registry
+ static Map<String, ProcessEngine> engineRegistry = new HashMap<String, ProcessEngine>();
+
+ // Hide constructor
+ private ProcessEngineRegistry()
+ {
+ }
+
+ /**
+ * Get the set of registered engine names
+ */
+ public static Set<String> getRegisteredProcessEngines()
+ {
+ return engineRegistry.keySet();
+ }
+
+ /**
+ * Register a ProcessEngine
+ * @throws IllegalStateException If a ProcessEngine with that name is already registered
+ */
+ public static void registerProcessEngine(ProcessEngine pe)
+ {
+ if (engineRegistry.get(pe.getName()) != null)
+ throw new IllegalStateException("Process engine already regitered: " + pe.getName());
+
+ log.debug("Register: " + pe);
+ engineRegistry.put(pe.getName(), pe);
+ }
+
+ /**
+ * Unregister a ProcessEngine for a given name
+ */
+ public static ProcessEngine unregisterProcessEngine(String name)
+ {
+ ProcessEngine pe = engineRegistry.remove(name);
+ log.debug("Unregister: " + name + "=" + pe);
+ return pe;
+ }
+
+
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngineRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessService.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessService.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,73 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The marker interface for all Services
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 25-Sep-2008
+ */
+public abstract class ProcessService implements Service
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(ProcessService.class);
+
+ // The set of registered processes
+ private Map<ObjectName, Process> procs = new HashMap<ObjectName, Process>();
+
+ // Hide public constructor
+ protected ProcessService()
+ {
+ }
+
+ /**
+ * Deploy a new process to the process service.
+ */
+ ObjectName deploy(Deployment deployment)
+ {
+
+ return null;
+ }
+
+ /**
+ * Get the set of registered Processes
+ */
+ public Set<Process> getProcesses()
+ {
+ Set<Process> procSet = new HashSet<Process>(procs.values());
+ return Collections.unmodifiableSet(procSet);
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Service.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Service.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Service.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -0,0 +1,38 @@
+/*
+ * 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.api.client;
+
+//$Id$
+
+/**
+ * The base interface for all Services
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 25-Sep-2008
+ */
+public interface Service
+{
+ /**
+ * Get the associated ProcessEngine
+ */
+ ProcessEngine getProcessEngine();
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/Service.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processengine/ProcessEngineTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processengine/ProcessEngineTest.java 2008-09-26 05:26:28 UTC (rev 2391)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processengine/ProcessEngineTest.java 2008-09-26 06:48:52 UTC (rev 2392)
@@ -27,6 +27,7 @@
import org.jbpm.api.client.MicrocontainerConfiguration;
import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.client.ProcessEngineRegistry;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -42,22 +43,39 @@
ProcessEngine engine = ProcessEngine.getProcessEngine();
assertNotNull("ProcessEngine not null", engine);
}
-
+
public void testUnregisteredProcessEngine() throws Exception
{
ProcessEngine engine = ProcessEngine.getProcessEngine("bogus");
assertNull("ProcessEngine null", engine);
}
-
+
public void testMicrocontainerConfiguration() throws Exception
{
+ // create an engine from an MC config
URL cfgURL = getResourceURL("cts/processengine/test-cfg-beans.xml");
ProcessEngine engineOne = new MicrocontainerConfiguration(cfgURL).getProcessEngine();
assertNotNull("ProcessEngine not null", engineOne);
-
+
+ // the engine is not automatically registered
ProcessEngine engineTwo = ProcessEngine.getProcessEngine("mock engine");
+ assertNull("ProcessEngine null", engineTwo);
+
+ // register the engine and do the lockup again
+ ProcessEngineRegistry.registerProcessEngine(engineOne);
+ engineTwo = ProcessEngine.getProcessEngine("mock engine");
assertNotNull("ProcessEngine not null", engineTwo);
-
assertSame("ProcessEngine same", engineOne, engineTwo);
+
+ // Try to register the engine twice
+ try
+ {
+ ProcessEngineRegistry.registerProcessEngine(engineTwo);
+ fail("Expceted IllegalStateException");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
}
}
Modified: jbpm4/branches/tdiesler/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/pom.xml 2008-09-26 05:26:28 UTC (rev 2391)
+++ jbpm4/branches/tdiesler/pom.xml 2008-09-26 06:48:52 UTC (rev 2392)
@@ -192,7 +192,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
- <include>org/jbpm/test/cts/**/Test.java</include>
+ <include>org/jbpm/test/cts/**/*Test.java</include>
</includes>
</configuration>
</plugin>
17 years, 6 months
JBoss JBPM SVN: r2391 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-26 01:26:28 -0400 (Fri, 26 Sep 2008)
New Revision: 2391
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
Log:
[JBPM-702] correction to sybase's trailing zeros truncation
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 22:21:39 UTC (rev 2390)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-26 05:26:28 UTC (rev 2391)
@@ -22,6 +22,7 @@
package org.jbpm.bytes;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.commons.logging.Log;
@@ -42,12 +43,12 @@
}
public static List chopItUp(byte[] byteArray) {
- int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
List bytes = null;
if ( (byteArray!=null)
&& (byteArray.length>0) ){
log.debug("chopping " + byteArray.length + " bytes");
bytes = new ArrayList();
+ int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
int offset = 0;
while ( (byteArray.length-offset) > blockSize ) {
bytes.add(subArray(byteArray, offset, blockSize));
@@ -68,25 +69,35 @@
public static byte[] glueChopsBackTogether(List bytes) {
byte[] byteArray = null;
- if (bytes!=null && !bytes.isEmpty()) {
- if (bytes.size() == 1) {
+ if (bytes!=null) {
+ int blockCount = bytes.size();
+ switch (blockCount) {
+ case 0:
+ break;
+ case 1:
byteArray = (byte[]) bytes.get(0);
- }
- else {
- int totalLength = 0;
- for (int i = 0, n = bytes.size(); i < n; i++) {
- byte[] block = (byte[]) bytes.get(i);
- totalLength += block.length;
- }
- log.debug("gluing " + totalLength + " bytes");
- byteArray = new byte[totalLength];
+ break;
+ default:
+ int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
+ byte[] lastBlock = (byte[]) bytes.get(blockCount - 1);
+ int byteCount = blockSize * (blockCount - 1) + lastBlock.length;
+ log.debug("gluing " + byteCount + " bytes");
+ byteArray = new byte[byteCount];
int offset = 0;
- for (int i = 0, n = bytes.size(); i < n; i++) {
+ for (int i = 0, n = blockCount; i < n; i++) {
byte[] block = (byte[]) bytes.get(i);
- int blockLength = block.length;
- System.arraycopy(block, 0, byteArray, offset, blockLength);
- log.debug("glued " + blockLength + " bytes beggining at " + offset);
- offset += blockLength;
+ int length = block.length;
+ System.arraycopy(block, 0, byteArray, offset, length);
+ log.debug("glued " + length + " bytes beggining at " + offset);
+ // JBPM-702 sybase truncates trailing zeros
+ if (length < blockSize && i < n-1) {
+ Arrays.fill(byteArray, offset + length, offset + blockSize, (byte) 0);
+ log.debug("zero filled " + (blockSize - length) + " trailing bytes");
+ offset += blockSize;
+ }
+ else {
+ offset += length;
+ }
}
}
}
17 years, 6 months
JBoss JBPM SVN: r2390 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-25 18:21:39 -0400 (Thu, 25 Sep 2008)
New Revision: 2390
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
Log:
added debug messages to byte block chopper
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 22:07:42 UTC (rev 2389)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 22:21:39 UTC (rev 2390)
@@ -46,6 +46,7 @@
List bytes = null;
if ( (byteArray!=null)
&& (byteArray.length>0) ){
+ log.debug("chopping " + byteArray.length + " bytes");
bytes = new ArrayList();
int offset = 0;
while ( (byteArray.length-offset) > blockSize ) {
@@ -77,14 +78,15 @@
byte[] block = (byte[]) bytes.get(i);
totalLength += block.length;
}
+ log.debug("gluing " + totalLength + " bytes");
byteArray = new byte[totalLength];
int offset = 0;
for (int i = 0, n = bytes.size(); i < n; i++) {
byte[] block = (byte[]) bytes.get(i);
int blockLength = block.length;
System.arraycopy(block, 0, byteArray, offset, blockLength);
+ log.debug("glued " + blockLength + " bytes beggining at " + offset);
offset += blockLength;
- log.debug("glued " + blockLength + " bytes beggining at " + offset);
}
}
}
17 years, 6 months
JBoss JBPM SVN: r2389 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-25 18:07:42 -0400 (Thu, 25 Sep 2008)
New Revision: 2389
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteArray.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
Log:
added debug messages to byte block chopper
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteArray.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteArray.java 2008-09-25 19:31:25 UTC (rev 2388)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteArray.java 2008-09-25 22:07:42 UTC (rev 2389)
@@ -48,7 +48,7 @@
protected String name = null;
protected List byteBlocks = null;
- private static Log log = LogFactory.getLog(ByteArray.class);
+ private static final Log log = LogFactory.getLog(ByteArray.class);
public ByteArray() {
}
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 19:31:25 UTC (rev 2388)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 22:07:42 UTC (rev 2389)
@@ -24,6 +24,9 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
/**
@@ -32,6 +35,8 @@
*/
public class ByteBlockChopper {
+ private static final Log log = LogFactory.getLog(ByteBlockChopper.class);
+
private ByteBlockChopper() {
// hide default constructor to prevent instantiation
}
@@ -42,12 +47,12 @@
if ( (byteArray!=null)
&& (byteArray.length>0) ){
bytes = new ArrayList();
- int index = 0;
- while ( (byteArray.length-index) > blockSize ) {
- bytes.add(subArray(byteArray, index, blockSize));
- index+=blockSize;
+ int offset = 0;
+ while ( (byteArray.length-offset) > blockSize ) {
+ bytes.add(subArray(byteArray, offset, blockSize));
+ offset+=blockSize;
}
- bytes.add(subArray(byteArray, index, byteArray.length-index));
+ bytes.add(subArray(byteArray, offset, byteArray.length-offset));
}
return bytes;
}
@@ -55,6 +60,7 @@
private static byte[] subArray(byte[] array, int offset, int length) {
byte[] subArray = new byte[length];
System.arraycopy(array, offset, subArray, 0, length);
+ log.debug("chopped " + length + " bytes beggining at " + offset);
return subArray;
}
@@ -72,11 +78,13 @@
totalLength += block.length;
}
byteArray = new byte[totalLength];
- int index = 0;
+ int offset = 0;
for (int i = 0, n = bytes.size(); i < n; i++) {
byte[] block = (byte[]) bytes.get(i);
- System.arraycopy(block, 0, byteArray, index, block.length);
- index += block.length;
+ int blockLength = block.length;
+ System.arraycopy(block, 0, byteArray, offset, blockLength);
+ offset += blockLength;
+ log.debug("glued " + blockLength + " bytes beggining at " + offset);
}
}
}
17 years, 6 months
JBoss JBPM SVN: r2388 - in jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm: context and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-25 15:31:25 -0400 (Thu, 25 Sep 2008)
New Revision: 2388
Removed:
jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/command/
jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/context/package.html
Modified:
jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
Log:
excused classes with no public constructors from serializability requirement, also removed some useless files
Modified: jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2008-09-25 19:29:34 UTC (rev 2387)
+++ jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2008-09-25 19:31:25 UTC (rev 2388)
@@ -99,7 +99,6 @@
"org.jbpm.security.authorizer.JbpmIdentityAuthorizer",
"org.jbpm.security.authorizer.RolesAuthorizer",
"org.jbpm.security.filter.JbpmAuthenticationFilter",
- "org.jbpm.util.ClassLoaderUtil",
"org.jbpm.command.service.CommandServiceImpl",
"org.jbpm.msg.jms.JmsCommandFactory",
"org.jbpm.msg.jms.JmsMessageConstants",
@@ -147,9 +146,10 @@
private void assertSerializabilityOfClass(String className) {
Class clazz = ClassLoaderUtil.loadClass(className);
- if ( ! ( (Serializable.class.isAssignableFrom(clazz))
- || (Modifier.isAbstract(clazz.getModifiers()))
- || (isExcused(className))
+ if ( ! ( Serializable.class.isAssignableFrom(clazz)
+ || Modifier.isAbstract(clazz.getModifiers())
+ || isExcused(className)
+ || clazz.getConstructors().length == 0
)
) {
fail(className+" is NOT Serializable");
@@ -168,5 +168,4 @@
return isExcused;
}
- // private static final Log log = LogFactory.getLog(SerializabilityTest.class);
}
Deleted: jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/context/package.html
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/context/package.html 2008-09-25 19:29:34 UTC (rev 2387)
+++ jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/context/package.html 2008-09-25 19:31:25 UTC (rev 2388)
@@ -1,4 +0,0 @@
-<body>
-is the package that contains the context module, adding
-process variables to the graph execution.
-</body>
\ No newline at end of file
17 years, 6 months
JBoss JBPM SVN: r2387 - in jbpm3/branches/aguizar/modules/core/src: test/java/org/jbpm/bytes and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-25 15:29:34 -0400 (Thu, 25 Sep 2008)
New Revision: 2387
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java
jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayTest.java
Log:
revised the chopping and gluing logic
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 19:26:24 UTC (rev 2386)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2008-09-25 19:29:34 UTC (rev 2387)
@@ -22,7 +22,6 @@
package org.jbpm.bytes;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.jbpm.JbpmConfiguration;
@@ -45,36 +44,42 @@
bytes = new ArrayList();
int index = 0;
while ( (byteArray.length-index) > blockSize ) {
- byte[] byteBlock = new byte[blockSize];
- System.arraycopy(byteArray, index, byteBlock, 0, blockSize);
- bytes.add(byteBlock);
+ bytes.add(subArray(byteArray, index, blockSize));
index+=blockSize;
}
- byte[] byteBlock = new byte[byteArray.length-index];
- System.arraycopy(byteArray, index, byteBlock, 0, byteArray.length-index);
- bytes.add(byteBlock);
+ bytes.add(subArray(byteArray, index, byteArray.length-index));
}
return bytes;
}
+ private static byte[] subArray(byte[] array, int offset, int length) {
+ byte[] subArray = new byte[length];
+ System.arraycopy(array, offset, subArray, 0, length);
+ return subArray;
+ }
+
public static byte[] glueChopsBackTogether(List bytes) {
- byte[] value = null;
+ byte[] byteArray = null;
- if (bytes!=null) {
- Iterator iter = bytes.iterator();
- while (iter.hasNext()) {
- byte[] byteBlock = (byte[]) iter.next();
- if (value==null) {
- value = byteBlock;
- } else {
- byte[] oldValue = value;
- value = new byte[value.length+byteBlock.length];
- System.arraycopy(oldValue, 0, value, 0, oldValue.length);
- System.arraycopy(byteBlock, 0, value, oldValue.length, byteBlock.length);
+ if (bytes!=null && !bytes.isEmpty()) {
+ if (bytes.size() == 1) {
+ byteArray = (byte[]) bytes.get(0);
+ }
+ else {
+ int totalLength = 0;
+ for (int i = 0, n = bytes.size(); i < n; i++) {
+ byte[] block = (byte[]) bytes.get(i);
+ totalLength += block.length;
}
+ byteArray = new byte[totalLength];
+ int index = 0;
+ for (int i = 0, n = bytes.size(); i < n; i++) {
+ byte[] block = (byte[]) bytes.get(i);
+ System.arraycopy(block, 0, byteArray, index, block.length);
+ index += block.length;
+ }
}
}
-
- return value;
+ return byteArray;
}
}
Modified: jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java 2008-09-25 19:26:24 UTC (rev 2386)
+++ jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java 2008-09-25 19:29:34 UTC (rev 2387)
@@ -75,7 +75,7 @@
assertNull(retrievedByteArray.getBytes());
}
- private byte[] getMultipleBlockBytes() {
+ private static byte[] getMultipleBlockBytes() {
String text = "muchos bytes"; // (10 bytes)
for (int i=0; i<8; i++) text+=text;
// now text should be 2560 bytes
Modified: jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayTest.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayTest.java 2008-09-25 19:26:24 UTC (rev 2386)
+++ jbpm3/branches/aguizar/modules/core/src/test/java/org/jbpm/bytes/ByteArrayTest.java 2008-09-25 19:29:34 UTC (rev 2387)
@@ -21,25 +21,31 @@
*/
package org.jbpm.bytes;
+import java.util.List;
+
import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.JbpmConfiguration;
public class ByteArrayTest extends AbstractJbpmTestCase {
- public void testByteChopping2Blocks() {
- ByteArray byteArray = new ByteArray(new byte[2048]);
- assertEquals(2, byteArray.byteBlocks.size());
+ public void testByteChoppingBlockCount() {
+ int blockSize = JbpmConfiguration.Configs.getInt("jbpm.byte.block.size");
+ for (int arrayLength = 125; arrayLength <= 1000; arrayLength *= 2) {
+ ByteArray byteArray = new ByteArray(new byte[arrayLength]);
+ int blockCount = arrayLength / blockSize;
+ if (arrayLength % blockSize > 0) blockCount++;
+ List byteBlocks = byteArray.byteBlocks;
+ assertEquals(blockCount, byteBlocks.size());
+ }
}
- public void testByteChopping3Blocks() {
- ByteArray byteArray = new ByteArray(new byte[2049]);
- assertEquals(3, byteArray.byteBlocks.size());
+ public void testReassembling() {
+ for (int arrayLength = 125; arrayLength <= 1000; arrayLength *= 2) {
+ ByteArray byteArray = new ByteArray(new byte[arrayLength]);
+ assertEquals(arrayLength, byteArray.getBytes().length);
+ }
}
- public void testReassembling() {
- ByteArray byteArray = new ByteArray(new byte[2049]);
- assertEquals(2049, byteArray.getBytes().length);
- }
-
public void testEquals() {
ByteArray left = new ByteArray("the same bytes".getBytes());
ByteArray right = new ByteArray("the same bytes".getBytes());
17 years, 6 months
JBoss JBPM SVN: r2386 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-25 15:26:24 -0400 (Thu, 25 Sep 2008)
New Revision: 2386
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ByteUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/IoUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/JndiUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StaticUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StringUtil.java
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
Log:
made utility classes uninstantiable (as opposed to abstract)
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ArrayUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -21,8 +21,12 @@
*/
package org.jbpm.util;
-public abstract class ArrayUtil {
+public class ArrayUtil {
+ private ArrayUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static String toString(Object[] array) {
if (array==null) {
return "null";
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ByteUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ByteUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ByteUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -1,7 +1,10 @@
package org.jbpm.util;
+public class ByteUtil {
-public abstract class ByteUtil {
+ private ByteUtil() {
+ // hide default constructor to prevent instantiation
+ }
public static String toString(byte[] bytes) {
if (bytes == null) return "null";
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -34,6 +34,10 @@
*/
public class ClassLoaderUtil {
+ private ClassLoaderUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static Class loadClass(String className) {
try {
return getClassLoader().loadClass(className);
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -21,8 +21,12 @@
*/
package org.jbpm.util;
-public abstract class EqualsUtil {
+public class EqualsUtil {
+ private EqualsUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static boolean equals(Object thisObject, Object otherObject) {
if ( (thisObject==null) || (otherObject==null) ) return false;
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/IoUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/IoUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -28,10 +28,14 @@
import org.jbpm.JbpmException;
-public abstract class IoUtil {
+public class IoUtil {
- public static final int BUFFERSIZE = 4096;
+ private IoUtil() {
+ // hide default constructor to prevent instantiation
+ }
+ private static final int BUFFERSIZE = 4096;
+
public static byte[] readBytes(InputStream inputStream) throws IOException {
byte[] bytes = null;
if (inputStream==null) {
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/JndiUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/JndiUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/JndiUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -27,8 +27,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-public abstract class JndiUtil {
-
+public class JndiUtil {
+
+ private JndiUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static Object lookup(String jndiName, Class type) {
Object object = null;
try {
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StaticUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StaticUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StaticUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -26,7 +26,7 @@
import java.util.Iterator;
import java.util.Map;
-public abstract class StaticUtil {
+public class StaticUtil {
/*
public class MyClass ... {
@@ -45,7 +45,7 @@
...
}
*/
-
+
static Map initializers = Collections.synchronizedMap(new HashMap());
public abstract static class Initializer {
@@ -56,6 +56,28 @@
public abstract void init();
}
+ /*
+ public class MyClass ... {
+ static AType aStaticInMyClass = null;
+ static AnotherType anotherStaticInMyClass = null;
+
+ static {
+ new StaticUtil.Initializer(MyClass.class) {
+ public void init() {
+ // initialize static members here
+ aStaticInMyClass = ...;
+ anotherStaticInMyClass = ...;
+ }
+ };
+ }
+ ...
+ }
+ */
+
+ private StaticUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static void add(Class clazz, Initializer initializer) {
initializers.put(clazz, initializer);
}
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StringUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StringUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/StringUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -10,6 +10,10 @@
static final byte[] HEX_CHAR_TABLE = { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8',
(byte) '9', (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f' };
+ private StringUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static String toHexString(byte[] bytes) {
try {
byte[] hex = new byte[2 * bytes.length];
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2008-09-25 16:21:31 UTC (rev 2385)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2008-09-25 19:26:24 UTC (rev 2386)
@@ -47,8 +47,12 @@
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
-public abstract class XmlUtil {
-
+public class XmlUtil {
+
+ private XmlUtil() {
+ // hide default constructor to prevent instantiation
+ }
+
public static Document parseXmlText(String xml) {
ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
return parseXmlInputSource(new InputSource(bais));
17 years, 6 months