Element type Element type "service" must be followed by eith
luis.moretto Feb 14, 2006 12:54 PMlog4j:WARN No appenders could be found for logger (org.jbpm.JbpmConfiguration).
log4j:WARN Please initialize the log4j system properly.
[Fatal Error] :9:30: Element type "service" must be followed by either attribute specifications, ">" or "/>".
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
// A jbpm-context mechanism separates the jbpm core
// engine from the services that jbpm uses from
// the environment.
<jbpm-context>
<service name='persistence'factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />
</jbpm-context>
// Also all the resource files that are used by jbpm are
// referenced from the jbpm.cfg.xml
" +
" +
" +
" +
" +
</jbpm-configuration>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- jdbc connection properties -->
org.hibernate.dialect.PostgreSQLDialect
org.postgresql.Driver
jdbc:postgresql://127.0.0.1:5432/admissao_funcional
postgres
adpt
<!-- c3p0 connection pooling properties
1
3
-->
<!-- other hibernate properties -->
true
<!--identity mapping files -->
<!-- uncomment if you don't want to use the default jBPM identity mgmgt component -->
<!-- graph.def mapping files -->
<!-- graph.node mapping files -->
<!-- graph.action mapping files -->
<!-- context.def mapping files -->
<!-- taskmgmt.def mapping files -->
<!-- module.def mapping files -->
<!-- bytes mapping files -->
<!-- file.def mapping files -->
<!-- scheduler.def mapping files -->
<!-- graph.exe mapping files -->
<!-- module.exe mapping files -->
<!-- context.exe mapping files -->
<!-- taskmgmt.exe mapping files -->
<!-- scheduler.exe mapping files -->
<!-- logging mapping files -->
</session-factory>
</hibernate-configuration>
package org.adept.ca2.process;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.*;
public class AdmissaoFuncional implements ActionHandler {
private static final long serialVersionUID = 1L;
public void execute(ExecutionContext context)throws Exception {
context.getContextInstance().createVariable("Inicio do processo de seleção de funcionários","Início");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Admissao-Funcional">
<start-state name="Inicia seleção">
</start-state>
<end-state name="Fim da Seleção"></end-state>
</process-definition>
package org.adept.ca2.dao;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import junit.framework.TestCase;
import java.util.List;
/**
* @author Luís Augusto Machado Moretto
* @see Adept-Systems
*/
public class AdmissaoDAO extends TestCase {
private static JbpmConfiguration jbpmConf = JbpmConfiguration.getInstance("conf/config.jbpm.xml");
public AdmissaoDAO() {
super();// Chama o construtor da classe pai :>
}
public void setUp() {
this.jbpmConf.createSchema();// Cria o esquema
}
public void dropDown() {
this.jbpmConf.dropSchema();
}
public void testSimplePersistence() {
// Between the 3 method calls below, all data is passed via the
// database. Here, in this unit test, these 3 methods are executed
// right after each other because we want to test a complete process
// scenario. But in reality, these methods represent different
// requests to a server.
// Since we start with a clean, empty in-memory database, we have to
// deploy the process first. In reality, this is done once by the
// process developer.
deployProcessDefinition();
// Suppose we want to start a process instance (=process execution)
// when a user submits a form in a web application...
processInstanceIsCreatedWhenUserSubmitsWebappForm();
// Then, later, upon the arrival of an asynchronous message the
// execution must continue.
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
}
public void deployProcessDefinition() {
// This test shows a process definition and one execution
String uri = "Admissao-Funcional.par/processdefinition.xml";
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(uri);
// Lookup the pojo persistence context-builder that is configured above
JbpmContext jbpmContext = this.jbpmConf.createJbpmContext();
try {
// Deploy the process definition in the database
jbpmContext.deployProcessDefinition(processDefinition);
} finally {
// Tear down the pojo persistence context.
// This includes flush the SQL for inserting the process definition
// to the database.
jbpmContext.close();
}
}
public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
// The code in this method could be inside a struts-action
// or a JSF managed bean.
// Lookup the pojo persistence context-builder that is configured above
JbpmContext jbpmContext = this.jbpmConf.createJbpmContext();
try {
ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("hello world");
// With the processDefinition that we retrieved from the database,
// we
// can create an execution of the process definition just like in
// the
// hello world example (which was without persistence).
ProcessInstance processInstance = new ProcessInstance(processDefinition);
/**
*
* @see Inicializa o parse do XML
* */
assertNotNull("A definição do processo não pode ser null:<",processDefinition);
/**
*
* @see Cria uma instância do processo na raiz -> Inicia seleção
* */
processInstance = new ProcessInstance(processDefinition);
assertEquals("Inicio do processo de selecção de funcionários",processInstance.getRootToken().getNode().getName(),"Inicia seleção");
processInstance.signal();
jbpmContext.save(processInstance);
/**
*
* @see transição do processo
* @Estado de seleção dos candidatos
* */
assertEquals("Processo no estado de seleção dos candidatos",processInstance.getRootToken().getNode().getName(),"Seleciona candidatos");
processInstance.signal();
/**
*
* @see transição do processo
* @Estado de Entrevistas com os candidatos
* */
assertEquals("Processo de seleção na fase de entrevistas",processInstance.getRootToken().getNode().getName(),"Entrevista");
processInstance.signal();
/**
*
* @see transição do processo
* @Estado de validação do perfil funcional do candidato
* */
assertEquals("Processo de validação do perfil funcional do candidato",processInstance.getRootToken().getNode().getName(),"Possui perfil funcional");
processInstance.signal();
/**
*
* @see transição do processo
* @Estado de contratação do funcionário
* */
assertEquals("Processo de seleção na fase de contratação do(s) funcionário(s)",processInstance.getRootToken().getNode().getName(),"Contrata funcionário");
processInstance.signal();
/**
*
* @see transição do processo
* @Estado final do processo
* */
assertEquals("Processo de seleção finalizado",processInstance.getRootToken().getNode().getName(),"Fim da Seleção");
assertTrue("Fim da seleção",processInstance.hasEnded());
} finally {
// Tear down the pojo persistence context.
jbpmContext.close();
}
}
public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
// The code in this method could be the content of a message driven
// bean.
// Lookup the pojo persistence context-builder that is configured above
JbpmContext jbpmContext = this.jbpmConf.createJbpmContext();
try {
// First, we need to get the process instance back out of the
// database.
// There are several options to know what process instance we are
// dealing
// with here. The easiest in this simple test case is just to look
// for
// the full list of process instances. That should give us only one
// result. So let's look up the process definition.
ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("hello world");
// Now, we search for all process instances of this process
// definition.
List processInstances = jbpmContext.getGraphSession().findProcessInstances(processDefinition.getId());
// Because we know that in the context of this unit test, there is
// only one execution. In real life, the processInstanceId can be
// extracted from the content of the message that arrived or from
// the user making a choice.
ProcessInstance processInstance = (ProcessInstance)processInstances.get(0);
// Now we can continue the execution. Note that the processInstance
// delegates signals to the main path of execution (=the root
// token).
processInstance.signal();
// After this signal, we know the process execution should have
// arrived in the end-state.
assertTrue(processInstance.hasEnded());
// Now we can update the state of the execution in the database
jbpmContext.save(processInstance);
} finally {
// Tear down the pojo persistence context.
jbpmContext.close();
}
}
}