Author: mriou
Date: Thu Aug 10 12:41:44 2006
New Revision: 430501
URL: http://svn.apache.org/viewvc?rev=430501&view=rev
Log:
Resurrected memory DAOs.
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/DaoBaseImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/IdGen.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessPropertyDAOImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/package.html
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,34 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+
+/**
+ * Connection factory for the in-memory state store.
+ */
+public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactory {
+ private static final Map<QName, ProcessDaoImpl> __StateStore = new
HashMap<QName, ProcessDaoImpl>();
+
+
+ public BpelDAOConnection getConnection() {
+ return new BpelDAOConnectionImpl(__StateStore);
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.BpelDAOConnectionFactory#init(java.util.Properties)
+ */
+ public void init(Properties properties) {
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,268 @@
+/*
+ * File: $Id: BpelDAOConnectionImpl.java 1440 2006-06-05 13:22:47 +0200
(Mon, 05 Jun 2006) mriou $
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+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;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ProcessPropertyDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+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;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
BpelDAOConnection} interface.
+ */
+class BpelDAOConnectionImpl implements BpelDAOConnection {
+ private Map<QName, ProcessDaoImpl> _store;
+ private List<BpelEvent> _events = new LinkedList<BpelEvent>();
+
+ BpelDAOConnectionImpl(Map<QName, ProcessDaoImpl> store) {
+ _store = store;
+ }
+
+ public ProcessDAO getProcess(QName processId) {
+ return _store.get(processId);
+ }
+
+ public ProcessDAO createProcess(QName pid, QName type) {
+ return null;
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ for (ProcessDaoImpl proc : _store.values()) {
+ ProcessInstanceDAO instance = proc._instances.get(iid);
+ if (instance != null)
+ return instance;
+ }
+ return null;
+ }
+
+ public Collection<ProcessInstanceDAO> instanceQuery(InstanceFilter filter) {
+ if(filter.getLimit()==0) {
+ return Collections.EMPTY_LIST;
+ }
+ List<ProcessInstanceDAO> matched = new ArrayList<ProcessInstanceDAO>();
+ // Selecting
+ selectionCompleted:
+ for (ProcessDaoImpl proc : _store.values()) {
+ boolean pmatch = true;
+ if (filter.getNameFilter() != null
+ && !equalsOrWildcardMatch(filter.getNameFilter(),
proc.getProcessId().getLocalPart()))
+ pmatch = false;
+ if (filter.getNamespaceFilter() != null
+ && !equalsOrWildcardMatch(filter.getNamespaceFilter(),
proc.getProcessId().getNamespaceURI()))
+ pmatch = false;
+
+ if (pmatch) {
+ for (ProcessInstanceDAO inst : proc._instances.values()) {
+ boolean match = true;
+
+ if (filter.getStatusFilter() != null) {
+ boolean statusMatch = false;
+ for (Short status : filter.convertFilterState()) {
+ if (inst.getState() == status.byteValue()) statusMatch = true;
+ }
+ if (!statusMatch) match = false;
+ }
+ if (filter.getStartedDateFilter() != null
+ && !dateMatch(filter.getStartedDateFilter(),
inst.getCreateTime(), filter))
+ match = false;
+ if (filter.getLastActiveDateFilter() != null
+ && !dateMatch(filter.getLastActiveDateFilter(),
inst.getLastActiveTime(), filter))
+ match = false;
+
+ if (filter.getPropertyValuesFilter() != null) {
+ for (Map.Entry propEntry :
filter.getPropertyValuesFilter().entrySet()) {
+ boolean entryMatched = false;
+ for (ProcessPropertyDAO prop : proc.getProperties()) {
+ if (prop.getName().equals(propEntry.getKey())
+ && (propEntry.getValue().equals(prop.getMixedContent())
+ ||
propEntry.getValue().equals(prop.getSimpleContent()))) {
+ entryMatched = true;
+ }
+ }
+ if (!entryMatched) {
+ match = false;
+ }
+ }
+ }
+
+ if (match) {
+ matched.add(inst);
+ if(matched.size()==filter.getLimit()) {
+ break selectionCompleted;
+ }
+ }
+ }
+ }
+ }
+ // And ordering
+ if (filter.getOrders() != null) {
+ final List<String> orders = filter.getOrders();
+
+ Collections.sort(matched, new Comparator<ProcessInstanceDAO>() {
+ public int compare(ProcessInstanceDAO o1, ProcessInstanceDAO o2) {
+ for (String orderKey: orders) {
+ int result = compareInstanceUsingKey(orderKey, o1, o2);
+ if (result != 0) return result;
+ }
+ return 0;
+ }
+ });
+ }
+
+ return matched;
+ }
+
+ /**
+ * Close this DAO connection.
+ */
+ public void close() {
+ }
+
+ public Collection<ProcessDAO> processQuery(ProcessFilter filter) {
+ throw new UnsupportedOperationException("Can't query process configuration
using a transient DAO.");
+ }
+
+ public MessageExchangeDAO createMessageExchange(char dir) {
+ // TODO implement this.
+ throw new UnsupportedOperationException("Implement me.");
+ }
+
+ public MessageExchangeDAO getMessageExchange(String mexid) {
+ // TODO implement this.
+ throw new UnsupportedOperationException("Implement me.");
+ }
+
+ private int compareInstanceUsingKey(String key, ProcessInstanceDAO
instanceDAO1, ProcessInstanceDAO instanceDAO2) {
+ String s1 = null;
+ String s2 = null;
+ boolean ascending = true;
+ String orderKey = key;
+ if (key.startsWith("+") || key.startsWith("-")) {
+ orderKey = key.substring(1, key.length());
+ if (key.startsWith("-")) ascending = false;
+ }
+ ProcessDAO process1 = getProcess(instanceDAO1.getProcess().getProcessId());
+ ProcessDAO process2 = getProcess(instanceDAO2.getProcess().getProcessId());
+ if ("pid".equals(orderKey)) {
+ s1 = process1.getProcessId().toString();
+ s2 = process2.getProcessId().toString();
+ } else if ("name".equals(orderKey)) {
+ s1 = process1.getProcessId().getLocalPart();
+ s2 = process2.getProcessId().getLocalPart();
+ } else if ("namespace".equals(orderKey)) {
+ s1 = process1.getProcessId().getNamespaceURI();
+ s2 = process2.getProcessId().getNamespaceURI();
+ } else if ("version".equals(orderKey)) {
+ s1 = ""+process1.getVersion();
+ s2 = ""+process2.getVersion();
+ } else if ("status".equals(orderKey)) {
+ s1 = ""+instanceDAO1.getState();
+ s2 = ""+instanceDAO2.getState();
+ } else if ("started".equals(orderKey)) {
+ s1 = ISO8601DateParser.format(instanceDAO1.getCreateTime());
+ s2 = ISO8601DateParser.format(instanceDAO2.getCreateTime());
+ } else if ("last-active".equals(orderKey)) {
+ s1 = ISO8601DateParser.format(instanceDAO1.getLastActiveTime());
+ s2 = ISO8601DateParser.format(instanceDAO2.getLastActiveTime());
+ }
+ if (ascending) return s1.compareTo(s2);
+ else return s2.compareTo(s1);
+ }
+
+ private boolean equalsOrWildcardMatch(String s1, String s2) {
+ if (s1 == null || s2 == null) return false;
+ if (s1.equals(s2)) return true;
+ if (s1.endsWith("*")) {
+ if (s2.startsWith(s1.substring(0, s1.length() - 1))) return true;
+ }
+ if (s2.endsWith("*")) {
+ if (s1.startsWith(s2.substring(0, s2.length() - 1))) return true;
+ }
+ return false;
+ }
+
+ public boolean dateMatch(List<String> dateFilters, Date instanceDate,
InstanceFilter filter) {
+ boolean match = true;
+ for (String ddf : dateFilters) {
+ String isoDate = ISO8601DateParser.format(instanceDate);
+ String critDate = Filter.getDateWithoutOp(ddf);
+ if (ddf.startsWith("=")) {
+ if (!isoDate.startsWith(critDate)) match = false;
+ } else if (ddf.startsWith("<=")) {
+ if (!isoDate.startsWith(critDate) && isoDate.compareTo(critDate) > 0)
match = false;
+ } else if (ddf.startsWith(">=")) {
+ if (!isoDate.startsWith(critDate) && isoDate.compareTo(critDate) < 0)
match = false;
+ } else if (ddf.startsWith("<")) {
+ if (isoDate.compareTo(critDate) > 0) match = false;
+ } else if (ddf.startsWith(">")) {
+ if (isoDate.compareTo(critDate) < 0) match = false;
+ }
+ }
+ return match;
+ }
+
+
+ public ScopeDAO getScope(Long siidl) {
+ for (ProcessDaoImpl process : _store.values()) {
+ for (ProcessInstanceDAO instance : process._instances.values()) {
+ if (instance.getScope(siidl) != null) return instance.getScope(siidl);
+ }
+ }
+ return null;
+ }
+
+
+ public void insertBpelEvent(BpelEvent event, ProcessDAO
processConfiguration, ProcessInstanceDAO instance) {
+ _events.add(event);
+ }
+
+
+ public List<Date> bpelEventTimelineQuery(InstanceFilter ifilter,
BpelEventFilter efilter) {
+ // TODO : Provide more correct implementation:
+ ArrayList<Date> dates = new ArrayList<Date>();
+ CollectionsX.transform(dates, _events, new UnaryFunction<BpelEvent,Date>()
{
+ public Date apply(BpelEvent x) {
+ return x.getTimestamp();
+ }
+ });
+ return dates;
+ }
+
+
+ public List<BpelEvent> bpelEventQuery(InstanceFilter ifilter,
BpelEventFilter efilter) {
+ // TODO : Provide a more correct (filtering) implementation:
+ return _events;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.BpelDAOConnection#instanceQuery(String)
+ */
+ public Collection<ProcessInstanceDAO> instanceQuery(String expression) {
+ //TODO
+ throw new UnsupportedOperationException();
+ }
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,73 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
CorrelationSetDAO} interface.
+ */
+class CorrelationSetDaoImpl
+ implements CorrelationSetDAO {
+ private Long _csetId;
+ private ScopeDAO _scope;
+ private String _name;
+ private CorrelationKey _key;
+ private HashMap<QName,String> _corrValues;
+
+ /**
+ * Constructor.
+ * @param name correlation set name
+ * @param scope the scope for which the correlation set is relevant
+ */
+ public CorrelationSetDaoImpl(String name, org.apache.ode.bpel.dao.ScopeDAO
scope) {
+ _name = name;
+ _scope = scope;
+ _csetId = IdGen.newCorrelationSetId();
+ }
+
+ public Long getCorrelationSetId() {
+ return _csetId;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.CorrelationSetDAO#getName()
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.CorrelationSetDAO#getScope()
+ */
+ public ScopeDAO getScope() {
+ return _scope;
+ }
+
+ public void setValue(QName[] names, CorrelationKey values) {
+ _key = values;
+ _corrValues = new HashMap<QName, String>();
+ for (int m = 0; m < names.length; m++) {
+ _corrValues.put(names[m], values.getValues()[m]);
+ }
+ }
+
+
+ public CorrelationKey getValue() {
+ return _key;
+ }
+
+ public Map<QName, String> getProperties() {
+ return _corrValues;
+ }
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,128 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.utils.ArrayUtils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
CorrelatorDAO} interface.
+ */
+class CorrelatorDaoImpl extends DaoBaseImpl implements CorrelatorDAO {
+ private static final Log __log = LogFactory.getLog(CorrelatorDaoImpl.class);
+
+ private String _correlatorId;
+ private List<MsgQueueEntry> _messages;
+ private List<MessageRouteDaoImpl> _routes;
+
+ CorrelatorDaoImpl(String correlatorId) {
+ _messages = new ArrayList<MsgQueueEntry>();
+ _routes = new ArrayList<MessageRouteDaoImpl>();
+ _correlatorId = correlatorId;
+ }
+
+ public MessageExchangeDAO dequeueMessage(CorrelationKey key) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("dequeueEarliest: MATCHING correlationKey=" + key);
+ }
+ for (Iterator i = _messages.iterator(); i.hasNext();) {
+ MsgQueueEntry mqe = (MsgQueueEntry)i.next();
+ Set<CorrelationKey> keyset =
(Set<CorrelationKey>)ArrayUtils.makeCollection(HashSet.class, mqe.keys);
+ if ((key == null) || keyset.contains(key)) {
+ i.remove();
+ return mqe.message;
+ }
+ }
+ if (__log.isDebugEnabled()) {
+ __log.debug("dequeueEarliest: MATCH NOT FOUND!");
+ }
+ return null;
+ }
+
+ public MessageRouteDAO findRoute(CorrelationKey key) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("findRoute: key=" + key);
+ }
+ for (MessageRouteDaoImpl we : _routes) {
+ if ((we._ckey == null && key == null) || (we._ckey != null && key !=
null && we._ckey.equals(key))) {
+ return we;
+ }
+ }
+ return null;
+ }
+
+ public String getCorrelatorId() {
+ return _correlatorId;
+ }
+
+ public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
+ for (Iterator<MessageRouteDaoImpl> i = _routes.iterator(); i.hasNext();) {
+ MessageRouteDaoImpl we = i.next();
+ if ((we._groupId.equals(routeGroupId) || routeGroupId == null) &&
we._instance == target) {
+ i.remove();
+ }
+ }
+ }
+
+ public void enqueueMessage(MessageExchangeDAO mex, CorrelationKey[] keys) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("enqueueProcessInvocation: data=" + mex + " keys="
+ + ArrayUtils.makeCollection(ArrayList.class, keys));
+ }
+
+ MsgQueueEntry mqe = new MsgQueueEntry(mex, keys);
+ _messages.add(mqe);
+ }
+
+ public void addRoute(String routeId,ProcessInstanceDAO target, int idx,
CorrelationKey key) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("addRoute: target=" + target + " correlationKey=" + key);
+ }
+
+ MessageRouteDaoImpl mr = new
MessageRouteDaoImpl((ProcessInstanceDaoImpl)target, routeId, key, idx);
+ _routes.add(mr);
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer("{CorrelatorDaoImpl corrId=");
+ buf.append(_correlatorId);
+ buf.append(" waiters=");
+ buf.append(_routes);
+ buf.append(" messages=");
+ buf.append(_messages);
+ buf.append('}');
+
+ return buf.toString();
+ }
+
+ private class MsgQueueEntry {
+ public final MessageExchangeDAO message;
+ public final CorrelationKey[] keys;
+
+ private MsgQueueEntry(MessageExchangeDAO mex,
+ CorrelationKey[] keys) {
+ this.message = mex;
+ this.keys = keys;
+ }
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/DaoBaseImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/DaoBaseImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/DaoBaseImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/DaoBaseImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,26 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.utils.uuid.UUIDGen;
+
+import java.util.Date;
+
+
+/**
+ * Base-class for in-memory data-access objects.
+ */
+class DaoBaseImpl {
+ private static final UUIDGen __uuidGen = new UUIDGen();
+
+ Date _createTime = new Date();
+ String _uuid = __uuidGen.nextUUID();
+
+ public Date getCreateTime() {
+ return _createTime;
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/FaultDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,68 @@
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.utils.QNameUtils;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * In-memory implementation of [EMAIL PROTECTED] FaultDAO}.
+ */
+public class FaultDaoImpl extends DaoBaseImpl implements FaultDAO {
+
+ private String _name;
+ private String _explanation;
+ private Element _data;
+ private int _lineNo;
+ private int _activityId;
+
+ public FaultDaoImpl(String name, String explanation, Element data, int
lineNo, int activityId) {
+ _name = name;
+ _explanation = explanation;
+ _data = data;
+ _lineNo = lineNo;
+ _activityId = activityId;
+ }
+
+ public QName getName() {
+ return QNameUtils.toQName(_name);
+ }
+
+ public void setName(QName name) {
+ _name = QNameUtils.fromQName(name);
+ }
+
+ public String getExplanation() {
+ return _explanation;
+ }
+
+ public void setExplanation(String explanation) {
+ _explanation = explanation;
+ }
+
+ public Element getData() {
+ return _data;
+ }
+
+ public void setData(Element data) {
+ _data = data;
+ }
+
+ public int getLineNo() {
+ return _lineNo;
+ }
+
+ public void setLineNo(int lineNo) {
+ _lineNo = lineNo;
+ }
+
+ public int getActivityId() {
+ return _activityId;
+ }
+
+ public void setActivityId(int activityId) {
+ _activityId = activityId;
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/IdGen.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/IdGen.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/IdGen.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/IdGen.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,31 @@
+/*
+ * File: $Id: IdGen.java 843 2006-02-17 21:51:55Z mriou $
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Generates unique keys for process instances and scopes.
+ *
+ */
+class IdGen {
+ private static AtomicLong PROC_ID = new AtomicLong(0);
+ private static AtomicLong SCOPE_ID = new AtomicLong(0);
+ private static AtomicLong CSET_ID = new AtomicLong(0);
+
+ public static Long newProcessId() {
+ return PROC_ID.getAndIncrement();
+ }
+
+ public static Long newScopeId() {
+ return SCOPE_ID.getAndIncrement();
+ }
+
+ public static Long newCorrelationSetId() {
+ return CSET_ID.getAndIncrement();
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,40 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
MessageRouteDAO} interface.
+ */
+class MessageRouteDaoImpl extends DaoBaseImpl implements MessageRouteDAO {
+ ProcessInstanceDaoImpl _instance;
+ String _groupId;
+ CorrelationKey _ckey;
+ int _idx;
+
+ MessageRouteDaoImpl(ProcessInstanceDaoImpl owner, String groupId,
CorrelationKey ckey, int idx) {
+ _instance = owner;
+ _groupId = groupId;
+ _ckey = ckey;
+ _idx = idx;
+ }
+
+ public ProcessInstanceDAO getTargetInstance() {
+ return _instance;
+ }
+
+ public String getGroupId() {
+ return _groupId;
+ }
+
+ public int getIndex() {
+ return _idx;
+ }
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/PartnerLinkDAOImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,77 @@
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
org.apache.ode.bpel.dao.PartnerLinkDAO} interface.
+ */
+public class PartnerLinkDAOImpl extends DaoBaseImpl implements PartnerLinkDAO {
+
+ private int _modelId;
+ private String _linkName;
+ private String _myRoleName;
+ private QName _myRoleServiceName;
+ private String _partnerRoleName;
+ private Element _myEpr;
+ private Element _partnerEpr;
+
+ public String getPartnerLinkName() {
+ return _linkName;
+ }
+
+ public void setPartnerLinkName(String partnerLinkName) {
+ _linkName = partnerLinkName;
+ }
+
+ public int getPartnerLinkModelId() {
+ return _modelId;
+ }
+
+ public void setPartnerLinkModelId(int modelId) {
+ _modelId = modelId;
+ }
+
+ public String getMyRoleName() {
+ return _myRoleName;
+ }
+
+ public QName getMyRoleServiceName() {
+ return _myRoleServiceName;
+ }
+
+ public void setMyRoleServiceName(QName svcName) {
+ _myRoleServiceName = svcName;
+ }
+
+ public void setMyRoleName(String myRoleName) {
+ _myRoleName = myRoleName;
+ }
+
+ public String getPartnerRoleName() {
+ return _partnerRoleName;
+ }
+
+ public void setPartnerRoleName(String partnerRoleName) {
+ _partnerRoleName = partnerRoleName;
+ }
+
+ public Element getMyEPR() {
+ return _myEpr;
+ }
+
+ public void setMyEPR(Element myEpr) {
+ _myEpr = myEpr;
+ }
+
+ public Element getPartnerEPR() {
+ return _partnerEpr;
+ }
+
+ public void setPartnerEPR(Element partnerEpr) {
+ _partnerEpr = partnerEpr;
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,220 @@
+/*
+ * File: $Id: ProcessDaoImpl.java 1220 2006-04-27 20:03:24Z mbs $
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.commons.collections.map.MultiKeyMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+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.ProcessPropertyDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
ProcessDAO} interface.
+ */
+class ProcessDaoImpl extends DaoBaseImpl implements ProcessDAO {
+ private static final Log __log = LogFactory.getLog(ProcessDaoImpl.class);
+
+ private QName _processId;
+ private QName _type;
+ private final Map<String, CorrelatorDAO> _correlators = new
ConcurrentHashMap<String, CorrelatorDAO>();
+ protected final Map<Long, ProcessInstanceDAO> _instances = new
ConcurrentHashMap<Long, ProcessInstanceDAO>();
+ protected final Map<Integer, PartnerLinkDAO> _plinks = new
ConcurrentHashMap<Integer, PartnerLinkDAO>();
+ private Map<String, ProcessDaoImpl> _store;
+ private BpelDAOConnectionImpl _conn;
+ private final Date _deployDate = new Date();
+ private boolean _retired;
+ private boolean _active;
+ private byte[] _compiledProcess;
+ private URI _deployURI;
+ private MultiKeyMap _properties = new MultiKeyMap();
+
+ public ProcessDaoImpl(BpelDAOConnectionImpl conn,
+ Map<String, ProcessDaoImpl> store,
+ QName processId, QName type) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("Creating ProcessDao object for process \"" + processId +
"\".");
+ }
+
+ _conn = conn;
+ _store = store;
+ _processId = processId;
+ _type = type;
+ }
+
+ public QName getProcessId() {
+ return _processId;
+ }
+
+ public CorrelatorDAO getCorrelator(String cid) {
+ CorrelatorDAO ret = _correlators.get(cid);
+ if (ret == null) {
+ throw new IllegalArgumentException("no such correlator: " + cid);
+ }
+ return ret;
+ }
+
+ public Collection<CorrelatorDAO> getCorrelators() {
+ return _correlators.values();
+ }
+
+ public void removeRoutes(String routeId, ProcessInstanceDAO target) {
+ for (CorrelatorDAO correlatorDAO : _correlators.values()) {
+ correlatorDAO.removeRoutes(routeId, target);
+ }
+ }
+
+ public ProcessInstanceDAO createInstance(CorrelatorDAO correlator) {
+ ProcessInstanceDaoImpl newInstance = new ProcessInstanceDaoImpl(_conn,
this, correlator);
+ _instances.put(newInstance.getInstanceId(), newInstance);
+ return newInstance;
+ }
+
+ public ProcessInstanceDAO getInstance(Long instanceId) {
+ return _instances.get(instanceId);
+ }
+
+
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey key) {
+ ArrayList<ProcessInstanceDAO> result = new ArrayList<ProcessInstanceDAO>();
+ for (ProcessInstanceDAO instance : _instances.values()) {
+ for (CorrelationSetDAO corrSet : instance.getCorrelationSets()) {
+ if (corrSet.getValue().equals(key)) result.add(instance);
+ }
+ }
+ return result;
+ }
+
+ public void instanceCompleted(ProcessInstanceDAO instance) {
+ _instances.remove(instance.getInstanceId());
+ }
+
+ public void setProperty(String name, String ns, Node content) {
+ if (content == null) {
+ _properties.remove(name, ns);
+ } else {
+ ProcessPropertyDAOImpl pp = new ProcessPropertyDAOImpl();
+ pp.setName(name);
+ pp.setNamespace(ns);
+ pp.setMixedContent(DOMUtils.domToString(content));
+ _properties.put(name, ns, pp);
+ }
+ }
+
+ public void setProperty(String name, String ns, String content) {
+ if (content == null) {
+ _properties.remove(name, ns);
+ } else {
+ ProcessPropertyDAOImpl pp = new ProcessPropertyDAOImpl();
+ pp.setName(name);
+ pp.setNamespace(ns);
+ pp.setSimpleContent(content);
+ _properties.put(name, ns, pp);
+ }
+ }
+
+ public Collection<ProcessPropertyDAO> getProperties() {
+ return _properties.values();
+ }
+
+ public Collection<PartnerLinkDAO> getDeployedEndpointReferences() {
+ return _plinks.values();
+ }
+
+ public void delete() {
+ _store.remove(_processId);
+ }
+
+ public int getVersion() {
+ return 0;
+ }
+
+ public String getDeployer() {
+ return "nobody";
+ }
+
+ public Date getDeployDate() {
+ return _deployDate;
+ }
+
+ public boolean isRetired() {
+ return _retired;
+ }
+
+ public void setRetired(boolean retired) {
+ this._retired = retired;
+ }
+
+ public QName getType() {
+ return _type;
+ }
+
+ public PartnerLinkDAO addDeployedPartnerLink(int plinkModelId, String
plinkName, String myRoleName, String partnerRoleName) {
+ PartnerLinkDAOImpl plink = new PartnerLinkDAOImpl();
+ plink.setPartnerLinkModelId(plinkModelId);
+ plink.setPartnerLinkName(plinkName);
+ plink.setMyRoleName(myRoleName);
+ plink.setPartnerRoleName(partnerRoleName);
+ _plinks.put(plinkModelId, plink);
+ return plink;
+ }
+
+ public PartnerLinkDAO getDeployedEndpointReference(int plinkModelId) {
+ return _plinks.get(plinkModelId);
+ }
+
+ public void setActive(boolean active) {
+ _active = active;
+ }
+
+ public boolean isActive() {
+ return _active;
+ }
+
+ public void addCorrelator(String correlator) {
+ CorrelatorDaoImpl corr = new CorrelatorDaoImpl(correlator);
+ _correlators.put(corr.getCorrelatorId(), corr);
+ }
+
+ public void setDeployURI(URI dduri) {
+ _deployURI = dduri;
+ }
+
+ public void setCompiledProcess(byte[] cbp) {
+ _compiledProcess = cbp;
+ }
+
+ public byte[] getCompiledProcess() {
+ return _compiledProcess;
+ }
+
+ public URI getDeployURI() {
+ return _deployURI;
+ }
+
+ /**
+ * Nothing to do.
+ * @see org.apache.ode.bpel.dao.ProcessConfigurationDAO#update()
+ */
+ public void update() {
+ //TODO Check requirement for persisting.
+ }
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,286 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.FaultDAO;
+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.ProcessInstanceEvent;
+import org.apache.ode.utils.QNameUtils;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
ProcessInstanceDAO} interface.
+ */
+ class ProcessInstanceDaoImpl extends DaoBaseImpl implements
ProcessInstanceDAO {
+ private static final Collection<ScopeDAO> EMPTY_SCOPE_DAOS =
Collections.emptyList();
+
+ private short _previousState;
+ private short _state;
+ private Long _instanceId;
+ private ProcessDaoImpl _processDao;
+ private byte[] _jacobState;
+ private Map<Long, ScopeDAO> _scopes = new HashMap<Long, ScopeDAO>();
+ private Map<String, List<ScopeDAO>> _scopesByName = new HashMap<String,
List<ScopeDAO>>();
+ private Map<String, byte[]> _messageExchanges = new HashMap<String,
byte[]>();
+ private ScopeDAO _rootScope;
+ private FaultDAO _fault;
+ private CorrelatorDAO _instantiatingCorrelator;
+ private BpelDAOConnection _conn;
+
+ // TODO: Remove this, we should be using the main event store...
+ private List<ProcessInstanceEvent> _events = new
ArrayList<ProcessInstanceEvent>();
+
+ private Date _lastActive;
+
+ private int _seq;
+
+ ProcessInstanceDaoImpl(BpelDAOConnection conn, ProcessDaoImpl processDao,
CorrelatorDAO correlator) {
+ _state = 0;
+ _processDao = processDao;
+ _instantiatingCorrelator = correlator;
+ _jacobState = null;
+ _instanceId = IdGen.newProcessId();
+ _conn = conn;
+ }
+
+ public BpelDAOConnection getConnection() {
+ return _conn;
+ }
+
+ public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
+ ArrayList<XmlDataDAO> res = new ArrayList<XmlDataDAO>();
+ for (ScopeDAO scope : _scopes.values()) {
+ if (scope.getModelId() == scopeModelId) {
+ XmlDataDAO xmld = scope.getVariable(variableName);
+ if (xmld != null) res.add(xmld);
+ }
+ }
+ return res.toArray(new XmlDataDAO[res.size()]);
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ HashSet<CorrelationSetDAO> res = new HashSet<CorrelationSetDAO>();
+ for (ScopeDAO scopeDAO : _scopes.values()) {
+ res.addAll(scopeDAO.getCorrelationSets());
+ }
+ return res;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String name) {
+ for (ScopeDAO scopeDAO : _scopes.values()) {
+ if (scopeDAO.getCorrelationSet(name) != null) return
scopeDAO.getCorrelationSet(name);
+ }
+ return null;
+ }
+
+ public void setFault(QName name, String explanation, int lineNo, int
activityId, Element faultData) {
+ _fault = new FaultDaoImpl(QNameUtils.fromQName(name), explanation,
faultData, lineNo, activityId);
+ }
+
+ public void setFault(FaultDAO fault) {
+ _fault = fault;
+ }
+
+ public FaultDAO getFault() {
+ return _fault;
+ }
+
+ /**
+ * @see ProcessInstanceDAO#getExecutionState()
+ */
+ public byte[] getExecutionState() {
+ return _jacobState;
+ }
+
+ public void setExecutionState(byte[] bytes) {
+ _jacobState = bytes;
+ }
+
+ public byte[] getMessageExchange(String identifier) {
+ byte[] mex = _messageExchanges.get(identifier);
+ assert (mex != null);
+ return mex;
+ }
+
+ /**
+ * @see ProcessInstanceDAO#getProcess()
+ */
+ public ProcessDAO getProcess() {
+ return _processDao;
+ }
+
+ /**
+ * @see ProcessInstanceDAO#getRootScope()
+ */
+ public ScopeDAO getRootScope() {
+ return _rootScope;
+ }
+
+ /**
+ * @see ProcessInstanceDAO#setState(short)
+ */
+ public void setState(short state) {
+ _previousState = _state;
+ _state = state;
+ if(state==ProcessState.STATE_TERMINATED) {
+ for (CorrelatorDAO correlatorDAO : _processDao.getCorrelators()) {
+ correlatorDAO.removeRoutes(null, this);
+ }
+ }
+ }
+
+ /**
+ * @see ProcessInstanceDAO#getState()
+ */
+ public short getState() {
+ return _state;
+ }
+
+ public void addMessageExchange(String identifier, byte[] data) {
+ assert (!_messageExchanges.containsKey(identifier));
+ _messageExchanges.put(identifier, data);
+ }
+
+
+ public ScopeDAO createScope(ScopeDAO parentScope, String scopeType, int
scopeModelId) {
+ ScopeDaoImpl newScope = new ScopeDaoImpl(this, parentScope, scopeType,
scopeModelId);
+ _scopes.put(newScope.getScopeInstanceId(), newScope);
+ List<ScopeDAO> namedScopes = _scopesByName.get(scopeType);
+ if(namedScopes == null){
+ namedScopes = new LinkedList<ScopeDAO>();
+ _scopesByName.put(scopeType, namedScopes);
+ }
+ namedScopes.add(newScope);
+ if (parentScope == null) {
+ assert _rootScope == null;
+ _rootScope = newScope;
+ }
+
+ return newScope;
+ }
+
+ public Long getInstanceId() {
+ return _instanceId;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getScope(java.lang.Long)
+ */
+ public ScopeDAO getScope(Long scopeInstanceId) {
+ return _scopes.get(scopeInstanceId);
+ }
+
+ public List<ProcessInstanceEvent> getEvents(int idx, int count) {
+ int sidx = Math.max(idx, 0);
+ sidx = Math.min(sidx, _events.size()-1);
+ int eidx = Math.min(sidx + count, _events.size());
+ return _events.subList(sidx, eidx);
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.ProcessInstanceDAO#insertBpelEvent(org.apache.ode.bpel.evt.ProcessInstanceEvent)
+ */
+ public void insertBpelEvent(ProcessInstanceEvent event) {
+ _events.add(event);
+ }
+
+ public int getEventCount() {
+ return _events.size();
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.ProcessInstanceDAO#getInstantiatingCorrelator()
+ */
+ public CorrelatorDAO getInstantiatingCorrelator() {
+ return _instantiatingCorrelator;
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.ProcessInstanceDAO#getScopes(java.lang.String)
+ */
+ public Collection<ScopeDAO> getScopes(String scopeName) {
+ List<ScopeDAO> scopes = _scopesByName.get(scopeName);
+ return (scopes == null ? EMPTY_SCOPE_DAOS : scopes);
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getPreviousState()
+ */
+ public short getPreviousState() {
+ return _previousState;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#getLastActiveTime()
+ */
+ public Date getLastActiveTime() {
+ return _lastActive;
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.ProcessInstanceDAO#setLastActiveTime(java.util.Date)
+ */
+ public void setLastActiveTime(Date dt) {
+ _lastActive = dt;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ProcessInstanceDAO#finishCompletion()
+ */
+ public void finishCompletion() {
+ // make sure we have completed.
+ assert (ProcessState.isFinished(this.getState()));
+ // let our process know that we've done our work.
+ this.getProcess().instanceCompleted(this);
+ }
+
+ public void delete() {
+ _processDao._instances.remove(_instanceId);
+ }
+
+ public Collection<ScopeDAO> getScopes() {
+ return _scopes.values();
+ }
+
+ public EventsFirstLastCountTuple getEventsFirstLastCount() {
+ EventsFirstLastCountTuple ret = new EventsFirstLastCountTuple();
+ ret.count = _events.size();
+ Date first = new Date();
+ Date last = new Date(0);
+ for (ProcessInstanceEvent event : _events) {
+ if (event.getTimestamp().before(first)) first = event.getTimestamp();
+ if (event.getTimestamp().after(last)) last = event.getTimestamp();
+ }
+ ret.first = first;
+ ret.last = last;
+ return ret;
+ }
+
+ public long genMonotonic() {
+ return ++_seq;
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessPropertyDAOImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessPropertyDAOImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessPropertyDAOImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessPropertyDAOImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,46 @@
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.dao.ProcessPropertyDAO;
+
+/**
+ * In memory implementation of the [EMAIL PROTECTED] ProcessPropertyDAO}
interface.
+ */
+public class ProcessPropertyDAOImpl extends DaoBaseImpl implements
ProcessPropertyDAO {
+
+ private String name;
+ private String namespace;
+ private String simpleContent;
+ private String mixedContent;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getSimpleContent() {
+ return simpleContent;
+ }
+
+ public void setSimpleContent(String simpleContent) {
+ this.simpleContent = simpleContent;
+ }
+
+ public String getMixedContent() {
+ return mixedContent;
+ }
+
+ public void setMixedContent(String mixedContent) {
+ this.mixedContent = mixedContent;
+ }
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,165 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.common.BpelEventFilter;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ScopeStateEnum;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED] ScopeDAO}
interface.
+ */
+class ScopeDaoImpl extends DaoBaseImpl implements ScopeDAO {
+ private String _type;
+ private ScopeStateEnum _state;
+ private Map<String, XmlDataDAO> _variables = new HashMap<String,
XmlDataDAO>();
+ private Map<String, CorrelationSetDAO> _correlations = new HashMap<String,
CorrelationSetDAO>();
+ private Map<Integer, PartnerLinkDAO> _eprs = new HashMap<Integer,
PartnerLinkDAO>();
+ private ProcessInstanceDaoImpl _processInstance;
+ private org.apache.ode.bpel.dao.ScopeDAO _parent;
+ private Long _instanceId;
+ private int _scopeModelId;
+
+ /**
+ * Constructor.
+ * @param owner process instance owner
+ * @param parent scope parent
+ * @param type scope type (name)
+ * @param scopeModelId
+ */
+ public ScopeDaoImpl(ProcessInstanceDaoImpl owner, ScopeDAO parent, String
type, int scopeModelId) {
+ _processInstance = owner;
+ _parent = parent;
+ _type = type;
+ _instanceId = IdGen.newScopeId();
+ _scopeModelId = scopeModelId;
+ }
+
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
+ */
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ CorrelationSetDAO corr = _correlations.get(corrSetName);
+
+ if (corr == null) {
+ corr = new CorrelationSetDaoImpl(corrSetName, this);
+ _correlations.put(corrSetName, corr);
+ }
+
+ return corr;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
+ */
+ public org.apache.ode.bpel.dao.ScopeDAO getParentScope() {
+ return _parent;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
+ */
+ public org.apache.ode.bpel.dao.ProcessInstanceDAO getProcessInstance() {
+ return _processInstance;
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
+ */
+ public void setState(org.apache.ode.bpel.dao.ScopeStateEnum state) {
+ _state = state;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
+ */
+ public org.apache.ode.bpel.dao.ScopeStateEnum getState() {
+ return _state;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
+ */
+ public String getName() {
+ return _type;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
+ */
+ public XmlDataDAO getVariable(String varName) {
+ XmlDataDAO v = _variables.get(varName);
+
+ if (v == null) {
+ v = new XmlDataDaoImpl(this,varName);
+ _variables.put(varName, v);
+ }
+
+ return v;
+ }
+
+ public Collection<CorrelationSetDAO> getCorrelationSets() {
+ return _correlations.values();
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
+ */
+ public Long getScopeInstanceId() {
+ return _instanceId;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
+ */
+ public int getModelId() {
+ return _scopeModelId;
+ }
+
+
+ public Collection<ScopeDAO> getChildScopes() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Collection<XmlDataDAO> getVariables() {
+ return _variables.values();
+ }
+
+ public List<BpelEvent> listEvents(BpelEventFilter efilter) {
+ // TODO: provide a better implementation.
+ return new ArrayList<BpelEvent>();
+ }
+
+ public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
String myRole, String partnerRole) {
+ PartnerLinkDAOImpl eprImpl = new PartnerLinkDAOImpl();
+ eprImpl.setPartnerLinkModelId(plinkModelId);
+ eprImpl.setPartnerLinkName(pLinkName);
+ eprImpl.setMyRoleName(myRole);
+ eprImpl.setPartnerRoleName(partnerRole);
+ _eprs.put(plinkModelId, eprImpl);
+ return eprImpl;
+ }
+
+
+ public PartnerLinkDAO getPartnerLink(int modelId) {
+ return _eprs.get(modelId);
+ }
+
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/XmlDataDaoImpl.java
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,87 @@
+/*
+ * File: $RCSfile$
+ * Copyright: (C) 1999-2005 FiveSight Technologies Inc.
+ *
+ */
+package org.apache.ode.bpel.memdao;
+
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.w3c.dom.Node;
+
+import java.util.Properties;
+
+
+/**
+ * A very simple, in-memory implementation of the [EMAIL PROTECTED]
XmlDataDAO} interface.
+ */
+class XmlDataDaoImpl implements XmlDataDAO {
+
+ private Node _data;
+ private Properties _properties = new Properties();
+ private ScopeDaoImpl _scope;
+ private String _name;
+
+ XmlDataDaoImpl(ScopeDaoImpl scope,String varname){
+ _scope = scope;
+ _name = varname;
+ }
+
+ /**
+ * @see XmlDataDAO#isNull()
+ */
+ public boolean isNull() {
+ return _data == null;
+ }
+
+ /**
+ * @see XmlDataDAO#get()
+ */
+ public Node get() {
+ return _data;
+ }
+
+ /**
+ * @see XmlDataDAO#remove()
+ */
+ public void remove() {
+ _data = null;
+ }
+
+ /**
+ * @see XmlDataDAO#set(org.w3c.dom.Node)
+ */
+ public void set(Node val) {
+ _data = val;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.XmlDataDAO#getProperty(java.lang.String)
+ */
+ public String getProperty(String propertyName) {
+ return _properties.getProperty(propertyName);
+ }
+
+ /**
+ * @see
org.apache.ode.bpel.dao.XmlDataDAO#setProperty(java.lang.String,
java.lang.String)
+ */
+ public void setProperty(String pname, String pvalue) {
+ _properties.setProperty(pname, pvalue);
+ }
+
+ public Properties getProperties() {
+ return _properties;
+ }
+
+ /**
+ * @see org.apache.ode.bpel.dao.XmlDataDAO#getScopeDAO()
+ */
+ public ScopeDAO getScopeDAO() {
+ return _scope;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+}
Added:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/package.html
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/package.html?rev=430501&view=auto
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/package.html
(added)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/package.html
Thu Aug 10 12:41:44 2006
@@ -0,0 +1,7 @@
+<html>
+<body>
+An in-memory implementation of the BPEL data-access object (DAO) interfaces.
+Provides a backing store for the BPEL service-provider in those rare
circumstances where reliabilty
+is not required.
+</body>
+</html>