You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:05:47 UTC
svn commit: r381686 [12/40] - in /incubator/ode/scratch/bpe: ./ bpelTests/
bpelTests/probeService/ bpelTests/test1/ bpelTests/test10/
bpelTests/test12/ bpelTests/test13/ bpelTests/test14/ bpelTests/test15/
bpelTests/test16/ bpelTests/test17/ bpelTests/...
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,305 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.bped;
+import java.io.IOException;
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.CreateException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import com.sybase.bpe.bped.managed.BPEventDirectorLocal;
+import com.sybase.bpe.bped.managed.BPEventDirectorLocalHome;
+import com.sybase.bpe.bped.managed.BPEventDirector;
+import com.sybase.bpe.bped.managed.BPEventDirectorHome;
+import com.sybase.bpe.bped.managed.EventDirectorLocal;
+import com.sybase.bpe.bped.managed.EventDirectorRemote;
+import com.sybase.bpe.correlation.CorrelationService;
+import com.sybase.bpe.correlation.CorrelationServiceFactory;
+import com.sybase.bpe.definition.service.managed.ProcessDefinition;
+import com.sybase.bpe.definition.service.managed.ProcessDefinitionHome;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.enginestate.service.EngineStateFactory;
+import com.sybase.bpe.inmemory.jndi.IMContext;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+import com.sybase.bpe.uuid.UUIDServiceFactory;
+import com.sybase.bpe.locking.LockingService;
+import com.sybase.bpe.locking.LockingServiceFactory;
+/**
+ * Factory for Event Director's
+ *
+ * @author charper
+ *
+ */
+public class EventDirectorFactory
+{
+ public static final String IM_ENGINE_PROPERTY_FILE_NAME = "bpeEngine.properties";
+ public static final String JNFI = "java.naming.factory.initial";
+ public static final String IMJNFI =
+ "com.sybase.bpe.inmemory.jndi.IMContextFactory";
+ private static Logger logger = Logger.getLogger(EventDirectorFactory.class
+ .getName());
+ private static UUIDService us;
+ private static EventDirector cachedEventDirector;
+
+
+ /**
+ * Create an in memoroy event director for the BPE package.
+ * @return and EventDirector
+ * @throws BPException
+ */
+ public static EventDirector createEventDirector() throws BPException
+ {
+ return createEventDirector("BPE");
+ }
+
+ /**
+ * Create an in memoroy event director.
+ * @param pkgName the pakgName to create the EventDirector for.
+ * @return
+ * @throws BPException
+ */
+ public static EventDirector createEventDirector(String pkgName) throws BPException
+ {
+ boolean remote = true;
+
+ String val = System.getProperty(JNFI);
+ if (val != null && val.compareTo(IMJNFI) == 0) {
+ remote = false;
+ }
+
+ if (remote)
+ {
+ return createRemoteEventDirector(pkgName);
+ }
+ else
+ {
+ return createInMemoryEventDirector();
+ }
+ }
+
+ public synchronized static EventDirector createEventDirectorCached(String pkgName)
+ throws BPException
+{
+ if ( cachedEventDirector != null ) {
+ return cachedEventDirector;
+ }
+ return createEventDirector(pkgName);
+}
+
+ public synchronized static EventDirector createEventDirectorCached()
+ throws BPException
+ {
+ if ( cachedEventDirector != null ) {
+ return cachedEventDirector;
+ }
+ return createEventDirector();
+ }
+
+ private static EventDirector createInMemoryEventDirector()
+ throws BPException
+ {
+
+ us = UUIDServiceFactory.createUUIDService();
+ BPEProperties props = new BPEProperties();
+ try
+ {
+ IMContext.getProperties(props,IM_ENGINE_PROPERTY_FILE_NAME);
+/* File file = new File(IM_ENGINE_PROPERTY_FILE_NAME);
+ if (file.exists() == true)
+ {
+ FileInputStream ifstrm = new FileInputStream(
+ IM_ENGINE_PROPERTY_FILE_NAME);
+ props.load(ifstrm);
+ }*/
+ } catch (IOException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"IOException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ cachedEventDirector = createEventDirector(props);
+ return cachedEventDirector;
+ }
+ /**
+ * Create an in memory event director
+ *
+ * @param props
+ * properites for event director
+ * @return an in memory event director
+ * @throws EventDirectorException
+ */
+ public static EventDirector createEventDirector(BPEProperties props)
+ throws BPException
+ {
+ CorrelationService cs;
+ ProcessService ps;
+ LockingService ls;
+ IInternalEventDirector ed = null;
+ try
+ {
+ // load the implementation
+ Class instClass = java.lang.Class.forName(props
+ .getEventDirectorClass());
+ // try to instantiate the subclass
+ ed = (IInternalEventDirector) instClass.newInstance();
+ // set engine state name
+ props.setProperty(EngineStateFactory.ENGINE_NAME,"BPE_ENGINE_"+
+ ed.hashCode());
+ // LLW: 10-22-03
+ // If the client has created a BPEProperties object - init UUID
+ // with the user specified props.
+ if (us == null)
+ us = UUIDServiceFactory.createUUIDService(props);
+ ps = new ProcessService(props, us);
+ cs = CorrelationServiceFactory.createCorrelationService(props, ps);
+ ls = LockingServiceFactory.createLockingService(props);
+ ed.init(props, ps, cs, us, ls);
+ } catch (ClassNotFoundException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "CLASS_NOT_FOUND", new Object[]
+ {props.getEventDirectorClass()});
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (InstantiationException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"InstantiationException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (IllegalAccessException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"IllegalAccessException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ return (EventDirector) ed;
+ }
+
+ /**
+ * Create a remote event director for BPE package. This a remote event
+ * director will conect to a remote engine.
+ * @return
+ * @throws BPException
+ */
+ public static EventDirector createRemoteEventDirector() throws BPException {
+ return createRemoteEventDirector(false);
+ }
+
+ /**
+ * Create a remote event director for BPE package. This a remote event
+ * director will conect to a remote engine.
+ * @param localBPED
+ * @return
+ * @throws BPException
+ */
+ public static EventDirector createRemoteEventDirector(boolean localBPED) throws BPException
+ {
+ return createRemoteEventDirector("BPE", localBPED);
+ }
+ /**
+ * Create a remote event director. This a remote event director will conect
+ * to a remote engine.
+ *
+ * @return a remote event director
+ * @throws EventDirectorException
+ */
+ public static EventDirector createRemoteEventDirector(String pkgName) throws BPException
+ {
+ return createRemoteEventDirector(pkgName, false);
+ }
+
+ /**
+ * Create a remote event director. This a remote event director will conect
+ * to a remote engine.
+ *
+ * @return a remote event director
+ * @throws EventDirectorException
+ */
+ public static EventDirector createRemoteEventDirector(String pkgName, boolean localBPED) throws BPException
+ {
+ EventDirector ed = null;
+ try
+ {
+ // get the interface
+ InitialContext ic = new InitialContext();
+
+ Object o = ic.lookup(pkgName+"/ProcessDefinition");
+ ProcessDefinitionHome pdHome = (ProcessDefinitionHome) PortableRemoteObject
+ .narrow(o, ProcessDefinitionHome.class);
+ // get a bean
+ ProcessDefinition pd = pdHome.create();
+
+ // get a bean
+ if (localBPED) {
+ BPEventDirectorLocalHome bpedLocalHome = (BPEventDirectorLocalHome) ic.lookup("java:comp/env/theLocalBPEDBean");
+ BPEventDirectorLocal bpedLocal = bpedLocalHome.create();
+ ed = new EventDirectorLocal(bpedLocal, pd);
+ } else {
+ o = ic.lookup(pkgName+"/BPEventDirector");
+ BPEventDirectorHome bpedHome = (BPEventDirectorHome) PortableRemoteObject.narrow(o, BPEventDirectorHome.class);
+ BPEventDirector bped = bpedHome.create();
+ ed = new EventDirectorRemote(bped, pd);
+ }
+ } catch (ClassCastException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"ClassCastException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (RemoteException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"RemoteException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (NamingException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"NamingException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (CreateException e)
+ {
+ EventDirectorException bpx = new EventDirectorException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"CreateException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ return ed;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,198 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.bped;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.correlation.CorrelationService;
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.IScopeService;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Utilities for EventDirectors
+ */
+public class EventDirectorUtil{
+
+ private static Logger logger =
+ Logger.getLogger(EventDirectorUtil.class.getName());
+
+
+ /**
+ * Activate a given process.
+ * @param ed The Event Director to use.
+ * @param procKey The process to activate.
+ * @return An EventResult.
+ * @throws EventDirectorException if Exception occurs while sending
+ * an activate event.
+ */
+ public static void activate(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,StateEnum.STARTED);
+ ed.sendEvent(se,true);
+
+ }
+
+ /**
+ * Terminate a process.
+ * @param ed
+ * @param procKey
+ * @return
+ * @throws EventDirectorException
+ */
+ public static void terminate(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,
+ StateEnum.TERMINATED);
+ ed.sendEvent(se,true);
+ }
+
+ /**
+ * Pause a process.
+ * @param ed
+ * @param procKey
+ * @return
+ * @throws EventDirectorException
+ */
+ public static void pause(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,
+ StateEnum.PAUSED);
+ ed.sendEvent(se,true);
+ }
+
+
+ /**
+ * Handle a state event in a EventDirector non implementation specific
+ * way.
+ * @param ed
+ * @param ps
+ * @param se
+ * @return An Event Result.
+ * @throws EventDirectorException
+ */
+ public static void handleStateEvent ( IInternalEventDirector ed,
+ ProcessService ps, StateEvent se )
+ throws BPException {
+
+ ProcessInstance pi =
+ ps.lookupProcess(se.getRootProcessInstanceKey(),
+ se.getProcessInstanceKey());
+ pi.processEvent(se,ed, ed);
+
+ InstanceService is = ps.getInstanceService();
+
+ IPMIProcess ipmip =
+ is.getInstance(
+ se.getRootProcessInstanceKey(),
+ se.getRootProcessInstanceKey());
+
+ // update the instance service
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(
+ "updatting instance service and removing lock for:"
+ + ipmip.getRootKey());
+ }
+ ed.getProcessService().update(ipmip.getRootKey(), ed, ed);
+
+ }
+
+
+ public static void handleLoadDefintionEvent(IInternalEventDirector ed,
+ LoadDefinitionEvent lde) throws BPException{
+
+ DefinitionService ds =
+ ed.getProcessService().getInstanceService().getDefinitionService();
+// CorrelationService cs =
+// ed.getCorrelationService();
+ ds.loadDefintion(new ProcessDefinitionKey(lde.getDefinitionName()),ed);
+
+ }
+
+ public static void handleTimerEvent(IInternalEventDirector ed,
+ IBPETimer timer) throws EventDirectorException{
+
+ try {
+ ITimerEvent te = timer.getTimerEvent();
+ CorrelationService cs = ed.getCorrelationService();
+ ProcessService ps = ed.getProcessService();
+ InstanceService is = ps.getInstanceService();
+ DefinitionService ds = is.getDefinitionService();
+ // get the process instance
+ ProcessInstance pi;
+
+ // routing to wait
+ if ( te.getDefId() == null ) {
+ pi = ed.getProcessService().lookupProcess(
+ te.getRootId(), te.getProcId());
+ // routing to onAlarm
+ } else {
+ ProcessDefinitionKey rpdk = new ProcessDefinitionKey(te.getRootDefId());
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey(te.getDefId());
+ IPMDProcess ipmd = ds.getProcessDefintion(pdk,rpdk);
+ IPMIProcess ipmi = is.getInstance(te.getRootId(),te.getRootId());
+ // create the process
+ pi = ps.createSubProcess(ipmi,ipmd);
+ pi.setState(StateEnum.STARTED);
+ // since we are creating the proc off the root
+ // we have to set the scope path to the scope path
+ // of the process that made the registration
+ ProcessInstance regProc = ed.getProcessService().
+ lookupProcess( te.getRootId(), te.getProcId());
+ pi.setScopePath(regProc.getScopePath());
+ }
+
+ String rootKey = pi.getRootKey();
+
+ // init the process service
+ ps.init();
+
+ cs.lock(ed, rootKey);
+
+ // remove the timer from the scope
+ IScopeService ss = pi.getScopeService();
+ IFCScopeInstance scope = ss.getScope(pi.getScopePath());
+ scope.removeTimer(timer);
+
+ pi.processEvent(te, ed, ed);
+ ps.update(rootKey,ed,ed);
+
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java.keep
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java.keep?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java.keep (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/EventDirectorUtil.java.keep Tue Feb 28 08:02:48 2006
@@ -0,0 +1,174 @@
+package com.sybase.bpe.bped;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.correlation.CorrelationService;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.definition.service.IPMDProcess;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.instance.service.IPMIProcess;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.IScopeService;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Utilities for EventDirectors
+ */
+public class EventDirectorUtil{
+
+ private static Logger logger =
+ Logger.getLogger(EventDirectorUtil.class.getName());
+
+
+ /**
+ * Activate a given process.
+ * @param ed The Event Director to use.
+ * @param procKey The process to activate.
+ * @return An EventResult.
+ * @throws EventDirectorException if Exception occurs while sending
+ * an activate event.
+ */
+ public static void activate(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,StateEnum.STARTED);
+ ed.sendEvent(se,true);
+
+ }
+
+ /**
+ * Terminate a process.
+ * @param ed
+ * @param procKey
+ * @return
+ * @throws EventDirectorException
+ */
+ public static void terminate(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,
+ StateEnum.TERMINATED);
+ ed.sendEvent(se,true);
+ }
+
+ /**
+ * Pause a process.
+ * @param ed
+ * @param procKey
+ * @return
+ * @throws EventDirectorException
+ */
+ public static void pause(IInternalEventDirector ed, String rootKey, String procKey)
+ throws BPException {
+ StateEvent se = new StateEvent(rootKey, procKey,
+ StateEnum.PAUSED);
+ ed.sendEvent(se,true);
+ }
+
+
+ /**
+ * Handle a state event in a EventDirector non implementation specific
+ * way.
+ * @param ed
+ * @param ps
+ * @param se
+ * @return An Event Result.
+ * @throws EventDirectorException
+ */
+ public static void handleStateEvent ( IInternalEventDirector ed,
+ ProcessService ps, StateEvent se )
+ throws BPException {
+
+ ProcessInstance pi =
+ ps.lookupProcess(se.getRootProcessInstanceKey(),
+ se.getProcessInstanceKey());
+ pi.processEvent(se,ed, ed);
+
+ InstanceService is = ps.getInstanceService();
+
+ IPMIProcess ipmip =
+ is.getInstance(
+ se.getRootProcessInstanceKey(),
+ se.getRootProcessInstanceKey());
+
+ // update the instance service
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine(
+ "updatting instance service and removing lock for:"
+ + ipmip.getRootKey());
+ }
+ ed.getProcessService().update(ipmip.getRootKey(), ed, ed);
+
+ }
+
+
+ public static void handleLoadDefintionEvent(IInternalEventDirector ed,
+ LoadDefinitionEvent lde) throws BPException{
+
+ DefinitionService ds =
+ ed.getProcessService().getInstanceService().getDefinitionService();
+ CorrelationService cs =
+ ed.getCorrelationService();
+ ds.loadDefintion(new ProcessDefinitionKey(lde.getDefinitionName()),ed);
+
+ }
+
+ public static void handleTimerEvent(IInternalEventDirector ed,
+ IBPETimer timer) throws BPException {
+
+ ITimerEvent te = timer.getTimerEvent();
+ CorrelationService cs = ed.getCorrelationService();
+ ProcessService ps = ed.getProcessService();
+ InstanceService is = ps.getInstanceService();
+ DefinitionService ds = is.getDefinitionService();
+ // get the process instance
+ ProcessInstance pi;
+
+ // routing to wait
+ if ( te.getDefId() == null ) {
+ pi = ed.getProcessService().lookupProcess(
+ te.getRootId(), te.getProcId());
+ // routing to onAlarm
+ } else {
+ ProcessDefinitionKey rpdk = new ProcessDefinitionKey(te.getRootDefId());
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey(te.getDefId());
+ IPMDProcess ipmd = ds.getProcessDefintion(pdk,rpdk);
+ IPMIProcess ipmi = is.getInstance(te.getRootId(),te.getRootId());
+ // create the process
+ pi = ps.createSubProcess(ipmi,ipmd);
+ pi.setState(StateEnum.STARTED);
+ // since we are creating the proc off the root
+ // we have to set the scope path to the scope path
+ // of the process that made the registration
+ ProcessInstance regProc = ed.getProcessService().
+ lookupProcess( te.getRootId(), te.getProcId());
+ pi.setScopePath(regProc.getScopePath());
+ }
+
+ String rootKey = pi.getRootKey();
+
+ // init the process service
+ ps.init();
+
+ cs.lock(ed, rootKey);
+
+ // remove the timer from the scope
+ IScopeService ss = pi.getScopeService();
+ IFCScopeInstance scope = ss.getScope(pi.getScopePath());
+ scope.removeTimer(timer);
+
+ pi.processEvent(te, ed, ed);
+ ps.update(rootKey,ed,ed);
+
+
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ExternalEventDirectorBase.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ExternalEventDirectorBase.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ExternalEventDirectorBase.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ExternalEventDirectorBase.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,111 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.bped;
+
+import com.sybase.bpe.client.impl.IInternalMessage;
+import com.sybase.bpe.client.impl.IInternalResult;
+import com.sybase.bpe.client.impl.MessageConverter;
+import com.sybase.bpe.client.impl.def.InternalResult;
+import com.sybase.bpe.engine.InactiveDefinitionException;
+import com.sybase.bpe.engine.ProcessInstancePausedException;
+import com.sybase.bpe.event.IRequestMessageEvent;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.IStaticKey;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.scope.service.BPRuntimeException;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Serves as an implementation base class for
+ * all external event director implementations.
+ */
+public abstract class ExternalEventDirectorBase
+ implements
+ EventDirector
+{
+ /**
+ * @ejb:interface-method
+ */
+ public IInternalResult sendRequest(IStaticKey key,
+ IInternalMessage internalRequest)
+ {
+ MessageConverter mc = new MessageConverter();
+ IRequestMessageEvent rme = mc.createRequest(key, internalRequest);
+ IResponseMessage response;
+ IInternalResult iresult;
+ try
+ {
+ response = sendEvent(rme, true);
+ iresult = mc.createResult(response);
+ }
+ catch (BPRuntimeException bpre )
+ {
+ InternalResult internalResult = new InternalResult();
+ MessageConverter.PopulateBusinessProcessFaultResult( internalResult, bpre);
+ iresult = internalResult;
+ }
+ catch( ProcessInstancePausedException pipe )
+ {
+ InternalResult internalResult = new InternalResult();
+ MessageConverter.PopulatePausedInstanceException(
+ internalResult, pipe);
+ iresult = internalResult;
+ }
+ catch( InactiveDefinitionException iade )
+ {
+ InternalResult internalResult = new InternalResult();
+ MessageConverter.PopulateInactiveDefinitionException(
+ internalResult, iade );
+ iresult = internalResult;
+ }
+ catch (Exception e)
+ {
+ InternalResult internalResult = new InternalResult();
+ MessageConverter.PopulateSystemExceptionResult(internalResult, e);
+ iresult = internalResult;
+ }
+ return iresult;
+ }
+
+ public IDeployer getDeployer(DeployTypeEnum type)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public IResponseMessage sendEvent(IRequestMessageEvent msg, boolean sync) throws BPException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.ISendEvent#sendEvent(com.sybase.bpe.event.StateEvent, boolean)
+ */
+ public void sendEvent(StateEvent me, boolean sync) throws BPException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IDeployer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IDeployer.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IDeployer.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IDeployer.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,71 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 13, 2003
+ *
+ */
+package com.sybase.bpe.bped;
+
+import java.io.InputStream;
+import java.util.Collection;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Interface to definition services.
+ * @author charper
+ *
+ */
+public interface IDeployer {
+
+ /**
+ * Deploy a definition into the engine.
+ * @param is input stream for the defintion; a zip file that holds the BPEL definiton and supporting documents
+ * @param validating if the defintion is to be validated
+ * @return a Collection of DefinitionKeys
+ * @see com.sybase.bpe.deployment.DefinitionKey
+ */
+ public Collection loadDefinition(InputStream is, boolean validating) throws BPException;
+
+ /**
+ * Deploy a definition into the engine from a resource.
+ * @param resource resrouce path the the bpel deploy file
+ * @param validating if the defintion is to be validated
+ * @return a Collection of DefinitionKeys
+ * @see com.sybase.bpe.deployment.DefinitionKey
+ */
+ public Collection loadDefinition(String resource, boolean validating) throws BPException;
+
+ /**
+ * Remove a deployed definition.
+ * @param defID the identifier of the definiton to remove.
+ */
+ public void removeDefinition(String defID) throws BPException;
+
+ /**
+ * Set the given process to statless.
+ * @param defID
+ * @throws BPException
+ */
+ public void setStateless(String defID) throws BPException;
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IInternalEventDirector.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IInternalEventDirector.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IInternalEventDirector.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/IInternalEventDirector.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,41 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.bped;
+
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.event.Fault;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Event director methods called by the BPE internally.
+ * These methods are not consumable by clients running
+ * outside the BPE.
+ */
+public interface IInternalEventDirector
+extends IEvaluationContext, IProcessCallBack
+{
+ public void sendEvent(LoadDefinitionEvent me, boolean sync) throws BPException;
+ public Fault sendEvent(IBPETimer me, boolean sync) throws BPException;
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ISendEvent.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ISendEvent.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ISendEvent.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/ISendEvent.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,55 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 13, 2003
+ *
+ */
+package com.sybase.bpe.bped;
+
+import com.sybase.bpe.event.IRequestMessageEvent;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Interface to send messages to the message router.
+ * @author charper
+ *
+ */
+public interface ISendEvent {
+
+ /**
+ * Send an Event. The event can be sent syncronously or
+ * asyncronously.
+ * @param msg The event meassage to send to the engine.
+ * @param sync True for a syncronous call.
+ * @return The event result.
+ * @throws EventDirectorException If and error occurs while
+ * processing the Event. Note that the method can complete with out
+ * error, but the returned EventResult can contain fault messages.
+ */
+ IResponseMessage sendEvent(IRequestMessageEvent msg, boolean sync)
+ throws BPException;
+
+ public void sendEvent(StateEvent me, boolean sync) throws BPException;
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPELDeployerRemote.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPELDeployerRemote.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPELDeployerRemote.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPELDeployerRemote.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,131 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 16, 2003
+ *
+ */
+package com.sybase.bpe.bped.managed;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.RemoteException;
+import java.util.Collection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.bped.IDeployer;
+import com.sybase.bpe.definition.service.managed.ProcessDefinition;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author charper
+ *
+ */
+public class BPELDeployerRemote implements IDeployer {
+
+ private static Logger logger =
+ Logger.getLogger(BPELDeployerRemote.class.getName());
+
+ private ProcessDefinition pd;
+
+ /**
+ * @param bped
+ * @param pd
+ */
+ public BPELDeployerRemote(ProcessDefinition pd) {
+ this.pd = pd;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.IDeployer#loadDefintion(java.io.InputStream, boolean)
+ */
+ public Collection loadDefinition(InputStream is, boolean validating) throws BPException{
+
+ Collection keys = null;
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = is.read(buf)) >= 0) {
+ bos.write(buf,0,len);
+ }
+ keys = pd.deploy(bos.toByteArray(),validating,null);
+
+
+ } catch (RemoteException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"RemoteException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (IOException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"IOException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ return keys;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.IDeployer#removeDefinition(java.lang.String)
+ */
+ public void removeDefinition(String defID) throws BPException {
+ try {
+ pd.removeDefinition(defID);
+ } catch (RemoteException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"RemoteException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.IDeployer#setStateless(java.lang.String)
+ */
+ public void setStateless(String defID) throws BPException {
+ try {
+ pd.setStateless(defID);
+ } catch (RemoteException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"RemoteException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.IDeployer#loadDefinition(java.lang.String, boolean)
+ */
+ public Collection loadDefinition(String resource, boolean validating) throws BPException {
+ Collection keys = null;
+ try {
+ keys = pd.deploy(resource,validating,null);
+
+
+ } catch (RemoteException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"RemoteException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ return keys;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPETimerBean.java.j2ee14
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPETimerBean.java.j2ee14?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPETimerBean.java.j2ee14 (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPETimerBean.java.j2ee14 Tue Feb 28 08:02:48 2006
@@ -0,0 +1,317 @@
+package com.sybase.bpe.bped.ejbimpl;
+
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.ejb.TimedObject;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.naming.InitialContext;
+
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.bped.IInternalEventDirector;
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.ejbTimerImpl.BPETimerEjbTimerImpl;
+import com.sybase.bpe.util.BPEProperties;
+
+/**
+ * This bean can start definitions.
+ * @ejb:bean
+ * type="Stateless"
+ * name="BPETimer"
+ * local-jndi-name="BPE/BPETimerLocal"
+ * view-type="local"
+ *
+ * @ejb.transaction type="Required"
+ *
+ * @ejb.resource-ref
+ * res-name="BPEDThreadConnectionFactory"
+ * res-type="javax.jms.QueueConnectionFactory"
+ * res-auth="Container"
+ *
+ * @ejb.resource-env-ref
+ * name="BPEDThreadQueue"
+ * type="javax.jms.Queue"
+ *
+ * @ejb.env-entry
+ * name="UUID_USE_CONNECTOR_KEY"
+ * value="false"
+ * type="java.lang.Boolean"
+ * @ejb.env-entry
+ * name="UUID_CLASS_KEY"
+ * value="com.sybase.bpe.uuid.EMFUUIDService"
+ * @ejb.env-entry
+ * name="UUID_SIZE_KEY"
+ * value="200"
+ * type="java.lang.Integer"
+ * @ejb.env-entry
+ * name="DEF_CLASS_KEY"
+ * --value="com.sybase.bpe.definition.enginestateimpl.DefintionServiceEngineStateImpl"
+ * value="com.sybase.bpe.definition.beanimpl.DefinitionService_BeanImpl"
+ * @ejb.env-entry
+ * name="DEF_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="INST_CLASS_KEY"
+ * --value="com.sybase.bpe.instance.service.enginestateimpl.InstanceServiceEngineStateImpl"
+ * value="com.sybase.bpe.instance.beanimpl.InstanceService_BeanImpl"
+ * @ejb.env-entry
+ * name="INST_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="ED_CLASS_KEY"
+ * value="com.sybase.bpe.bped.ejbimpl.EventDirectorEjbImpl"
+ * @ejb.env-entry
+ * name="CORL_CLASS_KEY"
+ * --value="com.sybase.bpe.correlation.enginestateimpl.CorrelationServiceEngineStateImpl"
+ * value="com.sybase.bpe.correlation.ejbimpl.CorrelationServiceEjbImpl"
+ * @ejb.env-entry
+ * name="LOCK_CLASS_KEY"
+ * value="com.sybase.bpe.locking.DBLockingService"
+ * @ejb.env-entry
+ * name="LOCK_HASH_BUCKETS_KEY"
+ * value="1000"
+ * @ejb.env-entry
+ * name="CTX_CLASS_KEY"
+ * value="com.sybase.bpe.context.ejb.EJBContextService"
+ * @ejb.env-entry
+ * name="BPEL_COMPLIANT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="DEF_SCHEMA_KEY"
+ * value="BPEL4WS.xsd"
+ * @ejb.env-entry
+ * name="SCOPE_CLASS_KEY"
+ * value="com.sybase.bpe.scope.service.impl.ScopeServiceImpl"
+ * @ejb.env-entry
+ * name="BPETIMER_CLASS_KEY"
+ * value="com.sybase.bpe.timerservice.ejbTimerImpl.BPETimerServiceEjbTimerImpl"
+ * --value="com.sybase.bpe.timerservice.quartzimpl.BPETimerServiceQuartzImpl"
+ *
+ * @ejb.ejb-ref
+ * ejb-name="PackageInfo"
+ * view-type="local"
+ * ref-name="thePackageInfo"
+ * @ejb.ejb-ref
+ * --ejb-name="EngineState"
+ * ejb-name="EngineStateCoarse"
+ * view-type="local"
+ * ref-name="theEngineState"
+ * @ejb.ejb-ref
+ * ejb-name="BPE_CMPBLOB"
+ * view-type="local"
+ * ref-name="theCMPObjectBean"
+ * @ejb.ejb-ref
+ * ejb-name="RegistrationEntity"
+ * view-type="local"
+ * ref-name="registrationBean"
+ * @ejb.ejb-ref
+ * ejb-name="BPEventDirector"
+ * view-type="local"
+ * ref-name="BPEventDirectorLocal"
+ * -- EAS is not j2ee 1.4 compatible
+ * --@ejb.ejb-ref
+ * -- ejb-name="BPETimer"
+ * -- view-type="local"
+ * -- ref-name="BPETimerLocal"
+ *
+ *
+ * @jboss.resource-ref
+ * res-ref-name="BPEDThreadConnectionFactory"
+ * jndi-name="java:/XAConnectionFactory"
+ * @jboss.resource-env-ref
+ * resource-env-ref-name="BPEDThreadQueue"
+ * jndi-name="queue/BPED_IN"
+ *
+ * @weblogic.resource-description
+ * res-ref-name="BPEDThreadConnectionFactory"
+ * jndi-name="XAConnectionFactory"
+ * @weblogic.resource-env-description
+ * res-env-ref-name="BPEDThreadQueue"
+ * jndi-name="jms/BPED_THREAD"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="theUUIDService"
+ * res-type="javax.resource.cci.ConnectionFactory"
+ * res-auth="Container"
+ * res-sharing-scope="Unshareable"
+ * @jboss.resource-ref
+ * res-ref-name="theUUIDService"
+ * jndi-name="java:/UUIDService"
+ * @weblogic.resource-description
+ * res-ref-name="theUUIDService"
+ * jndi-name="UUIDService"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="theXMLDocBuilderService"
+ * res-type="javax.resource.cci.ConnectionFactory"
+ * res-auth="Container"
+ * res-sharing-scope="Unshareable"
+ *
+ * @jboss.resource-ref
+ * res-ref-name="theXMLDocBuilderService"
+ * jndi-name="java:/XMLDocBuilderService"
+ * @weblogic.resource-description
+ * res-ref-name="theXMLDocBuilderService"
+ * jndi-name="XMLDocBuilderService"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="theFormatterService"
+ * res-type="javax.resource.cci.ConnectionFactory"
+ * res-auth="Container"
+ * res-sharing-scope="Unshareable"
+ * @jboss.resource-ref
+ * res-ref-name="theFormatterService"
+ * jndi-name="java:/FormatterService"
+ * @weblogic.resource-description
+ * res-ref-name="theFormatterService"
+ * jndi-name="FormatterService"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="theBNRuleEngineRAService"
+ * res-type="javax.resource.cci.ConnectionFactory"
+ * res-auth="Container"
+ * res-sharing-scope="Unshareable"
+ * @jboss.resource-ref
+ * res-ref-name="theBNRuleEngineRAService"
+ * jndi-name="java:/BNRuleEngineService"
+ * @weblogic.resource-description
+ * res-ref-name="theBNRuleEngineRAService"
+ * jndi-name="BNRuleEngineService"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="SybaseBPETimerService"
+ * res-type="javax.resource.cci.ConnectionFactory"
+ * res-auth="Container"
+ * res-sharing-scope="Unshareable"
+ * @jboss.resource-ref
+ * res-ref-name="SybaseBPETimerService"
+ * jndi-name="java:/SybaseBPETimerService"
+ * @weblogic.resource-description
+ * res-ref-name="SybaseBPETimerService"
+ * jndi-name="SybaseBPETimerService"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * res-type="javax.sql.DataSource"
+ * res-auth="Container"
+ * @jboss.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="java:/jdbc/JavaCache"
+ * @weblogic.resource-description
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="jdbc/JavaCache"
+ *
+ */
+public class BPETimerBean implements SessionBean, TimedObject {
+
+ private static Logger logger =
+ Logger.getLogger(BPEventDirectorBean.class.getName());
+ private SessionContext context;
+ private IInternalEventDirector ed;
+
+ /* (non-Javadoc)
+ * @see javax.ejb.SessionBean#ejbActivate()
+ */
+ public void ejbActivate() throws EJBException, RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.ejb.SessionBean#ejbPassivate()
+ */
+ public void ejbPassivate() throws EJBException, RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.ejb.SessionBean#ejbRemove()
+ */
+ public void ejbRemove() throws EJBException, RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
+ */
+ public void setSessionContext(SessionContext arg0) throws EJBException,
+ RemoteException {
+ this.context = arg0;
+
+ }
+
+ public void ejbCreate(){
+
+ try {
+
+ InitialContext ic = new InitialContext();
+ BPEProperties p = new BPEProperties(true,ic);
+ ed = (IInternalEventDirector)EventDirectorFactory.createEventDirector(p);
+
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE,"",ex);
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.ejb.TimedObject#ejbTimeout(javax.ejb.Timer)
+ */
+ public void ejbTimeout(Timer arg0) {
+ try {
+ if ( logger.isLoggable(Level.FINE)){
+ logger.fine("timeout for timer: " + arg0.toString());
+ }
+ ed.sendEvent(new BPETimerEjbTimerImpl(arg0.getHandle()), true);
+ } catch (Exception ex) {
+ // this may happen if a timer expires and
+ // blocks on a proccess that is finishing
+ logger.log(Level.WARNING, "", ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Timer createTimer(long duration, ITimerEvent event) {
+ try {
+ TimerService ts = context.getTimerService();
+ Timer t = ts.createTimer(duration,event);
+ if ( logger.isLoggable(Level.FINE)){
+ logger.fine("registered timer: " + t.toString());
+ }
+
+ return t;
+ } catch (Exception ex) {
+ throw new EJBException(ex.getLocalizedMessage(), ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Timer createTimer(Date experation, ITimerEvent event) {
+ try {
+ TimerService ts = context.getTimerService();
+ Timer t = ts.createTimer(experation,event);
+ if ( logger.isLoggable(Level.FINE)){
+ logger.fine("registered timer: " + t.toString());
+ }
+
+ return t;
+ } catch (Exception ex) {
+ throw new EJBException(ex.getLocalizedMessage(), ex);
+ }
+ }
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,287 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.bped.managed;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.bped.ExternalEventDirectorBase;
+import com.sybase.bpe.bped.IInternalEventDirector;
+import com.sybase.bpe.client.impl.IInternalRequestConsumer;
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.event.Fault;
+import com.sybase.bpe.event.IRequestMessageEvent;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * This bean can start definitions.
+ * @ejb:bean
+ * type="Stateless"
+ * name="BPEventDirector"
+ * jndi-name="BPE/BPEventDirector"
+ * local-jndi-name="BPE/BPEventDirectorLocal"
+ * view-type="both"
+ *
+ * @ejb.transaction type="Required"
+ *
+ * @ejb.env-entry
+ * name="UUID_USE_CONNECTOR_KEY"
+ * value="false"
+ * type="java.lang.Boolean"
+ * @ejb.env-entry
+ * name="UUID_CLASS_KEY"
+ * value="com.sybase.bpe.uuid.EMFUUIDService"
+ * @ejb.env-entry
+ * name="UUID_SIZE_KEY"
+ * value="200"
+ * type="java.lang.Integer"
+ * @ejb.env-entry
+ * name="DEF_CLASS_KEY"
+ * --value="com.sybase.bpe.definition.enginestateimpl.DefintionServiceEngineStateImpl"
+ * value="com.sybase.bpe.definition.serialimpl.DefinitionService_SerImpl"
+ * @ejb.env-entry
+ * name="DEF_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="INST_CLASS_KEY"
+ * --value="com.sybase.bpe.instance.service.enginestateimpl.InstanceServiceEngineStateImpl"
+ * value="com.sybase.bpe.instance.beanimpl.InstanceServicePersistentImpl"
+ * @ejb.env-entry
+ * name="INST_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="ED_CLASS_KEY"
+ * value="com.sybase.bpe.bped.managed.EventDirectorEjbImpl"
+ * @ejb.env-entry
+ * name="CORL_CLASS_KEY"
+ * --value="com.sybase.bpe.correlation.enginestateimpl.CorrelationServiceEngineStateImpl"
+ * value="com.sybase.bpe.correlation.managed.CorrelationServiceEjbImpl"
+ * @ejb.env-entry
+ * name="LOCK_CLASS_KEY"
+ * value="com.sybase.bpe.locking.DBLockingService"
+ * @ejb.env-entry
+ * name="LOCK_HASH_BUCKETS_KEY"
+ * value="1000"
+ * @ejb.env-entry
+ * name="CTX_CLASS_KEY"
+ * value="com.sybase.bpe.context.ejb.EJBContextService"
+ * @ejb.env-entry
+ * name="BPEL_COMPLIANT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="DEF_SCHEMA_KEY"
+ * value="BPEL4WS.xsd"
+ * @ejb.env-entry
+ * name="SCOPE_CLASS_KEY"
+ * value="com.sybase.bpe.scope.service.impl.ScopeServiceImpl"
+ * @ejb.env-entry
+ * name="BPETIMER_CLASS_KEY"
+ * --value="com.sybase.bpe.timerservice.ejbTimerImpl.BPETimerServiceEjbTimerImpl"
+ * value="com.sybase.bpe.timerservice.quartzimpl.BPETimerServiceQuartzImpl"
+ * --value="com.sybase.bpe.timerservice.noop.NoopTimerService"
+ *
+ * @ejb.ejb-ref
+ * ejb-name="PackageInfo"
+ * view-type="remote"
+ * ref-name="thePackageInfo"
+ * @ejb.ejb-ref
+ * --ejb-name="EngineState"
+ * ejb-name="EngineStateCoarse"
+ * view-type="local"
+ * ref-name="theEngineState"
+ * @ejb.ejb-ref
+ * ejb-name="BPE_CMPBLOB"
+ * view-type="local"
+ * ref-name="theCMPObjectBean"
+ * @ejb.ejb-ref
+ * ejb-name="RegistrationEntity"
+ * view-type="local"
+ * ref-name="registrationBean"
+ * @ejb.ejb-ref
+ * ejb-name="BPEventDirector"
+ * view-type="local"
+ * ref-name="theLocalBPEDBean"
+ * -- EAS is not j2ee 1.4 compatible
+ * --@ejb.ejb-ref
+ * -- ejb-name="BPETimer"
+ * -- view-type="local"
+ * -- ref-name="BPETimerLocal"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * res-type="javax.sql.DataSource"
+ * res-auth="Container"
+ * @jboss.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="java:/jdbc/JavaCache"
+ * @weblogic.resource-description
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="jdbc/JavaCache"
+ *
+ */
+public class BPEventDirectorBean extends ExternalEventDirectorBase implements SessionBean,
+ IInternalRequestConsumer {
+
+ static final long serialVersionUID = 8909646742595626256L;
+
+ private static Logger logger =
+ Logger.getLogger(BPEventDirectorBean.class.getName());
+ private InitialContext ic;
+// private SessionContext context;
+
+ private ProcessService ps;
+ private IInternalEventDirector ed;
+
+ /**
+ * @ejb:interface-method
+ */
+ public void startProcess(String id) {
+ try {
+ // create the process
+ ProcessInstance pi = ps.createProcess(
+ new ProcessDefinitionKey(id));
+ // creat the processes root container
+ IContextService ctxs = pi.getContextService();
+ IContainer cont = ctxs.getRoot();
+ cont.createContainer(pi.getRootKey());
+ // send a start event
+ pi.processEvent(new StateEvent(pi.getRootKey(),
+ pi.getKey(),StateEnum.STARTED),
+ ed, ed);
+ } catch (BPException ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public IResponseMessage sendEvent(IRequestMessageEvent event, boolean sync) {
+
+ try {
+ IResponseMessage rsp = ed.sendEvent(event,sync);
+ return rsp;
+ } catch (Exception ex) {
+ logger.log(Level.FINE,"",ex);
+ try {
+ IResponseMessage resp = event.createResponseMessage();
+ Fault fault = new Fault();
+ fault.setFaultString(ex.getLocalizedMessage());
+ fault.setFaultException(ex);
+ resp.setFault(fault);
+ return resp;
+ } catch (BPException e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void sendEvent(StateEvent event, boolean sync) {
+ try {
+ ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void sendEvent(LoadDefinitionEvent event, boolean sync) {
+ try {
+ ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Fault sendEvent(IBPETimer event, boolean sync) {
+ Fault fault = null;
+ try {
+ fault = ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ //logger.log(Level.SEVERE,"",ex);
+ fault = new Fault();
+ fault.setFaultString(ex.getLocalizedMessage());
+ }
+ return fault;
+ }
+
+
+ public void ejbCreate(){
+
+ try {
+
+ ic = new InitialContext();
+ BPEProperties p = new BPEProperties(true,ic);
+ ed = (IInternalEventDirector)EventDirectorFactory.createEventDirector(p);
+ ps = ed.getProcessService();
+
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE,"",ex);
+ }
+
+ }
+
+ public void setSessionContext(SessionContext ctx) {
+// this.context = ctx;
+ }
+ public void ejbRemove() {ed.release();}
+ public void ejbActivate() {}
+ public void ejbPassivate() {}
+ public void ejbLoad() {}
+ public void ejbStore() {}
+
+
+ /**
+ * @ejb:interface-method
+ * view-type="local"
+ */
+ public IInternalEventDirector getIInternalEventDirector() {
+ return ed;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java.keep
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java.keep?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java.keep (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/BPEventDirectorBean.java.keep Tue Feb 28 08:02:48 2006
@@ -0,0 +1,270 @@
+package com.sybase.bpe.bped.ejbimpl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.bped.ExternalEventDirectorBase;
+import com.sybase.bpe.bped.IInternalEventDirector;
+import com.sybase.bpe.client.impl.IInternalRequestConsumer;
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.event.Fault;
+import com.sybase.bpe.event.IRequestMessageEvent;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * This bean can start definitions.
+ * @ejb:bean
+ * type="Stateless"
+ * name="BPEventDirector"
+ * jndi-name="BPE/BPEventDirector"
+ * local-jndi-name="BPE/BPEventDirectorLocal"
+ * view-type="both"
+ *
+ * @ejb.transaction type="Required"
+ *
+ * @ejb.env-entry
+ * name="UUID_USE_CONNECTOR_KEY"
+ * value="false"
+ * type="java.lang.Boolean"
+ * @ejb.env-entry
+ * name="UUID_CLASS_KEY"
+ * value="com.sybase.bpe.uuid.EMFUUIDService"
+ * @ejb.env-entry
+ * name="UUID_SIZE_KEY"
+ * value="200"
+ * type="java.lang.Integer"
+ * @ejb.env-entry
+ * name="DEF_CLASS_KEY"
+ * --value="com.sybase.bpe.definition.enginestateimpl.DefintionServiceEngineStateImpl"
+ * value="com.sybase.bpe.definition.beanimpl.DefinitionService_BeanImpl"
+ * @ejb.env-entry
+ * name="DEF_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="INST_CLASS_KEY"
+ * --value="com.sybase.bpe.instance.service.enginestateimpl.InstanceServiceEngineStateImpl"
+ * value="com.sybase.bpe.instance.beanimpl.InstanceService_BeanImpl"
+ * @ejb.env-entry
+ * name="INST_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="ED_CLASS_KEY"
+ * value="com.sybase.bpe.bped.ejbimpl.EventDirectorEjbImpl"
+ * @ejb.env-entry
+ * name="CORL_CLASS_KEY"
+ * --value="com.sybase.bpe.correlation.enginestateimpl.CorrelationServiceEngineStateImpl"
+ * value="com.sybase.bpe.correlation.ejbimpl.CorrelationServiceEjbImpl"
+ * @ejb.env-entry
+ * name="LOCK_CLASS_KEY"
+ * value="com.sybase.bpe.locking.DBLockingService"
+ * @ejb.env-entry
+ * name="LOCK_HASH_BUCKETS_KEY"
+ * value="1000"
+ * @ejb.env-entry
+ * name="CTX_CLASS_KEY"
+ * value="com.sybase.bpe.context.ejb.EJBContextService"
+ * @ejb.env-entry
+ * name="BPEL_COMPLIANT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="DEF_SCHEMA_KEY"
+ * value="BPEL4WS.xsd"
+ * @ejb.env-entry
+ * name="SCOPE_CLASS_KEY"
+ * value="com.sybase.bpe.scope.service.impl.ScopeServiceImpl"
+ * @ejb.env-entry
+ * name="BPETIMER_CLASS_KEY"
+ * --value="com.sybase.bpe.timerservice.ejbTimerImpl.BPETimerServiceEjbTimerImpl"
+ * value="com.sybase.bpe.timerservice.quartzimpl.BPETimerServiceQuartzImpl"
+ * --value="com.sybase.bpe.timerservice.noop.NoopTimerService"
+ *
+ * @ejb.ejb-ref
+ * ejb-name="PackageInfo"
+ * view-type="remote"
+ * ref-name="thePackageInfo"
+ * @ejb.ejb-ref
+ * --ejb-name="EngineState"
+ * ejb-name="EngineStateCoarse"
+ * view-type="local"
+ * ref-name="theEngineState"
+ * @ejb.ejb-ref
+ * ejb-name="BPE_CMPBLOB"
+ * view-type="local"
+ * ref-name="theCMPObjectBean"
+ * @ejb.ejb-ref
+ * ejb-name="RegistrationEntity"
+ * view-type="local"
+ * ref-name="registrationBean"
+ * @ejb.ejb-ref
+ * ejb-name="BPEventDirector"
+ * view-type="local"
+ * ref-name="theLocalBPEDBean"
+ * -- EAS is not j2ee 1.4 compatible
+ * --@ejb.ejb-ref
+ * -- ejb-name="BPETimer"
+ * -- view-type="local"
+ * -- ref-name="BPETimerLocal"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * res-type="javax.sql.DataSource"
+ * res-auth="Container"
+ * @jboss.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="java:/jdbc/JavaCache"
+ * @weblogic.resource-description
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="jdbc/JavaCache"
+ *
+ */
+public class BPEventDirectorBean extends ExternalEventDirectorBase implements SessionBean,
+ IInternalRequestConsumer {
+
+ static final long serialVersionUID = 8909646742595626256L;
+
+ private static Logger logger =
+ Logger.getLogger(BPEventDirectorBean.class.getName());
+ private InitialContext ic;
+ private SessionContext context;
+
+ private ProcessService ps;
+ private IInternalEventDirector ed;
+
+ /**
+ * @ejb:interface-method
+ */
+ public void startProcess(String id) {
+ try {
+ // create the process
+ ProcessInstance pi = ps.createProcess(
+ new ProcessDefinitionKey(id));
+ // creat the processes root container
+ IContextService ctxs = pi.getContextService();
+ IContainer cont = ctxs.getRoot();
+ cont.createContainer(pi.getRootKey());
+ // send a start event
+ pi.processEvent(new StateEvent(pi.getRootKey(),
+ pi.getKey(),StateEnum.STARTED),
+ ed, ed);
+ } catch (BPException ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public IResponseMessage sendEvent(IRequestMessageEvent event, boolean sync) {
+
+ try {
+ IResponseMessage rsp = ed.sendEvent(event,sync);
+ return rsp;
+ } catch (Exception ex) {
+ logger.log(Level.FINE,"",ex);
+ try {
+ IResponseMessage resp = event.createResponseMessage();
+ Fault fault = new Fault();
+ fault.setFaultString(ex.getLocalizedMessage());
+ fault.setFaultException(ex);
+ resp.setFault(fault);
+ // clear cached correlation service state
+ if ( ed instanceof EventDirectorEjbImpl ) {
+ ((EventDirectorEjbImpl)ed).clearState();
+ }
+ return resp;
+ } catch (BPException e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void sendEvent(StateEvent event, boolean sync) {
+ try {
+ ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void sendEvent(LoadDefinitionEvent event, boolean sync) {
+ try {
+ ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ // TODO: Cory - should the exception be rethrown?
+ // logger.log(Level.SEVERE,"",ex);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Fault sendEvent(IBPETimer event, boolean sync) {
+ Fault fault = null;
+ try {
+ fault = ed.sendEvent(event,sync);
+ } catch (Exception ex) {
+ //logger.log(Level.SEVERE,"",ex);
+ fault = new Fault();
+ fault.setFaultString(ex.getLocalizedMessage());
+ }
+ return fault;
+ }
+
+
+ public void ejbCreate(){
+
+ try {
+
+ ic = new InitialContext();
+ BPEProperties p = new BPEProperties(true,ic);
+ ed = (IInternalEventDirector)EventDirectorFactory.createEventDirector(p);
+ ps = ed.getProcessService();
+
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE,"",ex);
+ }
+
+ }
+
+ public void setSessionContext(SessionContext ctx) {
+ this.context = ctx;
+ }
+ public void ejbRemove() {ed.release();}
+ public void ejbActivate() {}
+ public void ejbPassivate() {}
+ public void ejbLoad() {}
+ public void ejbStore() {}
+
+
+ /**
+ * @ejb:interface-method
+ * view-type="local"
+ */
+ public IInternalEventDirector getIInternalEventDirector() {
+ return ed;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/EventDirectorEjbImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/EventDirectorEjbImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/EventDirectorEjbImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/bped/managed/EventDirectorEjbImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,375 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.bped.managed;
+
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import com.sybase.bpe.bped.DeployTypeEnum;
+import com.sybase.bpe.bped.EventDirector;
+import com.sybase.bpe.bped.EventDirectorException;
+import com.sybase.bpe.bped.EventDirectorUtil;
+import com.sybase.bpe.bped.IDeployer;
+import com.sybase.bpe.bped.IInternalEventDirector;
+import com.sybase.bpe.client.impl.IInternalMessage;
+import com.sybase.bpe.client.impl.IInternalResult;
+import com.sybase.bpe.correlation.CorrelationService;
+import com.sybase.bpe.correlation.managed.CorrelationServiceEjbImpl;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.ReturnMessageLocatorHolder;
+import com.sybase.bpe.event.Fault;
+import com.sybase.bpe.event.IRequestMessageEvent;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.IStaticKey;
+import com.sybase.bpe.event.LoadDefinitionEvent;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.locking.LockingService;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+
+/**
+ * An EJB implementation of EventDirector.
+ *
+ */
+public class EventDirectorEjbImpl implements IInternalEventDirector, EventDirector {
+
+ private static Logger logger =
+ Logger.getLogger(EventDirectorEjbImpl.class.getName());
+
+ private ReturnMessageLocatorHolder rmlh;
+ private IRequestMessageEvent me;
+ private UUIDService us;
+ private ProcessService processService;
+ // correlation service
+ private CorrelationService correlationService;
+ private LockingService lockingService;
+ private DefinitionService definitionService;
+
+
+ // The event director will use a stack to push and pop ProcessInstance
+ // on the evaluation context. This will cause the engine to use depth
+ // first evaluation of the process tree.
+ private Stack processInstanceStack = new Stack();
+
+ // mark for dead current process
+ private boolean dead;
+
+
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#init(BPEProperties, CorrelationService)
+ */
+ public void init(BPEProperties props, ProcessService ps, CorrelationService cs, UUIDService us, LockingService ls)
+ throws BPException {
+
+ try {
+
+ InitialContext context = new InitialContext();
+
+ // get process service
+ props = new BPEProperties(true,context);
+ this.us = us;
+ processService = ps;
+ correlationService = cs;
+ lockingService = ls;
+
+
+ } catch ( NamingException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",new Object[] {"NamingException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#getCorrelationService()
+ */
+ public CorrelationService getCorrelationService() {
+ return correlationService;
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#getLockingService()
+ */
+ public LockingService getLockingService() {
+ return lockingService;
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#getProcessService()
+ */
+ public ProcessService getProcessService() {
+
+ return processService;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#getReturnMessageMetadata()
+ */
+ public ReturnMessageLocatorHolder getReturnMessageMetadata() {
+
+ return this.rmlh;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#setReturnMessageMetadata(java.util.Collection)
+ */
+ public void setReturnMessageMetadata(ReturnMessageLocatorHolder rmlh) {
+ this.rmlh = rmlh;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#getMessageEvent()
+ */
+ public IRequestMessageEvent getMessageEvent() {
+
+ return this.me;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#setMessageEvent(com.sybase.bpe.event.MessageEvent)
+ */
+ public void setMessageEvent(IRequestMessageEvent me) {
+ this.me =me;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.engine.IEvaluationContext#release()
+ */
+ public void release() {
+ try {
+ us.close();
+ } catch ( Exception e ) {
+ // log a warning if the uuid service doesn't close properly
+ logger.log(Level.WARNING,"",e);
+ }
+ processService.getInstanceService().getDefinitionService().releaseExternalActions();
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#sendEvent(IRequestMessageEvent, boolean)
+ * @ejb:interface-method
+ */
+ public IResponseMessage sendEvent(IRequestMessageEvent msg, boolean sync)
+ throws BPException
+ {
+
+ IResponseMessage er = null;
+ logger.fine("Received message event.");
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = ( CorrelationServiceEjbImpl )
+ ( correlationService );
+ // The component may have some cached registration updates
+ // which were never cleared because of a previous transaction rollback.
+ // Clear them now just in case.
+ csei.clearState();
+ }
+
+ //Let the definition service know that the definition load
+ //phase has completed and we are now sending service requests.
+ //This is needed for the definitionService optimization caching.
+ getDefinitionService().prepare();
+ er = correlationService.correlateEvent((IRequestMessageEvent) msg,
+ sync, this);
+
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = ( CorrelationServiceEjbImpl )
+ ( correlationService );
+ csei.persistRegistrationChanges();
+ }
+ return er;
+ }
+
+ private DefinitionService getDefinitionService() throws BPException
+ {
+ if ( definitionService == null )
+ {
+ definitionService = this.correlationService.
+ getProcessService().getInstanceService().getDefinitionService();
+ }
+ return definitionService;
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#activate(String)
+ */
+ public void activate(String rootKey, String procKey) throws BPException {
+
+ try {
+ EventDirectorUtil.activate(this,rootKey,procKey);
+ } catch ( EventDirectorException ede ) {
+ logger.log(Level.SEVERE,"",ede);
+ throw ede;
+ }
+ }
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#terminate(String)
+ */
+
+ public void terminate(String rootKey,String procKey) throws BPException {
+
+ try
+ {
+ EventDirectorUtil.terminate(this,rootKey,procKey);
+ } catch ( EventDirectorException ede ) {
+ logger.log(Level.SEVERE,"",ede);
+ throw ede;
+ }
+
+ }
+
+
+ /**
+ * @see com.sybase.bpe.bped.IInternalEventDirector#pause(String)
+ */
+ public void pause(String rootKey, String procKey) throws BPException {
+ EventDirectorUtil.pause(this,rootKey,procKey);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.IEventDirector#getDeployer(com.sybase.bpe.bped.DeployTypeEnum)
+ */
+ public IDeployer getDeployer(DeployTypeEnum type) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#sendEvent(com.sybase.bpe.event.StateEvent, boolean)
+ */
+ public void sendEvent(StateEvent me, boolean sync) throws BPException
+ {
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = (CorrelationServiceEjbImpl) (correlationService);
+ csei.clearState();
+ }
+
+ EventDirectorUtil.handleStateEvent(this, processService, me);
+
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = (CorrelationServiceEjbImpl) (correlationService);
+ csei.persistRegistrationChanges();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sybase.bpe.bped.EventDirector#sendEvent(com.sybase.bpe.event.LoadDefinitionEvent,
+ * boolean)
+ */
+ public void sendEvent(LoadDefinitionEvent me, boolean sync) throws BPException {
+
+ EventDirectorUtil.handleLoadDefintionEvent(this,me);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#sendEvent(com.sybase.bpe.timerservice.IBPETimer, boolean)
+ */
+ public Fault sendEvent(IBPETimer me, boolean sync) throws BPException {
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = (CorrelationServiceEjbImpl) (correlationService);
+ csei.clearState();
+ }
+ EventDirectorUtil.handleTimerEvent(this,me);
+ if (correlationService instanceof CorrelationServiceEjbImpl)
+ {
+ CorrelationServiceEjbImpl csei = (CorrelationServiceEjbImpl) (correlationService);
+ csei.persistRegistrationChanges();
+ }
+ return null;
+ }
+
+ /**
+ * @see com.sybase.bpe.engine.IEvaluationContext#addProcessInstance(com.sybase.bpe.engine.ProcessInstance)
+ */
+ public void addProcessInstance(ProcessInstance pi) {
+ processInstanceStack.push(pi);
+
+ }
+
+ /**
+ * @see com.sybase.bpe.engine.IEvaluationContext#getNextProcessInstance()
+ */
+ public ProcessInstance getNextProcessInstance() {
+ return ( processInstanceStack.size() > 0 ) ? (ProcessInstance)processInstanceStack.pop() : null;
+ }
+
+ /**
+ * @see com.sybase.bpe.engine.IEvaluationContext#initProcessInstanceCollection()
+ */
+ public void initProcessInstanceCollection() {
+ processInstanceStack.clear();
+ }
+ /**
+ * @see com.sybase.bpe.engine.IEvaluationContext#hasMoreProcessInstances()
+ */
+ public boolean processInstanceCollectionIsEmpty() {
+ return processInstanceStack.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.engine.IEvaluationContext#setDeadProcess()
+ */
+ public void setDeadProcess(boolean mark) {
+ dead = mark;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.engine.IEvaluationContext#isDeadProcess()
+ */
+ public boolean isDeadProcess() {
+ return dead;
+ }
+
+ public IInternalResult sendRequest(IStaticKey staticKey, IInternalMessage internalRequest)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.bped.EventDirector#getIInternalEventDirector()
+ */
+ public IInternalEventDirector getIInternalEventDirector() {
+ return this;
+ }
+
+}