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 [35/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/scope/service/ScopeServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,57 @@
+/*
+* 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.scope.service;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author charper
+ *
+ *
+ *
+ */
+public class ScopeServiceException extends BPException {
+
+
+ static final long serialVersionUID = -7777563832523244653L;
+
+ /**
+ * @param message_id
+ * @param msgParams
+ */
+ public ScopeServiceException(String message_id, Object[] msgParams) {
+ super(message_id, msgParams);
+ }
+
+ /**
+ * @param message_id
+ * @param msgParams
+ * @param cause
+ */
+ public ScopeServiceException(
+ String message_id,
+ Object[] msgParams,
+ Throwable cause) {
+ super(message_id, msgParams, cause);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/ScopeServiceFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,81 @@
+/*
+* 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.scope.service;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/** Creates a ScopeService implementation from a set of properties.
+ * <P>
+ * A ScopeService is an abstraction over a repository that will store
+ * scoping information
+ */
+public class ScopeServiceFactory
+{
+
+ private static Logger logger =
+ Logger.getLogger(ScopeServiceFactory.class.getName());
+
+ private static Class defClass;
+
+ /** Get a scope service.
+ *
+ * @param properties */
+ public static IScopeService createScopeService(IContextService cs,
+ String containerId, BPEProperties props) throws BPException {
+
+ IScopeService ss = null;
+
+ try {
+
+ if ( defClass == null ) {
+ // load the implementation
+ defClass = java.lang.Class.forName(props.getScopeServiceClass());
+ }
+
+ // try to instantiate the subclass
+ ss = (IScopeService) defClass.newInstance();
+ ss.init(cs, containerId);
+
+ } catch (ClassNotFoundException e) {
+ ScopeServiceException bpx = new ScopeServiceException("CLASS_NOT_FOUND",new Object[] {props.getScopeServiceClass()});
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (InstantiationException e) {
+ ScopeServiceException bpx = new ScopeServiceException("NATIVE_EXCEPTION",new Object[] {"InstantiationException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (IllegalAccessException e) {
+ ScopeServiceException bpx = new ScopeServiceException("NATIVE_EXCEPTION",new Object[] {"IllegalAccessException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+
+ return ss;
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/FCScopeInstanceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/FCScopeInstanceImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/FCScopeInstanceImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/FCScopeInstanceImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,771 @@
+/*
+* 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.scope.service.impl;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.action.bpel.TimerAction;
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.context.IPart;
+import com.sybase.bpe.context.resolver.ContextResolvedObject;
+import com.sybase.bpe.context.resolver.ContextResolver;
+import com.sybase.bpe.correlation.CorrelationService;
+import com.sybase.bpe.correlation.Registration;
+import com.sybase.bpe.definition.IPMDLocator;
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.event.StateEvent;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.lang.ResourceGetter;
+import com.sybase.bpe.scope.service.BPRuntimeException;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.ScopePath;
+import com.sybase.bpe.timerservice.BPETimerServiceFactory;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.timerservice.IBPETimerService;
+import com.sybase.bpe.util.BPException;
+
+/**
+ *
+ */
+public class FCScopeInstanceImpl implements IFCScopeInstance, Serializable {
+
+ static final long serialVersionUID = -810005833715560330L;
+
+ private static Logger logger =
+ Logger.getLogger(FCScopeInstanceImpl.class.getName());
+
+ // scope path for this scope
+ private ScopePath scopePath;
+ // when scope is created it is active
+ private boolean active = true;
+ // when scope is created it has not been faulted
+ private boolean faulted = false;
+ // when a scope is create it has not been compensated
+ private boolean compensated = false;
+ // index fault proc defs by name
+ private HashMap faultsByName = new HashMap();
+ // ndex fault proc defs bytype
+ private HashMap faultsByType = new HashMap();
+ // ndex fault proc defs by name and type
+ private HashMap faultsByNameType = new HashMap();
+ // proc def to run after fault hanlder is run
+ private String faultObserver;
+ // proc def for compensation handler
+ private String compensationHandler;
+ // context container id for compensation snap shot
+ private String compenstationCtxId;
+ // contxt id that this scope executes in
+ private String ctxId;
+ // registrations made in this scope
+ private ArrayList receives = new ArrayList();
+ // timers registered in this scope
+ private ArrayList timers = new ArrayList();
+ // processes that need to be cleaned up after scope completes
+ // HashSet so we don't get dups
+ private HashSet procs = new HashSet();
+ // this scopes parent
+ private FCScopeInstanceImpl parentScope;
+ // this scopes children
+ private HashMap childrenScopes = new HashMap();
+ // this scopes completed children ordered by completion
+ private ArrayList completedChildrenScopes = new ArrayList();
+ // index to all scopes
+ private HashMap allScopes;
+ // timer action stuff for special case
+ private transient TimerAction act;
+ private transient ContextResolver resolver;
+ private ScopePath _sp;
+
+ // this flag is set if this scope is
+ // executing a faultHanlder, this flag is not
+ // set if this scope is in a fault handler
+ private boolean executingFaultHandler = false;
+
+ // this is used to instantiate the root scope
+ protected FCScopeInstanceImpl() {
+ allScopes = new HashMap();
+ this.scopePath = new ScopePath();
+ allScopes.put(this.scopePath.toString(),this);
+ }
+
+ private FCScopeInstanceImpl(ScopePath scopePath, String newScopeName,
+ String newScopeId, String ctxId, FCScopeInstanceImpl parentScope, HashMap allScopes) {
+ try {
+ this.scopePath = (ScopePath)scopePath.clone();
+ } catch (CloneNotSupportedException e) {
+ // this shouldn't happen
+ this.scopePath = scopePath;
+ }
+ this.ctxId = ctxId;
+ this.scopePath.addScope(newScopeName,newScopeId);
+ this.parentScope = parentScope;
+ parentScope.addChildScope(this);
+ this.allScopes = allScopes;
+ this.allScopes.put(this.scopePath.toString(),this);
+ }
+
+ protected FCScopeInstanceImpl getParentScope() {
+ return parentScope;
+ }
+
+ protected List getCompletedChildrenScopes() {
+ return completedChildrenScopes;
+ }
+
+ private void addChildScope(FCScopeInstanceImpl childScope) {
+ childrenScopes.put(childScope.getScopePath().toString(),childScope);
+ }
+
+ private void addCompletedChiledScope(FCScopeInstanceImpl scope) {
+ completedChildrenScopes.add(scope);
+ }
+
+ protected IFCScopeInstance getScope(ScopePath scopePath) {
+ return (IFCScopeInstance)this.allScopes.get(scopePath.toString());
+ }
+
+ protected HashMap getScopes() {
+ return allScopes;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#createScope(java.lang.String, java.lang.String)
+ */
+ public IFCScopeInstance createScope(String newScopeName, String newScopeId, String ctxId) throws BPException {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Creating new " +
+ newScopeName+newScopeId + " scope in: " + this.scopePath);
+ }
+ return new FCScopeInstanceImpl(this.scopePath, newScopeName, newScopeId, ctxId, this, this.allScopes);
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#addFaultHandler(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void addFaultHandler(String faultName, String faultType,
+ String defintionId) throws BPException {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding fault handler for scope:" +
+ scopePath + " name: " + faultName +
+ " faultType: " + faultType + " defid: " + defintionId);
+ }
+ if ( faultName != null ) {
+ faultsByName.put(faultName,defintionId);
+ }
+ if ( faultType != null ) {
+ faultsByType.put(faultType,defintionId);
+ }
+ if ( faultType != null && faultName != null ) {
+ faultsByNameType.put(faultName+faultType,defintionId);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#setFaultHandlerObserver(java.lang.String, com.sybase.bpe.context.resolver.ContextResolver, com.sybase.bpe.engine.IEvaluationContext)
+ */
+ public void setFaultHandlerObserver(String defintionId) throws BPException {
+ faultObserver = defintionId;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#setCompensationHandler(java.lang.String, com.sybase.bpe.context.resolver.ContextResolver, com.sybase.bpe.engine.IEvaluationContext)
+ */
+ public void setCompensationHandler(String defintionId, List locators,
+ ContextResolver resolver, String ctxId ) throws BPException {
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Creating compensation snap shot for " + this.scopePath +
+ " defid :" + defintionId +
+ " snap shot context: " + ctxId);
+ }
+
+ compensationHandler = defintionId;
+ compenstationCtxId = ctxId;
+
+ IContextService cs = resolver.getContextService();
+ IContainer rootCont = cs.getRoot();
+ IContainer snapShot = rootCont.createContainer(compenstationCtxId);
+
+ // for each locator creat path in snap shot context
+ //Iterator it = resolver.getLocatorHolder().getLocators();
+ Iterator it = locators.iterator();
+ while ( it.hasNext() ) {
+
+ IPMDLocator loc = (IPMDLocator)it.next();
+ String path[] = this.scopePath.applyPathIdsToPath(
+ loc.getPath()).split(ScopePath.DELIMITER);
+ IContainer cont = snapShot;
+ for ( int i = 1; i < path.length - 1 ; i++ ) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Created snap shot container("+
+ compenstationCtxId+"):"+path[i]);
+ }
+ cont = cont.createContainer(path[i]);
+ }
+ ContextResolvedObject from =
+ (ContextResolvedObject) resolver.resolveWithOutInvocation(loc);
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Copying snap shot part("+
+ compenstationCtxId+"):"+path[path.length-1]);
+ }
+ cont.copyNode(from.getContextNode(), path[path.length-1]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#setInactive()
+ */
+ public void setInactive(IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+
+ // this process could have already been deactivated
+ if ( active ) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating scope:" + this.scopePath);
+ }
+
+ active = false;
+ // inactive scopes should not have any register timers or receives
+ cleanUp(pcb);
+ if ( this.parentScope != null ) {
+ this.parentScope.addCompletedChiledScope(this);
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#isActive()
+ */
+ public boolean isActive() {
+ return active;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#isFaulted()
+ */
+ public boolean isFaulted() {
+ return faulted;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#isCompensated()
+ */
+ public boolean isCompensated() {
+ return compensated;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#addRegistration(com.sybase.bpe.correlation.Registration)
+ */
+ public void addRegistration(Registration registration) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding registration for scope:" + this.scopePath +
+ " registration: " + registration);
+ }
+ receives.add(registration);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#addTimer(com.sybase.bpe.timerservice.IBPETimer)
+ */
+ public void addTimer(IBPETimer timer) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Adding timer for scope:" + this.scopePath +
+ " timer: " + timer);
+ }
+ timers.add(timer);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#getScopePath()
+ */
+ public ScopePath getScopePath() {
+ return scopePath;
+ }
+
+
+ private String getFaultHandler(String faultName, String faultType,
+ Throwable t) {
+
+ // the following implements the fault processing described in the
+ // BPEL specification
+
+ String faultHandler = null;
+ // if no faulType, meaning no fault data, match on faultName
+ if ( faultType == null ) {
+
+ if ( faultName != null ) {
+ faultHandler = (String)faultsByName.get(faultName);
+ }
+
+ // if faultType, meaning there is fault data, match on faultName
+ // and faultType
+ } else {
+ // is there a faultName/faultType match
+
+ if ( faultName != null && faultType != null ) {
+ faultHandler = (String)faultsByNameType.get(faultName+faultType);
+ }
+
+ if ( faultHandler == null ) {
+ // look by faultName
+ if ( faultName != null ) {
+ faultHandler = (String)faultsByName.get(faultName);
+ }
+ if ( faultHandler == null ) {
+ // look by faultType
+ if ( faultType != null ) {
+ faultHandler = (String)faultsByType.get(faultType);
+ }
+ }
+ }
+
+ }
+
+ // we don't want to return a catch all if this is a forced termination
+ if ( faultHandler == null && faultName != FORCED_TERMINATION) {
+ // we still have not found a handler, so look for
+ // the catchAll
+ faultHandler = (String)faultsByName.get(CATCH_ALL);
+
+ if ( faultHandler != null && faultName == null
+ && faultType == null ) {
+ // we are catching all non BPEL spec defined
+ // errors with catch all so we'll dump the error
+ // to the log
+ if ( logger.isLoggable(Level.WARNING)) {
+ logger.log(Level.WARNING,ResourceGetter.getString("NON_BPEL_CATCHALL"), t);
+ }
+ }
+ }
+ return faultHandler;
+
+ }
+
+ private void executeProcess(String procId, IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+
+ IPMDProcess def = ec.getProcessService().getInstanceService().getDefinitionService().getProcessDefintion(
+ new ProcessDefinitionKey(procId),proc.getDefinition().getRootKey());
+
+ ProcessInstance pi = ec.getProcessService().createSubProcess(proc,def);
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine( "Executing process:" + pi.getKey() + "(Parent:" +
+ proc.getKey() + ")");
+ }
+
+ // Send a Start event to the fault handler process instance
+ pi.processEvent(
+ new StateEvent(pi.getRootKey(),pi.getKey(), StateEnum.STARTED),
+ ec, pcb);
+ }
+
+ private void reThrow(Throwable t) throws BPException
+ {
+ if ( t instanceof BPException ) {
+ throw (BPException)t;
+ } else if ( t instanceof Error ) {
+ throw (Error)t;
+ } else if ( t instanceof RuntimeException ) {
+ throw (RuntimeException)t;
+ } else {
+ // checked exceptions other than
+ // BPException shouldn't ever get here
+ throw new RuntimeException(t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#handleFault(com.sybase.bpe.scope.service.BPRuntimeException, com.sybase.bpe.engine.IEvaluationContext)
+ */
+ public void handleFault(Throwable exception, IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb)
+ throws BPException {
+
+ // set the execution context to fault hanlder
+ // if we are executing in a fault context, this whould
+ // be the case if a fault is thrown from a scope created
+ // inside a fault handler
+ if ( executingFaultHandler ) {
+ proc.setExecutionContext(FAULT_HANDLER);
+ }
+
+ if (_sp != null){
+ // Special case - A fault has been thrown within a compensation handler.
+ // Need to reset the scope path so that the stack will unwind correctly.
+ proc.setScopePath(_sp);
+ ScopePath esp = _sp.getEnclosingScopePath();
+ while((this.parentScope != null)&&(!esp.equals(this.parentScope.getScopePath())))
+ this.parentScope = this.parentScope.parentScope;
+
+ _sp = null;
+ }
+
+ // check to see if this fault was thrown inside a fault handler,
+ // this special case exists because fault handlers are allowed
+ // access to variables in the same scope the fault handler is define,
+ // but faults thrown from a fault handler are handled by the parent
+ // scope of the scope that the fault handler is defined in
+ if ( proc.getExecutionContext().equals(FAULT_HANDLER)) {
+ if ( this.parentScope != null &&
+ ! this.parentScope.scopePath.getCurrentScope().equals("") )
+ {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Fault thrown from fault handler, passing fault to parent scope:" + this.parentScope.getScopePath());
+ }
+ // change the scope of our process
+ proc.setScopePath(this.parentScope.getScopePath());
+ // execution context is back in process, for fault handling
+ proc.setExecutionContext(PROCESS);
+ this.parentScope.handleFault(exception,proc,ec,pcb);
+ } else {
+ reThrow(exception);
+ }
+ return;
+ }
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Handling fault " + exception.toString()
+ + " in scope:" + this.scopePath);
+ }
+
+ // activity termination
+ // for each eclosed active scope terminate it
+ Iterator it = childrenScopes.values().iterator();
+ while (it.hasNext()) {
+ IFCScopeInstance scope = (IFCScopeInstance) it.next();
+ if (scope.isActive()) {
+ scope.terminate(proc, ec, pcb);
+ }
+ }
+
+ // after activity termination another fault could have been thrown
+ // and this scope could have been faulted, so we don't want to fault this
+ // scope again
+ if ( ! this.faulted ) {
+ // mark this scope as faulted
+ this.faulted = true;
+
+ String faultName = null;
+ String faultType = null;
+
+
+ if (exception instanceof BPRuntimeException ) {
+
+ BPRuntimeException brpe = (BPRuntimeException)exception;
+ // copy fault parts into context
+ if (brpe.getMessageParts().size() > 0) {
+ IContextService cs = ec.getProcessService()
+ .getContextService(proc.getRootKey());
+ IContainer rootCont = cs.getRoot();
+ IContainer globalCont = rootCont.createContainer(proc
+ .getContextContainerId());
+ IContainer faultCont = globalCont
+ .createContainer(CURRENT_FAULT);
+ for (Iterator itrPart = brpe.getMessageParts()
+ .entrySet().iterator(); itrPart.hasNext();) {
+ Map.Entry me = (Map.Entry) itrPart.next();
+ IPart faultPart = (IPart) faultCont
+ .createPart((String) me.getKey());
+ faultPart.setObject(me.getValue());
+ }
+ }
+
+ // look for fault handler
+ faultName = brpe.getNameSpace() + ":" + brpe.getName();
+ faultType = brpe.getType();
+ }
+
+ // look for fault handler
+ String faultHandler = getFaultHandler(faultName, faultType,
+ exception);
+
+ // found a fault handler
+ if ( faultHandler != null ) {
+ // execute fault handler
+ // make sure we are executing in the context id
+ // of this scope, the process context id may not be
+ // correct in the case where we are throwing out of a
+ // scope that was executing in a compensation handler
+ proc.setContextContaionerId(this.ctxId);
+ // we are executing in a fault handler now
+ proc.setExecutionContext(FAULT_HANDLER);
+ // this scope is executing in a fault handler
+ // this is not true when executing in scope
+ // inside a fault handler
+ executingFaultHandler = true;
+ executeProcess(faultHandler,proc,ec,pcb);
+ // we are back in process context
+ proc.setExecutionContext(PROCESS);
+
+ // execute fault handler observer
+ if ( faultObserver != null ) {
+ executeProcess(this.faultObserver,proc,ec,pcb);
+ } else {
+ return;
+ }
+
+ // didn't find fault handler
+ } else {
+ // implicit compensation
+ this.compensate(proc,ec,pcb);
+
+ // rethrow fault if the parent is not the root
+ if ( this.parentScope != null &&
+ ! this.parentScope.scopePath.getCurrentScope().equals("") )
+ {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Re throwing fault to scope:" + this.parentScope.getScopePath());
+ }
+ // change the scope of our process
+ proc.setScopePath(this.parentScope.getScopePath());
+ this.parentScope.handleFault(exception,proc,ec,pcb);
+ } else {
+ reThrow(exception);
+ }
+ }
+
+ }
+
+ }
+
+ private void cleanUp(IProcessCallBack pcb) throws BPException {
+ // cancel timers
+ IBPETimerService ts = BPETimerServiceFactory.getBPETimerService();
+ Iterator it = timers.iterator();
+ while ( it.hasNext() ) {
+ IBPETimer timer = (IBPETimer)it.next();
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Canceling timer in scope:" + this.scopePath +
+ " timer: " + timer);
+ }
+ ts.removeTimer(timer);
+ }
+
+ // cancel registrations
+ CorrelationService cs = pcb.getCorrelationService();
+ it = receives.iterator();
+ while ( it.hasNext() ) {
+ Registration reg = (Registration)it.next();
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Removing registration in scope:" + this.scopePath +
+ " registration: " + reg);
+ }
+ cs.removeRegistration(reg);
+ }
+
+ // delete any process kept for this scope
+ InstanceService is = pcb.getCorrelationService().getProcessService().getInstanceService();
+ it = procs.iterator();
+ while ( it.hasNext() ) {
+ IPMIProcess proc = (IPMIProcess)it.next();
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Removing process in scope:" + this.scopePath +
+ " process: " + proc.getKey());
+ }
+ is.getInstance(proc.getRootKey(),proc.getKey()).remove();
+ }
+
+ timers.clear();
+ receives.clear();
+ procs.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#terminate(com.sybase.bpe.engine.IEvaluationContext)
+ */
+ public void terminate(IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+
+ // if this scope is active terminate it
+ if (this.active) {
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Terminating scope:" + this.scopePath);
+ }
+
+ // mark scope as inactive
+ this.active = false;
+
+ // for each eclosed active scope terminate it
+ Iterator it = childrenScopes.values().iterator();
+ while (it.hasNext()) {
+ IFCScopeInstance scope = (IFCScopeInstance) it.next();
+ if (scope.isActive()) {
+ scope.terminate(proc, ec, pcb);
+ }
+ }
+
+ // cancel all the timers and receives
+ cleanUp(pcb);
+
+ // does this scope have a bpws:forcedTermination fault handler
+ String forcedTermination = getFaultHandler(FORCED_TERMINATION, null, null);
+ if (forcedTermination != null) {
+ // execute fault handler
+ executeProcess(forcedTermination, proc, ec, pcb);
+
+ // no bpws:forcedTermination fault handler
+ } else {
+ // implicit compensation
+ this.compensate(proc, ec, pcb);
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#compensate(com.sybase.bpe.engine.IEvaluationContext)
+ */
+ public void compensate(IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+
+ // if this scope has been compensated return
+ if ( this.compensated ) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Scope has already been compensated:" + this.scopePath);
+ }
+ return;
+ }
+
+ // does this scope have a compensation handler and
+ if ( this.compensationHandler != null ) {
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Compensating scope:" + this.scopePath);
+ }
+
+ // The scope path in the IPMIProcess object is used to resolve variables.
+ // However, it's scope path is set up to the level that initiated compensation
+ // (at least one level below). Need to update the scope path here so the snapshot
+ // variables can be accessed. CR379112.
+ _sp = proc.getScopePath();
+ proc.setScopePath(this.scopePath);
+
+
+ this.compensated = true;
+ // point the process at the snap shot context
+ String saveCtxId = proc.getContextContainerId();
+ proc.setContextContaionerId(this.compenstationCtxId);
+ // run compensation handler
+ executeProcess(this.compensationHandler,proc,ec,pcb);
+ proc.setContextContaionerId(saveCtxId);
+ proc.setScopePath(_sp);
+ _sp = null;
+
+
+ // this scope doesn't have compensation handler
+ } else {
+ // look for an enclosed completed scope that has a compensation handler
+ //Iterator it = completedChildrenScopes.iterator();
+ //while ( it.hasNext() ) {
+ // IFCScopeInstance scope = (IFCScopeInstance)it.next();
+ // scope.compensate(proc,ec,pcb);
+ // Scopes should be compensated in the reverse order of the completion of the scopes
+ for (int i = completedChildrenScopes.size(); i > 0; i--)
+ {
+ IFCScopeInstance scope = (IFCScopeInstance)completedChildrenScopes.get(i-1);
+ scope.compensate(proc,ec,pcb);
+ }
+
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#removeRegistration(com.sybase.bpe.correlation.Registration)
+ */
+ public void removeRegistration(Registration registration) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Removing registration from scope:" + this.scopePath +
+ " registration: " + registration );
+ }
+ receives.remove(registration);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#removeTimer(com.sybase.bpe.timerservice.IBPETimer)
+ */
+ public void removeTimer(IBPETimer timer) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Canceling timer in scope:" + this.scopePath +
+ " timer: " + timer);
+ }
+ timers.remove(timer);
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#addProcess(com.sybase.bpe.instance.service.IPMIProcess)
+ */
+ public void addProcess(IPMIProcess proc) {
+ procs.add(proc);
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.scopePath.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#setTimerAction(com.sybase.bpe.action.bpel.TimerAction, com.sybase.bpe.context.resolver.ContextResolver, com.sybase.bpe.engine.IEvaluationContext, com.sybase.bpe.engine.IProcessCallBack, com.sybase.bpe.instance.service.IPMIProcess, com.sybase.bpe.definition.service.IPMDProcess)
+ */
+ public void setTimerAction(TimerAction act, ContextResolver resolver ) {
+ this.act = act;
+ this.resolver = resolver;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IFCScopeInstance#executeTimerAction()
+ */
+ public void executeTimerAction(IEvaluationContext ec,
+ IProcessCallBack pcb, IPMIProcess processInstance, IPMDProcess processDefinition) throws BPException {
+ if ( this.act != null ) {
+ this.act.execute(resolver, ec, pcb,processInstance, processDefinition);
+ }
+
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/ScopeServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/ScopeServiceImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/ScopeServiceImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/scope/service/impl/ScopeServiceImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,124 @@
+/*
+* 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.scope.service.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.context.IPart;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.IScopeService;
+import com.sybase.bpe.scope.service.ScopePath;
+import com.sybase.bpe.util.BPException;
+
+/**
+ *
+ */
+public class ScopeServiceImpl implements IScopeService {
+
+ private static Logger logger =
+ Logger.getLogger(ScopeServiceImpl.class.getName());
+
+// private IContextService cs;
+ private FCScopeInstanceImpl rootScope;
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IScopeService#init(com.sybase.bpe.context.IContextService)
+ */
+ public void init(IContextService cs, String ctxId) throws BPException {
+// this.cs = cs;
+ IContainer root = cs.getRoot();
+ IContainer procroot = (IContainer)root.findChild(ctxId);
+ IPart rootScopePart = (IPart)procroot.findChild("rootScope");
+ if ( rootScopePart == null ){
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Initializing context service for ctxid:" + ctxId);
+ }
+ rootScopePart = procroot.createPart("rootScope");
+ rootScope = new FCScopeInstanceImpl();
+ rootScopePart.setObject(rootScope);
+ } else {
+ rootScope = (FCScopeInstanceImpl)rootScopePart.getObjectForReadWrite();
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IScopeService#getStcope(java.lang.String)
+ */
+ public IFCScopeInstance getScope(ScopePath scopePath) throws BPException {
+ return rootScope.getScope(scopePath);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IScopeService#compensate(java.lang.String)
+ */
+ public void compensate(String scopeName, IPMIProcess proc,
+ IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+ // find a matching scope and get it's parents completed scopes
+ // matching the scope name to compensate
+ FCScopeInstanceImpl parentScope = null;
+ Iterator it = rootScope.getScopes().values().iterator();
+ while( it.hasNext() ) {
+ FCScopeInstanceImpl scope = (FCScopeInstanceImpl)it.next();
+ String name = scope.getScopePath().getCurrentScope();
+ if ( name.startsWith(scopeName) ) {
+ parentScope = scope.getParentScope();
+ break;
+ }
+ }
+
+ // bad scope name
+ if ( parentScope == null ) {
+ throw new BPException("SS_BAD_COMP_SCOPE_NAME",new Object[] { scopeName });
+ }
+
+ // compensate the scopes the start with the scope name
+ List completedScopes = parentScope.getCompletedChildrenScopes();
+ for (int i = completedScopes.size(); i > 0; i--)
+ {
+ IFCScopeInstance scope = (IFCScopeInstance)completedScopes.get(i-1);
+ String name = scope.getScopePath().getCurrentScope();
+ if ( name.startsWith(scopeName)) {
+ scope.compensate(proc,ec,pcb);
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.scope.service.IScopeService#getRootScope()
+ */
+ public IFCScopeInstance getRootScope() throws BPException {
+ return rootScope;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/BPETimerServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/BPETimerServiceFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/BPETimerServiceFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/BPETimerServiceFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,96 @@
+/*
+* 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.timerservice;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.inmemory.jndi.IMContext;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+public class BPETimerServiceFactory {
+
+ private static Logger logger = Logger.getLogger(BPETimerServiceFactory.class
+ .getName());
+ public static String BPETIMER_CLASS = "BPETIMER_CLASS_KEY";
+
+ public static IBPETimerService getBPETimerService() throws BPException {
+ BPEProperties props;
+ try {
+ String val = System.getProperty(EventDirectorFactory.JNFI);
+ if (val != null && val.compareTo(EventDirectorFactory.IMJNFI) == 0)
+ {
+ props = new BPEProperties();
+ IMContext.getProperties(props,
+ EventDirectorFactory.IM_ENGINE_PROPERTY_FILE_NAME);
+ } else {
+ props =
+ BPEProperties.getCachedProperties();
+ }
+ } catch (IOException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"IOException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ return getBPETimerService(props);
+ }
+
+ private static IBPETimerService getBPETimerService(BPEProperties props) throws BPException {
+ String className = props.getProperty(BPETIMER_CLASS);
+ if ( className == null ) {
+ return null;
+ }
+ IBPETimerService ts;
+ try {
+ Class instClass = java.lang.Class.forName(className);
+ ts = (IBPETimerService)instClass.newInstance();
+ ts.init(props);
+ } catch (ClassNotFoundException e) {
+ BPException bpx = new BPException(
+ "CLASS_NOT_FOUND", new Object[]
+ {props.getProperty(BPETIMER_CLASS)});
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (InstantiationException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"InstantiationException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (IllegalAccessException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"IllegalAccessException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+
+ return ts;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimer.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimer.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimer.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,48 @@
+/*
+* 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.timerservice;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.event.ITimerEvent;
+
+/**
+ * BPE Timer
+ */
+public interface IBPETimer extends Serializable {
+
+ static final long serialVersionUID = -1722001456714424366L;
+
+ /**
+ * Get the timer id.
+ * @return
+ */
+ public Object getId();
+
+ /**
+ * Get the time event for this timer.
+ * @return
+ */
+ public ITimerEvent getTimerEvent();
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimerService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimerService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimerService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/IBPETimerService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,62 @@
+/*
+* 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.timerservice;
+
+import java.util.Date;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Service used by the timer action.
+ */
+public interface IBPETimerService {
+
+ /**
+ * Create a duration timer.
+ * @param startDuration
+ * @param timerEvent
+ */
+ public IBPETimer createTimer(long startDuration, ITimerEvent timerEvent) throws BPException;
+ /**
+ * Create a date timer.
+ * @param startTime
+ * @param timerEvent
+ */
+ public IBPETimer createTimer(Date startTime, ITimerEvent timerEvent) throws BPException;
+
+ /**
+ * Remove a timer
+ * @param timer
+ * @throws BPException
+ */
+ public void removeTimer(IBPETimer timer) throws BPException;
+
+ /**
+ * Initialize the service.
+ *
+ */
+ public void init(BPEProperties props) throws BPException;
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerEjbTimerImpl.java.j2ee14
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerEjbTimerImpl.java.j2ee14?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerEjbTimerImpl.java.j2ee14 (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerEjbTimerImpl.java.j2ee14 Tue Feb 28 08:02:48 2006
@@ -0,0 +1,43 @@
+
+package com.sybase.bpe.timerservice.ejbTimerImpl;
+
+import javax.ejb.TimerHandle;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+
+/**
+ * BPE Timer EjbTimer impl.
+ */
+public class BPETimerEjbTimerImpl implements IBPETimer {
+
+ private TimerHandle id;
+
+ public BPETimerEjbTimerImpl(TimerHandle id)
+ {
+ this.id = id;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getId()
+ */
+ public Object getId() {
+ return this.id;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getTimerEvent()
+ */
+ public ITimerEvent getTimerEvent() {
+ return (ITimerEvent)id.getTimer().getInfo();
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ boolean eq = this.id.equals(((BPETimerEjbTimerImpl)obj).getId());
+ return eq;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerServiceEjbTimerImpl.java.j2ee14
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerServiceEjbTimerImpl.java.j2ee14?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerServiceEjbTimerImpl.java.j2ee14 (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/ejbTimerImpl/BPETimerServiceEjbTimerImpl.java.j2ee14 Tue Feb 28 08:02:48 2006
@@ -0,0 +1,114 @@
+
+package com.sybase.bpe.timerservice.ejbTimerImpl;
+
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.NoSuchObjectLocalException;
+import javax.ejb.Timer;
+import javax.ejb.TimerHandle;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import com.sybase.bpe.bped.ejbimpl.BPETimerLocal;
+import com.sybase.bpe.bped.ejbimpl.BPETimerLocalHome;
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.timerservice.IBPETimerService;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ *
+ */
+public class BPETimerServiceEjbTimerImpl implements IBPETimerService {
+
+ private static Logger logger = Logger.getLogger(BPETimerServiceEjbTimerImpl.class
+ .getName());
+ private static String TIMER_REF = "java:comp/env/BPETimerLocal";
+
+ private BPETimerLocalHome timerHome;
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(long, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(long startDuration, ITimerEvent timerEvent) throws BPException {
+ BPETimerLocal timer;
+ try {
+ timer = timerHome.create();
+ Timer t = timer.createTimer(startDuration,timerEvent);
+ return new BPETimerEjbTimerImpl(t.getHandle());
+ } catch (CreateException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"CreateException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(java.util.Date, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(Date startTime, ITimerEvent timerEvent) throws BPException{
+ try {
+ BPETimerLocal timer = timerHome.create();
+ Timer t = timer.createTimer(startTime, timerEvent);
+ return new BPETimerEjbTimerImpl(t.getHandle());
+ } catch (CreateException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",
+ new Object[] { "CreateException" }, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#init(com.sybase.bpe.util.BPEProperties)
+ */
+ public void init(BPEProperties props) throws BPException {
+ InitialContext ic;
+ try {
+ ic = new InitialContext();
+ Object o = ic.lookup(TIMER_REF);
+ timerHome = (BPETimerLocalHome) PortableRemoteObject
+ .narrow(o, BPETimerLocalHome.class);
+ } catch (NamingException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",
+ new Object[] { "CreateException" }, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#removeTimer(com.sybase.bpe.timerservice.IBPETimer)
+ */
+ public void removeTimer(IBPETimer timer) throws BPException {
+ TimerHandle handle = (TimerHandle)timer.getId();
+ Timer t = null;
+ try {
+ t = handle.getTimer();
+ t.cancel();
+ } catch (IllegalStateException e) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",
+ new Object[] { "IllegalStateException" }, e);
+ } catch ( NoSuchObjectLocalException e ) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Timer has expired or been canceled.");
+ }
+ return;
+ } catch ( EJBException e ) {
+ BPException bpx = new BPException("NATIVE_EXCEPTION",
+ new Object[] { "EJBException" }, e);
+ }
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Canceled timer:" + t);
+ }
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimer.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimer.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimer.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,59 @@
+/*
+* 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 Oct 28, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.sybase.bpe.timerservice.noop;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+
+/**
+ * @author charper
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class NoopTimer implements IBPETimer {
+
+ static final long serialVersionUID = 1650723050727088370L;
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getId()
+ */
+ public Object getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getTimerEvent()
+ */
+ public ITimerEvent getTimerEvent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimerService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimerService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimerService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/noop/NoopTimerService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,80 @@
+/*
+* 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 Oct 28, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.sybase.bpe.timerservice.noop;
+
+import java.util.Date;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.timerservice.IBPETimerService;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author charper
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class NoopTimerService implements IBPETimerService {
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(long, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(long startDuration, ITimerEvent timerEvent)
+ throws BPException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(java.util.Date, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(Date startTime, ITimerEvent timerEvent)
+ throws BPException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#removeTimer(com.sybase.bpe.timerservice.IBPETimer)
+ */
+ public void removeTimer(IBPETimer timer) throws BPException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#init(com.sybase.bpe.util.BPEProperties)
+ */
+ public void init(BPEProperties props) throws BPException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerJob.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerJob.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerJob.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerJob.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,75 @@
+/*
+* 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.timerservice.quartzimpl;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.quartz.Job;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import com.sybase.bpe.bped.managed.BPEventDirector;
+import com.sybase.bpe.bped.managed.BPEventDirectorHome;
+
+/**
+ * BPE timer job
+ */
+public class BPETimerJob implements Job {
+
+ private static Logger logger = Logger.getLogger(BPETimerJob.class
+ .getName());
+
+ /* (non-Javadoc)
+ * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
+ */
+ public void execute(JobExecutionContext arg0) throws JobExecutionException {
+
+ JobDataMap dm = arg0.getJobDetail().getJobDataMap();
+ BPETimerQuartzImpl timer = (BPETimerQuartzImpl)
+ dm.get(BPETimerServiceQuartzImpl.TIMER_EVENT);
+ String pkgName = dm.getString(BPETimerServiceQuartzImpl.PACKAGE);
+
+ try {
+ InitialContext ic = new InitialContext();
+ Object o = ic.lookup(pkgName + "/BPEventDirector");
+ BPEventDirectorHome bpedHome = (BPEventDirectorHome) PortableRemoteObject
+ .narrow(o, BPEventDirectorHome.class);
+ // get a bean
+ BPEventDirector bped = bpedHome.create();
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Timer fired: "+timer);
+ }
+ bped.sendEvent(timer, true);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"",e);
+ throw new JobExecutionException(e);
+ }
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerQuartzImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerQuartzImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerQuartzImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerQuartzImpl.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
+*/
+
+package com.sybase.bpe.timerservice.quartzimpl;
+
+import java.io.Serializable;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+
+/**
+ * Quartz timer impl
+ */
+public class BPETimerQuartzImpl implements IBPETimer, Serializable {
+
+ static final long serialVersionUID = 1162762368537854362L;
+
+
+ private ITimerEvent te;
+
+
+
+ /**
+ * @param te
+ */
+ public BPETimerQuartzImpl(ITimerEvent te) {
+ super();
+ this.te = te;
+ }
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getId()
+ */
+ public Object getId() {
+ return te.getProcId();
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimer#getTimerEvent()
+ */
+ public ITimerEvent getTimerEvent() {
+ return te;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "procid:"+te.getProcId()+" rootprocid:"+
+ te.getRootId()+" defid:"+te.getDefId()+
+ " rootdefid:"+te.getRootDefId();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerServiceQuartzImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerServiceQuartzImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerServiceQuartzImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/BPETimerServiceQuartzImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,156 @@
+/*
+* 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.timerservice.quartzimpl;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.quartz.JobDetail;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.SchedulerFactory;
+import org.quartz.SimpleTrigger;
+
+import com.sybase.bpe.event.ITimerEvent;
+import com.sybase.bpe.timerservice.IBPETimer;
+import com.sybase.bpe.timerservice.IBPETimerService;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Quartz timer service impl
+ */
+public class BPETimerServiceQuartzImpl implements IBPETimerService {
+
+ private static Logger logger = Logger.getLogger(BPETimerServiceQuartzImpl.class
+ .getName());
+ public static final String TIMER_EVENT="TIMER_EVENT";
+ public static final String PACKAGE="PACKAGE";
+ private String packageName;
+ private static Map schedulerMap = Collections.synchronizedMap(new HashMap());
+
+
+ private IBPETimer schedule(Date date, ITimerEvent timerEvent) throws BPException {
+ // proc id should be unique
+ JobDetail jobDetail = new JobDetail(timerEvent.getProcId() + timerEvent.getDefId(),
+ Scheduler.DEFAULT_GROUP,
+ BPETimerJob.class);
+
+ SimpleTrigger trigger = new SimpleTrigger(timerEvent.getProcId() + timerEvent.getDefId(),
+ Scheduler.DEFAULT_GROUP,
+ date,
+ null,
+ 0,
+ 0L);
+ IBPETimer timer = new BPETimerQuartzImpl(timerEvent);
+ jobDetail.getJobDataMap().put(TIMER_EVENT,timer);
+ jobDetail.getJobDataMap().put(PACKAGE,packageName);
+ try {
+ getScheduler().scheduleJob(jobDetail, trigger);
+ } catch (SchedulerException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"SchedulerException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+
+ return timer;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(long, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(long startDuration, ITimerEvent timerEvent)
+ throws BPException {
+
+ long startTime = System.currentTimeMillis() + startDuration;
+ return schedule(new Date(startTime),timerEvent);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#createTimer(java.util.Date, com.sybase.bpe.event.ITimerEvent)
+ */
+ public IBPETimer createTimer(Date startTime, ITimerEvent timerEvent)
+ throws BPException {
+ return schedule(startTime,timerEvent);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#removeTimer(com.sybase.bpe.timerservice.IBPETimer)
+ */
+ public void removeTimer(IBPETimer timer) throws BPException {
+ try {
+ getScheduler().unscheduleJob((String)timer.getId(),Scheduler.DEFAULT_GROUP);
+ } catch (SchedulerException e) {
+ BPException bpx = new BPException(
+ "NATIVE_EXCEPTION", new Object[]
+ {"SchedulerException"}, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.timerservice.IBPETimerService#init(com.sybase.bpe.util.BPEProperties)
+ */
+ public void init(BPEProperties props) throws BPException {
+
+ Properties packageProperties =
+ props.getPackageProperties();
+ packageName = packageProperties.getProperty("PACKAGE_NAME");
+ }
+
+ private static Scheduler getScheduler() {
+
+ Scheduler ret = null;
+
+ // get current thread object
+ Thread currThread = Thread.currentThread();
+
+ // check to see if the tread object link already exists
+ if (schedulerMap.containsKey(currThread) == false) {
+ SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
+ try {
+ ret = schedFact.getScheduler();
+ schedulerMap.put(currThread, ret);
+ }catch (SchedulerException e) {
+ // just log a warning, bp's can still execute if
+ // they don't use the timer service
+ logger.warning(e.getLocalizedMessage());
+ schedulerMap.put(currThread, null);
+ }
+ } else {
+ ret = (Scheduler)(schedulerMap.get(currThread));
+ }
+
+ return ret;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/QuartzService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/QuartzService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/QuartzService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/timerservice/quartzimpl/QuartzService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,59 @@
+/*
+* 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.timerservice.quartzimpl;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.quartz.Scheduler;
+import org.quartz.SchedulerFactory;
+import org.quartz.impl.StdSchedulerFactory;
+
+public class QuartzService {
+
+ public static void main(String[] args) throws Exception {
+ if ( args.length == 2 && ( args[0].equalsIgnoreCase("start") ||
+ args[0].equalsIgnoreCase("stop")) ){
+
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new java.rmi.RMISecurityManager());
+ }
+
+ Properties props = new Properties();
+ File f = new File(args[1]);
+ props.load(f.toURL().openStream());
+
+ SchedulerFactory fact = new StdSchedulerFactory(props);
+ Scheduler sched = fact.getScheduler();
+
+ if ( args[0].equalsIgnoreCase("start") ) {
+ sched.start();
+ } else {
+ sched.shutdown();
+ }
+
+ } else {
+ System.out.println("Usage QuartzService 'start|stop' 'properties file'");
+ }
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoder.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,44 @@
+/*
+* 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.util;
+import java.io.InputStream;
+
+
+public class BPEDecoder
+{
+ private IBPEDecoder m_bpeDecoderImpl = null;
+
+ public BPEDecoder(InputStream iInputStream)
+ {
+ m_bpeDecoderImpl = new BPEDecoderXStreamImpl( iInputStream );
+ //new BPEDecoderJavaObjectImpl( iInputStream );
+ //new BPEDecoderXMLImpl( iInputStream );
+ }
+ public Object readObject()
+ {
+ return m_bpeDecoderImpl.readObject();
+ }
+ public void close()
+ {
+ m_bpeDecoderImpl.close();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderJavaObjectImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderJavaObjectImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderJavaObjectImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderJavaObjectImpl.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
+*/
+package com.sybase.bpe.util;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+
+
+public class BPEDecoderJavaObjectImpl implements IBPEDecoder
+{
+ private ObjectInputStream m_ois;
+ public BPEDecoderJavaObjectImpl(InputStream iInputStream)
+ {
+ try
+ {
+ m_ois = new ObjectInputStream(iInputStream);
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ public Object readObject()
+ {
+ if (m_ois != null)
+ {
+ try
+ {
+ return m_ois.readObject();
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ } catch ( ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+ public void close()
+ {
+ if (m_ois != null)
+ {
+ try
+ {
+ m_ois.close();
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXMLImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXMLImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXMLImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXMLImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,44 @@
+/*
+* 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.util;
+
+import java.beans.XMLDecoder;
+import java.io.InputStream;
+
+
+public class BPEDecoderXMLImpl implements IBPEDecoder
+{
+
+ private XMLDecoder m_xmlDecoder = null;
+ public BPEDecoderXMLImpl( InputStream iInputStream)
+ {
+ m_xmlDecoder = new XMLDecoder( iInputStream );
+ }
+ public Object readObject()
+ {
+ return m_xmlDecoder.readObject();
+ }
+ public void close()
+ {
+ m_xmlDecoder.close();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXStreamImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXStreamImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXStreamImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEDecoderXStreamImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,51 @@
+/*
+* 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.util;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import com.thoughtworks.xstream.XStream;
+
+public class BPEDecoderXStreamImpl implements IBPEDecoder
+{
+ private InputStream m_istream;
+
+ public BPEDecoderXStreamImpl( InputStream is )
+ {
+ m_istream = is;
+ }
+
+ public Object readObject()
+ {
+ XStream xstream = new XStream();
+ InputStreamReader reader =
+ new InputStreamReader( m_istream );
+ Object object = xstream.fromXML( reader );
+ return object;
+ }
+
+ public void close()
+ {
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoder.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,48 @@
+/*
+* 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.util;
+
+import java.io.OutputStream;
+
+
+public class BPEEncoder
+{
+ IBPEEncoder m_encoderImpl = null;
+
+ public BPEEncoder( OutputStream iOutputStream )
+ {
+ m_encoderImpl = new BPEEncoderXStreamImpl(iOutputStream);
+ //new BPEEncoderJavaObjectImpl( iOutputStream );
+ //new BPEEncoderXMLImpl( iOutputStream );
+ }
+
+ public void writeObject( Object iObject )
+ {
+ m_encoderImpl.writeObject( iObject );
+ }
+
+ public void close()
+ {
+ m_encoderImpl.close();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderJavaObjectImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderJavaObjectImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderJavaObjectImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderJavaObjectImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,69 @@
+/*
+* 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.util;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+
+public class BPEEncoderJavaObjectImpl implements IBPEEncoder
+{
+ private OutputStream m_outputStream;
+ private ObjectOutputStream m_oos;
+ public BPEEncoderJavaObjectImpl( OutputStream iOutputStream)
+ {
+ m_outputStream = iOutputStream;
+ try
+ {
+ m_oos = new ObjectOutputStream(m_outputStream);
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void writeObject( Object iObject )
+ {
+ try
+ {
+ m_oos.writeObject( iObject );
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void close()
+ {
+ try
+ {
+ m_oos.close();
+ } catch ( IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXMLImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXMLImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXMLImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXMLImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,42 @@
+/*
+* 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.util;
+
+import java.beans.XMLEncoder;
+import java.io.OutputStream;
+
+public class BPEEncoderXMLImpl implements IBPEEncoder
+{
+ private XMLEncoder m_xmlEncoder = null;
+ public BPEEncoderXMLImpl(OutputStream iOutputStream)
+ {
+ m_xmlEncoder = new XMLEncoder( iOutputStream );
+ }
+ public void writeObject(Object iObject)
+ {
+ m_xmlEncoder.writeObject(iObject);
+ }
+ public void close()
+ {
+ m_xmlEncoder.close();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXStreamImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXStreamImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXStreamImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEEncoderXStreamImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,50 @@
+/*
+* 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.util;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import com.thoughtworks.xstream.XStream;
+
+public class BPEEncoderXStreamImpl implements IBPEEncoder
+{
+ private OutputStream m_ostream;
+
+ public BPEEncoderXStreamImpl(OutputStream ostream)
+ {
+ m_ostream = ostream;
+ }
+
+ public void writeObject(Object iObject)
+ {
+ XStream xstream = new XStream();
+ Writer writer = new OutputStreamWriter(m_ostream);
+ xstream.toXML(iObject, writer);
+ }
+
+ public void close()
+ {
+ }
+
+}