[jbpm-commits] JBoss JBPM SVN: r4768 - in jbpm3/branches/jbpm-3.2.5.SP/modules: core/src/main/java/org/jbpm/configuration and 14 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri May 8 16:47:43 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-05-08 16:47:42 -0400 (Fri, 08 May 2009)
New Revision: 4768
Modified:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/BeanInfo.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ConstructorInfo.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/hibernate/Converters.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/action/ActionTypes.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ExceptionHandler.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/NodeTypes.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/BeanInstantiator.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/par/ProcessArchive.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessArchiveClassLoadingDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/main/java/org/jbpm/identity/hibernate/PermissionUserType.java
Log:
[JBPM-1976] merge r3836-3837 from trunk
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -31,6 +31,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+
import org.jbpm.configuration.ObjectFactory;
import org.jbpm.db.ContextSession;
import org.jbpm.db.GraphSession;
@@ -50,9 +51,9 @@
/**
* is used to surround persistent operations to processes.
- *
* <p>
- * Obtain JbpmContext's via {@link org.jbpm.JbpmConfiguration#createJbpmContext()} and put it in a try-finally block like this:
+ * Obtain JbpmContext's via {@link org.jbpm.JbpmConfiguration#createJbpmContext()} and put it in a
+ * try-finally block like this:
* </p>
*
* <pre>
@@ -69,39 +70,39 @@
* jbpmContext.close();
* }
* </pre>
- *
* <p>
- * A JbpmContext separates jBPM from a sprecific environment. For each service that jBPM uses, there is an interface specified in the jBPM codebase. jBPM also includes
- * implementations that implement these services by using services in a specific environment. e.g. a hibernate session, a JMS asynchronous messaging system, ...
+ * A JbpmContext separates jBPM from a sprecific environment. For each service that jBPM uses, there
+ * is an interface specified in the jBPM codebase. jBPM also includes implementations that implement
+ * these services by using services in a specific environment. e.g. a hibernate session, a JMS
+ * asynchronous messaging system, ...
* </p>
- *
* <p>
- * A JbpmContext can demarcate a transaction. When a PersistenceService is fetched from the JbpmContext, the default implementation for the persistence service will
- * create a hibernate session and start a transaction. So that transactions can be configured in the hibernate configuration.
+ * A JbpmContext can demarcate a transaction. When a PersistenceService is fetched from the
+ * JbpmContext, the default implementation for the persistence service will create a hibernate
+ * session and start a transaction. So that transactions can be configured in the hibernate
+ * configuration.
* </p>
- *
* <p>
- * A JbpmContext allows the user to overwrite (or make complete) the configuration by injecting objects programmatically. like e.g. a hibernate session factory or a
- * hibernate session or any other resource that can be fetched or created from the configuration.
+ * A JbpmContext allows the user to overwrite (or make complete) the configuration by injecting
+ * objects programmatically. like e.g. a hibernate session factory or a hibernate session or any
+ * other resource that can be fetched or created from the configuration.
* </p>
- *
* <p>
- * Last but not least, JbpmContext provides convenient access to the most common operations such as {@link #getTaskList(String)}, {@link #newProcessInstance(String)}
+ * Last but not least, JbpmContext provides convenient access to the most common operations such as
+ * {@link #getTaskList(String)}, {@link #newProcessInstance(String)}
* {@link #loadTaskInstanceForUpdate(long)} and {@link #save(ProcessInstance)}.
* </p>
- *
* <p>
- * All the <code>...ForUpdate(...)</code> methods will automatically save the loaded objects at <code>jbpmContext.close();</code>
+ * All the <code>...ForUpdate(...)</code> methods will automatically save the loaded objects at
+ * <code>jbpmContext.close();</code>
* </p>
*/
-public class JbpmContext implements Serializable
-{
+public class JbpmContext implements Serializable {
+
private static final long serialVersionUID = 1L;
public static final String DEFAULT_JBPM_CONTEXT_NAME = "default.jbpm.context";
- static ThreadLocal currentContextsStack = new ThreadLocal();
-
ObjectFactory objectFactory = null;
Services services = null;
List autoSaveProcessInstances = null;
@@ -110,8 +111,7 @@
/**
* normally, JbpmContext object are created via a {@link JbpmConfiguration}.
*/
- public JbpmContext(Services services, ObjectFactory objectFactory)
- {
+ public JbpmContext(Services services, ObjectFactory objectFactory) {
log.debug("creating " + toString());
this.services = services;
this.objectFactory = objectFactory;
@@ -120,44 +120,35 @@
/**
* make sure you close your JbpmContext in a finally block.
*/
- public void close()
- {
+ public void close() {
log.debug("closing jbpmContext " + toString());
- try
- {
- if (services != null)
- {
- try
- {
+ try {
+ if (services != null) {
+ try {
autoSave();
}
- finally
- {
+ finally {
services.close();
}
}
}
- finally
- {
- if (jbpmConfiguration != null)
- {
+ finally {
+ if (jbpmConfiguration != null) {
jbpmConfiguration.jbpmContextClosed(this);
}
}
}
/**
- * obtains the current JbpmContext from a thread local. The current JbpmContexts are maintained in a stack so that you can do nested context operations for different
- * jbpm configurations.
+ * obtains the current JbpmContext from a thread local. The current JbpmContexts are maintained in
+ * a stack so that you can do nested context operations for different jbpm configurations.
*
* @deprecated method moved to {@link JbpmConfiguration}.
*/
- public static JbpmContext getCurrentJbpmContext()
- {
+ public static JbpmContext getCurrentJbpmContext() {
JbpmContext currentJbpmContext = null;
JbpmConfiguration currentJbpmConfiguration = JbpmConfiguration.getCurrentJbpmConfiguration();
- if (currentJbpmConfiguration != null)
- {
+ if (currentJbpmConfiguration != null) {
currentJbpmContext = currentJbpmConfiguration.getCurrentJbpmContext();
}
return currentJbpmContext;
@@ -166,19 +157,19 @@
// convenience methods //////////////////////////////////////////////////////
/**
- * deploys a process definition. For parsing process definitions from archives, see the static parseXxx methods on {@link ProcessDefinition}.
+ * deploys a process definition. For parsing process definitions from archives, see the static
+ * parseXxx methods on {@link ProcessDefinition}.
*/
- public void deployProcessDefinition(ProcessDefinition processDefinition)
- {
+ public void deployProcessDefinition(ProcessDefinition processDefinition) {
getGraphSession().deployProcessDefinition(processDefinition);
}
/**
- * fetches the tasklist for the current authenticated actor. With the default configured authentication service, you can set the authenticated user with
- * {@link #setActorId(String)}, then all the subsequent operations will be performed on behalf of that actor.
+ * fetches the tasklist for the current authenticated actor. With the default configured
+ * authentication service, you can set the authenticated user with {@link #setActorId(String)},
+ * then all the subsequent operations will be performed on behalf of that actor.
*/
- public List getTaskList()
- {
+ public List getTaskList() {
String actorId = getActorId();
return getTaskMgmtSession().findTaskInstances(actorId);
}
@@ -186,19 +177,19 @@
/**
* fetches the tasklist for the given actor.
*/
- public List getTaskList(String actorId)
- {
+ public List getTaskList(String actorId) {
return getTaskMgmtSession().findTaskInstances(actorId);
}
/**
- * fetches all the task instances for which at least one of the given actorIds is a candidate (pooled actor). Typically, for an actor, his/her personal actorId plus
- * all the actorIds representing the groups that person belongs to form the actorIds. Then the user interface should show only the option to take these tasks to the
- * actor's personal task list (with {@link TaskInstance#setActorId(String)}). Only task instances that are assigned to the actor directly should be offered the
- * possibility for performing the actual task.
+ * fetches all the task instances for which at least one of the given actorIds is a candidate
+ * (pooled actor). Typically, for an actor, his/her personal actorId plus all the actorIds
+ * representing the groups that person belongs to form the actorIds. Then the user interface
+ * should show only the option to take these tasks to the actor's personal task list (with
+ * {@link TaskInstance#setActorId(String)}). Only task instances that are assigned to the actor
+ * directly should be offered the possibility for performing the actual task.
*/
- public List getGroupTaskList(List actorIds)
- {
+ public List getGroupTaskList(List actorIds) {
return getTaskMgmtSession().findPooledTaskInstances(actorIds);
}
@@ -210,8 +201,7 @@
* @see #loadTaskInstanceForUpdate(long)
* @see #getTaskInstanceForUpdate(long)
*/
- public TaskInstance loadTaskInstance(long taskInstanceId)
- {
+ public TaskInstance loadTaskInstance(long taskInstanceId) {
return getTaskMgmtSession().loadTaskInstance(taskInstanceId);
}
@@ -223,41 +213,39 @@
* @see #loadTaskInstanceForUpdate(long)
* @see #getTaskInstanceForUpdate(long)
*/
- public TaskInstance getTaskInstance(long taskInstanceId)
- {
+ public TaskInstance getTaskInstance(long taskInstanceId) {
return getTaskMgmtSession().getTaskInstance(taskInstanceId);
}
/**
- * loads a task instance from the db and registers it for auto-save. The loaded task instance will be save automatically at the {@link #close()}. This is a
- * convenience method in case you plan to do update operations on this task instance.
+ * loads a task instance from the db and registers it for auto-save. The loaded task instance will
+ * be save automatically at the {@link #close()}. This is a convenience method in case you plan to
+ * do update operations on this task instance.
*
* @throws JbpmException in case no such task instance exists
* @see #loadTaskInstance(long)
* @see #getTaskInstance(long)
* @see #getTaskInstanceForUpdate(long)
*/
- public TaskInstance loadTaskInstanceForUpdate(long taskInstanceId)
- {
+ public TaskInstance loadTaskInstanceForUpdate(long taskInstanceId) {
TaskInstance taskInstance = getTaskMgmtSession().loadTaskInstance(taskInstanceId);
addAutoSaveTaskInstance(taskInstance);
return taskInstance;
}
/**
- * gets a task instance from the db and registers it for auto-save. The loaded task instance will be save automatically at the {@link #close()}. This is a convenience
- * method in case you plan to do update operations on this task instance.
+ * gets a task instance from the db and registers it for auto-save. The loaded task instance will
+ * be save automatically at the {@link #close()}. This is a convenience method in case you plan to
+ * do update operations on this task instance.
*
* @return the task instance or null in case no such task instance exists.
* @see #loadTaskInstance(long)
* @see #getTaskInstance(long)
* @see #loadTaskInstanceForUpdate(long)
*/
- public TaskInstance getTaskInstanceForUpdate(long taskInstanceId)
- {
+ public TaskInstance getTaskInstanceForUpdate(long taskInstanceId) {
TaskInstance taskInstance = getTaskMgmtSession().getTaskInstance(taskInstanceId);
- if (taskInstance != null)
- {
+ if (taskInstance != null) {
addAutoSaveTaskInstance(taskInstance);
}
return taskInstance;
@@ -271,8 +259,7 @@
* @see #loadTokenForUpdate(long)
* @see #getTokenForUpdate(long)
*/
- public Token loadToken(long tokenId)
- {
+ public Token loadToken(long tokenId) {
return getGraphSession().loadToken(tokenId);
}
@@ -284,103 +271,100 @@
* @see #loadTokenForUpdate(long)
* @see #getTokenForUpdate(long)
*/
- public Token getToken(long tokenId)
- {
+ public Token getToken(long tokenId) {
return getGraphSession().getToken(tokenId);
}
/**
- * loads a token from the db and registers it for auto-save. The loaded token will be {@link #save(Token)}d automatically at the {@link #close()}. This is a
- * convenience method in case you plan to do update operations on this token.
+ * loads a token from the db and registers it for auto-save. The loaded token will be
+ * {@link #save(Token)}d automatically at the {@link #close()}. This is a convenience method in
+ * case you plan to do update operations on this token.
*
* @throws JbpmException in case no such token exists.
* @see #getToken(long)
* @see #loadToken(long)
* @see #getTokenForUpdate(long)
*/
- public Token loadTokenForUpdate(long tokenId)
- {
+ public Token loadTokenForUpdate(long tokenId) {
Token token = getGraphSession().loadToken(tokenId);
addAutoSaveToken(token);
return token;
}
/**
- * get a token from the db and registers it for auto-save. The loaded token will be {@link #save(Token)}d automatically at the {@link #close()}. This is a convenience
- * method in case you plan to do update operations on this token.
+ * get a token from the db and registers it for auto-save. The loaded token will be
+ * {@link #save(Token)}d automatically at the {@link #close()}. This is a convenience method in
+ * case you plan to do update operations on this token.
*
* @return the token or null in case no such token exists.
* @see #getToken(long)
* @see #loadToken(long)
* @see #loadTokenForUpdate(long)
*/
- public Token getTokenForUpdate(long tokenId)
- {
+ public Token getTokenForUpdate(long tokenId) {
Token token = getGraphSession().getToken(tokenId);
- if (token != null)
- {
+ if (token != null) {
addAutoSaveToken(token);
}
return token;
}
/**
- * loads a process instance from the db. Consider using {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an update operation on the process
- * instance.
+ * loads a process instance from the db. Consider using
+ * {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an update operation on the
+ * process instance.
*
* @throws JbpmException in case no such process instance exists.
* @see #getProcessInstance(long)
* @see #loadProcessInstanceForUpdate(long)
* @see #getProcessInstanceForUpdate(long)
*/
- public ProcessInstance loadProcessInstance(long processInstanceId)
- {
+ public ProcessInstance loadProcessInstance(long processInstanceId) {
return getGraphSession().loadProcessInstance(processInstanceId);
}
/**
- * gets a process instance from the db. Consider using {@link #loadProcessInstanceForUpdate(long)} if you plan to perform an update operation on the process instance.
+ * gets a process instance from the db. Consider using {@link #loadProcessInstanceForUpdate(long)}
+ * if you plan to perform an update operation on the process instance.
*
* @return the token or null in case no such token exists.
* @see #loadProcessInstance(long)
* @see #loadProcessInstanceForUpdate(long)
* @see #getProcessInstanceForUpdate(long)
*/
- public ProcessInstance getProcessInstance(long processInstanceId)
- {
+ public ProcessInstance getProcessInstance(long processInstanceId) {
return getGraphSession().getProcessInstance(processInstanceId);
}
/**
- * loads a process instances from the db and registers it for auto-save. The loaded process instance will be {@link #save(ProcessInstance)}d automatically at the
- * {@link #close()}. This is a convenience method in case you plan to do update operations on this process instance.
+ * loads a process instances from the db and registers it for auto-save. The loaded process
+ * instance will be {@link #save(ProcessInstance)}d automatically at the {@link #close()}. This is
+ * a convenience method in case you plan to do update operations on this process instance.
*
* @throws JbpmException in case no such process instance exists.
* @see #loadProcessInstance(long)
* @see #getProcessInstance(long)
* @see #getProcessInstanceForUpdate(long)
*/
- public ProcessInstance loadProcessInstanceForUpdate(long processInstanceId)
- {
+ public ProcessInstance loadProcessInstanceForUpdate(long processInstanceId) {
ProcessInstance processInstance = getGraphSession().loadProcessInstance(processInstanceId);
addAutoSaveProcessInstance(processInstance);
return processInstance;
}
/**
- * gets a process instances from the db and registers it for auto-save. The loaded process instance will be {@link #save(ProcessInstance)}d automatically at the
- * {@link #close()}. This is a convenience method in case you plan to do update operations on this process instance.
+ * gets a process instances from the db and registers it for auto-save. The loaded process
+ * instance will be {@link #save(ProcessInstance)}d automatically at the {@link #close()}. This is
+ * a convenience method in case you plan to do update operations on this process instance.
*
* @return the token or null in case no such token exists.
* @see #loadProcessInstance(long)
* @see #getProcessInstance(long)
* @see #loadProcessInstanceForUpdate(long)
*/
- public ProcessInstance getProcessInstanceForUpdate(long processInstanceId)
- {
+ public ProcessInstance getProcessInstanceForUpdate(long processInstanceId) {
ProcessInstance processInstance = getGraphSession().getProcessInstance(processInstanceId);
- if (processInstance != null)
- {
+ if (processInstance != null) {
addAutoSaveProcessInstance(processInstance);
}
return processInstance;
@@ -389,65 +373,62 @@
/**
* returns the process instance with the given key or null if no such instance exists.
*/
- public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String key)
- {
+ public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String key) {
return getGraphSession().getProcessInstance(processDefinition, key);
}
/**
- * returns the process instance with the given key or throws an exception if no such instance exists.
+ * returns the process instance with the given key or throws an exception if no such instance
+ * exists.
*/
- public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String key)
- {
+ public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String key) {
return getGraphSession().loadProcessInstance(processDefinition, key);
}
/**
- * returns the process instance with the given key or null if no such instance exists. Upon close of this jbpmContext, the fetched process instance will be
- * automatically saved.
+ * returns the process instance with the given key or null if no such instance exists. Upon close
+ * of this jbpmContext, the fetched process instance will be automatically saved.
*/
- public ProcessInstance getProcessInstanceForUpdate(ProcessDefinition processDefinition, String key)
- {
+ public ProcessInstance getProcessInstanceForUpdate(ProcessDefinition processDefinition, String key) {
ProcessInstance processInstance = getGraphSession().getProcessInstance(processDefinition, key);
- if (processInstance != null)
- {
+ if (processInstance != null) {
addAutoSaveProcessInstance(processInstance);
}
return processInstance;
}
/**
- * returns the process instance with the given key or throws an exception if no such instance exists. Upon close of this jbpmContext, the fetched process instance
- * will be automatically saved.
+ * returns the process instance with the given key or throws an exception if no such instance
+ * exists. Upon close of this jbpmContext, the fetched process instance will be automatically
+ * saved.
*/
- public ProcessInstance loadProcessInstanceForUpdate(ProcessDefinition processDefinition, String key)
- {
+ public ProcessInstance loadProcessInstanceForUpdate(ProcessDefinition processDefinition,
+ String key) {
ProcessInstance processInstance = getGraphSession().loadProcessInstance(processDefinition, key);
- if (processInstance != null)
- {
+ if (processInstance != null) {
addAutoSaveProcessInstance(processInstance);
}
return processInstance;
}
/**
- * creates a new process instance for the latest version of the process definition with the given name.
+ * creates a new process instance for the latest version of the process definition with the given
+ * name.
*
* @throws JbpmException when no processDefinition with the given name is deployed.
*/
- public ProcessInstance newProcessInstance(String processDefinitionName)
- {
+ public ProcessInstance newProcessInstance(String processDefinitionName) {
ProcessDefinition processDefinition = getGraphSession().findLatestProcessDefinition(processDefinitionName);
return new ProcessInstance(processDefinition);
}
/**
- * creates a new process instance for the latest version of the process definition with the given name and registers it for auto-save.
+ * creates a new process instance for the latest version of the process definition with the given
+ * name and registers it for auto-save.
*
* @throws JbpmException when no processDefinition with the given name is deployed.
*/
- public ProcessInstance newProcessInstanceForUpdate(String processDefinitionName)
- {
+ public ProcessInstance newProcessInstanceForUpdate(String processDefinitionName) {
ProcessDefinition processDefinition = getGraphSession().findLatestProcessDefinition(processDefinitionName);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
addAutoSaveProcessInstance(processInstance);
@@ -457,10 +438,8 @@
/**
* saves the process instance.
*/
- public void save(ProcessInstance processInstance)
- {
- if (services != null)
- {
+ public void save(ProcessInstance processInstance) {
+ if (services != null) {
services.save(processInstance, this);
}
}
@@ -468,31 +447,27 @@
/**
* saves the complete process instance for this token.
*/
- public void save(Token token)
- {
+ public void save(Token token) {
save(token.getProcessInstance());
}
/**
* saves the complete process instance for this task instance.
*/
- public void save(TaskInstance taskInstance)
- {
+ public void save(TaskInstance taskInstance) {
save(taskInstance.getTaskMgmtInstance().getProcessInstance());
}
/**
- * mark this transaction for rollback only in the persistence service. The {@link #close()} operation will then perform a rollback.
+ * mark this transaction for rollback only in the persistence service. The {@link #close()}
+ * operation will then perform a rollback.
*/
- public void setRollbackOnly()
- {
+ public void setRollbackOnly() {
TxService txService = (services != null ? services.getTxService() : null);
- if (txService != null)
- {
+ if (txService != null) {
txService.setRollbackOnly();
}
- else
- {
+ else {
throw new JbpmException("no transaction service configured");
}
}
@@ -502,21 +477,19 @@
/**
* gives access to the services and service factories.
*/
- public Services getServices()
- {
+ public Services getServices() {
return services;
}
- public ServiceFactory getServiceFactory(String name)
- {
+ public ServiceFactory getServiceFactory(String name) {
return services.getServiceFactory(name);
}
/**
- * gives access to the object factory containing the configuration for creating the service factories.
+ * gives access to the object factory containing the configuration for creating the service
+ * factories.
*/
- public ObjectFactory getObjectFactory()
- {
+ public ObjectFactory getObjectFactory() {
return objectFactory;
}
@@ -524,23 +497,22 @@
/**
* gets the hibernate session factory from the default configured persistence service.
- * @return the hibernate session factory, or <code>null</code> if a nonstandard
- * persistence service is configured
+ *
+ * @return the hibernate session factory, or <code>null</code> if a nonstandard persistence
+ * service is configured
*/
- public SessionFactory getSessionFactory()
- {
+ public SessionFactory getSessionFactory() {
PersistenceService persistenceService = getPersistenceService();
- return persistenceService instanceof DbPersistenceService
- ? ((DbPersistenceService) persistenceService).getSessionFactory()
- : null;
+ return persistenceService instanceof DbPersistenceService ? ((DbPersistenceService) persistenceService).getSessionFactory()
+ : null;
}
/**
- * sets the hibernate session factory into the default configured persistence service, overwriting the configured session factory (if there is one configured).
- * if a nonstandard persistence service is configured, then this call has no effect.
+ * sets the hibernate session factory into the default configured persistence service, overwriting
+ * the configured session factory (if there is one configured). if a nonstandard persistence
+ * service is configured, then this call has no effect.
*/
- public void setSessionFactory(SessionFactory sessionFactory)
- {
+ public void setSessionFactory(SessionFactory sessionFactory) {
PersistenceService persistenceService = getPersistenceService();
if (persistenceService instanceof DbPersistenceService) {
DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
@@ -550,24 +522,22 @@
/**
* gets the hibernate session from the default configured persistence service.
- * @return the hibernate session, or <code>null</code> if a nonstandard
- * persistence service is configured.
+ *
+ * @return the hibernate session, or <code>null</code> if a nonstandard persistence service is
+ * configured.
*/
- public Session getSession()
- {
+ public Session getSession() {
PersistenceService persistenceService = getPersistenceService();
- return persistenceService instanceof DbPersistenceService
- ? ((DbPersistenceService) persistenceService).getSession()
- : null;
+ return persistenceService instanceof DbPersistenceService ? ((DbPersistenceService) persistenceService).getSession()
+ : null;
}
/**
- * sets the hibernate session into the default configured persistence service, preventing the creation of a session from the configured session factory (if there is
- * one configured).
- * if a nonstandard persistence service is configured, then this call has no effect.
+ * sets the hibernate session into the default configured persistence service, preventing the
+ * creation of a session from the configured session factory (if there is one configured). if a
+ * nonstandard persistence service is configured, then this call has no effect.
*/
- public void setSession(Session session)
- {
+ public void setSession(Session session) {
PersistenceService persistenceService = getPersistenceService();
if (persistenceService instanceof DbPersistenceService) {
DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
@@ -577,23 +547,21 @@
/**
* gets the jdbc connection from the default configured persistence service.
- * @return the jdbc connectoin, or <code>null</code> if a nonstandard
- * persistence service is configured.
+ *
+ * @return the jdbc connectoin, or <code>null</code> if a nonstandard persistence service is
+ * configured.
*/
- public Connection getConnection()
- {
+ public Connection getConnection() {
PersistenceService persistenceService = getPersistenceService();
- return persistenceService instanceof DbPersistenceService
- ? ((DbPersistenceService) persistenceService).getConnection()
- : null;
+ return persistenceService instanceof DbPersistenceService ? ((DbPersistenceService) persistenceService).getConnection()
+ : null;
}
/**
- * allows users to provide a jdbc connection to be used when the hibernate session is created.
- * if a nonstandard persistence service is configured, then this call has no effect.
+ * allows users to provide a jdbc connection to be used when the hibernate session is created. if
+ * a nonstandard persistence service is configured, then this call has no effect.
*/
- public void setConnection(Connection connection)
- {
+ public void setConnection(Connection connection) {
PersistenceService persistenceService = getPersistenceService();
if (persistenceService instanceof DbPersistenceService) {
DbPersistenceService dbPersistenceService = (DbPersistenceService) persistenceService;
@@ -606,8 +574,7 @@
/**
* more variables related database access.
*/
- public ContextSession getContextSession()
- {
+ public ContextSession getContextSession() {
PersistenceService persistenceService = getPersistenceService();
return persistenceService != null ? persistenceService.getContextSession() : null;
}
@@ -615,8 +582,7 @@
/**
* more logging related database access.
*/
- public LoggingSession getLoggingSession()
- {
+ public LoggingSession getLoggingSession() {
PersistenceService persistenceService = getPersistenceService();
return (persistenceService != null ? persistenceService.getLoggingSession() : null);
}
@@ -624,8 +590,7 @@
/**
* more job related database access.
*/
- public JobSession getJobSession()
- {
+ public JobSession getJobSession() {
PersistenceService persistenceService = getPersistenceService();
return (persistenceService != null ? persistenceService.getJobSession() : null);
}
@@ -633,8 +598,7 @@
/**
* more graph (process) related database access.
*/
- public GraphSession getGraphSession()
- {
+ public GraphSession getGraphSession() {
PersistenceService persistenceService = getPersistenceService();
return (persistenceService != null ? persistenceService.getGraphSession() : null);
}
@@ -642,8 +606,7 @@
/**
* more task related database access.
*/
- public TaskMgmtSession getTaskMgmtSession()
- {
+ public TaskMgmtSession getTaskMgmtSession() {
PersistenceService persistenceService = getPersistenceService();
return (persistenceService != null ? persistenceService.getTaskMgmtSession() : null);
}
@@ -653,60 +616,49 @@
/**
* retrieves the current authenticated actor from the authentication service.
*/
- public String getActorId()
- {
+ public String getActorId() {
return services.getAuthenticationService().getActorId();
}
/**
* sets the currently authenticated actorId.
*/
- public void setActorId(String actorId)
- {
- AuthenticationService authenticationService = (AuthenticationService)services.getAuthenticationService();
+ public void setActorId(String actorId) {
+ AuthenticationService authenticationService = (AuthenticationService) services.getAuthenticationService();
authenticationService.setActorId(actorId);
}
- public void addAutoSaveProcessInstance(ProcessInstance processInstance)
- {
- if (autoSaveProcessInstances == null)
- autoSaveProcessInstances = new ArrayList();
+ public void addAutoSaveProcessInstance(ProcessInstance processInstance) {
+ if (autoSaveProcessInstances == null) autoSaveProcessInstances = new ArrayList();
autoSaveProcessInstances.add(processInstance);
}
- public void addAutoSaveToken(Token token)
- {
+ public void addAutoSaveToken(Token token) {
addAutoSaveProcessInstance(token.getProcessInstance());
}
- public void addAutoSaveTaskInstance(TaskInstance taskInstance)
- {
+ public void addAutoSaveTaskInstance(TaskInstance taskInstance) {
addAutoSaveProcessInstance(taskInstance.getTaskMgmtInstance().getProcessInstance());
}
-
+
// private methods //////////////////////////////////////////////////////////
- void autoSave()
- {
- if (autoSaveProcessInstances != null)
- {
+ void autoSave() {
+ if (autoSaveProcessInstances != null) {
Iterator iter = autoSaveProcessInstances.iterator();
- while (iter.hasNext())
- {
- ProcessInstance processInstance = (ProcessInstance)iter.next();
+ while (iter.hasNext()) {
+ ProcessInstance processInstance = (ProcessInstance) iter.next();
save(processInstance);
iter.remove();
}
}
}
- PersistenceService getPersistenceService()
- {
+ PersistenceService getPersistenceService() {
return services != null ? services.getPersistenceService() : null;
}
- public JbpmConfiguration getJbpmConfiguration()
- {
+ public JbpmConfiguration getJbpmConfiguration() {
return jbpmConfiguration;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/BeanInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/BeanInfo.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/BeanInfo.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -25,12 +25,13 @@
import java.util.Iterator;
import java.util.List;
+import org.w3c.dom.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Element;
public class BeanInfo extends AbstractObjectInfo {
-
+
private static final long serialVersionUID = 1L;
String className = null;
@@ -42,21 +43,21 @@
public BeanInfo(Element beanElement, ObjectFactoryParser objectFactoryParser) {
super(beanElement, objectFactoryParser);
-
+
// parse constructor or factory
Element constructorElement = XmlUtil.element(beanElement, "constructor");
- if (constructorElement!=null) {
+ if (constructorElement != null) {
constructorInfo = new ConstructorInfo(constructorElement, objectFactoryParser);
constructorInfo.beanInfo = this;
}
-
+
if (beanElement.hasAttribute("class")) {
className = beanElement.getAttribute("class");
- } else if ( (constructorInfo.factoryRefName==null)
- && (constructorInfo.factoryClassName==null )
- ) {
- throw new JbpmException("bean element must have a class attribute: "+XmlUtil.toString(beanElement));
}
+ else if ((constructorInfo.factoryRefName == null) && (constructorInfo.factoryClassName == null)) {
+ throw new JbpmException("bean element must have a class attribute: "
+ + XmlUtil.toString(beanElement));
+ }
// parse fields
List propertyInfoList = new ArrayList();
@@ -65,46 +66,56 @@
Element fieldElement = (Element) iter.next();
propertyInfoList.add(new FieldInfo(fieldElement, objectFactoryParser));
}
-
+
// parse properties
iter = XmlUtil.elementIterator(beanElement, "property");
while (iter.hasNext()) {
Element propertyElement = (Element) iter.next();
propertyInfoList.add(new PropertyInfo(propertyElement, objectFactoryParser));
}
-
+
propertyInfos = (PropertyInfo[]) propertyInfoList.toArray(new PropertyInfo[propertyInfoList.size()]);
}
public Object createObject(ObjectFactoryImpl objectFactory) {
Object object = null;
-
- if (constructorInfo==null) {
- if (className==null) throw new JbpmException("bean '"+getName()+"' doesn't have a class or constructor specified");
+
+ if (constructorInfo == null) {
+ if (className == null)
+ throw new JbpmException("bean '"
+ + getName()
+ + "' doesn't have a class or constructor specified");
try {
- Class clazz = objectFactory.loadClass(className);
+ Class clazz = objectFactory.classForName(className);
object = clazz.newInstance();
- } catch (Exception e) {
- throw new JbpmException("couldn't instantiate bean '"+getName()+"' of type '"+className+"'", e);
}
- } else {
+ catch (Exception e) {
+ throw new JbpmException("couldn't instantiate bean '"
+ + getName()
+ + "' of type '"
+ + className
+ + "'", e);
+ }
+ }
+ else {
object = constructorInfo.createObject(objectFactory);
}
-
- if (className==null) className = object.getClass().getName();
- if (propertyInfos!=null) {
- for (int i=0; i<propertyInfos.length; i++) {
+ if (className == null) className = object.getClass().getName();
+
+ if (propertyInfos != null) {
+ for (int i = 0; i < propertyInfos.length; i++) {
propertyInfos[i].injectProperty(object, objectFactory);
}
}
-
+
return object;
}
public String getClassName() {
return className;
}
+
public void setClassName(String className) {
this.className = className;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ConstructorInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ConstructorInfo.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ConstructorInfo.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -26,10 +26,11 @@
import java.lang.reflect.Method;
import java.util.List;
+import org.w3c.dom.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Element;
public class ConstructorInfo implements Serializable {
@@ -42,49 +43,59 @@
String factoryMethodName = null;
String[] parameterClassNames = null;
ObjectInfo[] parameterInfos = null;
-
+
public ConstructorInfo(Element constructorElement, ObjectFactoryParser configParser) {
// beanInfo is set by the beanInfo itself
-
+
// className
if (constructorElement.hasAttribute("class")) {
className = constructorElement.getAttribute("class");
}
-
+
// factoryInfo
if (constructorElement.hasAttribute("factory")) {
factoryRefName = constructorElement.getAttribute("factory");
if (!constructorElement.hasAttribute("method")) {
- throw new JbpmException("factory element in constructor requires method attribute in constructor: "+XmlUtil.toString(constructorElement));
+ throw new JbpmException(
+ "factory element in constructor requires method attribute in constructor: "
+ + XmlUtil.toString(constructorElement));
}
factoryMethodName = constructorElement.getAttribute("method");
- } else if (constructorElement.hasAttribute("factory-class")) {
+ }
+ else if (constructorElement.hasAttribute("factory-class")) {
factoryClassName = constructorElement.getAttribute("factory-class");
if (!constructorElement.hasAttribute("method")) {
- throw new JbpmException("factory-class element in constructor requires method attribute in constructor: "+XmlUtil.toString(constructorElement));
+ throw new JbpmException(
+ "factory-class element in constructor requires method attribute in constructor: "
+ + XmlUtil.toString(constructorElement));
}
factoryMethodName = constructorElement.getAttribute("method");
- } else {
+ }
+ else {
if (constructorElement.hasAttribute("method")) {
- throw new JbpmException("'method' element in constructor requires 'factory' of 'factory-class' attribute in constructor: "+XmlUtil.toString(constructorElement));
+ throw new JbpmException(
+ "'method' element in constructor requires 'factory' of 'factory-class' attribute in constructor: "
+ + XmlUtil.toString(constructorElement));
}
}
// parameterTypesNames and parameterInfos
List parameterElements = XmlUtil.elements(constructorElement, "parameter");
- parameterClassNames = new String[parameterElements.size()];
- parameterInfos = new ObjectInfo[parameterElements.size()];
- for (int i=0; i<parameterElements.size(); i++) {
+ parameterClassNames = new String[parameterElements.size()];
+ parameterInfos = new ObjectInfo[parameterElements.size()];
+ for (int i = 0; i < parameterElements.size(); i++) {
Element parameterElement = (Element) parameterElements.get(i);
if (!parameterElement.hasAttribute("class")) {
- throw new JbpmException("parameter element must have a class attribute: "+XmlUtil.toString(parameterElement));
+ throw new JbpmException("parameter element must have a class attribute: "
+ + XmlUtil.toString(parameterElement));
}
parameterClassNames[i] = parameterElement.getAttribute("class");
Element parameterInfoElement = XmlUtil.element(parameterElement);
- if (parameterInfoElement==null) {
- throw new JbpmException("parameter element must have exactly 1 child element: "+XmlUtil.toString(parameterElement));
+ if (parameterInfoElement == null) {
+ throw new JbpmException("parameter element must have exactly 1 child element: "
+ + XmlUtil.toString(parameterElement));
}
parameterInfos[i] = configParser.parse(parameterInfoElement);
}
@@ -96,55 +107,60 @@
Object[] args = getArgs(objectFactory);
Class[] parameterTypes = getParameterTypes(objectFactory);
- if ( (factoryRefName!=null)
- || (factoryClassName!=null)
- ) {
+ if ((factoryRefName != null) || (factoryClassName != null)) {
Object factory = null;
Class factoryClass = null;
- if (factoryRefName!=null) {
+ if (factoryRefName != null) {
factory = objectFactory.getObject(factoryRefName);
factoryClass = factory.getClass();
- } else {
- factoryClass = ClassLoaderUtil.loadClass(factoryClassName);
}
+ else {
+ factoryClass = ClassLoaderUtil.classForName(factoryClassName);
+ }
try {
Method factoryMethod = findMethod(factoryClass, parameterTypes);
newObject = factoryMethod.invoke(factory, args);
- } catch (Exception e) {
- throw new JbpmException("couldn't create new bean with factory method '"+factoryClass.getName()+"."+factoryMethodName, e);
}
+ catch (Exception e) {
+ throw new JbpmException("couldn't create new bean with factory method '"
+ + factoryClass.getName()
+ + "."
+ + factoryMethodName, e);
+ }
- } else {
- String className = (this.className!=null ? this.className : beanInfo.getClassName());
- Class clazz = objectFactory.loadClass(className);
-
+ }
+ else {
+ String className = (this.className != null ? this.className : beanInfo.getClassName());
+ Class clazz = objectFactory.classForName(className);
+
try {
Constructor constructor = clazz.getDeclaredConstructor(parameterTypes);
newObject = constructor.newInstance(args);
- } catch (Exception e) {
- throw new JbpmException("couldn't instantiate new '"+className+"' with constructor", e);
}
-
+ catch (Exception e) {
+ throw new JbpmException("couldn't instantiate new '" + className + "' with constructor", e);
+ }
+
}
-
+
return newObject;
}
protected Class[] getParameterTypes(ObjectFactoryImpl objectFactory) {
- int nbrOfParameters = (parameterClassNames!=null ? parameterClassNames.length : 0);
+ int nbrOfParameters = (parameterClassNames != null ? parameterClassNames.length : 0);
Class[] parameterTypes = new Class[nbrOfParameters];
- for (int i=0; i<nbrOfParameters; i++) {
- parameterTypes[i] = objectFactory.loadClass(parameterClassNames[i]);
+ for (int i = 0; i < nbrOfParameters; i++) {
+ parameterTypes[i] = objectFactory.classForName(parameterClassNames[i]);
}
return parameterTypes;
}
protected Object[] getArgs(ObjectFactoryImpl objectFactory) {
- int nbrOfParameters = (parameterClassNames!=null ? parameterClassNames.length : 0);
+ int nbrOfParameters = (parameterClassNames != null ? parameterClassNames.length : 0);
Object[] args = new Object[nbrOfParameters];
- for (int i=0; i<nbrOfParameters; i++) {
+ for (int i = 0; i < nbrOfParameters; i++) {
args[i] = objectFactory.getObject(parameterInfos[i]);
}
return args;
@@ -152,22 +168,25 @@
public Method findMethod(Class clazz, Class[] parameterTypes) {
Method method = null;
-
+
Class candidateClass = clazz;
- while ( (candidateClass!=null)
- && (method==null)
- ) {
+ while ((candidateClass != null) && (method == null)) {
try {
method = clazz.getDeclaredMethod(factoryMethodName, parameterTypes);
- } catch (NoSuchMethodException e1) {
+ }
+ catch (NoSuchMethodException e1) {
candidateClass = candidateClass.getSuperclass();
}
}
- if (method==null) {
- throw new JbpmException("couldn't find factory method '"+factoryMethodName+"' in class '"+clazz.getName()+"'");
+ if (method == null) {
+ throw new JbpmException("couldn't find factory method '"
+ + factoryMethodName
+ + "' in class '"
+ + clazz.getName()
+ + "'");
}
-
+
return method;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/JbpmTypeObjectInfo.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -23,6 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
import org.jbpm.context.exe.Converter;
import org.jbpm.context.exe.JbpmType;
import org.jbpm.context.exe.JbpmTypeMatcher;
@@ -30,61 +32,84 @@
import org.jbpm.db.hibernate.Converters;
import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Element;
public class JbpmTypeObjectInfo extends AbstractObjectInfo {
private static final long serialVersionUID = 1L;
-
+
ObjectInfo typeMatcherObjectInfo = null;
Converter converter = null;
Class variableInstanceClass = null;
-
+
public JbpmTypeObjectInfo(Element jbpmTypeElement, ObjectFactoryParser objectFactoryParser) {
super(jbpmTypeElement, objectFactoryParser);
-
+
try {
Element typeMatcherElement = XmlUtil.element(jbpmTypeElement, "matcher");
- if (typeMatcherElement==null) {
- throw new ConfigurationException("matcher is a required element in a jbpm-type: "+XmlUtil.toString(jbpmTypeElement));
+ if (typeMatcherElement == null) {
+ throw new ConfigurationException("matcher is a required element in a jbpm-type: "
+ + XmlUtil.toString(jbpmTypeElement));
}
Element typeMatcherBeanElement = XmlUtil.element(typeMatcherElement);
typeMatcherObjectInfo = objectFactoryParser.parse(typeMatcherBeanElement);
-
+
Element converterElement = XmlUtil.element(jbpmTypeElement, "converter");
- if (converterElement!=null) {
- if (! converterElement.hasAttribute("class")) {
- throw new ConfigurationException("class attribute is required in a converter element: "+XmlUtil.toString(jbpmTypeElement));
+ if (converterElement != null) {
+ if (!converterElement.hasAttribute("class")) {
+ throw new ConfigurationException("class attribute is required in a converter element: "
+ + XmlUtil.toString(jbpmTypeElement));
}
String converterClassName = converterElement.getAttribute("class");
converter = Converters.getConverterByClassName(converterClassName);
}
-
+
Element variableInstanceElement = XmlUtil.element(jbpmTypeElement, "variable-instance");
- if (! variableInstanceElement.hasAttribute("class")) {
- throw new ConfigurationException("class is a required attribute in element variable-instance: "+XmlUtil.toString(jbpmTypeElement));
+ if (!variableInstanceElement.hasAttribute("class")) {
+ throw new ConfigurationException(
+ "class is a required attribute in element variable-instance: "
+ + XmlUtil.toString(jbpmTypeElement));
}
String variableInstanceClassName = variableInstanceElement.getAttribute("class");
- variableInstanceClass = ClassLoaderUtil.loadClass(variableInstanceClassName);
- if (! VariableInstance.class.isAssignableFrom(variableInstanceClass)) {
- throw new ConfigurationException("variable instance class '"+variableInstanceClassName+"' is not a VariableInstance");
+ variableInstanceClass = ClassLoaderUtil.classForName(variableInstanceClassName);
+ if (!VariableInstance.class.isAssignableFrom(variableInstanceClass)) {
+ throw new ConfigurationException("variable instance class '"
+ + variableInstanceClassName
+ + "' is not a VariableInstance");
}
- } catch (ConfigurationException e){
+ }
+ catch (ConfigurationException e) {
throw e;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
// Probably the user doesn't need support for this type and doesn't have a required library in the path.
// So let's log and ignore
- log.debug("jbpm variables type "+XmlUtil.toString(jbpmTypeElement)+" couldn't be instantiated properly: "+e.toString());
+ log.debug("jbpm variables type "
+ + XmlUtil.toString(jbpmTypeElement)
+ + " couldn't be instantiated properly: "
+ + e.toString());
// now, let's make sure that this JbpmType is ignored by always returning false in the JbpmTypeMatcher
typeMatcherObjectInfo = new ObjectInfo() {
+
private static final long serialVersionUID = 1L;
- public boolean hasName() {return false;}
- public String getName() {return null;}
- public boolean isSingleton() {return true;}
+
+ public boolean hasName() {
+ return false;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
public Object createObject(ObjectFactoryImpl objectFactory) {
return new JbpmTypeMatcher() {
+
private static final long serialVersionUID = 1L;
+
public boolean matches(Object value) {
return false;
}
@@ -100,6 +125,6 @@
JbpmTypeMatcher jbpmTypeMatcher = (JbpmTypeMatcher) objectFactory.createObject(typeMatcherObjectInfo);
return new JbpmType(jbpmTypeMatcher, converter, variableInstanceClass);
}
-
+
private static Log log = LogFactory.getLog(JbpmTypeObjectInfo.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -30,11 +30,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmException;
import org.jbpm.util.ClassLoaderUtil;
public class ObjectFactoryImpl implements ObjectFactory {
-
+
private static final long serialVersionUID = 1L;
ClassLoader classLoader = null; // lazy load it later! See below..
@@ -48,17 +49,17 @@
objectInfos = new ArrayList();
namedObjectInfos = new HashMap();
}
-
+
public ObjectFactoryImpl(Map namedObjectInfos, List objectInfos) {
this.namedObjectInfos = namedObjectInfos;
this.objectInfos = objectInfos;
}
-
+
public void addObjectInfo(ObjectInfo objectInfo) {
if (objectInfo.hasName()) {
- log.debug("adding object info '"+objectInfo.getName()+"'");
+ log.debug("adding object info '" + objectInfo.getName() + "'");
Object removed = namedObjectInfos.put(objectInfo.getName(), objectInfo);
- if (removed!=null) {
+ if (removed != null) {
objectInfos.remove(removed);
}
}
@@ -66,14 +67,16 @@
}
/**
- * create a new object of the given name.
- * Before creation starts, the non-singlton objects will be cleared
- * from the registry. The singletons will remain in the registry.
+ * create a new object of the given name. Before creation starts, the non-singlton objects will be
+ * cleared from the registry. The singletons will remain in the registry.
*/
public synchronized Object createObject(String name) {
- ObjectInfo objectInfo = (ObjectInfo)namedObjectInfos.get(name);
- if (objectInfo==null) {
- throw new ConfigurationException("name '"+name+"' is not defined in the configuration. configured names: "+namedObjectInfos.keySet());
+ ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
+ if (objectInfo == null) {
+ throw new ConfigurationException("name '"
+ + name
+ + "' is not defined in the configuration. configured names: "
+ + namedObjectInfos.keySet());
}
return createObject(objectInfo);
}
@@ -81,53 +84,58 @@
public synchronized boolean hasObject(String name) {
return namedObjectInfos.containsKey(name);
}
-
+
/**
- * create a new object for the given index.
- * Before creation starts, the non-singlton objects will be cleared
- * from the registry. The singletons will remain in the registry.
+ * create a new object for the given index. Before creation starts, the non-singlton objects will
+ * be cleared from the registry. The singletons will remain in the registry.
*/
public Object createObject(int index) {
- if ( (index<0) || (index>=objectInfos.size())) {
- throw new ConfigurationException("index '"+index+"' is not defined in the configuration. range [0.."+(objectInfos.size()-1)+"]");
+ if ((index < 0) || (index >= objectInfos.size())) {
+ throw new ConfigurationException("index '"
+ + index
+ + "' is not defined in the configuration. range [0.."
+ + (objectInfos.size() - 1)
+ + "]");
}
- return createObject((ObjectInfo)objectInfos.get(index));
+ return createObject((ObjectInfo) objectInfos.get(index));
}
+
/**
- * create a new object for the given {@link ObjectInfo}.
- * Before creation starts, the non-singlton objects will be cleared
- * from the registry. The singletons will remain in the registry.
+ * create a new object for the given {@link ObjectInfo}. Before creation starts, the non-singlton
+ * objects will be cleared from the registry. The singletons will remain in the registry.
*/
public Object createObject(ObjectInfo objectInfo) {
clearRegistry();
return getObject(objectInfo);
}
-
+
void clearRegistry() {
objects.clear();
objectsUnderConstruction.clear();
}
/**
- * create an object of the given name.
- * If the object was created before, that object is returned from
- * the registry.
+ * create an object of the given name. If the object was created before, that object is returned
+ * from the registry.
*/
Object getObject(String name) {
Object object = null;
ObjectInfo objectInfo = (ObjectInfo) namedObjectInfos.get(name);
- if (objectInfo!=null) {
+ if (objectInfo != null) {
object = getObject(objectInfo);
- } else {
- log.warn("no info for object '"+name+"'. defined objects: "+namedObjectInfos.keySet().toString());
}
+ else {
+ log.warn("no info for object '"
+ + name
+ + "'. defined objects: "
+ + namedObjectInfos.keySet().toString());
+ }
return object;
}
/**
- * create an object for the given {@link ObjectInfo}.
- * If the object was created before, that object is returned from
- * the registry.
+ * create an object for the given {@link ObjectInfo}. If the object was created before, that
+ * object is returned from the registry.
*/
Object getObject(ObjectInfo objectInfo) {
Object object = null;
@@ -135,40 +143,44 @@
Object registryKey = getRegistryKey(objectInfo);
if (isInRegistry(registryKey)) {
object = findInRegistry(registryKey);
-
- } else {
- if (registryKey!=null) {
+
+ }
+ else {
+ if (registryKey != null) {
if (objectsUnderConstruction.contains(registryKey)) {
- throw new JbpmException("circular object dependency on bean '"+registryKey+"'");
+ throw new JbpmException("circular object dependency on bean '" + registryKey + "'");
}
objectsUnderConstruction.add(registryKey);
try {
object = objectInfo.createObject(this);
- } finally {
+ }
+ finally {
objectsUnderConstruction.remove(registryKey);
}
-
+
putInRegistry(objectInfo, object, registryKey);
-
- } else {
+
+ }
+ else {
object = objectInfo.createObject(this);
}
}
return object;
}
- Class loadClass(String className) {
+ Class classForName(String className) {
// "lazy load" classloader, shouldn't be loaded too early
// because if jbpm.cfg.xml is not yet parsed, the correct class loader
// may not be initialized yet.
- if (classLoader==null) {
+ if (classLoader == null) {
classLoader = ClassLoaderUtil.getClassLoader();
- }
+ }
try {
- return classLoader.loadClass(className);
- } catch (ClassNotFoundException e) {
- throw new JbpmException("couldn't load class '"+className+"'", e);
+ return Class.forName(className, false, classLoader);
}
+ catch (ClassNotFoundException e) {
+ throw new JbpmException("couldn't load class '" + className + "'", e);
+ }
}
Object getRegistryKey(ObjectInfo objectInfo) {
@@ -180,29 +192,26 @@
}
boolean isInRegistry(Object registryKey) {
- return ( (registryKey!=null)
- && ( (objects.containsKey(registryKey))
- || (singletons.containsKey(registryKey))
- )
- );
+ return ((registryKey != null) && ((objects.containsKey(registryKey)) || (singletons.containsKey(registryKey))));
}
void putInRegistry(ObjectInfo objectInfo, Object object, Object registryKey) {
if (objectInfo.isSingleton()) {
singletons.put(registryKey, object);
- } else {
+ }
+ else {
objects.put(registryKey, object);
}
}
Object findInRegistry(Object registryKey) {
Object object = null;
- if (registryKey!=null) {
+ if (registryKey != null) {
object = objects.get(registryKey);
- if (object==null) object = singletons.get(registryKey);
+ if (object == null) object = singletons.get(registryKey);
}
return object;
}
-
+
private static Log log = LogFactory.getLog(ObjectFactoryImpl.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -31,14 +31,12 @@
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.job.Job;
import org.jbpm.job.Timer;
import org.jbpm.persistence.JbpmPersistenceException;
-import org.jbpm.util.ArrayUtil;
public class JobSession {
@@ -145,26 +143,6 @@
}
}
- public List loadJobs(long[] jobIds) {
- try {
- return session.createCriteria(Job.class)
- .add(Restrictions.in("id", toObjectArray(jobIds)))
- .list();
- }
- catch (HibernateException e) {
- throw new JbpmPersistenceException("could not load jobs " + ArrayUtil.toString(jobIds), e);
- }
- }
-
- private static Long[] toObjectArray(long[] primitives) {
- final int length = primitives.length;
- Long[] objects = new Long[length];
- for (int i = 0; i < length; i++) {
- objects[i] = new Long(primitives[i]);
- }
- return objects;
- }
-
public Job getJob(long jobId) {
try {
return (Job) session.get(Job.class, new Long(jobId));
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/hibernate/Converters.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/hibernate/Converters.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/hibernate/Converters.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.configuration.ObjectFactory;
@@ -38,21 +39,23 @@
* provides access to the list of converters and ensures that the converter objects are unique.
*/
public abstract class Converters {
-
+
static final int CONVERTERS_BY_CLASS_NAMES = 0;
static final int CONVERTERS_BY_DATABASE_ID = 1;
static final int CONVERTERS_IDS = 2;
static Map converterMapsMap = new HashMap();
-
+
// public methods
public static Converter getConverterByClassName(String className) {
Converter converter = (Converter) getConvertersByClassNames().get(className);
- if (converter==null) {
- throw new JbpmException("converter '"+className+"' is not declared in jbpm.converter.properties");
+ if (converter == null) {
+ throw new JbpmException("converter '"
+ + className
+ + "' is not declared in jbpm.converter.properties");
}
- return converter;
+ return converter;
}
public static Converter getConverterByDatabaseId(String converterDatabaseId) {
@@ -60,7 +63,7 @@
}
public static String getConverterId(Converter converter) {
- return (String) getConvertersIds().get(converter);
+ return (String) getConvertersIds().get(converter);
}
// maps class names to unique converter objects
@@ -72,7 +75,7 @@
static Map getConvertersByDatabaseId() {
return getConverterMaps()[CONVERTERS_BY_DATABASE_ID];
}
-
+
// maps unique converter objects to their database-id-string
static Map getConvertersIds() {
return getConverterMaps()[CONVERTERS_IDS];
@@ -80,10 +83,10 @@
static Map[] getConverterMaps() {
Map[] converterMaps = null;
- synchronized(converterMapsMap) {
+ synchronized (converterMapsMap) {
ObjectFactory objectFactory = JbpmConfiguration.Configs.getObjectFactory();
converterMaps = (Map[]) converterMapsMap.get(objectFactory);
- if (converterMaps==null) {
+ if (converterMaps == null) {
converterMaps = createConverterMaps(objectFactory);
converterMapsMap.put(objectFactory, converterMaps);
}
@@ -105,26 +108,30 @@
if (objectFactory.hasObject("resource.converter")) {
String resource = (String) objectFactory.createObject("resource.converter");
converterProperties = ClassLoaderUtil.getProperties(resource);
- } else {
+ }
+ else {
converterProperties = new Properties();
}
Iterator iter = converterProperties.keySet().iterator();
while (iter.hasNext()) {
String converterDatabaseId = (String) iter.next();
- if (converterDatabaseId.length()!=1) throw new JbpmException("converter-ids must be of length 1 (to be stored in a char)");
- if (convertersByDatabaseId.containsKey(converterDatabaseId)) throw new JbpmException("duplicate converter id : '"+converterDatabaseId+"'");
+ if (converterDatabaseId.length() != 1)
+ throw new JbpmException("converter-ids must be of length 1 (to be stored in a char)");
+ if (convertersByDatabaseId.containsKey(converterDatabaseId))
+ throw new JbpmException("duplicate converter id : '" + converterDatabaseId + "'");
String converterClassName = converterProperties.getProperty(converterDatabaseId);
try {
- Class converterClass = ClassLoaderUtil.loadClass(converterClassName);
+ Class converterClass = ClassLoaderUtil.classForName(converterClassName);
Converter converter = (Converter) converterClass.newInstance();
- log.debug("adding converter '"+converterDatabaseId+"', '"+converterClassName+"'");
+ log.debug("adding converter '" + converterDatabaseId + "', '" + converterClassName + "'");
convertersByClassNames.put(converterClassName, converter);
convertersByDatabaseId.put(converterDatabaseId, converter);
convertersIds.put(converter, converterDatabaseId);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- log.debug("couldn't instantiate converter '"+converterClassName+"': "+e);
+ log.debug("couldn't instantiate converter '" + converterClassName + "': " + e);
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/action/ActionTypes.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/action/ActionTypes.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/action/ActionTypes.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -29,27 +29,27 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.graph.node.NodeTypes;
import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Element;
-
public class ActionTypes {
public static Set getActionTypes() {
return actionNames.keySet();
}
-
+
public static Set getActionNames() {
return actionTypes.keySet();
}
-
+
public static Class getActionType(String name) {
return (Class) actionTypes.get(name);
}
-
+
public static String getActionName(Class type) {
return (String) actionNames.get(type);
}
@@ -61,28 +61,34 @@
static final Log log = LogFactory.getLog(ActionTypes.class);
static Map actionTypes = initialiseActionTypes();
static Map actionNames = NodeTypes.createInverseMapping(actionTypes);
-
+
static Map initialiseActionTypes() {
Map types = new HashMap();
-
+
String resource = JbpmConfiguration.Configs.getString("resource.action.types");
InputStream actionTypesStream = ClassLoaderUtil.getStream(resource);
- Element actionTypesElement = XmlUtil.parseXmlInputStream(actionTypesStream).getDocumentElement();
+ Element actionTypesElement = XmlUtil.parseXmlInputStream(actionTypesStream)
+ .getDocumentElement();
Iterator actionTypeIterator = XmlUtil.elementIterator(actionTypesElement, "action-type");
- while(actionTypeIterator.hasNext()) {
+ while (actionTypeIterator.hasNext()) {
Element actionTypeElement = (Element) actionTypeIterator.next();
String elementTag = actionTypeElement.getAttribute("element");
String className = actionTypeElement.getAttribute("class");
try {
- Class actionClass = ClassLoaderUtil.getClassLoader().loadClass(className);
+ Class actionClass = ClassLoaderUtil.classForName(className);
types.put(elementTag, actionClass);
-
- } catch (Exception e) {
+
+ }
+ catch (Exception e) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
- log.debug("action '"+elementTag+"' will not be available. class '"+className+"' couldn't be loaded");
+ log.debug("action '"
+ + elementTag
+ + "' will not be available. class '"
+ + className
+ + "' couldn't be loaded");
}
}
- return types;
+ return types;
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ExceptionHandler.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ExceptionHandler.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ExceptionHandler.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -41,21 +41,21 @@
public ExceptionHandler() {
}
- public boolean matches( Throwable exception ) {
+ public boolean matches(Throwable exception) {
boolean matches = true;
- if (exceptionClassName!=null) {
- Class clazz = ClassLoaderUtil.loadClass(exceptionClassName);
- if (! clazz.isAssignableFrom(exception.getClass())) {
+ if (exceptionClassName != null) {
+ Class clazz = ClassLoaderUtil.classForName(exceptionClassName);
+ if (!clazz.isAssignableFrom(exception.getClass())) {
matches = false;
}
}
return matches;
}
- public void handleException(GraphElement graphElement, ExecutionContext executionContext) throws Exception {
- if (actions!=null) {
- Iterator iter = actions.iterator();
- while (iter.hasNext()) {
+ public void handleException(GraphElement graphElement, ExecutionContext executionContext)
+ throws Exception {
+ if (actions != null) {
+ for (Iterator iter = actions.iterator(); iter.hasNext();) {
Action action = (Action) iter.next();
graphElement.executeAction(action, executionContext);
}
@@ -67,33 +67,35 @@
public List getActions() {
return actions;
}
-
+
public void addAction(Action action) {
- if (actions==null) actions = new ArrayList();
+ if (actions == null) actions = new ArrayList();
actions.add(action);
}
-
+
public void removeAction(Action action) {
- if (actions!=null) {
+ if (actions != null) {
actions.remove(action);
}
}
public void reorderAction(int oldIndex, int newIndex) {
- if (actions!=null) {
+ if (actions != null) {
actions.add(newIndex, actions.remove(oldIndex));
}
}
// getters and setters
/////////////////////////////////////////////////////////////////////////////
-
+
public String getExceptionClassName() {
return exceptionClassName;
}
+
public void setExceptionClassName(String exceptionClassName) {
this.exceptionClassName = exceptionClassName;
}
+
public GraphElement getGraphElement() {
return graphElement;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/def/ProcessDefinition.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -89,12 +89,11 @@
// now add all the default modules that are configured in the file jbpm.default.modules
String resource = JbpmConfiguration.Configs.getString("resource.default.modules");
Properties defaultModulesProperties = ClassLoaderUtil.getProperties(resource);
- Iterator iter = defaultModulesProperties.keySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = defaultModulesProperties.keySet().iterator(); iter.hasNext();) {
String moduleClassName = (String) iter.next();
try {
- ModuleDefinition moduleDefinition = (ModuleDefinition) ClassLoaderUtil.loadClass(
- moduleClassName).newInstance();
+ ModuleDefinition moduleDefinition = (ModuleDefinition) ClassLoaderUtil.classForName(moduleClassName)
+ .newInstance();
processDefinition.addDefinition(moduleDefinition);
}
@@ -128,7 +127,7 @@
}
public void setProcessDefinition(ProcessDefinition processDefinition) {
- if (!this.equals(processDefinition)) {
+ if (!equals(processDefinition)) {
throw new JbpmException(
"can't set the process-definition-property of a process defition to something else then a self-reference");
}
@@ -212,8 +211,7 @@
if (nodesMap == null) {
nodesMap = new HashMap();
if (nodes != null) {
- Iterator iter = nodes.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = nodes.iterator(); iter.hasNext();) {
Node node = (Node) iter.next();
nodesMap.put(node.getName(), node);
}
@@ -309,8 +307,7 @@
}
static boolean containsName(List nodes, String name) {
- Iterator iter = nodes.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = nodes.iterator(); iter.hasNext();) {
Node node = (Node) iter.next();
if (name.equals(node.getName())) {
return true;
@@ -321,9 +318,9 @@
public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) {
Node node = null;
- if ((hierarchicalName != null) && (!"".equals(hierarchicalName.trim()))) {
+ if (hierarchicalName != null && hierarchicalName.trim().length() > 0) {
- if ((hierarchicalName.startsWith("/")) && (nodeCollection instanceof SuperState)) {
+ if (hierarchicalName.startsWith("/") && nodeCollection instanceof SuperState) {
nodeCollection = ((SuperState) nodeCollection).getProcessDefinition();
}
@@ -350,7 +347,7 @@
}
public void setStartState(StartState startState) {
- if ((this.startState != startState) && (this.startState != null)) {
+ if (this.startState != startState && this.startState != null) {
removeNode(this.startState);
}
this.startState = startState;
@@ -385,7 +382,7 @@
* removes the bidirectional relation between this process definition and the given action.
*
* @throws IllegalArgumentException if action is null or if the action was not present in the
- * actions of this process definition.
+ * actions of this process definition.
*/
public void removeAction(Action action) {
if (action == null)
@@ -410,7 +407,7 @@
}
public boolean hasActions() {
- return ((actions != null) && (actions.size() > 0));
+ return actions != null && !actions.isEmpty();
}
// module definitions ///////////////////////////////////////////////////////
@@ -420,9 +417,10 @@
}
public ModuleDefinition addDefinition(ModuleDefinition moduleDefinition) {
- if (moduleDefinition == null)
+ if (moduleDefinition == null) {
throw new IllegalArgumentException(
"can't add a null moduleDefinition to a process definition");
+ }
if (definitions == null) definitions = new HashMap();
definitions.put(moduleDefinition.getClass().getName(), moduleDefinition);
moduleDefinition.setProcessDefinition(this);
@@ -431,9 +429,10 @@
public ModuleDefinition removeDefinition(ModuleDefinition moduleDefinition) {
ModuleDefinition removedDefinition = null;
- if (moduleDefinition == null)
+ if (moduleDefinition == null) {
throw new IllegalArgumentException(
"can't remove a null moduleDefinition from a process definition");
+ }
if (definitions != null) {
removedDefinition = (ModuleDefinition) definitions.remove(moduleDefinition.getClass()
.getName());
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/NodeTypes.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/NodeTypes.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/node/NodeTypes.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -29,34 +29,35 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Element;
public class NodeTypes {
public static Set getNodeTypes() {
return nodeTypes.keySet();
}
-
+
public static Set getNodeNames() {
return nodeNames.keySet();
}
-
+
public static Class getNodeType(String name) {
return (Class) nodeTypes.get(name);
}
-
+
public static String getNodeName(Class type) {
return (String) nodeNames.get(type);
}
-
+
private static final Log log = LogFactory.getLog(NodeTypes.class);
static Map nodeTypes = initialiseNodeTypes();
static Map nodeNames = createInverseMapping(nodeTypes);
-
+
static Map initialiseNodeTypes() {
Map types = new HashMap();
@@ -64,29 +65,33 @@
InputStream actionTypesStream = ClassLoaderUtil.getStream(resource);
Element nodeTypesElement = XmlUtil.parseXmlInputStream(actionTypesStream).getDocumentElement();
Iterator nodeTypeIterator = XmlUtil.elementIterator(nodeTypesElement, "node-type");
- while(nodeTypeIterator.hasNext()) {
+ while (nodeTypeIterator.hasNext()) {
Element nodeTypeElement = (Element) nodeTypeIterator.next();
String elementTag = nodeTypeElement.getAttribute("element");
String className = nodeTypeElement.getAttribute("class");
try {
- Class nodeClass = ClassLoaderUtil.getClassLoader().loadClass(className);
+ Class nodeClass = ClassLoaderUtil.classForName(className);
types.put(elementTag, nodeClass);
-
- } catch (Exception e) {
+
+ }
+ catch (Exception e) {
if (!"org.jboss.seam.jbpm.Page".equals(className)) {
- log.debug("node '"+elementTag+"' will not be available. class '"+className+"' couldn't be loaded");
+ log.debug("node '"
+ + elementTag
+ + "' will not be available. class '"
+ + className
+ + "' couldn't be loaded");
}
}
}
- return types;
+ return types;
}
public static Map createInverseMapping(Map map) {
Map names = new HashMap();
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
names.put(entry.getValue(), entry.getKey());
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/BeanInstantiator.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/BeanInstantiator.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/BeanInstantiator.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -21,6 +21,7 @@
*/
package org.jbpm.instantiation;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.commons.logging.Log;
@@ -28,47 +29,54 @@
import org.dom4j.Element;
public class BeanInstantiator extends FieldInstantiator implements Instantiator {
-
- protected void setPropertyValue(Class clazz, Object newInstance, String propertyName, Element propertyElement) {
- try {
- // create the setter method name from the property name
- String setterMethodName = "set"+propertyName.substring(0,1).toUpperCase()+propertyName.substring(1);
-
- // find the setter method
- Method method = findSetter(clazz, setterMethodName);
- // if the setter method was found
- if (method!=null) {
- // make it accessible
- method.setAccessible(true);
- // invoke it
- Class propertyType = method.getParameterTypes()[0];
- method.invoke(newInstance, new Object[]{ getValue(propertyType, propertyElement) });
- } else {
- log.error( "couldn't set property '"+propertyName+"' to value '"+propertyElement.asXML()+"'" );
+ protected void setPropertyValue(Class clazz, Object newInstance, String propertyName,
+ Element propertyElement) {
+ // create the setter method name from the property name
+ String setterMethodName = "set"
+ + Character.toUpperCase(propertyName.charAt(0))
+ + propertyName.substring(1);
+
+ // find the setter method
+ Method method = findSetter(clazz, setterMethodName);
+
+ // if the setter method was found
+ if (method != null) {
+ // make it accessible
+ method.setAccessible(true);
+ // invoke it
+ Class propertyType = method.getParameterTypes()[0];
+ Object value = getValue(propertyType, propertyElement);
+ try {
+ method.invoke(newInstance, new Object[] { value });
}
- } catch (Exception e) {
- log.error( "couldn't parse property '"+propertyName+"' to value '"+propertyElement.asXML()+"'", e );
+ catch (IllegalArgumentException e) {
+ log.error("property '" + propertyName + "' cannot be set to value: " + value, e);
+ }
+ catch (IllegalAccessException e) {
+ log.error("property '" + propertyName + "' is inaccessible", e);
+ }
+ catch (InvocationTargetException e) {
+ log.error("property setter '" + setterMethodName + "' threw exception", e.getCause());
+ }
}
+ else {
+ log.error("property '" + propertyName + "' has no setter method");
+ }
}
-
+
private Method findSetter(Class clazz, String setterMethodName) {
- Method method = null;
- Method[] methods = clazz.getDeclaredMethods();
- for( int i=0; ( (i<methods.length)
- && (method==null) ); i++) {
- if ( (setterMethodName.equals(methods[i].getName()))
- && (methods[i].getParameterTypes()!=null)
- && (methods[i].getParameterTypes().length==1) ) {
- method = methods[i];
+ do {
+ Method[] methods = clazz.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ if (method.getName().equals(setterMethodName) && method.getParameterTypes().length == 1)
+ return method;
}
- }
- if ( (method==null)
- && (clazz!=Object.class)
- ) {
- method = findSetter(clazz.getSuperclass(), setterMethodName);
- }
- return method;
+ clazz = clazz.getSuperclass();
+ } while (clazz != null);
+
+ return null;
}
private static final Log log = LogFactory.getLog(BeanInstantiator.class);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -34,28 +33,30 @@
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
-import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
-import org.jbpm.JbpmConfiguration;
+
import org.jbpm.JbpmException;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
-import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.EqualsUtil;
public class Delegation implements Parsable, Serializable {
private static final long serialVersionUID = 1L;
-
- protected static Map instantiatorCache = new HashMap();
- static {
- instantiatorCache.put(null, new FieldInstantiator());
- instantiatorCache.put("field", new FieldInstantiator());
- instantiatorCache.put("bean", new BeanInstantiator());
- instantiatorCache.put("constructor", new ConstructorInstantiator());
- instantiatorCache.put("configuration-property", new ConfigurationPropertyInstantiator());
+
+ protected static Map instantiatorCache = createInstantiatorCache();
+
+ private static Map createInstantiatorCache() {
+ Map instantiators = new HashMap();
+ instantiators.put(null, new FieldInstantiator());
+ instantiators.put("field", new FieldInstantiator());
+ instantiators.put("bean", new BeanInstantiator());
+ instantiators.put("constructor", new ConstructorInstantiator());
+ instantiators.put("configuration-property", new ConfigurationPropertyInstantiator());
+ instantiators.put("xml", new XmlInstantiator());
+ return instantiators;
}
long id = 0;
@@ -79,26 +80,27 @@
public void read(Element delegateElement, JpdlXmlReader jpdlReader) {
processDefinition = jpdlReader.getProcessDefinition();
className = delegateElement.attributeValue("class");
- if (className==null) {
- jpdlReader.addWarning("no class specified in "+delegateElement.asXML());
+ if (className == null) {
+ jpdlReader.addWarning("no class specified in " + delegateElement.asXML());
}
-
+
configType = delegateElement.attributeValue("config-type");
- if ( delegateElement.hasContent() ) {
+ if (delegateElement.hasContent()) {
try {
StringWriter stringWriter = new StringWriter();
// when parsing, it could be to store the config in the database, so we want to make the configuration compact
- XMLWriter xmlWriter = new XMLWriter( stringWriter, OutputFormat.createCompactFormat() );
- Iterator iter = delegateElement.content().iterator();
- while (iter.hasNext()) {
+ XMLWriter xmlWriter = new XMLWriter(stringWriter, OutputFormat.createCompactFormat());
+ for (Iterator iter = delegateElement.content().iterator(); iter.hasNext();) {
Object node = iter.next();
- xmlWriter.write( node );
+ xmlWriter.write(node);
}
xmlWriter.flush();
configuration = stringWriter.toString();
- } catch (IOException e) {
- jpdlReader.addWarning("io problem while parsing the configuration of "+delegateElement.asXML());
}
+ catch (IOException e) {
+ jpdlReader.addWarning("io problem while parsing the configuration of "
+ + delegateElement.asXML());
+ }
}
}
@@ -106,71 +108,65 @@
element.addAttribute("class", className);
element.addAttribute("config-type", configType);
String configuration = this.configuration;
- if (configuration!=null) {
+ if (configuration != null) {
try {
- Element actionElement = DocumentHelper.parseText( "<action>"+configuration+"</action>" ).getRootElement();
- Iterator iter = new ArrayList( actionElement.content() ).iterator();
- while (iter.hasNext()) {
- Node node = (Node)iter.next();
- node.setParent(null);
- element.add( node );
- }
- } catch (DocumentException e) {
- log.error("couldn't create dom-tree for action configuration '"+configuration+"'", e);
+ Element actionElement = DocumentHelper.parseText("<action>" + configuration + "</action>")
+ .getRootElement();
+ element.appendContent(actionElement);
}
+ catch (DocumentException e) {
+ log.error("couldn't create dom-tree for action configuration '" + configuration + "'", e);
+ }
}
}
public Object getInstance() {
- if (instance==null) {
+ if (instance == null) {
instance = instantiate();
}
return instance;
}
public Object instantiate() {
-
- Object newInstance = null;
-
- // The thread class loader was set before the instantiation correctly
- // to the ProcesClassLoader which can be directly used here
+ // The thread class loader was set before the instantiation correctly
+ // to the ProcessClassLoader which can be directly used here
// If we would construct a JbpmConfiguration.getProcessClassLoder here
// we would have the hierarchy ProcessClassLoader -> ProcessClassLoader -> Context...
// this is one ProcessClassLoader too much
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- // load the class that needs to be instantiated
- Class clazz = null;
- try {
- clazz = classLoader.loadClass(className);
- } catch (ClassNotFoundException e) {
- log.error("couldn't load delegation class '"+className+"'", e);
- }
- Instantiator instantiator = null;
- try {
- // find the instantiator
- instantiator = (Instantiator) instantiatorCache.get(configType);
- if (instantiator == null) {
+ // find the instantiator
+ Instantiator instantiator = (Instantiator) instantiatorCache.get(configType);
+ if (instantiator == null) {
+ try {
// load the instantiator class
- Class instantiatorClass = classLoader.loadClass(configType);
+ Class instantiatorClass = Class.forName(configType, false, classLoader);
// instantiate the instantiator with the default constructor
instantiator = (Instantiator) instantiatorClass.newInstance();
instantiatorCache.put(configType, instantiator);
}
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't instantiate custom instantiator '" + configType + "'", e);
+ catch (ClassNotFoundException e) {
+ throw new JbpmException("could not load instantiator class '" + configType + "'", e);
+ }
+ catch (InstantiationException e) {
+ throw new JbpmException("could not instantiate " + configType, e);
+ }
+ catch (IllegalAccessException e) {
+ throw new JbpmException("could not access " + configType, e);
+ }
}
-
+
+ // load the class that needs to be instantiated
+ Class delegationClass = null;
try {
- // instantiate the object
- newInstance = instantiator.instantiate(clazz, configuration);
- } catch (RuntimeException e) {
- log.error("couldn't instantiate delegation class '"+className+"'", e);
+ delegationClass = Class.forName(className, false, classLoader);
}
+ catch (ClassNotFoundException e) {
+ log.error("couldn't load delegation class '" + className + "'", e);
+ }
- return newInstance;
+ // instantiate the object
+ return instantiator.instantiate(delegationClass, configuration);
}
// equals ///////////////////////////////////////////////////////////////////
@@ -179,36 +175,45 @@
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
// getters and setters //////////////////////////////////////////////////////
public String getClassName() {
return className;
}
+
public void setClassName(String className) {
this.className = className;
}
+
public String getConfiguration() {
return configuration;
}
+
public void setConfiguration(String configuration) {
this.configuration = configuration;
}
+
public String getConfigType() {
return configType;
}
+
public void setConfigType(String instantiatorType) {
this.configType = instantiatorType;
}
+
public long getId() {
return id;
}
+
public void setId(long id) {
this.id = id;
}
- public ProcessDefinition getProcessDefinition() {
+
+ public ProcessDefinition getProcessDefinition() {
return processDefinition;
}
+
public void setProcessDefinition(ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/instantiation/FieldInstantiator.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -23,6 +23,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -41,6 +42,7 @@
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
+
import org.jbpm.JbpmException;
import org.jbpm.util.ClassLoaderUtil;
@@ -51,15 +53,12 @@
// create a new instance with the default constructor
Object newInstance = newInstance(clazz);
- if ( (configuration!=null)
- && (! "".equals(configuration))
- ) {
+ if (configuration != null && configuration.length() > 0) {
// parse the bean configuration
Element configurationElement = parseConfiguration(configuration);
-
+
// loop over the configured properties
- Iterator iter = configurationElement.elements().iterator();
- while( iter.hasNext() ) {
+ for (Iterator iter = configurationElement.elementIterator(); iter.hasNext();) {
Element propertyElement = (Element) iter.next();
String propertyName = propertyElement.getName();
setPropertyValue(clazz, newInstance, propertyName, propertyElement);
@@ -67,35 +66,48 @@
}
return newInstance;
}
-
- protected void setPropertyValue(Class clazz, Object newInstance, String propertyName, Element propertyElement) {
- try {
- Field f = findField(clazz, propertyName);
- f.setAccessible(true);
- f.set(newInstance, getValue(f.getType(), propertyElement));
- } catch (Exception e) {
- log.error( "couldn't parse set field '"+propertyName+"' to value '"+propertyElement.asXML()+"'", e );
+
+ protected void setPropertyValue(Class clazz, Object instance, String propertyName,
+ Element propertyElement) {
+ Field field = findField(clazz, propertyName);
+ if (field != null) {
+ field.setAccessible(true);
+ Object value = getValue(field.getType(), propertyElement);
+ try {
+ field.set(instance, value);
+ }
+ catch (IllegalArgumentException e) {
+ log.error("field '" + propertyName + "' cannot be set to value: " + value, e);
+ }
+ catch (IllegalAccessException e) {
+ log.error(" field '" + propertyName + "' is inaccessible", e);
+ }
}
+ else {
+ log.error("field '" + propertyName + "' was not found");
+ }
}
- private Field findField(Class clazz, String propertyName) throws NoSuchFieldException {
- Field f = null;
- if (clazz!=null) {
+ private Field findField(Class clazz, String propertyName) {
+ do {
try {
- f = clazz.getDeclaredField(propertyName);
- } catch (NoSuchFieldException e) {
- f = findField(clazz.getSuperclass(), propertyName);
+ return clazz.getDeclaredField(propertyName);
}
- }
- return f;
+ catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ } while (clazz != null);
+
+ return null;
}
protected Element parseConfiguration(String configuration) {
Element element = null;
try {
- element = DocumentHelper.parseText( "<action>"+configuration+"</action>" ).getRootElement();
- } catch (DocumentException e) {
- log.error( "couldn't parse bean configuration : " + configuration, e );
+ element = DocumentHelper.parseText("<action>" + configuration + "</action>").getRootElement();
+ }
+ catch (DocumentException e) {
+ log.error("couldn't parse bean configuration : " + configuration, e);
throw new JbpmException(e);
}
return element;
@@ -105,8 +117,9 @@
Object newInstance = null;
try {
newInstance = clazz.newInstance();
- } catch (Exception e) {
- log.error( "couldn't instantiate type '" + clazz.getName() + "' with the default constructor" );
+ }
+ catch (Exception e) {
+ log.error("couldn't instantiate type '" + clazz.getName() + "' with the default constructor");
throw new JbpmException(e);
}
return newInstance;
@@ -115,93 +128,125 @@
public static Object getValue(Class type, Element propertyElement) {
// parse the value
Object value = null;
- try {
-
- if ( type == String.class ) {
- value = propertyElement.getText();
- } else if ( (type==Integer.class) || (type==int.class) ) {
- value = new Integer( propertyElement.getTextTrim() );
- } else if ( (type==Long.class) || (type==long.class) ) {
- value = new Long( propertyElement.getTextTrim() );
- } else if ( (type==Float.class ) || (type==float.class) ) {
- value = new Float( propertyElement.getTextTrim() );
- } else if ( (type==Double.class ) || (type==double.class) ) {
- value = new Double( propertyElement.getTextTrim() );
- } else if ( (type==Boolean.class ) || (type==boolean.class) ) {
- value = Boolean.valueOf( propertyElement.getTextTrim() );
- } else if ( (type==Character.class ) || (type==char.class) ) {
- value = new Character( propertyElement.getTextTrim().charAt(0) );
- } else if ( (type==Short.class ) || (type==short.class) ) {
- value = new Short( propertyElement.getTextTrim() );
- } else if ( (type==Byte.class ) || (type==byte.class) ) {
- value = new Byte( propertyElement.getTextTrim() );
- } else if (type==List.class || type==Collection.class) {
- value = getCollection(propertyElement, new ArrayList());
- } else if (type==Set.class) {
- value = getCollection(propertyElement, new HashSet());
- } else if (type==SortedSet.class) {
- value = getCollection(propertyElement, new TreeSet());
- } else if (Collection.class.isAssignableFrom(type)) {
- value = getCollection(propertyElement, (Collection)type.newInstance());
- } else if (type==Map.class) {
- value = getMap(propertyElement, new HashMap());
- } else if (type==SortedMap.class) {
- value = getMap(propertyElement, new TreeMap());
- } else if (Map.class.isAssignableFrom(type)) {
- value = getMap(propertyElement, (Map)type.newInstance());
- } else if ( Element.class.isAssignableFrom(type) ) {
- value = propertyElement;
- } else {
- Constructor constructor = type.getConstructor(new Class[]{String.class});
- if ( (propertyElement.isTextOnly())
- && (constructor!=null) ) {
- value = constructor.newInstance(new Object[]{propertyElement.getTextTrim()});
+ if (type == String.class) {
+ value = propertyElement.getText();
+ }
+ else if ((type == Integer.class) || (type == int.class)) {
+ value = new Integer(propertyElement.getTextTrim());
+ }
+ else if ((type == Long.class) || (type == long.class)) {
+ value = new Long(propertyElement.getTextTrim());
+ }
+ else if ((type == Float.class) || (type == float.class)) {
+ value = new Float(propertyElement.getTextTrim());
+ }
+ else if ((type == Double.class) || (type == double.class)) {
+ value = new Double(propertyElement.getTextTrim());
+ }
+ else if ((type == Boolean.class) || (type == boolean.class)) {
+ value = Boolean.valueOf(propertyElement.getTextTrim());
+ }
+ else if ((type == Character.class) || (type == char.class)) {
+ value = new Character(propertyElement.getTextTrim().charAt(0));
+ }
+ else if ((type == Short.class) || (type == short.class)) {
+ value = new Short(propertyElement.getTextTrim());
+ }
+ else if ((type == Byte.class) || (type == byte.class)) {
+ value = new Byte(propertyElement.getTextTrim());
+ }
+ else if (type == List.class || type == Collection.class) {
+ value = getCollection(propertyElement, new ArrayList());
+ }
+ else if (type == Set.class) {
+ value = getCollection(propertyElement, new HashSet());
+ }
+ else if (type == SortedSet.class) {
+ value = getCollection(propertyElement, new TreeSet());
+ }
+ else if (type == Map.class) {
+ value = getMap(propertyElement, new HashMap());
+ }
+ else if (type == SortedMap.class) {
+ value = getMap(propertyElement, new TreeMap());
+ }
+ else if (Element.class.isAssignableFrom(type)) {
+ value = propertyElement;
+ }
+ else {
+ try {
+ if (Collection.class.isAssignableFrom(type)) {
+ value = getCollection(propertyElement, (Collection) type.newInstance());
}
+ else if (Map.class.isAssignableFrom(type)) {
+ value = getMap(propertyElement, (Map) type.newInstance());
+ }
+ else {
+ try {
+ Constructor constructor = type.getConstructor(new Class[] { String.class });
+ if (propertyElement.isTextOnly()) {
+ value = constructor.newInstance(new Object[] { propertyElement.getTextTrim() });
+ }
+ else {
+ log.error("element '" + propertyElement.getName() + "' has non-text content");
+ }
+ }
+ catch (NoSuchMethodException e) {
+ log.error(type + " does not have a string constructor", e);
+ }
+ catch (IllegalArgumentException e) {
+ log.error(type + " cannot be constructed with value " + propertyElement.getTextTrim(), e);
+ }
+ }
}
- } catch (Exception e) {
- log.error("couldn't parse the bean property value '" + propertyElement.asXML() + "' to a '" + type.getName() + "'" );
- throw new JbpmException( e );
+ catch (InstantiationException e) {
+ log.error("could not instantiate " + type, e);
+ }
+ catch (IllegalAccessException e) {
+ log.error(type + " is inaccessible", e);
+ }
+ catch (InvocationTargetException e) {
+ log.error("constructor for " + type + " threw exception", e.getCause());
+ }
}
return value;
}
- static Object getMap(Element mapElement, Map map) {
- Class keyClass = String.class;
- String keyType = mapElement.attributeValue("key-type");
- if (keyType!=null) {
- keyClass = ClassLoaderUtil.loadClass(keyType);
- }
+ private static Map getMap(Element mapElement, Map map) {
+ Class keyClass = classForAttributeValue(mapElement, "key-type");
+ Class valueClass = classForAttributeValue(mapElement, "value-type");
- Class valueClass = String.class;
- String valueType = mapElement.attributeValue("value-type");
- if (valueType!=null) {
- valueClass = ClassLoaderUtil.loadClass(valueType);
- }
-
- Iterator iter = mapElement.elementIterator();
- while (iter.hasNext()) {
+ for (Iterator iter = mapElement.elementIterator(); iter.hasNext();) {
Element element = (Element) iter.next();
Element keyElement = element.element("key");
Element valueElement = element.element("value");
-
+
map.put(getValue(keyClass, keyElement), getValue(valueClass, valueElement));
}
return map;
}
static Object getCollection(Element collectionElement, Collection collection) {
- Class elementClass = String.class;
- String elementType = collectionElement.attributeValue("element-type");
- if (elementType!=null) {
- elementClass = ClassLoaderUtil.loadClass(elementType);
- }
- Iterator iter = collectionElement.elementIterator();
- while (iter.hasNext()) {
+ Class elementClass = classForAttributeValue(collectionElement, "element-type");
+
+ for (Iterator iter = collectionElement.elementIterator(); iter.hasNext();) {
Element element = (Element) iter.next();
collection.add(getValue(elementClass, element));
}
return collection;
}
+ /**
+ * Returns the <code>Class</code> associated with the value for the attribute with the given name.
+ */
+ private static Class classForAttributeValue(Element element, String attributeName) {
+ Class type = String.class;
+ String attributeValue = element.attributeValue(attributeName);
+ if (attributeValue != null) {
+ type = ClassLoaderUtil.classForName(attributeValue);
+ }
+ return type;
+ }
+
private static final Log log = LogFactory.getLog(FieldInstantiator.class);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/par/ProcessArchive.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/par/ProcessArchive.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/jpdl/par/ProcessArchive.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -32,6 +32,9 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.ProcessDefinition;
@@ -41,11 +44,8 @@
import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.IoUtil;
import org.jbpm.util.XmlUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-public class ProcessArchive implements ProblemListener
-{
+public class ProcessArchive implements ProblemListener {
private static final long serialVersionUID = 1L;
@@ -60,15 +60,12 @@
// constructors /////////////////////////////////////////////////////////////
- public ProcessArchive(ZipInputStream zipInputStream) throws IOException
- {
+ public ProcessArchive(ZipInputStream zipInputStream) throws IOException {
ZipEntry zipEntry = zipInputStream.getNextEntry();
- while (zipEntry != null)
- {
+ while (zipEntry != null) {
String entryName = zipEntry.getName();
byte[] bytes = IoUtil.readBytes(zipInputStream);
- if (bytes != null)
- {
+ if (bytes != null) {
entries.put(entryName, bytes);
}
zipEntry = zipInputStream.getNextEntry();
@@ -77,17 +74,14 @@
// parse the process definition from the contents ///////////////////////////
- public ProcessDefinition parseProcessDefinition()
- {
+ public ProcessDefinition parseProcessDefinition() {
ProcessDefinition processDefinition = ProcessDefinition.createNewProcessDefinition();
Iterator iter = processArchiveParsers.iterator();
- while (iter.hasNext())
- {
- ProcessArchiveParser processArchiveParser = (ProcessArchiveParser)iter.next();
+ while (iter.hasNext()) {
+ ProcessArchiveParser processArchiveParser = (ProcessArchiveParser) iter.next();
processDefinition = processArchiveParser.readFromArchive(this, processDefinition);
}
- if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR))
- {
+ if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
throw new JpdlException(problems);
}
return processDefinition;
@@ -95,74 +89,61 @@
// methods for the process archive parsers //////////////////////////////////
- public String toString()
- {
+ public String toString() {
return "process-archive(" + name + ")";
}
- public Map getEntries()
- {
+ public Map getEntries() {
return entries;
}
- public byte[] getEntry(String entryName)
- {
- return (byte[])entries.get(entryName);
+ public byte[] getEntry(String entryName) {
+ return (byte[]) entries.get(entryName);
}
- public InputStream getEntryInputStream(String entryName)
- {
+ public InputStream getEntryInputStream(String entryName) {
return new ByteArrayInputStream(getEntry(entryName));
}
- public byte[] removeEntry(String entryName)
- {
- return (byte[])entries.remove(entryName);
+ public byte[] removeEntry(String entryName) {
+ return (byte[]) entries.remove(entryName);
}
- public InputStream removeEntryInputStream(String entryName)
- {
+ public InputStream removeEntryInputStream(String entryName) {
return new ByteArrayInputStream(removeEntry(entryName));
}
- public void addProblem(Problem problem)
- {
+ public void addProblem(Problem problem) {
problems.add(problem);
}
- public List getProblems()
- {
+ public List getProblems() {
return problems;
}
- public void resetProblems()
- {
+ public void resetProblems() {
problems = new ArrayList();
}
- static List getProcessArchiveParsers()
- {
+ static List getProcessArchiveParsers() {
List processArchiveParsers = new ArrayList();
- try
- {
+ try {
String resource = JbpmConfiguration.Configs.getString("resource.parsers");
InputStream parsersStream = ClassLoaderUtil.getStream(resource);
Document document = XmlUtil.parseXmlInputStream(parsersStream);
Iterator iter = XmlUtil.elementIterator(document.getDocumentElement(), "parser");
- while (iter.hasNext())
- {
- Element element = (Element)iter.next();
+ while (iter.hasNext()) {
+ Element element = (Element) iter.next();
String className = element.getAttribute("class");
- ProcessArchiveParser processArchiveParser = (ProcessArchiveParser)ClassLoaderUtil.loadClass(className).newInstance();
- if (processArchiveParser instanceof ConfigurableParser)
- {
- ((ConfigurableParser)processArchiveParser).configure(element);
+ ProcessArchiveParser processArchiveParser = (ProcessArchiveParser) ClassLoaderUtil.classForName(className)
+ .newInstance();
+ if (processArchiveParser instanceof ConfigurableParser) {
+ ((ConfigurableParser) processArchiveParser).configure(element);
}
processArchiveParsers.add(processArchiveParser);
}
}
- catch (Exception e)
- {
+ catch (Exception e) {
throw new JbpmException("couldn't parse process archive parsers (jbpm.parsers.xml)", e);
}
return processArchiveParsers;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/module/def/ModuleDefinition.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -21,21 +21,24 @@
*/
package org.jbpm.module.def;
-import java.io.*;
+import java.io.Serializable;
-import org.jbpm.graph.def.*;
-import org.jbpm.module.exe.*;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.module.exe.ModuleInstance;
import org.jbpm.util.EqualsUtil;
public abstract class ModuleDefinition implements Serializable {
- long id = 0;
- protected String name = null;
- protected ProcessDefinition processDefinition = null;
-
- public ModuleDefinition() {
+ long id;
+ protected String name;
+ protected ProcessDefinition processDefinition;
+
+ private static final long serialVersionUID = 1L;
+
+ protected ModuleDefinition() {
+ // for invocation by subclasses
}
-
+
public abstract ModuleInstance createInstance();
// equals ///////////////////////////////////////////////////////////////////
@@ -44,18 +47,21 @@
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
// getters and setters //////////////////////////////////////////////////////
public long getId() {
return id;
}
+
public String getName() {
return name;
}
+
public ProcessDefinition getProcessDefinition() {
return processDefinition;
}
+
public void setProcessDefinition(ProcessDefinition processDefinition) {
this.processDefinition = processDefinition;
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/security/authentication/SubjectAuthenticationService.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -80,7 +80,7 @@
}
protected void initPrincipalClass(String principalClassName) {
- this.principalClass = ClassLoaderUtil.loadClass(principalClassName);
+ this.principalClass = ClassLoaderUtil.classForName(principalClassName);
}
public String getActorId() {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -57,7 +57,7 @@
public static Class classForName(String className) {
try {
- return Class.forName(className, true, getClassLoader());
+ return Class.forName(className, false, getClassLoader());
}
catch (ClassNotFoundException e) {
throw new JbpmException("class not found: " + className, e);
@@ -69,12 +69,12 @@
// try context class loader first, so that applications can override provided classes
try {
- return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
+ return Class.forName(className, false, Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException e) {
// try the class loader of the current class
try {
- return Class.forName(className);
+ return Class.forName(className, false, ClassLoaderUtil.class.getClassLoader());
}
catch (ClassNotFoundException e2) {
// give up
@@ -167,7 +167,7 @@
}
catch (IOException e) {
Log log = LogFactory.getLog(ClassLoaderUtil.class);
- log.warn("failed to close stream from resource: " + resource, e);
+ log.warn("failed to close resource: " + resource, e);
}
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/util/EqualsUtil.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -28,19 +28,20 @@
}
public static boolean equals(Object thisObject, Object otherObject) {
- if ( (thisObject==null) || (otherObject==null) ) return false;
-
+ if ((thisObject == null) || (otherObject == null)) return false;
+
if (isProxy(otherObject)) {
return otherObject.equals(thisObject);
- } else {
- return otherObject==thisObject;
}
+ else {
+ return otherObject == thisObject;
+ }
}
static boolean isInitialized = false;
static boolean isHibernateInClasspth = true;
static Class hibernateProxyClass = null;
-
+
static boolean isProxy(Object otherObject) {
boolean isProxy = false;
if (!isInitialized) initializeHibernateProxyClass();
@@ -53,8 +54,9 @@
static synchronized void initializeHibernateProxyClass() {
try {
- hibernateProxyClass = ClassLoaderUtil.getClassLoader().loadClass("org.hibernate.proxy.HibernateProxy");
- } catch (ClassNotFoundException e) {
+ hibernateProxyClass = ClassLoaderUtil.classForName("org.hibernate.proxy.HibernateProxy");
+ }
+ catch (RuntimeException e) {
isHibernateInClasspth = false;
}
isInitialized = true;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/SerializabilityTest.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -96,7 +96,7 @@
}
private void assertSerializabilityOfClass(String className) {
- Class clazz = ClassLoaderUtil.loadClass(className);
+ Class clazz = ClassLoaderUtil.classForName(className);
if (!(Serializable.class.isAssignableFrom(clazz)
|| Modifier.isAbstract(clazz.getModifiers())
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -23,16 +23,17 @@
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
+
import org.jbpm.db.hibernate.HibernateHelper;
import org.jbpm.util.ClassLoaderUtil;
public abstract class CustomSessionFactoryFactory {
String extraClassMapping = null;
-
+
public static SessionFactory createSessionFactory(String extraClassMapping) {
Configuration configuration = HibernateHelper.createConfiguration(null, null);
- Class clazz = ClassLoaderUtil.loadClass(extraClassMapping);
+ Class clazz = ClassLoaderUtil.classForName(extraClassMapping);
configuration.addClass(clazz);
return HibernateHelper.createSessionFactory(configuration, false);
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessArchiveClassLoadingDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessArchiveClassLoadingDbTest.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessArchiveClassLoadingDbTest.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -32,6 +32,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
@@ -54,10 +55,8 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(baos);
addEntry(zipOutputStream, "processdefinition.xml", "org/jbpm/jpdl/par/resourceprocess.xml");
- addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/ResourceAction.class",
- "org/jbpm/jpdl/par/ResourceAction.class");
- addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/classresource.txt",
- "org/jbpm/jpdl/par/classresource.txt");
+ addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/ResourceAction.class", "org/jbpm/jpdl/par/ResourceAction.class");
+ addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/classresource.txt", "org/jbpm/jpdl/par/classresource.txt");
addEntry(zipOutputStream, "archiveresource.txt", "org/jbpm/jpdl/par/archiveresource.txt");
zipOutputStream.close();
byte[] zipBytes = baos.toByteArray();
@@ -81,7 +80,7 @@
assertNull(testClassLoader.getResource("org/jbpm/jpdl/par/classresource.txt"));
assertNull(testClassLoader.getResource("org/jbpm/jpdl/par/archiveresource.txt"));
try {
- testClassLoader.loadClass("org.jbpm.jpdl.par.ResourceAction");
+ Class.forName("org.jbpm.jpdl.par.ResourceAction", false, testClassLoader);
fail("expected exception");
}
catch (ClassNotFoundException e) {
@@ -116,10 +115,8 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(baos);
addEntry(zipOutputStream, "processdefinition.xml", "org/jbpm/jpdl/par/instantiateprocess.xml");
- addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateAction.class",
- "org/jbpm/jpdl/par/InstantiateAction.class");
- addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateClass.class",
- "org/jbpm/jpdl/par/InstantiateClass.class");
+ addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateAction.class", "org/jbpm/jpdl/par/InstantiateAction.class");
+ addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateClass.class", "org/jbpm/jpdl/par/InstantiateClass.class");
zipOutputStream.close();
byte[] zipBytes = baos.toByteArray();
@@ -137,7 +134,7 @@
try {
ClassLoader testClassLoader = ProcessArchiveClassLoadingDbTest.class.getClassLoader();
try {
- testClassLoader.loadClass("org.jbpm.jpdl.par.InstantiateAction");
+ Class.forName("org.jbpm.jpdl.par.InstantiateAction", false, testClassLoader);
fail("expected exception");
}
catch (ClassNotFoundException e) {
@@ -145,7 +142,7 @@
}
try {
- testClassLoader.loadClass("org.jbpm.jpdl.par.InstantiateClass");
+ Class.forName("org.jbpm.jpdl.par.InstantiateClass", false, testClassLoader);
fail("expected exception");
}
catch (ClassNotFoundException e) {
@@ -179,8 +176,7 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zipOutputStream = new ZipOutputStream(baos);
addEntry(zipOutputStream, "processdefinition.xml", "org/jbpm/jpdl/par/instantiateprocess.xml");
- addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateAction.class",
- "org/jbpm/jpdl/par/InstantiateAction.class");
+ addEntry(zipOutputStream, "classes/org/jbpm/jpdl/par/InstantiateAction.class", "org/jbpm/jpdl/par/InstantiateAction.class");
zipOutputStream.close();
byte[] zipBytes = baos.toByteArray();
@@ -193,14 +189,14 @@
try {
ClassLoader testClassLoader = ProcessArchiveClassLoadingDbTest.class.getClassLoader();
try {
- testClassLoader.loadClass("org.jbpm.jpdl.par.InstantiateAction");
+ Class.forName("org.jbpm.jpdl.par.InstantiateAction", false, testClassLoader);
fail("expected exception");
}
catch (ClassNotFoundException e) {
// OK
}
// InstantiateClass should be visible on the test classpath
- testClassLoader.loadClass("org.jbpm.jpdl.par.InstantiateClass");
+ Class.forName("org.jbpm.jpdl.par.InstantiateClass", false, testClassLoader);
// deploy the process archive
ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(zipBytes));
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/jpdl/par/ProcessClassLoaderTest.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -24,19 +24,6 @@
public TestContextClassLoader(ClassLoader parent) {
super(parent);
}
-
- protected synchronized Class loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
- return super.loadClass(name, resolve);
- }
-
- public Class loadClass(String name) throws ClassNotFoundException {
- return super.loadClass(name);
- }
-
- protected Class findClass(String name) throws ClassNotFoundException {
- return super.findClass(name);
- }
}
static int contextLoadedActionInvocations = 0;
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/main/java/org/jbpm/identity/hibernate/PermissionUserType.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/main/java/org/jbpm/identity/hibernate/PermissionUserType.java 2009-05-08 03:37:18 UTC (rev 4767)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/identity/src/main/java/org/jbpm/identity/hibernate/PermissionUserType.java 2009-05-08 20:47:42 UTC (rev 4768)
@@ -36,27 +36,33 @@
public class PermissionUserType implements CompositeUserType {
- private static final String[] PROPERTY_NAMES = new String[]{"class", "name", "actions"};
+ private static final String[] PROPERTY_NAMES = new String[] { "class", "name", "actions" };
+
public String[] getPropertyNames() {
return PROPERTY_NAMES;
}
- private static final Type[] PROPERTY_TYPES = new Type[]{Hibernate.STRING, Hibernate.STRING, Hibernate.STRING};
+ private static final Type[] PROPERTY_TYPES = new Type[] { Hibernate.STRING, Hibernate.STRING,
+ Hibernate.STRING };
+
public Type[] getPropertyTypes() {
return PROPERTY_TYPES;
}
public Object getPropertyValue(Object component, int property) throws HibernateException {
Permission permission = (Permission) component;
- if (property==0) {
+ if (property == 0) {
return permission.getClass().getName();
- } else if (property==1) {
+ }
+ else if (property == 1) {
return permission.getName();
- } else if (property==2) {
+ }
+ else if (property == 2) {
return permission.getActions();
- } else {
- throw new IllegalArgumentException("illegal permission property '"+property+"'");
}
+ else {
+ throw new IllegalArgumentException("illegal permission property '" + property + "'");
+ }
}
public void setPropertyValue(Object arg0, int arg1, Object arg2) throws HibernateException {
@@ -74,31 +80,43 @@
public int hashCode(Object permission) throws HibernateException {
return permission.hashCode();
}
-
- private static final Class[] NAME_ACTIOS_CONSTRUCTOR_PARAMETER_TYPES = new Class[]{String.class, String.class};
- public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
+
+ private static final Class[] NAME_ACTIOS_CONSTRUCTOR_PARAMETER_TYPES = new Class[] {
+ String.class, String.class };
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session,
+ Object owner) throws HibernateException, SQLException {
Object permission = null;
String className = resultSet.getString(names[0]);
String name = resultSet.getString(names[1]);
String actions = resultSet.getString(names[2]);
-
+
try {
// TODO optimize performance by caching the constructors
- Class permissionClass = PermissionUserType.class.getClassLoader().loadClass(className);
+ ClassLoader classLoader = PermissionUserType.class.getClassLoader();
+ Class permissionClass = Class.forName(className, false, classLoader);
Constructor constructor = permissionClass.getDeclaredConstructor(NAME_ACTIOS_CONSTRUCTOR_PARAMETER_TYPES);
- permission = constructor.newInstance(new Object[]{name, actions});
- } catch (Exception e) {
- throw new HibernateException("couldn't create permission from database record ["+className+"|"+name+"|"+actions+"]. Does the permission class have a (String name,String actions) constructor ?", e);
+ permission = constructor.newInstance(new Object[] { name, actions });
}
-
+ catch (Exception e) {
+ throw new HibernateException("couldn't create permission from database record ["
+ + className
+ + "|"
+ + name
+ + "|"
+ + actions
+ + "]. Does the permission class have a (String name,String actions) constructor ?", e);
+ }
+
return permission;
}
- public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
+ public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
Permission permission = (Permission) value;
preparedStatement.setString(index, permission.getClass().getName());
- preparedStatement.setString(index+1, permission.getName());
- preparedStatement.setString(index+2, permission.getActions());
+ preparedStatement.setString(index + 1, permission.getName());
+ preparedStatement.setString(index + 2, permission.getActions());
}
public Object deepCopy(Object permission) throws HibernateException {
@@ -109,15 +127,18 @@
return false;
}
- public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException {
+ public Serializable disassemble(Object value, SessionImplementor session)
+ throws HibernateException {
return (Serializable) value;
}
- public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException {
+ public Object assemble(Serializable cached, SessionImplementor session, Object owner)
+ throws HibernateException {
return cached;
}
- public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException {
+ public Object replace(Object original, Object target, SessionImplementor session, Object owner)
+ throws HibernateException {
return original;
}
}
More information about the jbpm-commits
mailing list