/** creates a new activity, if does not exists */ public DocumentActivity createDocumentActivity(DocumentSelector documentSelector) { ActivityHandle activityHandle = new ActivityHandle(documentSelector.toString()); DocumentActivity activity = (DocumentActivity) activities.get(activityHandle); if (activity == null) { activity = new DocumentActivity(documentSelector); DocumentActivity anotherActivity = (DocumentActivity) activities.putIfAbsent(activityHandle, activity); if (anotherActivity != null) { activity = anotherActivity; } else { // created, add to slee try { sleeEndpoint.startActivityTransacted(activityHandle, activity, ACTIVITY_FLAGS); } catch (Throwable e) { getLogger() .severe("failed to start activity for document selector " + documentSelector, e); } } } return activity; }
/** creates a new activity, if does not exists */ public CollectionActivity createCollectionActivity(String collection) { final ActivityHandle activityHandle = new ActivityHandle(collection); CollectionActivity activity = (CollectionActivity) activities.get(activityHandle); if (activity == null) { activity = new CollectionActivity(collection); final CollectionActivity anotherActivity = (CollectionActivity) activities.putIfAbsent(activityHandle, activity); if (anotherActivity != null) { activity = anotherActivity; } else { // created, add to slee try { sleeEndpoint.startActivityTransacted(activityHandle, activity, ACTIVITY_FLAGS); } catch (Throwable e) { getLogger().severe("failed to start activity for collection " + collection, e); } } } return activity; }