-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unification of persistence and transaction handling for jbpm and huma…
…n task (cherry picked from commit a054752)
- Loading branch information
1 parent
8987f08
commit 96cb2ea
Showing
12 changed files
with
403 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
kie-internal/src/main/java/org/kie/internal/runtime/manager/RuntimeManagerRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.kie.internal.runtime.manager; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.kie.api.runtime.manager.RuntimeManager; | ||
|
||
public class RuntimeManagerRegistry { | ||
|
||
private static RuntimeManagerRegistry INSTANCE = new RuntimeManagerRegistry(); | ||
|
||
protected volatile ConcurrentHashMap<String, RuntimeManager> registeredManager = new ConcurrentHashMap<String, RuntimeManager>(); | ||
|
||
private RuntimeManagerRegistry() { | ||
|
||
} | ||
|
||
public static RuntimeManagerRegistry get() { | ||
return INSTANCE; | ||
} | ||
|
||
public synchronized void register(RuntimeManager manager) { | ||
if (registeredManager.containsKey(manager.getIdentifier())) { | ||
throw new IllegalStateException("RuntimeManager is already registered with id " + manager.getIdentifier()); | ||
} | ||
this.registeredManager.put(manager.getIdentifier(), manager); | ||
} | ||
|
||
public synchronized void remove(RuntimeManager manager) { | ||
|
||
this.registeredManager.remove(manager.getIdentifier()); | ||
} | ||
|
||
public synchronized void remove(String identifier) { | ||
|
||
this.registeredManager.remove(identifier); | ||
} | ||
|
||
public RuntimeManager getManager(String id) { | ||
return this.registeredManager.get(id); | ||
} | ||
|
||
public boolean isRegistered(String id) { | ||
return this.registeredManager.containsKey(id); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
kie-internal/src/main/java/org/kie/internal/task/api/TaskContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.kie.internal.task.api; | ||
|
||
import org.kie.api.task.UserGroupCallback; | ||
import org.kie.internal.command.Context; | ||
|
||
public interface TaskContext extends Context { | ||
|
||
TaskPersistenceContext getPersistenceContext(); | ||
|
||
void setPersistenceContext(TaskPersistenceContext context); | ||
|
||
UserGroupCallback getUserGroupCallback(); | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
kie-internal/src/main/java/org/kie/internal/task/api/TaskEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.kie.internal.task.api; | ||
|
||
import org.kie.api.task.model.Task; | ||
|
||
public interface TaskEvent { | ||
|
||
Task getTask(); | ||
|
||
TaskContext getTaskContext(); | ||
} |
74 changes: 74 additions & 0 deletions
74
kie-internal/src/main/java/org/kie/internal/task/api/TaskModelFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.kie.internal.task.api; | ||
|
||
import org.kie.api.task.model.Attachment; | ||
import org.kie.api.task.model.Comment; | ||
import org.kie.api.task.model.Content; | ||
import org.kie.api.task.model.Group; | ||
import org.kie.api.task.model.I18NText; | ||
import org.kie.api.task.model.OrganizationalEntity; | ||
import org.kie.api.task.model.PeopleAssignments; | ||
import org.kie.api.task.model.Task; | ||
import org.kie.api.task.model.TaskData; | ||
import org.kie.api.task.model.User; | ||
import org.kie.internal.task.api.model.BooleanExpression; | ||
import org.kie.internal.task.api.model.ContentData; | ||
import org.kie.internal.task.api.model.Deadline; | ||
import org.kie.internal.task.api.model.Deadlines; | ||
import org.kie.internal.task.api.model.Delegation; | ||
import org.kie.internal.task.api.model.EmailNotification; | ||
import org.kie.internal.task.api.model.EmailNotificationHeader; | ||
import org.kie.internal.task.api.model.Escalation; | ||
import org.kie.internal.task.api.model.FaultData; | ||
import org.kie.internal.task.api.model.Language; | ||
import org.kie.internal.task.api.model.Notification; | ||
import org.kie.internal.task.api.model.Reassignment; | ||
import org.kie.internal.task.api.model.TaskDef; | ||
|
||
public interface TaskModelFactory { | ||
|
||
Attachment newAttachment(); | ||
|
||
BooleanExpression newBooleanExpression(); | ||
|
||
Comment newComment(); | ||
|
||
ContentData newContentData(); | ||
|
||
Content newContent(); | ||
|
||
Deadline newDeadline(); | ||
|
||
Deadlines newDeadlines(); | ||
|
||
Delegation newDelegation(); | ||
|
||
EmailNotificationHeader newEmailNotificationHeader(); | ||
|
||
EmailNotification newEmialNotification(); | ||
|
||
Escalation newEscalation(); | ||
|
||
FaultData newFaultData(); | ||
|
||
Group newGroup(); | ||
|
||
I18NText newI18NText(); | ||
|
||
Language newLanguage(); | ||
|
||
Notification newNotification(); | ||
|
||
OrganizationalEntity newOrgEntity(); | ||
|
||
PeopleAssignments newPeopleAssignments(); | ||
|
||
Reassignment newReassignment(); | ||
|
||
TaskData newTaskData(); | ||
|
||
TaskDef newTaskDef(); | ||
|
||
Task newTask(); | ||
|
||
User newUser(); | ||
} |
16 changes: 16 additions & 0 deletions
16
kie-internal/src/main/java/org/kie/internal/task/api/TaskModelProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.kie.internal.task.api; | ||
|
||
import java.util.ServiceLoader; | ||
|
||
public class TaskModelProvider { | ||
|
||
private static ServiceLoader<TaskModelFactory> serviceLoader = ServiceLoader.load(TaskModelFactory.class); | ||
|
||
public static TaskModelFactory getFactory() { | ||
for (TaskModelFactory factory : serviceLoader) { | ||
return factory; | ||
} | ||
|
||
throw new IllegalStateException("Cannot find any TaskModelFactory"); | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
kie-internal/src/main/java/org/kie/internal/task/api/TaskPersistenceContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package org.kie.internal.task.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.kie.api.task.model.Attachment; | ||
import org.kie.api.task.model.Comment; | ||
import org.kie.api.task.model.Content; | ||
import org.kie.api.task.model.Group; | ||
import org.kie.api.task.model.OrganizationalEntity; | ||
import org.kie.api.task.model.Task; | ||
import org.kie.api.task.model.User; | ||
import org.kie.internal.task.api.model.Deadline; | ||
|
||
public interface TaskPersistenceContext { | ||
|
||
Task findTask(Long taskId); | ||
|
||
Task persistTask(Task task); | ||
|
||
Task updateTask(Task task); | ||
|
||
Task removeTask(Task task); | ||
|
||
Group findGroup(String groupId); | ||
|
||
Group persistGroup(Group group); | ||
|
||
Group updateGroup(Group group); | ||
|
||
Group removeGroup(Group group); | ||
|
||
User findUser(String userId); | ||
|
||
User persistUser(User user); | ||
|
||
User updateUser(User user); | ||
|
||
User removeUser(User user); | ||
|
||
OrganizationalEntity findOrgEntity(String orgEntityId); | ||
|
||
OrganizationalEntity persistOrgEntity(OrganizationalEntity orgEntity); | ||
|
||
OrganizationalEntity updateOrgEntity(OrganizationalEntity orgEntity); | ||
|
||
OrganizationalEntity removeOrgEntity(OrganizationalEntity orgEntity); | ||
|
||
Content findContent(Long contentId); | ||
|
||
Content persistContent(Content content); | ||
|
||
Content updateContent(Content content); | ||
|
||
Content removeContent(Content content); | ||
|
||
Attachment findAttachment(Long attachmentId); | ||
|
||
Attachment persistAttachment(Attachment attachment); | ||
|
||
Attachment updateAttachment(Attachment attachment); | ||
|
||
Attachment removeAttachment(Attachment attachment); | ||
|
||
Comment findComment(Long commentId); | ||
|
||
Comment persistComment(Comment comment); | ||
|
||
Comment updateComment(Comment comment); | ||
|
||
Comment removeComment(Comment comment); | ||
|
||
Deadline findDeadline(Long deadlineId); | ||
|
||
Deadline persistDeadline(Deadline deadline); | ||
|
||
Deadline updateDeadline(Deadline deadline); | ||
|
||
Deadline removeDeadline(Deadline deadline); | ||
|
||
/* | ||
* Query related methods | ||
*/ | ||
|
||
<T> T queryWithParametersInTransaction(String queryName, Map<String, Object> params, Class<T> clazz); | ||
|
||
<T> T queryAndLockWithParametersInTransaction(String queryName, Map<String, Object> params, boolean singleResult, Class<T> clazz); | ||
|
||
<T> T queryInTransaction(String queryName, Class<T> clazz); | ||
|
||
<T> T queryStringInTransaction(String queryString, Class<T> clazz ); | ||
|
||
<T> T queryStringWithParametersInTransaction(String queryString, Map<String, Object> params, Class<T> clazz ); | ||
|
||
<T> T queryAndLockStringWithParametersInTransaction(String queryName, Map<String, Object> params, boolean singleResult, Class<T> clazz); | ||
|
||
int executeUpdateString(String updateString); | ||
|
||
HashMap<String, Object> addParametersToMap(Object ... parameterValues); | ||
|
||
/* | ||
* Following are optional methods that are more like extension to | ||
* default data model to allow flexible add-ons | ||
*/ | ||
<T> T persist(T object); | ||
|
||
<T> T find(Class<T> entityClass, Object primaryKey); | ||
|
||
<T> T remove(T entity); | ||
|
||
<T> T merge(T entity); | ||
|
||
/* | ||
* life cycle methods | ||
*/ | ||
boolean isOpen(); | ||
|
||
void joinTransaction(); | ||
|
||
void close(); | ||
} |
15 changes: 15 additions & 0 deletions
15
kie-internal/src/main/java/org/kie/internal/task/api/TaskPersistenceContextManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.kie.internal.task.api; | ||
|
||
public interface TaskPersistenceContextManager { | ||
|
||
TaskPersistenceContext getPersistenceContext(); | ||
|
||
void beginCommandScopedEntityManager(); | ||
|
||
void endCommandScopedEntityManager(); | ||
|
||
/** | ||
* Executes the necessary actions in order to clean up and dispose of the internal fields of this instance. | ||
*/ | ||
void dispose(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.