@Transactional(TransactionPropagationType.SUPPORTS) public void createJbpmSchema() throws Exception { // System.out.println("!!!!!!!!!!!!!!!!STARTTTTTT: " + Transaction.instance().isActive()); Transaction.instance().commit(); // System.out.println("!!!!!!!AFER COMMIT!!!!!!!!!: " + Transaction.instance().isActive()); JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(); // System.out.println("!!!!!!!!!!!!!!!! after getting JBPM CONF: " + // Transaction.instance().isActive()); jbpmConfiguration.createSchema(); // System.out.println("!!!!!!!!!!!!!!!! AFTER CREATING SCHEMA: " + // Transaction.instance().isActive()); // jbpmConfiguration.createSchema(); // jbpmContext.getJbpmConfiguration().createSchema(); }
public void testTestMapper() { JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString( "<jbpm-configuration>" + " <bean name='jbpm.function.mapper' class='" + TestFunctionMapper.class.getName() + "' />" + "</jbpm-configuration>"); JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try { Token token = new Token(); ExecutionContext executionContext = new ExecutionContext(token); Object result = JbpmExpressionEvaluator.evaluate("${sum(2, 3)}", executionContext); assertEquals(new Integer(5), result); } finally { jbpmContext.close(); } }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<h2>JBoss jBPM Scheduler Servlet</h2><hr />"); Collection threads = jbpmConfiguration.getJobExecutor().getThreads().values(); Iterator iter = threads.iterator(); while (iter.hasNext()) { Thread thread = (Thread) iter.next(); out.println("<h4>" + thread.getName() + "</h4>"); out.println("<b>Status</b>:" + thread.getState()); } out.println("</body>"); out.println("</html>"); }
protected void setUp() throws Exception { /* the bpel definition uses the jbpm configuration, so create a context before the definition * to avoid loading another configuration from the default resource */ jbpmContext = jbpmConfiguration.createJbpmContext(); // process and token BpelDefinition pd = new BpelDefinition(); token = new ProcessInstance(pd).getRootToken(); Scope scope = pd.getGlobalScope(); // port type 1 PortType portType1 = new PortTypeImpl(); portType1.setQName(new QName("pt1")); // port type 2 PortType portType2 = new PortTypeImpl(); portType2.setQName(new QName("pt2")); // partner link type PartnerLinkType partnerLinkType = new PartnerLinkTypeImpl(); partnerLinkType.setQName(new QName("plt")); // role 1 Role role1 = partnerLinkType.createRole(); role1.setName("r1"); role1.setPortType(portType1); partnerLinkType.setFirstRole(role1); // role 2 Role role2 = partnerLinkType.createRole(); role2.setName("r2"); role2.setPortType(portType2); partnerLinkType.setSecondRole(role2); // partner link PartnerLinkDefinition partnerLink = new PartnerLinkDefinition(); partnerLink.setName("pl1"); partnerLink.setPartnerLinkType(partnerLinkType); partnerLink.setMyRole(role1); partnerLink.setPartnerRole(role2); scope.addPartnerLink(partnerLink); // from from.setPartnerLink(partnerLink); // initialize scope scope.initScopeData(token); // provide a way to the partner link definition Empty activity = new Empty(); scope.addNode(activity); token.setNode(activity); }
/** * extract the list of information from the process variables and make them available locally. * Note that if no task instance variables are specified, the full process variables scope will be * visible (that means that the user did not specify a special task instance scope). */ public void initializeVariables(TaskInstance taskInstance) { ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader(); try { // set context class loader correctly for delegation class // (https://jira.jboss.org/jira/browse/JBPM-1448) Thread.currentThread() .setContextClassLoader( JbpmConfiguration.getProcessClassLoader( taskInstance.getTask().getProcessDefinition())); if (taskControllerDelegation != null) { TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate(); ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance(); ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null); Token token = taskInstance.getToken(); if (UserCodeInterceptorConfig.userCodeInterceptor != null) { UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerInitialization( taskControllerHandler, taskInstance, contextInstance, token); } else { taskControllerHandler.initializeTaskVariables(taskInstance, contextInstance, token); } } else { Token token = taskInstance.getToken(); ProcessInstance processInstance = token.getProcessInstance(); ContextInstance contextInstance = processInstance.getContextInstance(); if (variableAccesses != null) { Iterator iter = variableAccesses.iterator(); while (iter.hasNext()) { VariableAccess variableAccess = (VariableAccess) iter.next(); String mappedName = variableAccess.getMappedName(); if (variableAccess.isReadable()) { String variableName = variableAccess.getVariableName(); Object value = contextInstance.getVariable(variableName, token); log.debug( "creating task instance variable '" + mappedName + "' from process variable '" + variableName + "', value '" + value + "'"); taskInstance.setVariableLocally(mappedName, value); } else { log.debug( "creating task instance local variable '" + mappedName + "'. initializing with null value."); taskInstance.setVariableLocally(mappedName, null); } } } } } finally { Thread.currentThread().setContextClassLoader(surroundingClassLoader); } }
/** update the process variables from the the task-instance variables. */ public void submitParameters(TaskInstance taskInstance) { ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader(); try { // set context class loader correctly for delegation class // (https://jira.jboss.org/jira/browse/JBPM-1448) Thread.currentThread() .setContextClassLoader( JbpmConfiguration.getProcessClassLoader( taskInstance.getTask().getProcessDefinition())); if (taskControllerDelegation != null) { TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate(); ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance(); ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null); Token token = taskInstance.getToken(); if (UserCodeInterceptorConfig.userCodeInterceptor != null) { UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission( taskControllerHandler, taskInstance, contextInstance, token); } else { taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token); } } else { Token token = taskInstance.getToken(); ProcessInstance processInstance = token.getProcessInstance(); ContextInstance contextInstance = processInstance.getContextInstance(); if (variableAccesses != null) { String missingTaskVariables = null; Iterator iter = variableAccesses.iterator(); while (iter.hasNext()) { VariableAccess variableAccess = (VariableAccess) iter.next(); String mappedName = variableAccess.getMappedName(); // first check if the required variableInstances are present if ((variableAccess.isRequired()) && (!taskInstance.hasVariableLocally(mappedName))) { if (missingTaskVariables == null) { missingTaskVariables = mappedName; } else { missingTaskVariables += ", " + mappedName; } } } // if there are missing, required parameters, throw an // IllegalArgumentException if (missingTaskVariables != null) { throw new IllegalArgumentException("missing task variables: " + missingTaskVariables); } iter = variableAccesses.iterator(); while (iter.hasNext()) { VariableAccess variableAccess = (VariableAccess) iter.next(); String mappedName = variableAccess.getMappedName(); String variableName = variableAccess.getVariableName(); if (variableAccess.isWritable()) { Object value = taskInstance.getVariable(mappedName); if (value != null) { log.debug( "submitting task variable '" + mappedName + "' to process variable '" + variableName + "', value '" + value + "'"); contextInstance.setVariable(variableName, value, token); } } } } } } finally { Thread.currentThread().setContextClassLoader(surroundingClassLoader); } }
/* (non-Javadoc) * @see com.mg.merp.bpm.BPMManager#getCurrentBpmContext() */ public JbpmContext getCurrentBpmContext() { return jbpmConfiguration.createJbpmContext("merp.jbpm-context"); }
public void startService() throws Exception { jbpmConfiguration = JbpmConfiguration.parseResource("META-INF/jbpm.cfg.xml"); }
/** * @author Alejandro Guizar * @version $Revision: 1.3 $ $Date: 2006/08/21 01:05:59 $ */ public class FromPartnerLinkTest extends TestCase { private FromPartnerLink from = new FromPartnerLink(); private Token token; private JbpmContext jbpmContext; private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseResource("org/jbpm/bpel/exe/test.jbpm.cfg.xml"); public FromPartnerLinkTest(String name) { super(name); } protected void setUp() throws Exception { /* the bpel definition uses the jbpm configuration, so create a context before the definition * to avoid loading another configuration from the default resource */ jbpmContext = jbpmConfiguration.createJbpmContext(); // process and token BpelDefinition pd = new BpelDefinition(); token = new ProcessInstance(pd).getRootToken(); Scope scope = pd.getGlobalScope(); // port type 1 PortType portType1 = new PortTypeImpl(); portType1.setQName(new QName("pt1")); // port type 2 PortType portType2 = new PortTypeImpl(); portType2.setQName(new QName("pt2")); // partner link type PartnerLinkType partnerLinkType = new PartnerLinkTypeImpl(); partnerLinkType.setQName(new QName("plt")); // role 1 Role role1 = partnerLinkType.createRole(); role1.setName("r1"); role1.setPortType(portType1); partnerLinkType.setFirstRole(role1); // role 2 Role role2 = partnerLinkType.createRole(); role2.setName("r2"); role2.setPortType(portType2); partnerLinkType.setSecondRole(role2); // partner link PartnerLinkDefinition partnerLink = new PartnerLinkDefinition(); partnerLink.setName("pl1"); partnerLink.setPartnerLinkType(partnerLinkType); partnerLink.setMyRole(role1); partnerLink.setPartnerRole(role2); scope.addPartnerLink(partnerLink); // from from.setPartnerLink(partnerLink); // initialize scope scope.initScopeData(token); // provide a way to the partner link definition Empty activity = new Empty(); scope.addNode(activity); token.setNode(activity); } protected void tearDown() throws Exception { jbpmContext.close(); } public void testExtract_partnerRole() { // role ref from.setEndpointReference(Reference.PARTNER_ROLE); // endpoint ref EndpointReference endpointRef = new WsaEndpointReference(); from.getPartnerLink().getInstance(token).setPartnerReference(endpointRef); // verify extraction assertSame(endpointRef, from.extract(token)); } public void testExtract_myRole() { // role ref from.setEndpointReference(Reference.MY_ROLE); // endpoint ref EndpointReference endpointRef = new WsaEndpointReference(); MockIntegrationService relationService = (MockIntegrationService) jbpmContext.getServices().getService(IntegrationService.SERVICE_NAME); relationService.setMyReference(from.getPartnerLink(), endpointRef); // verify extraction assertSame(endpointRef, from.extract(token)); } }
public void destroy() { jbpmConfiguration.close(); }
public void init() throws ServletException { String configurationName = getInitParameter("jbpm.configuration.resource", null); jbpmConfiguration = JbpmConfiguration.getInstance(configurationName); jbpmConfiguration.startJobExecutor(); }