Author: mszefler
Date: Wed Aug 30 09:10:13 2006
New Revision: 438530

URL: http://svn.apache.org/viewvc?rev=438530&view=rev
Log:
Moved around the interceptor functionality into a separate package.
Changed MEX abort to be via exception mechanism.
Implemented base-class for interceptor implementations.
Implemented throttling interceptor to limit number of instances.


Added:
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java
   (with props)
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java
   (with props)
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java
   (with props)
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
   (with props)
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java
   (with props)
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java
   (with props)
Modified:
    
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java

Modified: 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
 (original)
+++ 
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
 Wed Aug 30 09:10:13 2006
@@ -156,4 +156,6 @@
 
     byte[] getCompiledProcess();
 
+       int getNumInstances();
+
 }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelEngineImpl.java
 Wed Aug 30 09:10:13 2006
@@ -33,6 +33,7 @@
 import org.apache.ode.bpel.iapi.MessageExchange.Status;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus;
+import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.utils.msg.MessageBundle;

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
 Wed Aug 30 09:10:13 2006
@@ -27,7 +27,6 @@
 import org.apache.ode.bpel.dao.MessageRouteDAO;
 import org.apache.ode.bpel.dao.ProcessDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import 
org.apache.ode.bpel.engine.MessageExchangeInterceptor.InterceptorContext;
 import org.apache.ode.bpel.epr.WSAEndpoint;
 import org.apache.ode.bpel.evt.CorrelationMatchEvent;
 import org.apache.ode.bpel.evt.CorrelationNoMatchEvent;
@@ -43,6 +42,10 @@
 import org.apache.ode.bpel.iapi.MessageExchange.Status;
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus;
 import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.bpel.intercept.AbortMessageExchangeException;
+import org.apache.ode.bpel.intercept.FaultMessageExchangeException;
+import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
+import 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext;
 import org.apache.ode.bpel.o.OBase;
 import org.apache.ode.bpel.o.OElementVarType;
 import org.apache.ode.bpel.o.OMessageVarType;
@@ -294,20 +297,24 @@
     }
 
     private boolean processInterceptor(MessageExchangeInterceptor i, 
MyRoleMessageExchangeImpl mex, InterceptorContext ictx) {
-        __log.debug("onBpelServerInvoked --> interceptor " + i);
-        boolean cont = i.onProcessInvoked(mex, ictx);
-        if (!cont) {
-            __log.debug("interceptor " + i + " caused invoke on " + this + "to 
be aborted");
-            if (mex.getStatus() == Status.REQUEST) {
-                __log.debug("aborting interceptor " + i + " did not set 
message exchange status, assuming failure");
-                mex.setFailure(MessageExchange.FailureType.ABORTED, 
__msgs.msgInterceptorAborted(mex
-                        .getMessageExchangeId(), i.toString()), null);
-            }
+        __log.debug("onProcessInvoked --> interceptor " + i);
+        try {
+               i.onProcessInvoked(mex, ictx);
+        } catch (FaultMessageExchangeException fme) {
+            __log.debug("interceptor " + i + " caused invoke on " + this + " 
to be aborted with FAULT " + fme.getFaultName());
+            mex.setFault(fme.getFaultName().getLocalPart(), 
fme.getFaultData());
             return false;
+        } catch (AbortMessageExchangeException ame) {
+               __log.debug("interceptor " + i + " cause invoke on " + this + " 
to be aborted with FAILURE: "+  ame.getMessage());
+               mex.setFailure(MessageExchange.FailureType.ABORTED, 
__msgs.msgInterceptorAborted(mex
+                        .getMessageExchangeId(), i.toString(), 
ame.getMessage()), null);
+               return false;
         }
-       
+        
         return true;
     }
+    
+    
     /**
      * Replacement object for serializtation of the [EMAIL PROTECTED] OBase} 
(compiled
      * BPEL) objects in the JACOB VPU.

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
 Wed Aug 30 09:10:13 2006
@@ -75,6 +75,7 @@
 import org.apache.ode.bpel.iapi.EndpointReferenceContext;
 import org.apache.ode.bpel.iapi.MessageExchangeContext;
 import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
 import org.apache.ode.bpel.o.OExpressionLanguage;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
 Wed Aug 30 09:10:13 2006
@@ -29,6 +29,7 @@
 import org.apache.ode.bpel.iapi.EndpointReferenceContext;
 import org.apache.ode.bpel.iapi.MessageExchangeContext;
 import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
 
 /**
  * Aggregation of all the contexts provided to the BPEL engine by the

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/InterceptorContextImpl.java
 Wed Aug 30 09:10:13 2006
@@ -20,10 +20,10 @@
 
 import org.apache.ode.bpel.dao.BpelDAOConnection;
 import org.apache.ode.bpel.dao.ProcessDAO;
-import 
org.apache.ode.bpel.engine.MessageExchangeInterceptor.InterceptorContext;
+import 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext;
 
 /**
- * Implementation of the [EMAIL PROTECTED] 
org.apache.ode.bpel.engine.MessageExchangeInterceptor.InterceptorContext}
+ * Implementation of the [EMAIL PROTECTED] 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext}
  * interface.
  * @author Maciej Szefler (m s z e f l e r @ g m a i l . c o m)
  *

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
 Wed Aug 30 09:10:13 2006
@@ -146,8 +146,8 @@
             "in any WSDL document: {0} {1}.", service, port);
   }
 
-  String msgInterceptorAborted(String mexId, String interceptor) {
-         return format("Message exchange {0} aborted by interceptor {1}", 
mexId, interceptor);
+  String msgInterceptorAborted(String mexId, String interceptor, String msg) {
+         return format("Message exchange {0} aborted by interceptor {1}: {2}", 
mexId, interceptor, msg);
   }    
   
   String msgMyRoleRoutingFailure(String messageExchangeId) {

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/MyRoleMessageExchangeImpl.java
 Wed Aug 30 09:10:13 2006
@@ -27,7 +27,6 @@
 
 
 import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import 
org.apache.ode.bpel.engine.MessageExchangeInterceptor.InterceptorContext;
 import org.apache.ode.bpel.iapi.BpelEngineException;
 import org.apache.ode.bpel.iapi.EndpointReference;
 import org.apache.ode.bpel.iapi.Message;
@@ -35,6 +34,10 @@
 
 import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
 import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.bpel.intercept.AbortMessageExchangeException;
+import org.apache.ode.bpel.intercept.FaultMessageExchangeException;
+import org.apache.ode.bpel.intercept.MessageExchangeInterceptor;
+import 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor.InterceptorContext;
 
 
 class MyRoleMessageExchangeImpl extends MessageExchangeImpl 
@@ -78,17 +81,19 @@
   }
 
   private boolean processInterceptor(MessageExchangeInterceptor i, 
MyRoleMessageExchangeImpl mex, InterceptorContext ictx) {
-      boolean cont = i.onBpelServerInvoked(mex, ictx);
-      if (!cont) {
-          __log.debug("interceptor " + i + " caused invoke on " + this + "to 
be aborted");
-          if (mex.getStatus() == Status.REQUEST) {
-              __log.debug("aborting interceptor " + i + " did not set message 
exchange status, assuming failure");
-              mex.setFailure(MessageExchange.FailureType.ABORTED, 
__msgs.msgInterceptorAborted(mex
-                      .getMessageExchangeId(), i.toString()), null);
-          }
+      __log.debug("onBpelServerInvoked --> interceptor " + i);
+      try {
+       i.onBpelServerInvoked(mex, ictx);
+      } catch (FaultMessageExchangeException fme) {
+          __log.debug("interceptor " + i + " caused invoke on " + this + " to 
be aborted with FAULT " + fme.getFaultName());
+          mex.setFault(fme.getFaultName().getLocalPart(), fme.getFaultData());
           return false;
+      } catch (AbortMessageExchangeException ame) {
+       __log.debug("interceptor " + i + " cause invoke on " + this + " to be 
aborted with FAILURE: "+  ame.getMessage());
+       mex.setFailure(MessageExchange.FailureType.ABORTED, 
__msgs.msgInterceptorAborted(mex
+                      .getMessageExchangeId(), i.toString(), 
ame.getMessage()), null);
+       return false;
       }
-
       return true;
   }
 

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+/**
+ * Base class for exception thrown by message-exchange interceptors.
+ * @author mszefler
+ */
+public abstract class AbortMessageExchangeException extends Exception {
+       protected AbortMessageExchangeException(String msg, Throwable cause) {
+               super(msg, cause);
+       }
+       
+       protected AbortMessageExchangeException(String msg) {
+               super(msg);
+       }
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/AbortMessageExchangeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+/**
+ * Exception thrown by [EMAIL PROTECTED] 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor}
+ * implementations that is used to indicate that the processing of the 
exchange should
+ * be aborted with a failure.
+ * @author Maciej Szefler
+ */
+public final class FailMessageExchangeException extends 
AbortMessageExchangeException{
+       private static final long serialVersionUID = 1L;
+
+       protected FailMessageExchangeException(String msg) {
+               super(msg);
+       }
+       
+       protected FailMessageExchangeException(String msg, Throwable cause) {
+               super(msg,cause);
+       }
+       
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FailMessageExchangeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.iapi.Message;
+
+/**
+ * Exception thrown by [EMAIL PROTECTED] 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor}
+ * implementations that is used to indicate that the processing of the 
exchange should
+ * be aborted with a fault.
+ * @author Maciej Szefler
+ */
+public final class FaultMessageExchangeException extends 
AbortMessageExchangeException {
+       private static final long serialVersionUID = 1L;
+
+       private QName _faultName;
+       private Message _faultData;
+
+       public FaultMessageExchangeException(String errmsg, QName faultName, 
Message faultData) {
+               super(errmsg);
+               
+               _faultName = faultName;
+               _faultData = faultData;
+       }
+       
+       public QName getFaultName() {
+               return _faultName;
+       }
+       
+       public Message getFaultData() {
+               return _faultData;
+       }
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/FaultMessageExchangeException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+
+/**
+ * Hook into the BPEL server that enables intercepting of message exchange
+ * invocation.
+ * 
+ * @author Maciej Szefler
+ * 
+ */
+public interface MessageExchangeInterceptor {
+
+    /**
+     * Called when the BPEL server is invoked, before any attempt to route the
+     * message exchange to a process.
+     * 
+     * @param mex
+     *            message exchange
+     */
+    void onBpelServerInvoked(MyRoleMessageExchange mex, InterceptorContext ic) 
+       throws FailMessageExchangeException, FaultMessageExchangeException;
+
+    /**
+     * Called when the BPEL server is invoked, after the message exchange has
+     * been routed to the process.
+     * 
+     * @param mex
+     *            message exchange
+     */
+    void onProcessInvoked(MyRoleMessageExchange mex, InterceptorContext ic)
+       throws FailMessageExchangeException, FaultMessageExchangeException;
+
+    /**
+     * Called when the BPEL server is invoked, before any attempt to route the
+     * message exchange to a process.
+     * 
+     * @param mex
+     *            message exchange
+     */
+    void onPartnerInvoked(PartnerRoleMessageExchange mex, InterceptorContext 
ic)
+       throws FailMessageExchangeException, FaultMessageExchangeException;
+
+    
+    public interface InterceptorContext {
+       
+       BpelDAOConnection getConnection();
+       
+       ProcessDAO getProcessDAO();
+       
+    }
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/MessageExchangeInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+
+/**
+ * No-Op implementation of the [EMAIL PROTECTED] 
org.apache.ode.bpel.intercept.MessageExchangeInterceptor interface;
+ * good for sub-classing.
+ * 
+ * @author mszefler
+ *
+ */
+public class NoOpInterceptor implements MessageExchangeInterceptor {
+
+       public void onBpelServerInvoked(MyRoleMessageExchange mex,
+                       InterceptorContext ic) throws 
FailMessageExchangeException,
+                       FaultMessageExchangeException {
+       }
+
+       public void onProcessInvoked(MyRoleMessageExchange mex,
+                       InterceptorContext ic) throws 
FailMessageExchangeException,
+                       FaultMessageExchangeException {
+       }
+
+       public void onPartnerInvoked(PartnerRoleMessageExchange mex,
+                       InterceptorContext ic) throws 
FailMessageExchangeException,
+                       FaultMessageExchangeException {
+       }
+
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/NoOpInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java?rev=438530&view=auto
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java
 (added)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java
 Wed Aug 30 09:10:13 2006
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.intercept;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.dao.ProcessPropertyDAO;
+import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
+import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+
+/**
+ * An example of a  simple interceptor providing a "throttling"  capability - 
that is an 
+ * ability to limit the number of instances created for a given process.
+ * 
+ * @author Maciej Szefler
+ */
+public class ThrottlingInterceptor extends NoOpInterceptor {
+       /** Name of process property that control the maximum number of 
instances. */
+       private static final QName PROP_MAX_INSTANCES = new 
QName("urn:org.apache.ode.bpel.intercept", "maxInstances");
+
+       @Override
+       public void onProcessInvoked(MyRoleMessageExchange mex,
+                       InterceptorContext ic) throws 
FailMessageExchangeException {
+               int maxInstances;
+               try {
+                       maxInstances = 
Integer.valueOf(getSimpleProperty(PROP_MAX_INSTANCES, ic));
+               } catch (Exception ex) {
+                       return;
+               }
+               
+               if (ic.getProcessDAO().getNumInstances() >= maxInstances)
+                       throw new FailMessageExchangeException("Too many 
instances.");
+       }
+
+       
+       /**
+        * Get the value of a simple process property
+        * @param propertyName name of the property
+        * @param ic interceptor context
+        * @return value of the property, or <code>null</code> if not set
+        */
+       private String getSimpleProperty(QName propertyName, InterceptorContext 
ic) {
+               Collection<ProcessPropertyDAO> props = 
ic.getProcessDAO().getProperties();
+               for (ProcessPropertyDAO prop : props) {
+                       QName pQname = new QName(prop.getNamespace(), 
prop.getName());
+                       if (pQname.equals(propertyName))
+                               return prop.getSimpleContent();
+               }
+               
+               return null;
+       }
+}

Propchange: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/intercept/ThrottlingInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
 Wed Aug 30 09:10:13 2006
@@ -208,4 +208,8 @@
     public void update() {
         //TODO Check requirement for persisting.
     }
+
+       public int getNumInstances() {
+               return _instances.size();
+       }
 }

Modified: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java?rev=438530&r1=438529&r2=438530&view=diff
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
 Wed Aug 30 09:10:13 2006
@@ -287,4 +287,9 @@
         return new PartnerLinkDAOImpl(_sm,hepr);
     }
 
+       public int getNumInstances() {
+               // TODO: Is this efficient? 
+               return _process.getInstances().size();
+       }
+
 }


Reply via email to