You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ms...@apache.org on 2007/01/02 17:34:11 UTC
svn commit: r491841 [1/2] - in /incubator/ode/trunk: ./ axis2/
axis2/src/main/java/org/apache/ode/axis2/
bpel-api/src/main/java/org/apache/ode/bpel/iapi/
bpel-dao/src/main/java/org/apache/ode/bpel/dao/ bpel-runtime/
bpel-runtime/src/main/java/org/apach...
Author: mszefler
Date: Tue Jan 2 08:34:09 2007
New Revision: 491841
URL: http://svn.apache.org/viewvc?view=rev&rev=491841
Log:
Fix NPEs in JBI.
Add real unit tests for JBI.
Added synchronization callbacks to scheduler.
Added missing read-lock on BPEL Engine usage.
Fixes to ProcessAndInstamceManagement process query.
Auto-detect of SQLServer.
Added:
incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ProcessManagementTest.java
incubator/ode/trunk/jbi/src/test/
incubator/ode/trunk/jbi/src/test/java/
incubator/ode/trunk/jbi/src/test/java/org/
incubator/ode/trunk/jbi/src/test/java/org/apache/
incubator/ode/trunk/jbi/src/test/java/org/apache/ode/
incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/
incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/TestOdeJbiComponentLifeCycle.java
incubator/ode/trunk/jbi/src/test/resources/
incubator/ode/trunk/jbi/src/test/resources/HelloWorldRequest.xml
incubator/ode/trunk/jbi/src/test/resources/carol.properties
incubator/ode/trunk/jbi/src/test/resources/log4j.properties
Removed:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelEventListener.java
incubator/ode/trunk/naming/
Modified:
incubator/ode/trunk/axis2/pom.xml
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
incubator/ode/trunk/bpel-runtime/pom.xml
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java
incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java
incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
incubator/ode/trunk/jacob/pom.xml
incubator/ode/trunk/jbi/pom.xml
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java
incubator/ode/trunk/pom.xml
Modified: incubator/ode/trunk/axis2/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/pom.xml?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/axis2/pom.xml (original)
+++ incubator/ode/trunk/axis2/pom.xml Tue Jan 2 08:34:09 2007
@@ -140,6 +140,12 @@
<version>2.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Tue Jan 2 08:34:09 2007
@@ -110,8 +110,6 @@
private BpelServerConnector _connector;
- private String _dbType;
- private String _dialect;
public void init(ServletConfig config, AxisConfiguration axisConf) throws ServletException {
_axisConfig = axisConf;
@@ -419,19 +417,13 @@
else __log.error(errmsg);
}
}
- if (properties.get(Environment.DIALECT) != null) {
- _dialect = (String) properties.get(Environment.DIALECT);
- if (_dialect.equals("org.hibernate.dialect.SQLServerDialect"))
- _dbType = "sqlserver";
- else _dbType = "other";
- }
SessionManager sm = new SessionManager(properties, _datasource, _txMgr);
_daoCF = new BpelDAOConnectionFactoryImpl(sm);
}
private void initProcessStore() {
- _store = new ProcessStoreImpl(_datasource, _dialect);
+ _store = new ProcessStoreImpl(_datasource);
_store.registerListener(new ProcessStoreListenerImpl());
_store.setDeployDir(new File(_workRoot, "processes"));
}
@@ -448,7 +440,6 @@
_scheduler.setExecutorService(_executorService, 20);
_scheduler.setTransactionManager(_txMgr);
_scheduler.setDataSource(_datasource);
- if ("sqlserver".equals(_dbType)) _scheduler.setSqlServer(true);
_scheduler.init();
_server.setDaoConnectionFactory(_daoCF);
Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java (original)
+++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java Tue Jan 2 08:34:09 2007
@@ -73,9 +73,30 @@
<T> T execTransaction(Callable<T> transaction)
throws Exception, ContextException;
+ /**
+ * Register a transaction synchronizer.
+ * @param synch synchronizer
+ * @throws ContextException
+ */
+ void registerSynchronizer(Synchronizer synch) throws ContextException;
+
void start();
void stop();
void shutdown();
+
+ public interface Synchronizer {
+ /**
+ * Called after the transaction is completed.
+ * @param success indicates whether the transaction was comitted
+ */
+ void afterCompletion(boolean success);
+
+ /**
+ * Called before the transaction is completed.
+ */
+ void beforeCompletion();
+
+ }
}
Modified: incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java (original)
+++ incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java Tue Jan 2 08:34:09 2007
@@ -18,17 +18,16 @@
*/
package org.apache.ode.bpel.dao;
-import org.apache.ode.bpel.common.BpelEventFilter;
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.evt.BpelEvent;
-
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.evt.BpelEvent;
+
/**
* Represents the physical resource for connecting to the bpel state store.
@@ -65,13 +64,6 @@
* @return Collection<ProcessInstanceDAO>
*/
Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter criteria);
-
- /**
- * Query processes in the database meeting the request criteria.
- * @param criteria
- * @return Collection<ProcessDAO>
- */
- Collection<ProcessDAO> processQuery(ProcessFilter criteria);
/**
* Insert a BPEL event into the database.
Modified: incubator/ode/trunk/bpel-runtime/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/pom.xml?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/pom.xml (original)
+++ incubator/ode/trunk/bpel-runtime/pom.xml Tue Jan 2 08:34:09 2007
@@ -136,11 +136,6 @@
</dependency>
<dependency>
<groupId>org.apache.ode</groupId>
- <artifactId>ode-naming</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.ode</groupId>
<artifactId>ode-minerva</artifactId>
<scope>test</scope>
</dependency>
@@ -155,6 +150,8 @@
<execution>
<phase>generate-sources</phase>
<configuration>
+ <nocompile>true</nocompile>
+ <fork>true</fork>
<generated>target/generated-sources/apt</generated>
<target>1.5</target>
</configuration>
Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java Tue Jan 2 08:34:09 2007
@@ -19,13 +19,28 @@
package org.apache.ode.bpel.engine;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.dao.ProcessDAO;
import org.apache.ode.bpel.dao.ProcessInstanceDAO;
import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.iapi.BpelEngine;
+import org.apache.ode.bpel.iapi.BpelEngineException;
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
import org.apache.ode.bpel.iapi.MessageExchange.Status;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus;
@@ -34,11 +49,6 @@
import org.apache.ode.bpel.o.OProcess;
import org.apache.ode.utils.msg.MessageBundle;
-import javax.wsdl.Operation;
-import javax.wsdl.PortType;
-import javax.xml.namespace.QName;
-import java.util.*;
-
/**
* Implementation of the {@link BpelEngine} interface: provides the server
* methods that should be invoked in the context of a transaction.
@@ -48,12 +58,11 @@
*/
public class BpelEngineImpl implements BpelEngine {
private static final Log __log = LogFactory.getLog(BpelEngineImpl.class);
+
/** RNG, for delays */
private Random _random = new Random(System.currentTimeMillis());
private static double _delayMean = 0;
- // Reaping
- private static long _processMaxAge = 60*60*1000;
static {
try {
@@ -69,20 +78,6 @@
__log.info("Could not read ODE_DEBUG_TX_DELAY environment variable; assuming 0 (mean) delay");
}
}
- // TODO Clean this up and factorize engine configuration
- try {
- String processMaxAge = System.getenv("ODE_DEF_MAX_AGE");
- if (processMaxAge != null && processMaxAge.length() > 0) {
- _processMaxAge = Long.valueOf(processMaxAge);
- __log.info("Process definition max age adjusted. Max age = " + _processMaxAge + "ms.");
- }
- } catch (Throwable t) {
- if (__log.isDebugEnabled()) {
- __log.debug("Could not read ODE_DEF_MAX_AGE environment variable; assuming " + _processMaxAge + " delay", t);
- } else {
- __log.info("Could not read ODE_DEF_MAX_AGE environment variable; assuming " + _processMaxAge + " delay");
- }
- }
}
private static final Messages __msgs = MessageBundle.getMessages(Messages.class);
@@ -90,8 +85,6 @@
/** Active processes, keyed by process id. */
final HashMap<QName, BpelProcess> _activeProcesses = new HashMap<QName, BpelProcess>();
- final HashMap<QName, Long> _processesLRU = new HashMap<QName, Long>();
-
/** Mapping from myrole endpoint name to active process. */
private final HashMap<Endpoint, BpelProcess> _serviceMap = new HashMap<Endpoint, BpelProcess>();
@@ -99,7 +92,6 @@
public BpelEngineImpl(Contexts contexts) {
_contexts = contexts;
- new Thread(new ProcessDefReaper()).start();
}
public MyRoleMessageExchange createMessageExchange(String clientKey, QName targetService, String operation)
@@ -109,7 +101,8 @@
MessageExchangeDAO dao;
if (target == null || target.isInMemory()) {
- dao = _contexts.inMemDao.getConnection().createMessageExchange(MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE);
+ dao = _contexts.inMemDao.getConnection().createMessageExchange(
+ MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE);
} else {
dao = _contexts.dao.getConnection().createMessageExchange(MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE);
}
@@ -123,7 +116,6 @@
if (target != null) {
target.initMyRoleMex(mex);
- refreshLRU(target._pid);
}
return mex;
@@ -139,37 +131,36 @@
MessageExchangeImpl mex;
switch (mexdao.getDirection()) {
- case MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE:
- if (process == null) {
- String errmsg = __msgs.msgProcessNotActive(pdao.getProcessId());
- __log.error(errmsg);
- // TODO: Perhaps we should define a checked exception for this
- // condition.
- throw new BpelEngineException(errmsg);
- } else {
- refreshLRU(process._pid);
- OPartnerLink plink = (OPartnerLink) process._oprocess.getChild(mexdao.getPartnerLinkModelId());
- PortType ptype = plink.partnerRolePortType;
- Operation op = plink.getPartnerRoleOperation(mexdao.getOperation());
- // TODO: recover Partner's EPR
- mex = new PartnerRoleMessageExchangeImpl(this, mexdao, ptype, op, null,
- plink.hasMyRole() ? process.getInitialMyRoleEPR(plink) : null,
- process.getPartnerRoleChannel(plink));
- }
- break;
- case MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE:
- mex = new MyRoleMessageExchangeImpl(this, mexdao);
- if (process != null) {
- OPartnerLink plink = (OPartnerLink) process._oprocess.getChild(mexdao.getPartnerLinkModelId());
- PortType ptype = plink.myRolePortType;
- Operation op = plink.getMyRoleOperation(mexdao.getOperation());
- mex.setPortOp(ptype, op);
- }
- break;
- default:
- String errmsg = "BpelEngineImpl: internal error, invalid MexDAO direction: " + mexId;
- __log.fatal(errmsg);
+ case MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE:
+ if (process == null) {
+ String errmsg = __msgs.msgProcessNotActive(pdao.getProcessId());
+ __log.error(errmsg);
+ // TODO: Perhaps we should define a checked exception for this
+ // condition.
throw new BpelEngineException(errmsg);
+ }
+ {
+ OPartnerLink plink = (OPartnerLink) process._oprocess.getChild(mexdao.getPartnerLinkModelId());
+ PortType ptype = plink.partnerRolePortType;
+ Operation op = plink.getPartnerRoleOperation(mexdao.getOperation());
+ // TODO: recover Partner's EPR
+ mex = new PartnerRoleMessageExchangeImpl(this, mexdao, ptype, op, null, plink.hasMyRole() ? process
+ .getInitialMyRoleEPR(plink) : null, process.getPartnerRoleChannel(plink));
+ }
+ break;
+ case MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE:
+ mex = new MyRoleMessageExchangeImpl(this, mexdao);
+ if (process != null) {
+ OPartnerLink plink = (OPartnerLink) process._oprocess.getChild(mexdao.getPartnerLinkModelId());
+ PortType ptype = plink.myRolePortType;
+ Operation op = plink.getMyRoleOperation(mexdao.getOperation());
+ mex.setPortOp(ptype, op);
+ }
+ break;
+ default:
+ String errmsg = "BpelEngineImpl: internal error, invalid MexDAO direction: " + mexId;
+ __log.fatal(errmsg);
+ throw new BpelEngineException(errmsg);
}
return mex;
@@ -236,8 +227,11 @@
OProcess getOProcess(QName processId) {
BpelProcess process = _activeProcesses.get(processId);
- if (process == null) return null;
- else return process._oprocess;
+
+ if (process == null)
+ return null;
+
+ return process._oprocess;
}
public void onScheduledJob(String jobId, Map<String, Object> jobDetail) {
@@ -270,20 +264,30 @@
}
assert process != null;
- refreshLRU(process._pid);
process.handleWorkEvent(jobDetail);
+ debuggingDelay();
+ }
+ /**
+ * Block the thread for random amount of time. Used for testing for races
+ * and the like. The delay generated is exponentially distributed with the
+ * mean obtained from the <code>ODE_DEBUG_TX_DELAY</code> environment
+ * variable.
+ */
+ private void debuggingDelay() {
// Do a delay for debugging purposes.
- if (_delayMean != 0 )
+ if (_delayMean != 0)
try {
- double u = _random.nextDouble(); // Uniform
- long delay = (long)(-Math.log(u)*_delayMean); // Exponential distribution with mean _delayMean
- __log.warn("Debugging delay has been activated; delaying transaction for " + delay + "ms." );
+ double u = _random.nextDouble(); // Uniform
+ long delay = (long) (-Math.log(u) * _delayMean); // Exponential
+ // distribution
+ // with mean
+ // _delayMean
+ __log.warn("Debugging delay has been activated; delaying transaction for " + delay + "ms.");
Thread.sleep(delay);
} catch (InterruptedException e) {
; // ignore
}
-
}
void fireEvent(BpelEvent event) {
@@ -301,46 +305,11 @@
/**
* Get the list of globally-registered message-exchange interceptors.
+ *
* @return list
*/
List<MessageExchangeInterceptor> getGlobalInterceptors() {
return _contexts.globalIntereceptors;
}
- void refreshLRU(QName pid) {
- synchronized(_processesLRU) {
- _processesLRU.put(pid, System.currentTimeMillis());
- }
- }
-
- private class ProcessDefReaper implements Runnable {
- public void run() {
- try {
- while (true) {
- Thread.sleep(10000);
- try {
- for (BpelProcess process : _activeProcesses.values()) {
- Long lru;
- synchronized(_processesLRU) {
- lru = _processesLRU.get(process._pid);
- }
- if (lru != null && process._oprocess != null
- && System.currentTimeMillis() - lru > _processMaxAge) {
- process._oprocess = null;
- __log.debug("Process definition reaper cleaning " + process._pid);
- }
- Thread.sleep(10);
- }
- } catch (ConcurrentModificationException cme) {
- // A concurrent modification could happen once in a while, it's not really a
- // problem as we'll try again 10s later.
- __log.debug("Concurrent modification exception while trying to reap process definitions, " +
- "will try again in a few seconds.");
- }
- }
- } catch (InterruptedException e) {
- __log.info(e);
- }
- }
- }
}
Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java Tue Jan 2 08:34:09 2007
@@ -95,6 +95,9 @@
private final ProcessConf _pconf;
+ /** Last time the process was used. */
+ volatile long _lastUsed;
+
public BpelProcess(ProcessConf conf, OProcess oprocess, BpelEventListener debugger, ExpressionLanguageRuntimeRegistry expLangRuntimeRegistry) {
_pid = conf.getProcessId();
_pconf = conf;
@@ -157,6 +160,7 @@
if (__log.isDebugEnabled())
__log.debug("Recovering activity in process " + instanceDAO.getInstanceId() + " with action " + action);
+ markused();
BpelRuntimeContextImpl processInstance = createRuntimeContext(instanceDAO, null, null);
processInstance.recoverActivity(channel, activityId, action, fault);
}
@@ -176,6 +180,7 @@
void invokeProcess(MyRoleMessageExchangeImpl mex) {
PartnerLinkMyRoleImpl target = getMyRoleForService(mex.getServiceName());
+ markused();
if (target == null) {
String errmsg = __msgs.msgMyRoleRoutingFailure(mex.getMessageExchangeId());
__log.error(errmsg);
@@ -202,7 +207,7 @@
}
void initMyRoleMex(MyRoleMessageExchangeImpl mex) {
- reload();
+ markused();
PartnerLinkMyRoleImpl target = null;
for (Endpoint endpoint : _endpointToMyRoleMap.keySet()) {
if (endpoint.serviceName.equals(mex.getServiceName()))
@@ -228,7 +233,7 @@
* @throws FaultException
*/
String extractProperty(Element msgData, OProcess.OPropertyAlias alias, String target) throws FaultException {
-
+ markused();
PropertyAliasEvaluationContext ectx = new PropertyAliasEvaluationContext(msgData, alias);
Node lValue = ectx.getRootNode();
@@ -641,7 +646,7 @@
* @see org.apache.ode.bpel.engine.BpelProcess#handleWorkEvent(java.util.Map<java.lang.String,java.lang.Object>)
*/
public void handleWorkEvent(Map<String, Object> jobData) {
- reload();
+ markused();
ProcessInstanceDAO procInstance;
if (__log.isDebugEnabled()) {
@@ -736,6 +741,8 @@
}
__log.debug("Activated " + _pid);
+
+ markused();
}
void deactivate() {
@@ -773,6 +780,7 @@
}
public void saveEvent(ProcessInstanceEvent event) {
+ markused();
boolean enabled = false;
List<String> scopeNames = null;
if (event instanceof ScopeEvent) {
@@ -794,16 +802,12 @@
return _pconf.isTransient();
}
- private void reload() {
- // Reload OProcess if it has been disposed
- if (_oprocess == null) {
- try {
- _oprocess = BpelServerImpl.deserializeCompiledProcess(_pconf.getCBPInputStream());
- } catch (Exception e) {
- String errmsg = __msgs.msgProcessLoadError(_pconf.getProcessId());
- __log.error(errmsg, e);
- throw new BpelEngineException(errmsg, e);
- }
- }
+ public long getLastUsed() {
+ return _lastUsed;
+ }
+
+ /** Keep track of the time the process was last used. */
+ private final void markused() {
+ _lastUsed = System.currentTimeMillis();
}
}
Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java Tue Jan 2 08:34:09 2007
@@ -27,6 +27,7 @@
import org.apache.ode.bpel.explang.ConfigurationException;
import org.apache.ode.bpel.iapi.*;
import org.apache.ode.bpel.iapi.BpelEventListener;
+import org.apache.ode.bpel.iapi.Scheduler.Synchronizer;
import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
import org.apache.ode.bpel.o.OExpressionLanguage;
import org.apache.ode.bpel.o.OProcess;
@@ -62,6 +63,26 @@
private static final Messages __msgs = MessageBundle.getMessages(Messages.class);
+ /** Maximum age of a process before it is quiesced */
+ private static Long __processMaxAge;
+
+ static {
+ // TODO Clean this up and factorize engine configuration
+ try {
+ String processMaxAge = System.getenv("ODE_DEF_MAX_AGE");
+ if (processMaxAge != null && processMaxAge.length() > 0) {
+ __processMaxAge = Long.valueOf(processMaxAge);
+ __log.info("Process definition max age adjusted. Max age = " + __processMaxAge + "ms.");
+ }
+ } catch (Throwable t) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Could not parse ODE_DEF_MAX_AGE environment variable." ,t);
+ } else {
+ __log.info("Could not parse ODE_DEF_MAX_AGE environment variable; reaping disabled.");
+ }
+ }
+ }
+
/**
* Management lock for synchronizing management operations and preventing
* processing (transactions) from occuring while management operations are
@@ -203,8 +224,15 @@
}
public BpelEngine getEngine() {
- // TODO: acquire read lock and tie the release to the current
- // transaction.
+
+ _mngmtLock.readLock().lock();
+ _contexts.scheduler.registerSynchronizer(new Synchronizer() {
+ public void afterCompletion(boolean success) {}
+ public void beforeCompletion() {
+ _mngmtLock.readLock().unlock();
+ }
+
+ });
return _engine;
}
@@ -450,4 +478,40 @@
}
}
+
+
+//
+// I've moved this code out of BpelEngineImpl, it should be here not there.
+// -Maciej 12/22/06
+// /**
+//
+// */
+// private class ProcessDefReaper implements Runnable {
+// public void run() {
+// try {
+// while (true) {
+// Thread.sleep(10000);
+// _mngmtLock.writeLock().lock();
+// try {
+// for (BpelProcess process : _activeProcesses.values()) {
+// Long lru;
+// synchronized(_processesLRU) {
+// lru = _processesLRU.get(process._pid);
+// }
+// if (lru != null && process._oprocess != null
+// && System.currentTimeMillis() - lru > _processMaxAge) {
+// process._oprocess = null;
+// __log.debug("Process definition reaper cleaning " + process._pid);
+// }
+// Thread.sleep(10);
+// }
+// } finally {
+// _mngmtLock.writeLock().unlock();
+// }
+// }
+// } catch (InterruptedException e) {
+// __log.info(e);
+// }
+// }
+// }
}
Modified: incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java Tue Jan 2 08:34:09 2007
@@ -19,6 +19,21 @@
package org.apache.ode.bpel.engine;
+import java.io.File;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -26,8 +41,34 @@
import org.apache.ode.bpel.common.Filter;
import org.apache.ode.bpel.common.InstanceFilter;
import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.*;
-import org.apache.ode.bpel.evt.*;
+import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.evt.ActivityEvent;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.bpel.evt.CorrelationEvent;
+import org.apache.ode.bpel.evt.CorrelationMatchEvent;
+import org.apache.ode.bpel.evt.CorrelationSetEvent;
+import org.apache.ode.bpel.evt.CorrelationSetWriteEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationEvent;
+import org.apache.ode.bpel.evt.ExpressionEvaluationFailedEvent;
+import org.apache.ode.bpel.evt.NewProcessInstanceEvent;
+import org.apache.ode.bpel.evt.PartnerLinkEvent;
+import org.apache.ode.bpel.evt.ProcessCompletionEvent;
+import org.apache.ode.bpel.evt.ProcessEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStartedEvent;
+import org.apache.ode.bpel.evt.ProcessInstanceStateChangeEvent;
+import org.apache.ode.bpel.evt.ProcessMessageExchangeEvent;
+import org.apache.ode.bpel.evt.ScopeCompletionEvent;
+import org.apache.ode.bpel.evt.ScopeEvent;
+import org.apache.ode.bpel.evt.ScopeFaultEvent;
+import org.apache.ode.bpel.evt.VariableEvent;
import org.apache.ode.bpel.evtproc.ActivityStateDocumentBuilder;
import org.apache.ode.bpel.iapi.BpelEngineException;
import org.apache.ode.bpel.iapi.BpelServer;
@@ -38,27 +79,57 @@
import org.apache.ode.bpel.o.OBase;
import org.apache.ode.bpel.o.OPartnerLink;
import org.apache.ode.bpel.o.OProcess;
-import org.apache.ode.bpel.pmapi.*;
+import org.apache.ode.bpel.pmapi.ActivityExtInfoListDocument;
+import org.apache.ode.bpel.pmapi.ActivityInfoDocument;
+import org.apache.ode.bpel.pmapi.EventInfoListDocument;
+import org.apache.ode.bpel.pmapi.InstanceInfoDocument;
+import org.apache.ode.bpel.pmapi.InstanceInfoListDocument;
+import org.apache.ode.bpel.pmapi.InstanceManagement;
+import org.apache.ode.bpel.pmapi.InstanceNotFoundException;
+import org.apache.ode.bpel.pmapi.InvalidRequestException;
+import org.apache.ode.bpel.pmapi.ManagementException;
+import org.apache.ode.bpel.pmapi.ProcessInfoCustomizer;
+import org.apache.ode.bpel.pmapi.ProcessInfoDocument;
+import org.apache.ode.bpel.pmapi.ProcessInfoListDocument;
+import org.apache.ode.bpel.pmapi.ProcessManagement;
+import org.apache.ode.bpel.pmapi.ProcessNotFoundException;
+import org.apache.ode.bpel.pmapi.ProcessingException;
+import org.apache.ode.bpel.pmapi.ScopeInfoDocument;
+import org.apache.ode.bpel.pmapi.TActivityExtInfo;
+import org.apache.ode.bpel.pmapi.TActivityStatus;
+import org.apache.ode.bpel.pmapi.TActivitytExtInfoList;
+import org.apache.ode.bpel.pmapi.TCorrelationProperty;
+import org.apache.ode.bpel.pmapi.TDefinitionInfo;
+import org.apache.ode.bpel.pmapi.TDeploymentInfo;
+import org.apache.ode.bpel.pmapi.TDocumentInfo;
+import org.apache.ode.bpel.pmapi.TEndpointReferences;
+import org.apache.ode.bpel.pmapi.TEventInfo;
+import org.apache.ode.bpel.pmapi.TEventInfoList;
+import org.apache.ode.bpel.pmapi.TFailureInfo;
+import org.apache.ode.bpel.pmapi.TFailuresInfo;
+import org.apache.ode.bpel.pmapi.TFaultInfo;
+import org.apache.ode.bpel.pmapi.TInstanceInfo;
+import org.apache.ode.bpel.pmapi.TInstanceInfoList;
+import org.apache.ode.bpel.pmapi.TInstanceStatus;
+import org.apache.ode.bpel.pmapi.TInstanceSummary;
+import org.apache.ode.bpel.pmapi.TProcessInfo;
+import org.apache.ode.bpel.pmapi.TProcessInfoList;
+import org.apache.ode.bpel.pmapi.TProcessProperties;
+import org.apache.ode.bpel.pmapi.TProcessStatus;
+import org.apache.ode.bpel.pmapi.TScopeInfo;
+import org.apache.ode.bpel.pmapi.TScopeRef;
+import org.apache.ode.bpel.pmapi.TVariableInfo;
+import org.apache.ode.bpel.pmapi.TVariableRef;
+import org.apache.ode.bpel.pmapi.VariableInfoDocument;
import org.apache.ode.utils.ISO8601DateParser;
import org.apache.ode.utils.msg.MessageBundle;
import org.apache.ode.utils.stl.CollectionsX;
import org.apache.ode.utils.stl.MemberOfFunction;
import org.apache.ode.utils.stl.UnaryFunction;
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.criterion.Example;
-import org.hibernate.criterion.Property;
-import org.hibernate.criterion.Restrictions;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.text.ParseException;
-import java.util.*;
-import java.util.regex.Pattern;
-
/**
* Implentation of the Process and InstanceManagement APIs.
*
@@ -717,6 +788,7 @@
String queryStatus = InstanceFilter.StatusKeys.valueOf(state.toString()).toString().toLowerCase();
final InstanceFilter instanceFilter = new InstanceFilter("status=" + queryStatus + " name="
+ pconf.getProcessId().getLocalPart() + " namespace=" + pconf.getProcessId().getNamespaceURI());
+
int count = dbexec(new BpelDatabase.Callable<Integer>() {
public Integer run(BpelDAOConnection conn) throws Exception {
@@ -1034,7 +1106,7 @@
// Name filter can be implemented using only the PIDs.
if (filter != null && filter.getNameFilter() != null) {
- final Pattern pattern = Pattern.compile(filter.getNameFilter());
+ final Pattern pattern = Pattern.compile(filter.getNameFilter().replace("*",".*"));
CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {
@Override
public boolean isMember(QName o) {
@@ -1044,7 +1116,7 @@
}
if (filter != null && filter.getNamespaceFilter() != null) {
- final Pattern pattern = Pattern.compile(filter.getNameFilter());
+ final Pattern pattern = Pattern.compile(filter.getNamespaceFilter().replace("*",".*"));
CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {
@Override
public boolean isMember(QName o) {
Modified: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Tue Jan 2 08:34:09 2007
@@ -18,11 +18,37 @@
*/
package org.apache.ode.bpel.runtime;
-import com.fs.naming.mem.InMemoryContextFactory;
+import java.io.File;
+import java.sql.DriverManager;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
import org.apache.ode.bpel.engine.BpelServerImpl;
-import org.apache.ode.bpel.iapi.*;
-import org.apache.ode.bpel.pmapi.BpelManagementFacade;
+import org.apache.ode.bpel.iapi.BindingContext;
+import org.apache.ode.bpel.iapi.BpelServer;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.Endpoint;
+import org.apache.ode.bpel.iapi.EndpointReference;
+import org.apache.ode.bpel.iapi.EndpointReferenceContext;
+import org.apache.ode.bpel.iapi.Message;
+import org.apache.ode.bpel.iapi.MessageExchangeContext;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.iapi.Scheduler.Synchronizer;
import org.apache.ode.bpel.scheduler.quartz.QuartzSchedulerImpl;
import org.apache.ode.daohib.DataSourceConnectionProvider;
import org.apache.ode.daohib.HibernateTransactionManagerLookup;
@@ -37,22 +63,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.Name;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.wsdl.PortType;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.sql.DriverManager;
-import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
class MockBpelServer {
@@ -160,14 +170,6 @@
_jotm = new Jotm(true, false);
_txManager = _jotm.getTransactionManager();
_txManager.setTransactionTimeout(30);
- Reference txm = new Reference("javax.transaction.TransactionManager",
- JotmTransactionManagerFactory.class.getName(), null);
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
- InMemoryContextFactory.class.getName());
- System.setProperty(Context.PROVIDER_URL, "pxe");
- InitialContext ctx = new InitialContext();
- ctx.rebind("TransactionManager", txm);
- ctx.close();
return _txManager;
}
@@ -213,11 +215,7 @@
properties.put(Environment.DIALECT, "org.hibernate.dialect.DerbyDialect");
SessionManager sm = new SessionManager(properties, _dataSource, _txManager);
_daoCF = new BpelDAOConnectionFactoryImpl(sm);
- Reference bpelSscfRef = new Reference(BpelDAOConnectionFactory.class.getName(),
- HibernateDaoObjectFactory.class.getName(), null);
- InitialContext ctx = new InitialContext();
- ctx.rebind("bpelSSCF", bpelSscfRef);
- ctx.close();
+
return _daoCF;
}
@@ -280,32 +278,7 @@
return _bindContext;
}
- /**
- * An {@link javax.naming.spi.ObjectFactory} implementation that can be used to bind the
- * JOTM {@link javax.transaction.TransactionManager} implementation in JNDI.
- */
- private class JotmTransactionManagerFactory implements ObjectFactory {
- public Object getObjectInstance(Object objref, Name name, Context ctx, Hashtable env) throws Exception {
- Reference ref = (Reference) objref;
- if (ref.getClassName().equals(TransactionManager.class.getName()))
- return _jotm.getTransactionManager();
- throw new RuntimeException("The reference class name \"" + ref.getClassName() + "\" is unknown.");
- }
- }
-
- /**
- * JNDI {@link ObjectFactory} implementation for Hibernate-based
- * connection factory objects.
- */
- private class HibernateDaoObjectFactory implements ObjectFactory {
- public Object getObjectInstance(Object objref, Name name, Context ctx, Hashtable env) throws Exception {
- Reference ref = (Reference) objref;
- if (ref.getClassName().equals(BpelDAOConnectionFactory.class.getName()))
- return _daoCF;
- throw new RuntimeException("The reference class name \"" + ref.getClassName() + "\" is unknown.");
- }
- }
-
+
private class SchedulerWrapper implements Scheduler {
QuartzSchedulerImpl _quartz;
@@ -344,6 +317,10 @@
public void start() { _quartz.start(); }
public void stop() { _quartz.stop(); }
public void shutdown() { _quartz.shutdown(); }
+
+ public void registerSynchronizer(Synchronizer synch) throws ContextException {
+ _quartz.registerSynchronizer(synch);
+ }
}
}
Added: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ProcessManagementTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ProcessManagementTest.java?view=auto&rev=491841
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ProcessManagementTest.java (added)
+++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/ProcessManagementTest.java Tue Jan 2 08:34:09 2007
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.runtime;
+
+import java.io.File;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.ode.bpel.engine.BpelManagementFacadeImpl;
+import org.apache.ode.bpel.pmapi.BpelManagementFacade;
+import org.apache.ode.bpel.pmapi.ProcessInfoCustomizer;
+import org.apache.ode.bpel.pmapi.TProcessInfo;
+import org.apache.ode.utils.DOMUtils;
+
+/**
+ * Test activity recovery and failure handling.
+ */
+public class ProcessManagementTest extends TestCase {
+
+ static final String NAMESPACE = "http://ode.apache.org/bpel/unit-test";
+ MockBpelServer _server;
+ BpelManagementFacade _management;
+ QName _processQName;
+
+
+ public void testFilterProcessesByName() throws Exception {
+
+ List<TProcessInfo> pilist = _management.listProcesses(null,null).getProcessInfoList().getProcessInfoList();
+ assertEquals(5,pilist.size());
+
+ pilist = _management.listProcesses("name=FailureInh*",null).getProcessInfoList().getProcessInfoList();
+ assertEquals(1,pilist.size());
+
+ pilist = _management.listProcesses("name=FailureToRecovery",null).getProcessInfoList().getProcessInfoList();
+ assertEquals(1,pilist.size());
+
+ pilist = _management.listProcesses("name=foobaz*",null).getProcessInfoList().getProcessInfoList();
+ assertEquals(0,pilist.size());
+
+ pilist = _management.listProcesses("namespace="+NAMESPACE,null).getProcessInfoList().getProcessInfoList();
+ assertEquals(5,pilist.size());
+
+ pilist = _management.listProcesses("namespace=http:*",null).getProcessInfoList().getProcessInfoList();
+ assertEquals(5,pilist.size());
+
+ pilist = _management.listProcesses("namespace=foo:*",null).getProcessInfoList().getProcessInfoList();
+ assertEquals(0,pilist.size());
+ }
+
+ public void testListProcessesOrder() {
+ List<TProcessInfo> pilist =
+ _management.listProcesses(null,"name").getProcessInfoList().getProcessInfoList();
+
+ for (int i = 1 ; i < pilist.size(); ++i) {
+ QName qname = QName.valueOf(pilist.get(i).getPid());
+ QName qnamePrev = QName.valueOf(pilist.get(i-1).getPid());
+ assertTrue(0<=qname.getLocalPart().compareTo(qnamePrev.getLocalPart()));
+ }
+
+ pilist =
+ _management.listProcesses(null,"-name").getProcessInfoList().getProcessInfoList();
+
+ for (int i = 1 ; i < pilist.size(); ++i) {
+ QName qname = QName.valueOf(pilist.get(i).getPid());
+ QName qnamePrev = QName.valueOf(pilist.get(i-1).getPid());
+ assertTrue(0>=qname.getLocalPart().compareTo(qnamePrev.getLocalPart()));
+ }
+ }
+
+ public void testListProcessCustom() {
+ List<TProcessInfo> pilist =
+ _management.listProcessesCustom(null,"name", ProcessInfoCustomizer.ALL).getProcessInfoList().getProcessInfoList();
+ assertEquals(5,pilist.size());
+ }
+
+ protected void setUp() throws Exception {
+
+ _server = new MockBpelServer();
+ _server.deploy(new File(new URI(this.getClass().getResource("/recovery").toString())));
+ _management = new BpelManagementFacadeImpl(_server._server,_server._store);
+ execute("FailureInheritence");
+ }
+
+ protected void tearDown() throws Exception {
+ _management.delete(null);
+ _server.shutdown();
+ _server = null;
+ _management = null;
+ _processQName = null;
+ }
+
+ /**
+ * Call this to execute the process so it fails the specified number of times.
+ * Returns when the process has either completed, or waiting for recovery to happen.
+ */
+ protected void execute(String process) throws Exception {
+ _management.delete(null);
+ _processQName = new QName(NAMESPACE, process);
+ _server.invoke(_processQName, "instantiate",
+ DOMUtils.newDocument().createElementNS(NAMESPACE, "tns:RequestElement"));
+ _server.waitForBlocking();
+ }
+}
Modified: incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java (original)
+++ incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java Tue Jan 2 08:34:09 2007
@@ -19,13 +19,31 @@
package org.apache.ode.bpel.scheduler.quartz;
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+
+import javax.sql.DataSource;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.TransactionManager;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.ContextException;
import org.apache.ode.bpel.iapi.Scheduler;
import org.apache.ode.utils.GUID;
-import org.quartz.*;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.SchedulerException;
+import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
import org.quartz.core.QuartzScheduler;
import org.quartz.core.QuartzSchedulerResources;
import org.quartz.core.SchedulingContext;
@@ -36,17 +54,11 @@
import org.quartz.spi.ThreadPool;
import org.quartz.utils.DBConnectionManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-
/**
- * Base class that can be used to quickly implement a persistent scheduler.
+ * Quartz-based scheduler.
+ *
+ * @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
+ *
*/
public class QuartzSchedulerImpl implements Scheduler {
@@ -69,7 +81,7 @@
private TransactionManager _txm;
- private boolean isSqlServer = false;
+ private boolean _isSqlServer = false;
public QuartzSchedulerImpl() {
_id = "ODE";
@@ -107,6 +119,8 @@
JobStoreJTA jobStore = new JobStoreJTA(_txm);
jobStore.setDataSource("managed");
+ checkSqlServer();
+
try {
_quartz = createScheduler(_id, _id, new QuartzThreadPoolExecutorServiceImpl(_executorSvc,
_threads), jobStore);
@@ -117,6 +131,27 @@
}
}
+ /**
+ * Check to see if the database is SQL server.
+ */
+ private void checkSqlServer() {
+ Connection conn = null;
+ try {
+ conn = _managedDS.getConnection();
+ String dbname = conn.getMetaData().getDatabaseProductName().toLowerCase();
+ _isSqlServer = dbname.contains("sqlserver") || dbname.contains(" sql server") || dbname.contains("microsoft sql");
+ } catch (Exception ex) {
+ throw new ContextException("Error connecting to the database.", ex);
+ } finally {
+ try {
+ conn.close();
+ } catch (Exception ex) {
+ ;
+ }
+ }
+
+ }
+
public void start() {
if (_quartz == null)
throw new IllegalStateException("init() not called!");
@@ -285,7 +320,7 @@
jobStore.setInstanceName(schedulerName);
jobStore.setInstanceId(schedulerInstanceId);
- if (isSqlServer)
+ if (_isSqlServer)
jobStore.setSelectWithLockSQL("SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
JTAJobRunShellFactory jrsf = new JTAJobRunShellFactory(_txm);
@@ -314,8 +349,23 @@
return scheduler;
}
- public void setSqlServer(boolean sqlServer) {
- isSqlServer = sqlServer;
+
+ public void registerSynchronizer(final Synchronizer synch) throws ContextException {
+ try {
+ _txm.getTransaction().registerSynchronization(new Synchronization() {
+
+ public void beforeCompletion() {
+ synch.beforeCompletion();
+ }
+
+ public void afterCompletion(int status) {
+ synch.afterCompletion(status == Status.STATUS_COMMITTED);
+ }
+
+ });
+ } catch (Exception e) {
+ throw new ContextException("Unable to register synchronizer.", e);
+ }
}
}
Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java Tue Jan 2 08:34:09 2007
@@ -1,11 +1,35 @@
package org.apache.ode.store;
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.sql.DataSource;
+import javax.xml.namespace.QName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.dd.DeployDocument;
import org.apache.ode.bpel.dd.TDeployment;
-import org.apache.ode.bpel.dd.TDeployment.Process;
-import org.apache.ode.bpel.iapi.*;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.ProcessState;
+import org.apache.ode.bpel.iapi.ProcessStore;
+import org.apache.ode.bpel.iapi.ProcessStoreEvent;
+import org.apache.ode.bpel.iapi.ProcessStoreListener;
import org.apache.ode.store.DeploymentUnitDir.CBPInfo;
import org.apache.ode.store.hib.DbConfStoreConnectionFactory;
import org.apache.ode.utils.DOMUtils;
@@ -16,19 +40,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import javax.sql.DataSource;
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
/**
* <p>
* JDBC-based implementation of a process store. Also provides an "in-memory" store by way of HSQL database.
@@ -82,12 +93,12 @@
private DataSource _inMemDs;
public ProcessStoreImpl() {
- this(null, null);
+ this(null);
}
- public ProcessStoreImpl(DataSource ds, String dbName) {
+ public ProcessStoreImpl(DataSource ds) {
if (ds != null) {
- _cf = new DbConfStoreConnectionFactory(ds, false, dbName);
+ _cf = new DbConfStoreConnectionFactory(ds, false);
} else {
// If the datasource is not provided, then we create a HSQL-based in-memory
@@ -96,7 +107,7 @@
hsqlds.setDatabase("jdbc:hsqldb:mem:" + _guid);
hsqlds.setUser("sa");
hsqlds.setPassword("");
- _cf = new DbConfStoreConnectionFactory(hsqlds, true, null);
+ _cf = new DbConfStoreConnectionFactory(hsqlds, true);
_inMemDs = hsqlds;
}
@@ -257,7 +268,7 @@
} catch (Exception ex) {
__log.error("Error synchronizing with data store; " + dir.getName() + " may be reappear after restart!");
}
-
+
Collection<QName> undeployed = Collections.emptyList();
_rw.writeLock().lock();
try {
@@ -392,6 +403,7 @@
*
*/
public void loadAll() {
+
exec(new Callable<Object>() {
public Object call(ConfStoreConnection conn) {
Collection<DeploymentUnitDAO> dus = conn.getDeploymentUnits();
Modified: incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java (original)
+++ incubator/ode/trunk/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java Tue Jan 2 08:34:09 2007
@@ -1,5 +1,15 @@
package org.apache.ode.store.hib;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.sql.DataSource;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.BpelEngineException;
@@ -15,15 +25,6 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DialectFactory;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
public class DbConfStoreConnectionFactory implements ConfStoreConnectionFactory {
private static final Log __log = LogFactory.getLog(DbConfStoreConnectionFactory.class);
@@ -59,7 +60,7 @@
final SessionFactory _sessionFactory;
- public DbConfStoreConnectionFactory(DataSource ds, boolean auto, String dbname) {
+ public DbConfStoreConnectionFactory(DataSource ds, boolean auto) {
_ds = ds;
Properties properties = new Properties();
@@ -69,16 +70,12 @@
properties.put("guid", _guid);
properties.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
- if (dbname != null) {
- properties.put(Environment.DIALECT, dbname);
- } else {
- try {
- properties.put(Environment.DIALECT, guessDialect(_ds));
- } catch (Exception ex) {
- String errmsg = __msgs.msgOdeInitHibernateDialectDetectFailed();
- __log.error(errmsg, ex);
- throw new BpelEngineException(errmsg, ex);
- }
+ try {
+ properties.put(Environment.DIALECT, guessDialect(_ds));
+ } catch (Exception ex) {
+ String errmsg = __msgs.msgOdeInitHibernateDialectDetectFailed();
+ __log.error(errmsg, ex);
+ throw new BpelEngineException(errmsg, ex);
}
if (auto) {
Modified: incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java (original)
+++ incubator/ode/trunk/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java Tue Jan 2 08:34:09 2007
@@ -20,7 +20,7 @@
hsqlds.setUser("sa");
hsqlds.setPassword("");
- cf = new DbConfStoreConnectionFactory(hsqlds, true, null);
+ cf = new DbConfStoreConnectionFactory(hsqlds, true);
}
public void tearDown() throws Exception {
Modified: incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java (original)
+++ incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java Tue Jan 2 08:34:09 2007
@@ -19,41 +19,59 @@
package org.apache.ode.test.scheduler;
-import org.apache.ode.bpel.iapi.ContextException;
-import org.apache.ode.bpel.iapi.Scheduler;
-
import java.util.Date;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArrayList;
-public class TestScheduler implements Scheduler {
-
- public String schedulePersistedJob(Map<String, Object> arg0, Date arg1)
- throws ContextException {
- return null;
- }
-
- public String scheduleVolatileJob(boolean arg0, Map<String, Object> arg1,
- Date arg2) throws ContextException {
- return null;
- }
-
- public void cancelJob(String arg0) throws ContextException {
-
- }
-
- public <T> T execTransaction(Callable<T> arg0) throws Exception,
- ContextException {
- T retval = arg0.call();
- return retval;
- }
-
- public void start() {
- }
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.Scheduler;
- public void stop() {
- }
+public class TestScheduler implements Scheduler {
+ List<Scheduler.Synchronizer> _synchros = new CopyOnWriteArrayList<Scheduler.Synchronizer>();
- public void shutdown() {
- }
+ public String schedulePersistedJob(Map<String, Object> arg0, Date arg1) throws ContextException {
+ return null;
+ }
+
+ public String scheduleVolatileJob(boolean arg0, Map<String, Object> arg1, Date arg2) throws ContextException {
+ return null;
+ }
+
+ public void cancelJob(String arg0) throws ContextException {
+
+ }
+
+ public <T> T execTransaction(Callable<T> arg0) throws Exception, ContextException {
+ try {
+ T retval = arg0.call();
+ return retval;
+ } finally {
+ for (Synchronizer s : _synchros)
+ try {
+ s.beforeCompletion();
+ } catch (Throwable t) {
+ }
+ for (Synchronizer s : _synchros)
+ try {
+ s.afterCompletion(true);
+ } catch (Throwable t) {
+ }
+
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public void shutdown() {
+ }
+
+ public void registerSynchronizer(Synchronizer synch) throws ContextException {
+ _synchros.add(synch);
+ }
}
Modified: incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java Tue Jan 2 08:34:09 2007
@@ -21,9 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.common.BpelEventFilter;
-import org.apache.ode.bpel.common.Filter;
import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.common.ProcessFilter;
import org.apache.ode.bpel.dao.BpelDAOConnection;
import org.apache.ode.bpel.dao.MessageExchangeDAO;
import org.apache.ode.bpel.dao.ProcessDAO;
@@ -154,102 +152,7 @@
return daos;
}
- public Collection<ProcessDAO> processQuery(ProcessFilter filter) {
- List<ProcessDAO> daos = new ArrayList<ProcessDAO>();
-
- Iterator<HProcess> iter = _processQuery(_session, filter);
- while (iter.hasNext()) {
- daos.add(new ProcessDaoImpl(_sm, iter.next()));
- }
-
- return daos;
- }
-
- @SuppressWarnings("unchecked")
- static Iterator<HProcess> _processQuery(Session session, ProcessFilter filter) {
- Criteria crit = session.createCriteria(HProcess.class);
-
- // TODO Implement process status filtering when status will exist
-
- // TODO separate localname and namespace to provide proper querying
- if (filter != null) {
- // Filtering using an example object
- HProcess exampleProcess = new HProcess();
- crit.add(Example.create(exampleProcess).ignoreCase().enableLike().excludeZeroes()
- .excludeProperty("retired").excludeProperty("active").excludeProperty("version"));
-
- if (filter.getNameFilter() != null) {
- exampleProcess.setTypeName(filter.getNameFilter().replaceAll("\\*", "%"));
- }
- if (filter.getNamespaceFilter() != null) {
- exampleProcess.setTypeNamespace(filter.getNamespaceFilter().replaceAll("\\*", "%"));
- }
-
- // Specific filter for deployment date.
- if (filter.getDeployedDateFilter() != null) {
- for (String ddf : filter.getDeployedDateFilter()) {
- Date deployDate = null;
- try {
- deployDate = ISO8601DateParser.parse(Filter.getDateWithoutOp(ddf));
- } catch (ParseException e) {
- // Never occurs, the deploy date format is pre-validated
- // by the filter
- }
- if (ddf.startsWith("=")) {
- crit.add(Restrictions.eq("deployDate", deployDate));
- } else if (ddf.startsWith("<=")) {
- crit.add(Restrictions.le("deployDate", deployDate));
- } else if (ddf.startsWith(">=")) {
- crit.add(Restrictions.ge("deployDate", deployDate));
- } else if (ddf.startsWith("<")) {
- crit.add(Restrictions.lt("deployDate", deployDate));
- } else if (ddf.startsWith(">")) {
- crit.add(Restrictions.gt("deployDate", deployDate));
- }
- }
- }
-
- // Ordering
- if (filter.getOrders() != null) {
- for (String key : filter.getOrders()) {
- boolean ascending = true;
- String orderKey = key;
- if (key.startsWith("+") || key.startsWith("-")) {
- orderKey = key.substring(1, key.length());
- if (key.startsWith("-"))
- ascending = false;
- }
-
- if ("name".equals(orderKey)) {
- if (ascending)
- crit.addOrder(Property.forName("processName").asc());
- else
- crit.addOrder(Property.forName("processName").desc());
- } else if ("namespace".equals(orderKey)) {
- if (ascending)
- crit.addOrder(Property.forName("processNamespace").asc());
- else
- crit.addOrder(Property.forName("processNamespace").desc());
- } else if ("version".equals(orderKey)) {
- if (ascending)
- crit.addOrder(Property.forName("version").asc());
- else
- crit.addOrder(Property.forName("version").desc());
- // TODO Implement when process status will be
- // implemented
- // } else if ("status".equals(orderKey)) {
- } else if ("deployed".equals(orderKey)) {
- if (ascending)
- crit.addOrder(Property.forName("deployDate").asc());
- else
- crit.addOrder(Property.forName("deployDate").desc());
- }
- }
- }
- }
- return crit.list().iterator();
- }
-
+
@SuppressWarnings("unchecked")
static Iterator<HProcessInstance> _instanceQuery(Session session, boolean countOnly, InstanceFilter filter) {
Criteria crit = session.createCriteria(HProcessInstance.class);
Modified: incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java (original)
+++ incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java Tue Jan 2 08:34:09 2007
@@ -45,19 +45,6 @@
stopTM();
}
- public void testListProcess() throws Exception {
- for (int index = 0; index < 5; index++) {
- StringBuffer filter = new StringBuffer();
- for (Map.Entry<String, List> entry : filterElmts.entrySet()) {
- filter.append(entry.getKey());
- filter.append(entry.getValue().get((index < entry.getValue().size()) ? index : index % entry.getValue().size()));
- ProcessFilter pfilter = new ProcessFilter(filter.toString(),
- order.get((index < order.size()) ? index : index % order.size()));
- daoConn.processQuery(pfilter);
- }
- }
- }
-
private void buildFilterElements() {
filterElmts = new HashMap<String, List>();
ArrayList<String> nameList = new ArrayList<String>();
Modified: incubator/ode/trunk/jacob/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jacob/pom.xml?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jacob/pom.xml (original)
+++ incubator/ode/trunk/jacob/pom.xml Tue Jan 2 08:34:09 2007
@@ -57,6 +57,8 @@
<phase>generate-sources</phase>
<configuration>
<generated>target/generated-sources/apt</generated>
+ <nocompile>true</nocompile>
+ <fork>true</fork>
<target>1.5</target>
</configuration>
<goals>
Modified: incubator/ode/trunk/jbi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/pom.xml?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jbi/pom.xml (original)
+++ incubator/ode/trunk/jbi/pom.xml Tue Jan 2 08:34:09 2007
@@ -31,7 +31,30 @@
<version>2.0-SNAPSHOT</version>
</parent>
<version>2.0-SNAPSHOT</version>
+ <properties>
+ <servicemixVersion>3.0-incubating-SNAPSHOT</servicemixVersion>
+ </properties>
+
<dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-jbi</artifactId>
+ <version>${servicemixVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>${servicemixVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ <version>${servicemixVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.ode</groupId>
<artifactId>ode-dao-hibernate</artifactId>
@@ -55,6 +78,12 @@
<dependency>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-jbi</artifactId>
+ <version>${servicemixVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ <version>${servicemixVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java Tue Jan 2 08:34:09 2007
@@ -159,6 +159,12 @@
public Boolean call() throws Exception {
PartnerRoleMessageExchange pmex = (PartnerRoleMessageExchange) _ode._server
.getEngine().getMessageExchange(mexref);
+
+ if (pmex == null) {
+ __log.warn("Cannot locate ODE message exchange: " + mexref + "; ignoring.");
+ return null;
+ }
+
pmex.replyWithFailure(FailureType.OTHER, "Error: "
+ jbiMex.getError(), null);
return null;
@@ -183,6 +189,12 @@
public Boolean call() throws Exception {
PartnerRoleMessageExchange pmex = (PartnerRoleMessageExchange) _ode._server
.getEngine().getMessageExchange(mexref);
+
+ if (pmex == null) {
+ // I'm a bit unclear as to why this would occur, but it appears to be possible.
+ __log.warn("Cannot locate ODE message exchange: " + mexref + "; ignoring.");
+ return null;
+ }
String mapperName = pmex.getProperty(Mapper.class.getName());
Mapper mapper = mapperName == null ? _ode.getDefaultMapper() : _ode.getMapper(mapperName);
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java Tue Jan 2 08:34:09 2007
@@ -26,6 +26,7 @@
import org.apache.ode.bpel.iapi.ProcessStore;
import org.apache.ode.bpel.scheduler.quartz.QuartzSchedulerImpl;
import org.apache.ode.jbi.msgmap.Mapper;
+import org.apache.ode.store.ProcessStoreImpl;
import org.w3c.dom.Document;
import javax.jbi.component.ComponentContext;
@@ -83,7 +84,7 @@
DataSource _dataSource;
- ProcessStore _store;
+ ProcessStoreImpl _store;
/** Mapping of Endpoint to OdeService */
private Map<Endpoint, OdeService> _activeOdeServices = new ConcurrentHashMap<Endpoint, OdeService>();
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java Tue Jan 2 08:34:09 2007
@@ -52,6 +52,7 @@
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.Executors;
@@ -74,8 +75,6 @@
private boolean _needDerbyShutdown;
private String _derbyUrl;
private BpelServerConnector _connector;
- private String _dbType;
- private String _dialect;
ServiceUnitManager getSUManager() {
return _suManager;
@@ -96,8 +95,9 @@
_ode._consumer = new OdeConsumer(_ode);
- TempFileManager.setWorkingDirectory(new File(_ode.getContext()
- .getWorkspaceRoot()));
+ if (_ode.getContext().getWorkspaceRoot() != null)
+ TempFileManager.setWorkingDirectory(new File(_ode.getContext()
+ .getWorkspaceRoot()));
__log.debug("Loading properties.");
initProperties();
@@ -248,10 +248,10 @@
_ode._scheduler.setTransactionManager((TransactionManager) _ode
.getContext().getTransactionManager());
_ode._scheduler.setDataSource(_ode._dataSource);
- if ("sqlserver".equals(_dbType)) _ode._scheduler.setSqlServer(true);
_ode._scheduler.init();
- _ode._store = new ProcessStoreImpl(_ode._dataSource, _dialect);
+ _ode._store = new ProcessStoreImpl(_ode._dataSource);
+ _ode._store.loadAll();
_ode._server.setInMemDaoConnectionFactory(new org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl());
@@ -307,12 +307,7 @@
else __log.error(errmsg);
}
}
- if (properties.get(Environment.DIALECT) != null) {
- _dialect = (String) properties.get(Environment.DIALECT);
- if (_dialect.equals("org.hibernate.dialect.SQLServerDialect"))
- _dbType = "sqlserver";
- else _dbType = "other";
- }
+
SessionManager sm = new SessionManager(properties, _ode._dataSource, _ode
.getTransactionManager());
@@ -332,7 +327,10 @@
try {
_connector.start();
} catch (Exception e) {
- __log.error("Failed to initialize JCA connector.",e);
+
+ __log.error("Failed to initialize JCA connector (check security manager configuration)");
+ __log.debug("Failed to initialize JCA connector (check security manager configuration)",e);
+
}
}
}
@@ -450,9 +448,14 @@
__log.debug("shutting down derby.");
EmbeddedDriver driver = new EmbeddedDriver();
try {
- driver.connect(_derbyUrl+";shutdown", new Properties());
+ driver.connect(_derbyUrl+";shutdown=true", new Properties());
+ } catch (SQLException ex) {
+ // Shutdown will always return an exeption!
+ if (ex.getErrorCode() != 45000)
+ __log.error("Error shutting down Derby: " + ex.getErrorCode(), ex);
+
} catch (Exception ex) {
- __log.error("Error shutting down derby.", ex);
+ __log.error("Error shutting down Derby.", ex);
}
}
__log.info("Shutdown completed.");
Modified: incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java?view=diff&rev=491841&r1=491840&r2=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java (original)
+++ incubator/ode/trunk/jbi/src/main/java/org/apache/ode/jbi/OdeServiceUnit.java Tue Jan 2 08:34:09 2007
@@ -58,14 +58,21 @@
}
public void deploy() throws DeploymentException {
-
+
+ // Do a pre-emptive undeploy.
+ try {
+ _ode._store.undeploy(_serviceUnitRootPath);
+ } catch (Exception ex) {
+ __log.debug("Undeploy failed.",ex);
+ }
+
try {
_ode._store.deploy(_serviceUnitRootPath);
} catch (Exception ex) {
String errmsg = __msgs.msgOdeProcessDeploymentFailed(_serviceUnitRootPath, _serviceUnitID);
__log.error(errmsg, ex);
throw new DeploymentException(errmsg, ex);
- }
+ }
}
public void undeploy() throws Exception {
@@ -94,6 +101,11 @@
public void start() throws Exception {
List<QName> pids = _ode._store.listProcesses(_serviceUnitRootPath.getName());
+ if (pids == null) {
+ __log.error(_serviceUnitRootPath.getName() + " not found in process stroe. ");
+ throw new IllegalStateException("Process store and JBI out of synch.");
+ }
+
Exception e = null;
for (QName pid : pids) {
try {
Added: incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/TestOdeJbiComponentLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/TestOdeJbiComponentLifeCycle.java?view=auto&rev=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/TestOdeJbiComponentLifeCycle.java (added)
+++ incubator/ode/trunk/jbi/src/test/java/org/apache/ode/jbi/TestOdeJbiComponentLifeCycle.java Tue Jan 2 08:34:09 2007
@@ -0,0 +1,111 @@
+package org.apache.ode.jbi;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.ode.utils.DOMUtils;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.objectweb.jotm.Jotm;
+import org.xml.sax.InputSource;
+
+import junit.framework.TestCase;
+
+public class TestOdeJbiComponentLifeCycle extends TestCase {
+
+ JBIContainer container;
+ File rootDir, installDir, odeDir;
+ Jotm jotm;
+ private OdeComponent component;
+
+ protected void setUp() throws Exception {
+ rootDir = File.createTempFile("smixInstallDir","");
+ installDir = new File(rootDir,"install");
+ installDir.mkdir();
+ jotm = new Jotm(true,false);
+ odeDir = new File(installDir,"ODE");
+ odeDir.mkdir();
+
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setEmbedded(true);
+
+
+ container.setTransactionManager(jotm.getTransactionManager());
+ container.init();
+ container.start();
+
+ component = new OdeComponent();
+
+ }
+
+ protected void tearDown() throws Exception {
+ // Make sure to shutdown ODE, otherwise DB will lock up
+ try {
+ container.deactivateComponent("ODE");
+ } catch (Exception ex) {
+ ;//ok ignore
+ }
+
+ if (container != null) {
+ container.shutDown();
+ container = null;
+ }
+
+ component = null;
+
+
+ }
+
+ public void testComponentLifeCycle() throws Exception {
+ container.activateComponent(component,"ODE");
+ container.deactivateComponent("ODE");
+ }
+
+ public void testProcessLifeCycle() throws Exception {
+ container.activateComponent(component, "ODE");
+ container.start();
+
+ // For lack of a better way of doing this:
+ component.getServiceUnitManager().deploy("HelloWorld", "../jbi-examples/src/examples/HelloWorld2/HelloWorld2-process");
+ component.getServiceUnitManager().init("HelloWorld", "../jbi-examples/src/examples/HelloWorld2/HelloWorld2-process");
+ component.getServiceUnitManager().start("HelloWorld");
+ component.getServiceUnitManager().stop("HelloWorld");
+ component.getServiceUnitManager().undeploy("HelloWorld", "../jbi-examples/src/examples/HelloWorld2/HelloWorld2-process");
+
+ container.deactivateComponent("ODE");
+
+ container.stop();
+
+ }
+
+
+ public void testHelloWorld() throws Exception {
+ OdeComponent component = new OdeComponent();
+ container.activateComponent(component, "ODE");
+
+ // For lack of a better way of doing this:
+ component.getServiceUnitManager().deploy("HelloWorld", "../jbi-examples/src/examples/HelloWorld2/HelloWorld2-process");
+ component.getServiceUnitManager().init("HelloWorld", "../jbi-examples/src/examples/HelloWorld2/HelloWorld2-process");
+ component.getServiceUnitManager().start("HelloWorld");
+ DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+ InOut io = client.createInOutExchange();
+ io.setService(new QName("urn:/HelloWorld2.wsdl", "HelloService"));
+ io.setOperation(new QName("urn:/HelloWorld2.wsdl", "Hello"));
+ io.getInMessage().setContent(new StreamSource(getClass().getResourceAsStream("/HelloWorldRequest.xml")));
+ client.sendSync(io,20000);
+ assertEquals(ExchangeStatus.ACTIVE,io.getStatus());
+ assertNotNull(io.getOutMessage());
+ assertNotNull(io.getOutMessage().getContent());
+
+ }
+
+
+}
Added: incubator/ode/trunk/jbi/src/test/resources/HelloWorldRequest.xml
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/test/resources/HelloWorldRequest.xml?view=auto&rev=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/test/resources/HelloWorldRequest.xml (added)
+++ incubator/ode/trunk/jbi/src/test/resources/HelloWorldRequest.xml Tue Jan 2 08:34:09 2007
@@ -0,0 +1,3 @@
+<HelloRequest xmlns="urn:/HelloWorld2.wsdl">
+ <text>hello</text>
+</HelloRequest>
Added: incubator/ode/trunk/jbi/src/test/resources/carol.properties
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/jbi/src/test/resources/carol.properties?view=auto&rev=491841
==============================================================================
--- incubator/ode/trunk/jbi/src/test/resources/carol.properties (added)
+++ incubator/ode/trunk/jbi/src/test/resources/carol.properties Tue Jan 2 08:34:09 2007
@@ -0,0 +1,14 @@
+# JNDI (Protocol Invocation)
+#carol.protocols=jrmp
+
+# Local RMI Invocation
+#carol.jvm.rmi.local.call=true
+
+# do not use CAROL JNDI wrapper
+carol.start.jndi=false
+
+# do not start a name server
+carol.start.ns=false
+
+# Naming Factory
+#carol.jndi.java.naming.factory.url.pkgs=org.apache.naming