Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Java API/IPartitionMonitor Example

The IPartitionMonitor service provider interface can be used to execute custom code when

  • a process model is deployed or deleted
  • a user is created, disabled or enabled
  • a user realm is created or dropped


This SPI can for instance be used to implement

  • a push synchronization of process participants and entitlements in other systems when a process model is deployed.
  • a callback to external systems to keep the user information in sync or send notifications

(also see SynchronizationProvider interface which syncs users and entitlements on login of an individual user)

Implementation

  1. Implement the IWorklistMonitor interface as shown below.
  2. Create a text file named org.eclipse.stardust.engine.core.spi.monitoring.IPartitionMonitor. The file contents needs to be the fully qualified name of your implementation class, e.g. org.eclipse.stardust.example.PartitionMonitorImpl.
  3. Place the file into the META-INF/services folder of the jar that will contain your implementation class

package org.eclipse.stardust.example;
 
import java.util.Iterator;
 
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
import org.eclipse.stardust.engine.api.model.IModel;
import org.eclipse.stardust.engine.api.model.IProcessDefinition;
import org.eclipse.stardust.engine.api.model.IRole;
import org.eclipse.stardust.engine.api.runtime.DeploymentException;
import org.eclipse.stardust.engine.core.model.utils.ModelElementList;
import org.eclipse.stardust.engine.core.runtime.beans.IUser;
import org.eclipse.stardust.engine.core.runtime.beans.IUserRealm;
import org.eclipse.stardust.engine.core.spi.monitoring.IPartitionMonitor;
 
 
public class PartitionMonitorImpl implements IPartitionMonitor {
 
	final Logger log = LogManager.getLogger(PartitionMonitorImpl.class);
 
	@Override
	public void modelDeleted(IModel arg0) throws DeploymentException {
	}
 
	@Override
	public void modelDeployed(IModel model, boolean arg1)
			throws DeploymentException {
 
		log.info("In modelDeployed. ModelId:" + model.getId());
		ModelElementList<IProcessDefinition> pdList = model.getProcessDefinitions();
 
		for (IProcessDefinition pd : pdList) {
			log.info("Found process definition: " + pd.getId());
		}
 
		@SuppressWarnings("unchecked")
		Iterator<IRole> ritr = model.getAllRoles();
		while (ritr.hasNext()) {
			IRole role = ritr.next();
			log.info(role.getQualifiedId());
		}
	}
 
	@Override
	public void userCreated(IUser arg0) {
	}
 
	@Override
	public void userDisabled(IUser arg0) {
	}
 
	@Override
	public void userEnabled(IUser arg0) {
	}
 
	@Override
	public void userRealmCreated(IUserRealm arg0) {
	}
 
	@Override
	public void userRealmDropped(IUserRealm arg0) {
	}
}

Back to the top