From agila-commits-return-14-apmail-incubator-agila-commits-archive=www.apache.org@incubator.apache.org Thu Apr 28 11:54:56 2005 Return-Path: Delivered-To: apmail-incubator-agila-commits-archive@www.apache.org Received: (qmail 62600 invoked from network); 28 Apr 2005 11:54:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2005 11:54:56 -0000 Received: (qmail 42108 invoked by uid 500); 28 Apr 2005 11:56:01 -0000 Mailing-List: contact agila-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: agila-dev@incubator.apache.org Delivered-To: mailing list agila-commits@incubator.apache.org Delivered-To: moderator for agila-commits@incubator.apache.org Received: (qmail 49538 invoked by uid 99); 27 Apr 2005 21:30:40 -0000 X-ASF-Spam-Status: No, hits=2.7 required=10.0 tests=HEAD_LONG,NO_REAL_NAME X-Spam-Check-By: apache.org Message-ID: <20050427202933.67298.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165042 [17/30] - in /incubator/agila/trunk: ./ config/ modules/ modules/bpel/ modules/bpel/client/ modules/bpel/client/api/ modules/bpel/client/api/src/ modules/bpel/client/api/src/conf/ modules/bpel/client/api/src/java/ modules/bpel/client/api/src/java/org/ modules/bpel/client/api/src/java/org/apache/ modules/bpel/client/api/src/java/org/apache/agila/ modules/bpel/client/api/src/java/org/apache/agila/bpel/ modules/bpel/client/api/src/java/org/apache/agila/bpel/client/ modules/bpel/client/api/src/test/ modules/bpel/client/api/src/test/junit/ modules/bpel/client/api/src/test/junit/org/ modules/bpel/client/api/src/test/junit/org/apache/ modules/bpel/client/api/src/test/junit/org/apache/agila/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/client/ modules/bpel/client/web/ modules/bpel/client/web/src/ modules/bpel/client/web/src/conf/ modules/bpel/client/web/src/java/ modules/bpel/client/web/src/java/org/ modules/bpel/client/web/src/java/org/apache/ modules/bpel/client/web/src/java/org/apache/agila/ modules/bpel/client/web/src/java/org/apache/agila/bpel/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/common/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/util/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/action/ modules/bpel/client/web/src/webapp/ modules/bpel/client/web/src/webapp/META-INF/ modules/bpel/client/web/src/webapp/WEB-INF/ modules/bpel/client/web/src/webapp/WEB-INF/classes/ modules/bpel/client/web/src/webapp/images/ modules/bpel/client/web/src/webapp/images/audit/ modules/bpel/client/web/src/webapp/style/ modules/bpel/common/ modules/bpel/common/src/ modules/bpel/common/src/aspect/ modules/bpel/common/src/conf/ modules/bpel/common/src/java/ modules/bpel/common/src/java/org/ modules/bpel/common/src/java/org/apache/ modules/bpel/common/src/java/org/apache/agila/ modules/bpel/common/src/java/org/apache/agila/bpel/ modules/bpel/common/src/java/org/apache/agila/bpel/common/ modules/bpel/common/src/java/org/apache/agila/bpel/common/aspect/ modules/bpel/common/src/java/org/apache/agila/bpel/common/configuration/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/logger/ modules/bpel/common/src/test/ modules/bpel/common/src/test/junit/ modules/bpel/common/src/test/junit/org/ modules/bpel/common/src/test/junit/org/apache/ modules/bpel/common/src/test/junit/org/apache/agila/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/util/ modules/bpel/dist/ modules/bpel/dist/src/ modules/bpel/dist/src/java/ modules/bpel/dist/src/java/org/ modules/bpel/dist/src/java/org/apache/ modules/bpel/dist/src/java/org/apache/agila/ modules/bpel/dist/src/java/org/apache/agila/bpel/ modules/bpel/dist/src/java/org/apache/agila/bpel/util/ modules/bpel/dist/src/script/ modules/bpel/engine/ modules/bpel/engine/common/ modules/bpel/engine/common/src/ modules/bpel/engine/common/src/aspect/ modules/bpel/engine/common/src/hibernate/ modules/bpel/engine/common/src/hibernate/org/ modules/bpel/engine/common/src/hibernate/org/apache/ modules/bpel/engine/common/src/hibernate/org/apache/agila/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/ modules/bpel/engine/common/src/java/org/ modules/bpel/engine/common/src/java/org/apache/ modules/bpel/engine/common/src/java/org/apache/agila/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/aspect/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/impl/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/dao/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/monitoring/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/persistence/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/transaction/ modules/bpel/engine/common/src/test/ modules/bpel/engine/common/src/test/junit/ modules/bpel/engine/common/src/test/junit/org/ modules/bpel/engine/common/src/test/junit/org/apache/ modules/bpel/engine/common/src/test/junit/org/apache/agila/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/test/resources/ modules/bpel/engine/core/ modules/bpel/engine/core/src/ modules/bpel/engine/core/src/aspect/ modules/bpel/engine/core/src/hibernate/ modules/bpel/engine/core/src/hibernate/org/ modules/bpel/engine/core/src/hibernate/org/apache/ modules/bpel/engine/core/src/hibernate/org/apache/agila/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/ modules/bpel/engine/core/src/java/org/ modules/bpel/engine/core/src/java/org/apache/ modules/bpel/engine/core/src/java/org/apache/agila/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/exception/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/timer/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/timer/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/timer/po/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/util/ modules/bpel/engine/core/src/test/ modules/bpel/engine/core/src/test/junit/ modules/bpel/engine/core/src/test/junit/org/ modules/bpel/engine/core/src/test/junit/org/apache/ modules/bpel/engine/core/src/test/junit/org/apache/agila/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/messaging/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/tools/ modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/util/ modules/bpel/engine/core/src/test/resources/ modules/bpel/engine/deployer/ modules/bpel/engine/deployer/src/ modules/bpel/engine/deployer/src/aspect/ modules/bpel/engine/deployer/src/java/ modules/bpel/engine/deployer/src/java/org/ modules/bpel/engine/deployer/src/java/org/apache/ modules/bpel/engine/deployer/src/java/org/apache/agila/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/exception/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/context/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/bpel/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/bpel/complex/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/bpel/exclusivity/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/bpel/reference/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/bpel/unicity/ modules/bpel/engine/deployer/src/java/org/apache/agila/bpel/deployer/priv/validate/wsdl/ modules/bpel/engine/deployer/src/test/ modules/bpel/engine/deployer/src/test/junit/ modules/bpel/engine/deployer/src/test/junit/org/ modules/bpel/engine/deployer/src/test/junit/org/apache/ modules/bpel/engine/deployer/src/test/junit/org/apache/agila/ modules/bpel/engine/deployer/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/deployer/src/test/junit/org/apache/agila/bpel/deployer/ modules/bpel/engine/deployer/src/test/resources/ modules/bpel/engine/user/ modules/bpel/engine/user/src/ modules/bpel/engine/user/src/aspect/ modules/bpel/engine/user/src/hibernate/ modules/bpel/engine/user/src/hibernate/org/ modules/bpel/engine/user/src/hibernate/org/apache/ modules/bpel/engine/user/src/hibernate/org/apache/agila/ modules/bpel/engine/user/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/user/src/hibernate/org/apache/agila/bpel/user/ modules/bpel/engine/user/src/java/ modules/bpel/engine/user/src/java/org/ modules/bpel/engine/user/src/java/org/apache/ modules/bpel/engine/user/src/java/org/apache/agila/ modules/bpel/engine/user/src/java/org/apache/agila/bpel/ modules/bpel/engine/user/src/java/org/apache/agila/bpel/user/ modules/bpel/engine/user/src/java/org/apache/agila/bpel/user/exception/ modules/bpel/engine/user/src/java/org/apache/agila/bpel/user/priv/ modules/bpel/engine/user/src/java/org/apache/agila/bpel/user/priv/dao/ modules/bpel/engine/user/src/test/ modules/bpel/engine/user/src/test/junit/ modules/bpel/engine/user/src/test/junit/org/ modules/bpel/engine/user/src/test/junit/org/apache/ modules/bpel/engine/user/src/test/junit/org/apache/agila/ modules/bpel/engine/user/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/user/src/test/junit/org/apache/agila/bpel/user/ modules/bpel/engine/user/src/test/resource/ modules/bpel/engine/worklist/ modules/bpel/engine/worklist/src/ modules/bpel/engine/worklist/src/aspect/ modules/bpel/engine/worklist/src/hibernate/ modules/bpel/engine/worklist/src/hibernate/org/ modules/bpel/engine/worklist/src/hibernate/org/apache/ modules/bpel/engine/worklist/src/hibernate/org/apache/agila/ modules/bpel/engine/worklist/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/worklist/src/hibernate/org/apache/agila/bpel/worklist/ modules/bpel/engine/worklist/src/java/ modules/bpel/engine/worklist/src/java/org/ modules/bpel/engine/worklist/src/java/org/apache/ modules/bpel/engine/worklist/src/java/org/apache/agila/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/worklist/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/worklist/exception/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/worklist/priv/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/worklist/priv/dao/ modules/bpel/engine/worklist/src/java/org/apache/agila/bpel/worklist/priv/po/ modules/bpel/engine/worklist/src/test/ modules/bpel/engine/worklist/src/test/junit/ modules/bpel/engine/worklist/src/test/junit/org/ modules/bpel/engine/worklist/src/test/junit/org/apache/ modules/bpel/engine/worklist/src/test/junit/org/apache/agila/ modules/bpel/engine/worklist/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/worklist/src/test/junit/org/apache/agila/bpel/worklist/ modules/bpel/engine/worklist/src/test/resource/ modules/bpel/engine/wsa/ modules/bpel/engine/wsa/src/ modules/bpel/engine/wsa/src/aspect/ modules/bpel/engine/wsa/src/conf/ modules/bpel/engine/wsa/src/hibernate/ modules/bpel/engine/wsa/src/java/ modules/bpel/engine/wsa/src/java/org/ modules/bpel/engine/wsa/src/java/org/apache/ modules/bpel/engine/wsa/src/java/org/apache/agila/ modules/bpel/engine/wsa/src/java/org/apache/agila/bpel/ modules/bpel/engine/wsa/src/java/org/apache/agila/bpel/wsa/ modules/bpel/engine/wsa/src/schema/ modules/bpel/engine/wsa/src/test/ modules/bpel/engine/wsa/src/test/junit/ modules/bpel/engine/wsa/src/test/junit/org/ modules/bpel/engine/wsa/src/test/junit/org/apache/ modules/bpel/engine/wsa/src/test/junit/org/apache/agila/ modules/bpel/engine/wsa/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/wsa/src/test/junit/org/apache/agila/bpel/worklist/ modules/bpel/engine/wsa/src/test/resources/ modules/bpel/engine/wsa/src/webapp/ modules/bpel/engine/wsa/src/webapp/META-INF/ modules/bpel/engine/wsa/src/webapp/WEB-INF/ modules/bpel/engine/wsa/src/webapp/WEB-INF/classes/ modules/bpel/samples/ modules/bpel/samples/src/ modules/bpel/samples/src/xml/ modules/bpel/samples/src/xml/example1/ modules/bpel/samples/src/xml/example1/messages/ modules/bpel/samples/src/xml/example2/ modules/bpel/samples/src/xml/example2/messages/ modules/bpel/samples/src/xml/example3/ modules/bpel/samples/src/xml/example3/messages/ modules/bpel/samples/src/xml/example4/ modules/bpel/samples/src/xml/example4/messages/ modules/bpm/ modules/bpm/config/ modules/bpm/src/ modules/bpm/src/java/ modules/bpm/src/resources/ modules/bpm/src/test/ modules/bpm/src/webapp/ src/ Date: Wed, 27 Apr 2005 20:28:07 -0000 To: agila-commits@incubator.apache.org From: mriou@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/CoreWrappingFactory.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/CoreWrappi= ngFactory.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/CoreWrappingFactory.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/CoreWrappingFactory.java Wed Apr 27 13:27= :43 2005 @@ -0,0 +1,122 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.agila.bpel.engine.common.persistence.DBSessionException; +import org.apache.agila.bpel.engine.common.persistence.FinderException; +import org.apache.agila.bpel.engine.priv.core.definition.Activity; +import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory; +import org.apache.agila.bpel.engine.priv.core.definition.Pick; +import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext; +import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFact= ory; +import org.apache.agila.bpel.engine.priv.core.dynamic.PickEC; +import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance; +import org.apache.agila.bpel.engine.priv.core.dynamic.ReceiveEC; + +/** + * Factory class used by the MessageController implementation to get activ= ities + * and execution contexts from the engine core. This factory includes meth= ods + * to find picks and receives and wraps the picks to behave as a receive u= sing + * the wrapping class. It basically calls factory methods of the engine co= re and + * creates correct wrappers for picks. + *=20 + * @see PickAsReceive + * @see PickECAsReceiveEC + * @see org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory + * @see org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFac= tory + */ +public class CoreWrappingFactory { + + /** + * Find execution context by its activity and an instance. A special c= ase is + * when the provided activity is our wrapper PickAsReceive. In this pa= rticular case + * we replace the wrapper with the Pick behind it in the finder and re= turn the PickEC + * wrapped around PickECAsReceiveEC. + *=20 + * @param activity=20 + * @return=20 + */ + public static ExecutionContext findECsByActivityAndInstance(ProcessIns= tance instance, Activity activity) throws FinderException { + if (activity instanceof PickAsReceive) { + PickAsReceive pickAsReceive =3D (PickAsReceive) activity; + PickEC pickEC =3D (PickEC) ExecutionContextFactory.findECForAc= tivityInInstance(instance, pickAsReceive.getPick()); + return new PickECAsReceiveEC(pickEC, pickAsReceive.getEventPos= ()); + } else { + return ExecutionContextFactory.findECForActivityInInstance(ins= tance, activity); + } + } + + /** + * Find receives as well as picks by invoker and wraps the picks using= the + * class PickAsReceive, returning a List only containing Receive imple= mentations. + *=20 + * @param partnerLink=20 + * @param portType =20 + * @param operation =20 + * @return List of Receive implementations, either a really Receive or= a pick wrapped as a Receive + * @throws DBSessionException=20 + */ + public static List findReceivesByInvoker(String partnerLink, String na= mespace, String portType, String operation) throws DBSessionException { + List result =3D ActivityFactory.findReceivesByInvoker(partnerLink,= namespace, portType, operation); + List pickEvents =3D ActivityFactory.findPickEventsByInvoker(partne= rLink,namespace, portType, operation); + result.addAll(wrapPicksAsReceives(pickEvents)); + return result; + } + =20 + /** + * Find receives as well as picks by invoker and wraps the picks using= the + * class PickAsReceive, returning a List only containing Receive imple= mentations. + *=20 + * @param partnerLink=20 + * @param portType =20 + * @param operation =20 + * @return List of Receive implementations, either a really Receive or= a pick wrapped as a Receive + * @throws DBSessionException=20 + */ + public static List findReceivesByInvoker(String partnerLink, String po= rtType, String operation) throws DBSessionException { + List result =3D ActivityFactory.findReceivesByInvoker(partnerLink,= portType, operation); + List pickEvents =3D ActivityFactory.findPickEventsByInvoker(partne= rLink, portType, operation); + result.addAll(wrapPicksAsReceives(pickEvents)); + return result; + } + + public static ReceiveEC reload(ReceiveEC receiveEC) throws DBSessionEx= ception, FinderException { + if (receiveEC instanceof PickECAsReceiveEC) { + PickEC pickEC =3D (PickEC) ExecutionContextFactory.findECById(= receiveEC.getId()); + return new PickECAsReceiveEC(pickEC, ((PickECAsReceiveEC) rece= iveEC).getEventPos()); + } else { + return (ReceiveEC) ExecutionContextFactory.findECById(receiveE= C=2EgetId()); + } + } + + private static List wrapPicksAsReceives(List pickEvents) { + List result =3D new ArrayList(pickEvents.size()); + Pick pick; + int eventPos; + for (int m =3D 0; m < pickEvents.size(); m++) { + Object[] objects =3D (Object[]) pickEvents.get(m); + pick =3D (Pick) objects[0]; + eventPos =3D pick.getMessageEvents().indexOf(objects[1]); + PickAsReceive pickAsReceive =3D new PickAsReceive(pick, eventP= os); + result.add(pickAsReceive); + } + return result; + } + +} Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/DefaultMessageBrokerImpl.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/DefaultMes= sageBrokerImpl.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/DefaultMessageBrokerImpl.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/DefaultMessageBrokerImpl.java Wed Apr 27 = 13:27:43 2005 @@ -0,0 +1,84 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; + +import org.apache.log4j.Logger; + +import org.apache.agila.bpel.engine.priv.core.definition.Activity; +import org.apache.agila.bpel.engine.priv.messaging.MessageBroker; + +/** + * A default implementation of the MessageBroker interface that + * does absolutely nothing except logging. + */ +public class DefaultMessageBrokerImpl extends MessageBroker { + + private static Logger log =3D Logger.getLogger(DefaultMessageBrokerImp= l=2Eclass); + + public void asyncSend(Activity sender, String partner, String portType= , String operation, Document message) { + if (message =3D=3D null) { + log.info("Send an asynchronous message with partner =3D " + pa= rtner + ", portType =3D " + + portType + ", operation =3D " + operation + " and mess= age null."); + } else { + log.info("Send an asynchronous message with partner =3D " + pa= rtner + ", portType =3D " + + portType + ", operation =3D " + operation + " and mess= age " + message.asXML()); + } + } + + public void asyncSend(Activity sender, String partner, String namespac= e, String portType, String operation, Document message) { + if (message =3D=3D null) { + log.info("Send an asynchronous message with partner =3D " + pa= rtner + ", portType =3D " + + "{" + namespace + "}" + portType + ", operation =3D " + o= peration + " and message null."); + } else { + log.info("Send an asynchronous message with partner =3D " + pa= rtner + ", portType =3D " + + "{" + namespace + "}" + portType + ", operation =3D " + o= peration + " and message " + message.asXML()); + } + } + =20 + public Document syncSend(Activity sender, String partner, String portT= ype, String operation, Document message) { + if (message =3D=3D null) { + log.info("Send a synchronous message with partner =3D " + part= ner + ", portType =3D " + + portType + ", operation =3D " + operation + " and mess= age null."); + } else { + log.info("Send a synchronous message with partner =3D " + part= ner + ", portType =3D " + + portType + ", operation =3D " + operation + " and mess= age " + message.asXML()); + } + + Document doc =3D DocumentHelper.createDocument(); + Element elmt =3D doc.addElement("message"); + elmt.addElement("reply").addElement("status").setText("ok"); + return doc; + } + =20 + public Document syncSend(Activity sender, String partner, String names= pace, String portType, String operation, Document message) { + if (message =3D=3D null) { + log.info("Send a synchronous message with partner =3D " + part= ner + ", portType =3D " + + "{" + namespace + "}" + portType + ", operation =3D "= + operation + " and message null."); + } else { + log.info("Send a synchronous message with partner =3D " + part= ner + ", portType =3D " + + "{" + namespace + "}" + portType + ", operation =3D "= + operation + " and message " + message.asXML()); + } + + Document doc =3D DocumentHelper.createDocument(); + Element elmt =3D doc.addElement("message"); + elmt.addElement("reply").addElement("status").setText("ok"); + return doc; + } +} Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/MessageControllerImpl.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/MessageCon= trollerImpl.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/MessageControllerImpl.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/MessageControllerImpl.java Wed Apr 27 13:= 27:43 2005 @@ -0,0 +1,518 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.apache.agila.bpel.engine.common.persistence.DBSessionException; +import org.apache.agila.bpel.engine.common.persistence.FinderException; +import org.apache.agila.bpel.engine.common.persistence.XMLSessionException; +import org.apache.agila.bpel.engine.exception.*; +import org.apache.agila.bpel.engine.priv.core.definition.CorrelationRef; +import org.apache.agila.bpel.engine.priv.core.definition.Receive; +import org.apache.agila.bpel.engine.priv.core.definition.Activity; +import org.apache.agila.bpel.engine.priv.core.definition.Flow; +import org.apache.agila.bpel.engine.priv.core.definition.impl.StructuredAc= tivityImpl; +import org.apache.agila.bpel.engine.priv.core.definition.impl.ProcessImpl; +import org.apache.agila.bpel.engine.priv.core.dynamic.*; +import org.apache.agila.bpel.engine.priv.core.dynamic.impl.ReceiveECImpl; +import org.apache.agila.bpel.engine.priv.messaging.MessageController; +import org.apache.agila.bpel.engine.priv.util.CorrelationExtractor; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * Implementation of the MessageController interface. + * + * @see org.apache.agila.bpel.engine.priv.messaging.MessageController + */ +public class MessageControllerImpl implements MessageController { + + private Logger log =3D Logger.getLogger(getClass()); + + /** + * As the acknowledge method requires a partner link it's always targe= ted at only one process. If + * a process includes several receives with createInstance, they must = have same correlation. + * 1. Checking all receives and selecting their correlations + * 2. For each receive, finding their ec from correlation and instance. + * 3. If several ecs are found, send conflicting receive failure. Done. + * 4. If one ec is found, sending it the message. Done. + * 5. If no ecs are found : + * 5.1. If no process instance exists for the extracted correlation, j= ust pick one of the receives + * and executing it. Done. + * 5.2. If a process instance already exists, using this instance to e= xecute a new receive into (case + * of a process having several starting receives in parrallel flow bra= nches). Done. + * Picks are processed exactly as receives using wrappers. + */ + public ReceiveEC acknowledge(String partnerLink, String namespace, Str= ing portType, String operation, Document message) throws CorrelationViolati= onException, ConflictingReceiveException { + // Finding the activity from partnerLink, portType and operation + if (message =3D=3D null || !"message".equals(message.getRootElemen= t().getName())) { + throw new IllegalArgumentException("The message must have a 'm= essage' element as root"); + } + List receives =3D null; + try { + receives =3D CoreWrappingFactory.findReceivesByInvoker(partner= Link, namespace, portType, operation); + } catch (DBSessionException e) { + log.error("Could not acknowledge a message from (" + partnerLi= nk + ", " + "{" + namespace + "}" + portType + + ", " + operation + ") : " + message.asXML(), e= ); + throw new EngineRuntimeException("Server error", e); + } + + + ReceiveEC receiveEC =3D null; + Map receiveECCorrels =3D null; + List createInstanceReceive =3D new ArrayList(); + List createInstanceReceiveCorrel =3D new ArrayList(); + + log.debug("Found receives: " + receives.size()); + + // 1 and 2 + for (int m =3D 0; m < receives.size(); m++) { + Receive receive =3D (Receive) receives.get(m); + Map selectedCorrelRefs =3D null; + + // Checking receive correlations to retrieve a value from the = message for all properties + // of those correlations. + try { + selectedCorrelRefs =3D getValuedCorrelations(receive, mess= age); + } catch (CorrelationViolationException e) { + log.error("Message doesn't include necessary correlation i= nformation : " + message.asXML(), e); + throw e; + } catch (RuntimeException e) { + log.error("Could not value correlations for receive " + re= ceive + " and message " + message.asXML()); + throw e; + } + + // Taking profit of this iteration to prepare collections with= receives that + // have the createInstance attribute to true and their valued = correlation. + if (receive.isCreateInstance()) { + createInstanceReceive.add(receive); + createInstanceReceiveCorrel.add(selectedCorrelRefs); + } + + // First correlation already initiated will lead us to the rig= ht receiveEC + CorrelationRef initiatedRef =3D null; + for (Iterator correlIter =3D selectedCorrelRefs.keySet().itera= tor(); correlIter.hasNext();) { + CorrelationRef setRef =3D (CorrelationRef) correlIter.next= (); + if (!setRef.isInitiate()) { + initiatedRef =3D setRef; + } + } + // If we cannot find any initiated correlation, no instance ca= n be found so the receive + // is ignored + if (initiatedRef !=3D null) { + if (receiveEC =3D=3D null) { + // The correlation ref helps us find the right instanc= e and with the instance + // and the originating activity we can find the right = waiting receive ec. + receiveEC =3D getExecutionContext(receive, initiatedRe= f=2EgetSet(), + (Map) selectedCorrelRefs.get(initiated= Ref), true); + receiveECCorrels =3D selectedCorrelRefs; + } else { + ReceiveEC anotherOne =3D getExecutionContext(receive, = initiatedRef.getSet(), + (Map) selectedCorrelRefs.get(initiated= Ref), true); + if (anotherOne !=3D null) { + // 3 The above condition just checks that there is= also an execution context for + // this receive. If not execution exist, it's not = a conflict. + throw new ConflictingReceiveException("Several rec= eive execution contexts are " + + "waiting= at the same message at the same time. Message : " + message.asXML(), ((Rec= eiveECImpl) anotherOne).fetchInstance()); + } + } + } + } + + // Forwarding the message to the right execution context given act= ivity and correlation + // 4 + if (receiveEC !=3D null) { + log.debug("Step 4."); + // Adding newly initiated correlations to the process instance + ProcessInstance instance =3D receiveEC.fetchInstance(); + try { + for (Iterator correlIter =3D receiveECCorrels.keySet().ite= rator(); correlIter.hasNext();) { + CorrelationRef correlationRef =3D (CorrelationRef) cor= relIter.next(); + if (correlationRef.isInitiate()) { + if (receiveECCorrels.get(correlationRef) !=3D null= ) { + ProcessInstanceFactory.addCorrelation(instance= , correlationRef.getSet(), + (Map) receiveECCorrels.get(correlation= Ref), true); + } else { + throw new CorrelationViolationException("A cor= relation " + correlationRef.getSet() + + " = defined as initiate could not be extracted from received message" + + me= ssage.asXML()); + } + } + } + } catch (DBSessionException e) { + throw new EngineRuntimeException("Could not add correlatio= n to receive execution context " + receiveEC, e); + } catch (XMLSessionException e) { + throw new EngineRuntimeException("Could not add correlatio= n to receive execution context " + receiveEC, e); + } + return receiveEC; + } else { + // 5.1 + log.debug("Step 5."); + if (createInstanceReceive.size() > 0) { + CorrelationRef correlationRef =3D (CorrelationRef) + ((Map) createInstanceReceiveCorrel.get(0)).keySet(= )=2Eiterator().next(); + Map correlationValues =3D (Map) ((Map) createInstanceRecei= veCorrel.get(0)).get(correlationRef); + ProcessInstance instance =3D null; + try { + instance =3D ProcessInstanceFactory.findInstanceByCorr= elation(correlationRef.getSet(), correlationValues); + } catch (DBSessionException e) { + throw new EngineRuntimeException("Could not find insta= nce from correlation " + correlationRef.getSet(), e); + } catch (FinderException e) { // instance is just null, it= 's ok this way + } + + if (instance =3D=3D null) { + log.debug("Step 5.1."); + ReceiveEC resultEC =3D executeReceive((Receive) create= InstanceReceive.get(0), message, (Map) createInstanceReceiveCorrel.get(0), = null); + // No need to go further, only activity with createIns= tance is served. + return resultEC; + } else { + log.debug("Step 5.2."); + // 5.2 + // All receives with createInstance must have same cor= relation so they all have same instance + if (createInstanceReceiveCorrel.size() =3D=3D 0) { + throw new ConflictingReceiveException("Several rec= eive with createInstance are " + + "waiting= at the same message at the same time. Message : " + message); + } + for (int m =3D 0; m < createInstanceReceive.size(); m+= +) { + Receive receive =3D (Receive) createInstanceReceiv= e=2Eget(m); + CorrelationRef receiveCorrelationRef =3D (Correlat= ionRef) + ((Map) createInstanceReceiveCorrel.get(m))= .keySet().iterator().next(); + Map receiveCorrelationValues =3D (Map) ((Map) crea= teInstanceReceiveCorrel.get(m)).get(correlationRef); + ReceiveEC ec =3D getExecutionContext(receive, rece= iveCorrelationRef.getSet(), receiveCorrelationValues, false); + if (ec =3D=3D null) { + // Executing first one not executed yet. + ReceiveEC resultEC =3D executeReceive(receive,= message, + (Map) createInstanceReceiveCor= rel.get(m), instance); + return resultEC; + } + } + } + } + } + return null; + } + + /** + * As the acknowledge method requires a partner link it's always targe= ted at only one process. If + * a process includes several receives with createInstance, they must = have same correlation. + * 1. Checking all receives and selecting their correlations + * 2. For each receive, finding their ec from correlation and instance. + * 3. If several ecs are found, send conflicting receive failure. Done. + * 4. If one ec is found, sending it the message. Done. + * 5. If no ecs are found : + * 5.1. If no process instance exists for the extracted correlation, j= ust pick one of the receives + * and executing it. Done. + * 5.2. If a process instance already exists, using this instance to e= xecute a new receive into (case + * of a process having several starting receives in parrallel flow bra= nches). Done. + * Picks are processed exactly as receives using wrappers. + */ + public ReceiveEC acknowledge(String partnerLink, String portType, Stri= ng operation, Document message) throws CorrelationViolationException, Confl= ictingReceiveException { + // Finding the activity from partnerLink, portType and operation + if (message =3D=3D null || !"message".equals(message.getRootElemen= t().getName())) { + throw new IllegalArgumentException("The message must have a 'm= essage' element as root"); + } + List receives =3D null; + try { + receives =3D CoreWrappingFactory.findReceivesByInvoker(partner= Link, portType, operation); + } catch (DBSessionException e) { + log.error("Could not acknowledge a message from (" + partnerLi= nk + ", " + portType + + ", " + operation + ") : " + message.asXML(), e= ); + throw new EngineRuntimeException("Server error", e); + } + + ReceiveEC receiveEC =3D null; + Map receiveECCorrels =3D null; + List createInstanceReceive =3D new ArrayList(); + List createInstanceReceiveCorrel =3D new ArrayList(); + // 1 and 2 + for (int m =3D 0; m < receives.size(); m++) { + Receive receive =3D (Receive) receives.get(m); + Map selectedCorrelRefs =3D null; + + // Checking receive correlations to retrieve a value from the = message for all properties + // of those correlations. + try { + selectedCorrelRefs =3D getValuedCorrelations(receive, mess= age); + } catch (CorrelationViolationException e) { + log.error("Message doesn't include necessary correlation i= nformation : " + message.asXML(), e); + throw e; + } catch (RuntimeException e) { + log.error("Could not value correlations for receive " + re= ceive + " and message " + message.asXML()); + throw e; + } + + // Taking profit of this iteration to prepare collections with= receives that + // have the createInstance attribute to true and their valued = correlation. + if (receive.isCreateInstance()) { + createInstanceReceive.add(receive); + createInstanceReceiveCorrel.add(selectedCorrelRefs); + } + + // First correlation already initiated will lead us to the rig= ht receiveEC + CorrelationRef initiatedRef =3D null; + for (Iterator correlIter =3D selectedCorrelRefs.keySet().itera= tor(); correlIter.hasNext();) { + CorrelationRef setRef =3D (CorrelationRef) correlIter.next= (); + if (!setRef.isInitiate()) { + initiatedRef =3D setRef; + } + } + // If we cannot find any initiated correlation, no instance ca= n be found so the receive + // is ignored + if (initiatedRef !=3D null) { + if (receiveEC =3D=3D null) { + // The correlation ref helps us find the right instanc= e and with the instance + // and the originating activity we can find the right = waiting receive ec. + receiveEC =3D getExecutionContext(receive, initiatedRe= f=2EgetSet(), + (Map) selectedCorrelRefs.get(initiated= Ref), true); + receiveECCorrels =3D selectedCorrelRefs; + } else if (getExecutionContext(receive, initiatedRef.getSe= t(), + (Map) selectedCorrelRefs.get(initiatedR= ef), true) !=3D null) { + // 3 The above condition just checks that there is als= o an execution context for + // this receive. If not execution exist, it's not a co= nflict. + throw new ConflictingReceiveException("Several receive= execution contexts are " + + "waiting at = the same message at the same time. Message : " + message); + } + } + } + + // Forwarding the message to the right execution context given act= ivity and correlation + // 4 + if (receiveEC !=3D null) { + // Adding newly initiated correlations to the process instance + ProcessInstance instance =3D receiveEC.fetchInstance(); + try { + for (Iterator correlIter =3D receiveECCorrels.keySet().ite= rator(); correlIter.hasNext();) { + CorrelationRef correlationRef =3D (CorrelationRef) cor= relIter.next(); + if (correlationRef.isInitiate()) { + if (receiveECCorrels.get(correlationRef) !=3D null= ) { + ProcessInstanceFactory.addCorrelation(instance= , correlationRef.getSet(), + (Map) receiveECCorrels.get(correlation= Ref), true); + } else { + throw new CorrelationViolationException("A cor= relation " + correlationRef.getSet() + + " = defined as initiate could not be extracted from received message" + + me= ssage.asXML()); + } + } + } + } catch (DBSessionException e) { + throw new EngineRuntimeException("Could not add correlatio= n to receive execution context " + receiveEC, e); + } catch (XMLSessionException e) { + throw new EngineRuntimeException("Could not add correlatio= n to receive execution context " + receiveEC, e); + } + return receiveEC; + } else { + // 5.1 + log.debug("Step 5."); + if (createInstanceReceive.size() > 0) { + ProcessInstance instance =3D null; + CorrelationRef correlationRef =3D null; + if (((Map) createInstanceReceiveCorrel.get(0)).size() > 0)= { + correlationRef =3D (CorrelationRef) + ((Map) createInstanceReceiveCorrel.get(0)).key= Set().iterator().next(); + Map correlationValues =3D (Map) ((Map) createInstanceR= eceiveCorrel.get(0)).get(correlationRef); + try { + instance =3D ProcessInstanceFactory.findInstanceBy= Correlation(correlationRef.getSet(), correlationValues); + } catch (DBSessionException e) { + throw new EngineRuntimeException("Could not find i= nstance from correlation " + correlationRef.getSet(), e); + } catch (FinderException e) { // instance is just null= , it's ok this way + } + } + + if (instance =3D=3D null) { + log.debug("Step 5.1."); + ReceiveEC resultEC =3D executeReceive((Receive) create= InstanceReceive.get(0), message, (Map) createInstanceReceiveCorrel.get(0), = null); + // No need to go further, only activity with createIns= tance is served. + return resultEC; + } else { + log.debug("Step 5.2."); + // 5.2 + // All receives with createInstance must have same cor= relation so they all have same instance + if (createInstanceReceiveCorrel.size() =3D=3D 0) { + throw new ConflictingReceiveException("Several rec= eive with createInstance are " + + "waiting= at the same message at the same time. Message : " + message); + } + for (int m =3D 0; m < createInstanceReceive.size(); m+= +) { + Receive receive =3D (Receive) createInstanceReceiv= e=2Eget(m); + CorrelationRef receiveCorrelationRef =3D (Correlat= ionRef) + ((Map) createInstanceReceiveCorrel.get(m))= .keySet().iterator().next(); + Map receiveCorrelationValues =3D (Map) ((Map) crea= teInstanceReceiveCorrel.get(m)).get(correlationRef); + ReceiveEC ec =3D getExecutionContext(receive, rece= iveCorrelationRef.getSet(), receiveCorrelationValues, false); + if (ec =3D=3D null) { + // Executing first one not executed yet. + ReceiveEC resultEC =3D executeReceive(receive,= message, (Map) createInstanceReceiveCorrel.get(m), instance); + return resultEC; + } + } + + } + } + } + return null; + } + + /* + * Returns a map containing the CorrelationRef as key and a map of prop= erties name/value + * pairs as value. + */ + private Map getValuedCorrelations(Receive receive, Document message) t= hrows CorrelationViolationException { + Map selectedCorrelRefs =3D CorrelationExtractor.extractCorrelation= sValues(receive.fetchProcess(), receive.getNamespace(), receive.getCorrelat= ions(), message); + return selectedCorrelRefs; + } + + /** + * Returns an execution context from its parent receive and its correl= ation values. The + * only solution here was to get the collection of all execution conte= xts for an activity + * and filtrate the collection the retain only the execution context b= elonging to the wanted + * process instance. + */ + private ReceiveEC getExecutionContext(Receive receive, String correlat= ionName, Map correlationValues, boolean active) { + ReceiveEC result =3D null; + ProcessInstance instance =3D null; + try { + instance =3D ProcessInstanceFactory.findInstanceByCorrelation(= correlationName, correlationValues); + } catch (DBSessionException e) { + //log.error("An error occured when finding a receive ec from r= eceive " + receive, e); + // TODO + return null; + //throw new RuntimeException("Server error"); + } catch (FinderException e) { + //log.error("Could not find instance from correlation (" + cor= relationName + ", " + correlationValues + ")", e); + // TODO + return null; + //throw new RuntimeException("Server error"); + } + + try { + result =3D (ReceiveEC) CoreWrappingFactory.findECsByActivityAn= dInstance(instance, receive); + } catch (FinderException e) { + // This just means that the provided receive doesn't have any = execution context so + // we're just returning null. + } + + if (result =3D=3D null) { + return null; + } + if (active && result.getStatus() !=3D ExecutionContext.ACTIVE) { + return null; + } else { + return result; + } + } + + private ReceiveEC executeReceive(Receive receive, Document message, Ma= p receiveCorrelations, ProcessInstance instance) { + ReceiveEC createdEC =3D null; + try { + // Executing the activity (creates activity ec and its contain= ers ec up to + // the process instance) providing it all correlations (if the= re are some). + if (receiveCorrelations.isEmpty()) { + createdEC =3D (ReceiveEC) receive.execute(null, null); + } else { + for (Iterator correlIter =3D receiveCorrelations.keySet().= iterator(); correlIter.hasNext();) { + CorrelationRef setRef =3D (CorrelationRef) correlIter.= next(); + if (setRef.isInitiate()) { + if (receiveCorrelations.get(setRef) !=3D null) { + if (createdEC =3D=3D null) { + if (instance =3D=3D null) { + createdEC =3D (ReceiveEC) receive.exec= ute(setRef.getSet(), + (Map) receiveCorrelati= ons.get(setRef)); + } else { + // Very specific case when an instance= already exists and we have to create + // an ec for another receive that is b= eing also executed in the same process. + // This basically heppens when several= receive can all start a process execution + // in different branches of a flow aci= vity. + createdEC =3D (ReceiveEC) executeInIns= tance(receive, instance); + createdEC.execute(); + } + } else { + ProcessInstanceFactory.addCorrelation(crea= tedEC.fetchInstance(), setRef.getSet(), + (Map) receiveCorrelations.get(setR= ef), true); + } + } else { + throw new CorrelationViolationException("A cor= relation " + setRef.getSet() + + " = defined as initiate could not be extracted from received message" + + me= ssage.asXML()); + } + } + } + } + } catch (EngineException e) { + log.error("Could not execute receive " + receive, e); + throw new EngineRuntimeException("Server error", e); + } catch (Exception e) { + log.error("Could not add correlation to receive execution cont= ext " + createdEC, e); + throw new EngineRuntimeException("Server error", e); + } + // Making the ReceiveEC to acknowledge the message. +// createdEC.acknowledgeMessage(message); + return createdEC; + } + + /** + * Instantiates an activity in an instance that has already been start= ed. Basically + * starts from instantiating the activity and all containers up to it = until reaching + * the container that has already been started in the provided instanc= e=2E + * This is necessary when several receive activities can all start a p= rocess execution in + * different branches of a flow activity. Recursive implementation. + * @param activity + * @param instance + * @return + */ + private ExecutionContext executeInInstance(Activity activity, ProcessI= nstance instance) { + ExecutionContext context =3D null; + + if (activity instanceof Flow) { + FlowEC flowEC =3D fetchFirstFlowEC(instance.getChildExecutionC= ontext()); + return flowEC; + } else if (activity.getContainer() !=3D null) { + StructuredEC parentContext =3D (StructuredEC) executeInInstanc= e(activity.getContainer(), instance); + try { + context =3D ExecutionContextFactory.createExecutionContext= (activity, parentContext); + } catch (DBSessionException e) { + throw new EngineRuntimeException("Server error", e); + } + } + + return context; + + } + + /** + * Gets the first flow execution context encountered while going down = the execution contexts + * containment hierarchy. Recursive implementation. + * @param childExecutionContext + * @return + */ + private FlowEC fetchFirstFlowEC(ExecutionContext childExecutionContext= ) { + if (childExecutionContext instanceof FlowEC) { + return (FlowEC) childExecutionContext; + } else { + if (childExecutionContext instanceof StructuredEC) { + List children =3D ((StructuredEC)childExecutionContext).ge= tExecutionContexts(); + for (int m =3D 0; m < children.size(); m++) { + ExecutionContext child =3D (ExecutionContext) children= .get(m); + return fetchFirstFlowEC(child); + } + } + } + return null; + } + + +} Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/MyMessageBroker.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/MyMessageB= roker.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/MyMessageBroker.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/MyMessageBroker.java Wed Apr 27 13:27:43 = 2005 @@ -0,0 +1,567 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.ByteArrayOutputStream; +import java.rmi.RemoteException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Service; +import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensibilityElement; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.wsdl.extensions.soap.SOAPOperation; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.wsdl.xml.WSDLWriter; +import javax.xml.namespace.QName; +import javax.xml.rpc.ServiceException; + +import org.apache.axis.client.Call; +import org.apache.axis.message.SOAPBodyElement; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.io.DOMReader; +import org.dom4j.io.DOMWriter; + +import org.apache.log4j.Logger; + +import org.apache.agila.bpel.engine.common.persistence.FinderException; +import org.apache.agila.bpel.engine.common.persistence.XMLDataAccess; +import org.apache.agila.bpel.engine.common.persistence.XMLSessionException; +import org.apache.agila.bpel.engine.priv.core.definition.Activity; +import org.apache.agila.bpel.engine.priv.core.definition.AgilaProcess; +import org.apache.agila.bpel.engine.priv.messaging.InvocationException; +import org.apache.agila.bpel.engine.priv.messaging.MessageBroker; + +import EDU.oswego.cs.dl.util.concurrent.BoundedBuffer; +import EDU.oswego.cs.dl.util.concurrent.PooledExecutor; + + +import javax.xml.namespace.QName; +/** + * Invokes a web service from a WSDL definition. + */ +public class MyMessageBroker extends MessageBroker { + + /** @TODO parameterize this */ + private PooledExecutor threadPool =3D new PooledExecutor(new BoundedBu= ffer(10), 100); + + private static final String SOAP_NS =3D "http://schemas.xmlsoap.org/ws= dl/soap/"; + private DOMReader domReader =3D null; + private DOMWriter domWriter =3D null; + + protected void asyncSend(Activity sender, String partner, String portT= ype, String operation, Document message) { + final Activity fsender =3D sender; + final String fpartner =3D partner; + final String fportType =3D portType; + final String foperation =3D operation; + final Document fmessage =3D message; + try { + threadPool.execute(new Runnable() { + public void run() { + syncSend(fsender, fpartner, fportType, foperation, fme= ssage); + } + }); + } catch (InterruptedException e) { + log.error("Could not send message to " + portType + " : " + me= ssage.asXML(), e); + } + } + + protected void asyncSend(Activity sender, String partner, String names= pace, String portType, String operation, Document message) { + final Activity fsender =3D sender; + final String fpartner =3D partner; + final String fportType =3D portType; + final String fnamespace =3D namespace; + final String foperation =3D operation; + final Document fmessage =3D message; + try { + threadPool.execute(new Runnable() { + public void run() { + syncSend(fsender, fpartner, fnamespace, fportType, fop= eration, fmessage); + } + }); + } catch (InterruptedException e) { + log.error("Could not send message to " + portType + " : " + me= ssage.asXML(), e); + } + } + =20 + protected Document syncSend(Activity sender, String partner, String po= rtType, String operation, Document message) { + AgilaProcess process =3D sender.fetchProcess(); + org.w3c.dom.Document wsdlDoc =3D getWSDLDesc(process.getNamespace(= ), process.getName()); + Definition def =3D readWSDL(wsdlDoc); + + String wsdlStringDoc =3D getDOMReader().read(wsdlDoc).asXML(); + String nameSpaceURI =3D def.getTargetNamespace(); + QName serviceName =3D getService(def, portType); + String[] wsdlAdditionalInfo =3D getWSDLAdditionalInfo(def, portTyp= e, operation); =20 + String soapAction =3D wsdlAdditionalInfo[0]; + String msgNS =3D null; + if (wsdlAdditionalInfo[1] !=3D null && wsdlAdditionalInfo[1].lengt= h() > 0) { + msgNS =3D wsdlAdditionalInfo[1]; + } else { + msgNS =3D nameSpaceURI; + } + String encoding =3D wsdlAdditionalInfo[2]; + InputStream wsdlDesc =3D new ByteArrayInputStream(wsdlStringDoc.ge= tBytes()); + Document preparedMsg =3D prepareMessage(message, operation, msgNS,= encoding); + =20 + Document result =3D null; + try { + new org.dom4j.io.XMLWriter(System.out).write(preparedMsg); + org.w3c.dom.Document domDoc =3D getDOMWriter().write(preparedM= sg); + result =3D getDOMReader().read(sendMessage(nameSpaceURI, servi= ceName, + new QName(nameSpaceURI,portTyp= e), operation, soapAction, wsdlDesc, domDoc)); + result.getRootElement().setName("message"); + } catch (DocumentException e) { + log.error("Could not send message to " + portType + " : " + pr= eparedMsg.asXML(), e); + } catch (ServiceException e) { + log.error("Could not send message to " + portType + " : " + pr= eparedMsg.asXML(), e); + } catch (RemoteException e) { + log.error("Could not send message to " + portType + " : " + pr= eparedMsg.asXML(), e); + } catch (Exception e) { + log.error("Could not send message to " + portType + " : " + prepa= redMsg.asXML(), e); + } + log.debug("Received message : " + result.asXML()); + return result; + } + =20 + =20 + protected Document syncSend(Activity sender, String partner, String na= mespace, String portType, String operation, Document message) { + QName qnPortType =3D new QName(namespace,portType); + AgilaProcess process =3D sender.fetchProcess(); + org.w3c.dom.Document wsdlDoc =3D getWSDLDesc(process.getNamespace(= ), process.getName()); + Definition def =3D readWSDL(wsdlDoc); + + //String wsdlStringDoc =3D getDOMReader().read(wsdlDoc).asXML(); + =20 + Object tempObj[]=3D null; + tempObj =3D getService(def, qnPortType); + QName serviceName =3D (QName)tempObj[0]; + String wsdlStringDoc=3Dnull;// =3D new String(); + def =3D (Definition)tempObj[1]; + String nameSpaceURI =3D def.getTargetNamespace(); + ByteArrayOutputStream byteOut =3D new ByteArrayOutputStream(); + writeWSDL(def,byteOut); + wsdlStringDoc =3D byteOut.toString(); + =20 + //getDOMReader().read(wsdlDoc).asXML(); + String[] wsdlAdditionalInfo =3D getWSDLAdditionalInfo(def, qnPortT= ype, operation); =20 + String soapAction =3D wsdlAdditionalInfo[0]; + String msgNS =3D null; + if (wsdlAdditionalInfo[1] !=3D null && wsdlAdditionalInfo[1].lengt= h() > 0) { + msgNS =3D wsdlAdditionalInfo[1]; + } else { + msgNS =3D nameSpaceURI; + } + String encoding =3D wsdlAdditionalInfo[2]; + // System.out.println(wsdlStringDoc); + InputStream wsdlDesc =3D new ByteArrayInputStream(wsdlStringDoc.ge= tBytes()); + Document preparedMsg =3D prepareMessage(message, operation, msgNS,= encoding); + =20 + Document result =3D null; + try { + new org.dom4j.io.XMLWriter(System.out).write(preparedMsg); + org.w3c.dom.Document domDoc =3D getDOMWriter().write(preparedM= sg); + result =3D getDOMReader().read(sendMessage(nameSpaceURI, servi= ceName, + qnPortType, operation, soapAction, wsdlDesc, domDoc)); + result.getRootElement().setName("message"); + //result.getRootElement().setTargetNamespace(qnPortType.getNam= espaceURI()); + } catch (DocumentException e) { + log.error("Could not send message to " + qnPortType + " : " + = preparedMsg.asXML(), e); + } catch (ServiceException e) { + log.error("Could not send message to " + qnPortType + " : " + = preparedMsg.asXML(), e); + } catch (RemoteException e) { + log.error("Could not send message to " + qnPortType + " : " + = preparedMsg.asXML(), e); + } catch (Exception e) { + log.error("Could not send message to " + portType + " : " + prepa= redMsg.asXML(), e); + } + log.debug("Received message : " + result.asXML()); + return result; + } + + =20 + =20 + private static org.dom4j.Document prepareMessage(Document doc, String = elmtName,=20 + String namespace, String encoding) { + org.dom4j.QName qName =3D null; + if ("literal".equals(encoding)) { + qName =3D org.dom4j.QName.get(elmtName, "", namespace); + } else { + qName =3D org.dom4j.QName.get(elmtName, "ns1", namespace); + } + Document resultDoc =3D DocumentHelper.createDocument(); =20 + org.dom4j.Element root =3D DocumentHelper.createElement(qName); + resultDoc.add(root); + List elmtList =3D doc.getRootElement().elements(); + for (int m =3D0; m < elmtList.size(); m++) { + org.dom4j.Element detachedElmt =3D (org.dom4j.Element) ((org.d= om4j.Element)elmtList.get(m)).detach(); + root.add(detachedElmt); + } + return resultDoc; + } + + private static Definition readWSDL(org.w3c.dom.Document wsdlDesc) { + WSDLFactory factory =3D null; + try { + factory =3D WSDLFactory.newInstance(); + } catch (WSDLException e) { + throw new InvocationException("Could not find WSDL factory.", = e); + } + WSDLReader reader =3D factory.newWSDLReader(); + reader.setFeature("javax.wsdl.verbose", true); + reader.setFeature("javax.wsdl.importDocuments", true); + + Definition def =3D null; + try { + def =3D reader.readWSDL(null, wsdlDesc); + } catch (WSDLException e) { + throw new InvocationException("Could not read a WSDL document.= ", e); + } + return def; + } + =20 + private static void writeWSDL(Definition def,OutputStream out) + { + WSDLFactory factory =3D null; + try { + factory =3D WSDLFactory.newInstance(); + WSDLWriter writer =3D factory.newWSDLWriter(); + writer.writeWSDL(def,out); + } catch (WSDLException e) { + throw new InvocationException("Could not find WSDL factory.", = e); + } + =20 + } + + private static org.w3c.dom.Document getWSDLDesc(String processNS, Stri= ng processName) { + org.w3c.dom.Document document =3D null; + try { + document =3D XMLDataAccess.getDOMDocument("/process/def", ""+(= processNS + processName).hashCode()); + } catch (XMLSessionException e) { + throw new InvocationException(e); + } catch (FinderException e) { + throw new InvocationException(e); + } + return document; + } + + =20 + /** + * gets wsdl info uses Qname porttype + * it goes inside imports, that's why there is QName + * @author milan chudik + */ + private static String[] getWSDLAdditionalInfo(Definition def,QName por= tTypeName, String operationName) + { + =20 + Binding portBinding =3D findPortBinding(def,portTypeName,operation= Name); + =20 + if (portBinding =3D=3D null) { + =20 + throw new InvocationException("Could not find a binding for = port " + + portTypeName + " in service " + def.getTargetNamespace()); + =20 + /*System.out.println("Could not find a binding for port " + + portTypeName + " in service " + def.getTargetNamespa= ce()); + System.exit(1);*/ + } + + String[] result =3D new String[3]; + String soapAction =3D null; + BindingOperation bindingOperation =3D portBinding.getBindingOperat= ion( + operationName, null, null); + List extensibilityElmts =3D bindingOperation.getExtensibilityEleme= nts(); + for (int m =3D 0; m < extensibilityElmts.size(); m++) { + ExtensibilityElement extensibilityElement =3D (ExtensibilityEl= ement) extensibilityElmts + .get(m); + if (SOAP_NS.equals(extensibilityElement.getElementType() + .getNamespaceURI())) { + soapAction =3D ((SOAPOperation) extensibilityElement) + .getSoapActionURI(); + break; + } + } + + String msgUrl =3D null; + String encoding =3D null; + List bindingInputExt =3D bindingOperation.getBindingInput() + .getExtensibilityElements(); + for (int m =3D 0; m < bindingInputExt.size(); m++) { + ExtensibilityElement extensibilityElement =3D (ExtensibilityEl= ement) bindingInputExt + .get(m); + extensibilityElement.getElementType().getNamespaceURI(); + if (SOAP_NS.equals(extensibilityElement.getElementType() + .getNamespaceURI())) { + SOAPBody soapBodyExt =3D (SOAPBody) extensibilityElement; + + msgUrl =3D soapBodyExt.getNamespaceURI(); + encoding =3D soapBodyExt.getUse(); + } + + } + + if (soapAction =3D=3D null) + System.out.println("No SOAPAction could be found for service " + + def.getTargetNamespace() + " no SOAPAction element " + + "will be included in the message."); + result[0] =3D soapAction; + result[1] =3D msgUrl; + result[2] =3D encoding; + + return result; + =20 + } + =20 + /** + * finds PortBinding in imports according to porttype and operation na= me + * @author milan chudik + */ + private static Binding findPortBinding(Definition def,QName portTypeNa= me,String operationName) + { + Binding retBind =3D null; + Map bindings =3D def.getBindings(); + if (bindings !=3D null) { + for (Iterator bindingsIter =3D bindings.keySet().iterator(); b= indingsIter + .hasNext();) { + QName bindingName =3D (QName) bindingsIter.next(); + if (bindingName.getNamespaceURI().equals( + portTypeName.getNamespaceURI())) { + Binding binding =3D (Binding) bindings.get(bindingName= ); + if (binding.getPortType().getQName().getLocalPart().eq= uals( + portTypeName.getLocalPart())) { + if (binding.getBindingOperation(operationName, nul= l, + null) =3D=3D null) { + =20 + throw new InvocationException("Service " + + def.getTargetNamespace() + " with port " + + portTypeName + " doesn't have the operation = " + + operationName + " declared in the port bindi= ng."); + + } + retBind =3D binding; + break; + } + } + } + } + =20 + if(retBind=3D=3Dnull) + { +// and now go in imports + Map mapImports =3D def.getImports(); + Definition tempDef =3D null; + if (mapImports !=3D null && retBind =3D=3D null) { + for (Iterator iter =3D mapImports.values().iterator(); ite= r=2EhasNext();) { + List element =3D (List) iter.next(); + for (Iterator iterator =3D element.iterator(); iterato= r=2EhasNext();) { + Import elem =3D (Import) iterator.next(); + if(elem.getDefinition().getTargetNamespace()!=3Dnu= ll && elem.getDefinition().getTargetNamespace().equals(portTypeName.getName= spaceURI())) + { + retBind =3D findPortBinding(elem.getDefinition= (), portTypeName,operationName); + if(retBind!=3Dnull) break; + } + } + } + } + =20 + } + return retBind; + =20 + } + + =20 + =20 + =20 + =20 + =20 + private static String[] getWSDLAdditionalInfo(Definition def, String p= ortTypeName, String operationName) { + Map bindings =3D def.getBindings(); + Binding portBinding =3D null; + if (bindings !=3D null) { + for (Iterator bindingsIter =3D bindings.keySet().iterator(); b= indingsIter.hasNext();) { + QName bindingName =3D (QName) bindingsIter.next(); + Binding binding =3D (Binding) bindings.get(bindingName); + if (binding.getPortType().getQName().getLocalPart().equals= (portTypeName)) { + if (binding.getBindingOperation(operationName, null, n= ull) =3D=3D null) { + throw new InvocationException("Service " + def.get= TargetNamespace() + " with port " + + portTypeName + " doesn't have the operatio= n " + operationName + + " declared in the port binding."); + } + portBinding =3D binding; + break; + } + } + } + if (portBinding =3D=3D null) { + throw new InvocationException("Could not find a binding for po= rt " + portTypeName + + " in service " + def.getTargetNamespace()); =20 + } + =20 + String[] result =3D new String[3]; + String soapAction =3D null; + BindingOperation bindingOperation =3D portBinding.getBindingOperat= ion(operationName, null, null); + List extensibilityElmts =3D bindingOperation.getExtensibilityEleme= nts(); + for (int m =3D 0; m < extensibilityElmts.size(); m++) { + ExtensibilityElement extensibilityElement =3D (ExtensibilityEl= ement) extensibilityElmts.get(m); + if (SOAP_NS.equals(extensibilityElement.getElementType().getNa= mespaceURI())) { + soapAction =3D ((SOAPOperation)extensibilityElement).getSo= apActionURI(); + break; + } + } + + String msgUrl =3D null; + String encoding =3D null; + List bindingInputExt =3D bindingOperation.getBindingInput().getExt= ensibilityElements(); + for (int m =3D 0; m < bindingInputExt.size(); m++) { + ExtensibilityElement extensibilityElement =3D (ExtensibilityEl= ement) bindingInputExt.get(m); + extensibilityElement.getElementType().getNamespaceURI(); + if (SOAP_NS.equals(extensibilityElement.getElementType().getNa= mespaceURI())) { + SOAPBody soapBodyExt =3D (SOAPBody)extensibilityElement; + =20 + msgUrl =3D soapBodyExt.getNamespaceURI(); + encoding =3D soapBodyExt.getUse(); + } + =20 + } + + if (soapAction =3D=3D null) + log.info("No SOAPAction could be found for service " + def.getTar= getNamespace() + " no SOAPAction element " + + "will be included in the message."); + result[0] =3D soapAction; + result[1] =3D msgUrl;=20 + result[2] =3D encoding;=20 + =20 + return result; + } + =20 + =20 + =20 + /** + * my search method for service, it uses QName to find sevice definiti= on in + * imports etc + *=20 + * @param def definition + * @param port port as QName + * @return array of object, 0. index is qname, 1. is definition for se= rvice + */ + private static Object[] getService(Definition def, QName port) { + + //first looks for service in root definition + Object retval[] =3D null; + QName retQName =3D null; + Map services =3D def.getServices(); + if (services !=3D null) { + for (Iterator serviceIter =3D services.keySet().iterator(); se= rviceIter + .hasNext();) { + QName serviceQName =3D (QName) serviceIter.next(); + if (serviceQName.getNamespaceURI().equals( + port.getNamespaceURI())) { + Service service =3D (Service) services.get(serviceQNam= e); + if (service.getPort(port.getLocalPart()) !=3D null) { + retQName =3D service.getQName(); + retval =3D new Object[2]; + retval[0]=3DretQName; + retval[1]=3Ddef; + break; + } + } + } + } + // and now go in imports + Map mapImports =3D def.getImports(); + Definition tempDef =3D null; + if (mapImports !=3D null && retval =3D=3D null) { + for (Iterator iter =3D mapImports.values().iterator(); iter.ha= sNext();) { + List element =3D (List) iter.next(); + for (Iterator iterator =3D element.iterator(); iterator.ha= sNext();) { + Import elem =3D (Import) iterator.next(); + if(elem.getDefinition().getTargetNamespace()!=3Dnull &= & elem.getDefinition().getTargetNamespace().equals(port.getNamespaceURI())) + { + retval =3D getService(elem.getDefinition(), port); + if(retval!=3Dnull) break; + } + } + } + } + if (retval =3D=3D null) + { + throw new InvocationException("No service have been defined fo= r portType " + port); + } + + return retval; + } + =20 + =20 + + private static QName getService(Definition def, String port) { + Map services =3D def.getServices(); + for (Iterator serviceIter =3D services.keySet().iterator(); servic= eIter.hasNext();) { + QName serviceQName =3D (QName) serviceIter.next(); + Service service =3D (Service) services.get(serviceQName); + if (service.getPort(port) !=3D null) { + return service.getQName(); + } + } + throw new InvocationException("No service have been defined for po= rtType " + port); + } + + private static org.w3c.dom.Document sendMessage(String nameSpaceURI, Q= Name serviceQName, QName portType, + String operation, Strin= g soapAction, InputStream wsdlDesc, + org.w3c.dom.Document se= ntDoc) throws ServiceException, RemoteException { + org.apache.axis.client.Service service =3D new org.apache.axis.cli= ent.Service(wsdlDesc, serviceQName); + QName portQName =3D portType;//new QName(nameSpaceURI, portType); + Call call =3D (Call)service.createCall(portQName, operation); + call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true)); + if (soapAction !=3D null) call.setProperty(Call.SOAPACTION_URI_PRO= PERTY, soapAction); + + SOAPBodyElement[] input =3D new SOAPBodyElement[1]; + input[0] =3D new SOAPBodyElement(sentDoc.getDocumentElement()); + Vector results =3D (Vector) call.invoke(input); + + org.w3c.dom.Document result =3D null; + try { + result =3D ((SOAPBodyElement) results.get(0)).getAsDocument(); + } catch (Exception e) { + throw new ServiceException(e); + } + return result; + } + + private DOMReader getDOMReader() { + if (domReader =3D=3D null) { + domReader =3D new DOMReader(); + } + return domReader; + } + private DOMWriter getDOMWriter() { + if (domWriter =3D=3D null) { + domWriter =3D new DOMWriter(); + } + return domWriter; + } +} Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/PickAsReceive.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/PickAsRece= ive.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/PickAsReceive.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/PickAsReceive.java Wed Apr 27 13:27:43 20= 05 @@ -0,0 +1,177 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.apache.agila.bpel.engine.exception.EngineException; +import org.apache.agila.bpel.engine.priv.core.definition.CorrelationRef; +import org.apache.agila.bpel.engine.priv.core.definition.MessageEvent; +import org.apache.agila.bpel.engine.priv.core.definition.Pick; +import org.apache.agila.bpel.engine.priv.core.definition.Receive; +import org.apache.agila.bpel.engine.priv.core.definition.StructuredActivit= y; +import org.apache.agila.bpel.engine.priv.core.definition.AgilaProcess; +import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext; +import org.apache.agila.bpel.engine.priv.core.dynamic.PickEC; + +/** + * This class is a wrapper around the MessageEvent of a Pick structured + * activity to use it just as using a Receive. This way our MessageControl= ler + * implementation just consider Receive activities and we don't have to wo= rry + * about always differentiating the two cases : Receive and Pick MessageEv= ent. + * @see org.apache.agila.bpel.engine.priv.messaging.MessageController + * @see org.apache.agila.bpel.engine.priv.core.definition.Receive + * @see org.apache.agila.bpel.engine.priv.core.definition.Pick + * @see org.apache.agila.bpel.engine.priv.core.definition.MessageEvent + */ +public class PickAsReceive implements Receive { + + private Pick pick; + private int eventPos; + + public PickAsReceive(Pick pick, int eventPos) { + this.pick =3D pick; + this.eventPos =3D eventPos; + } + + public Pick getPick() { + return pick; + } + + public int getEventPos() { + return eventPos; + } + + public String getPartner() { + return getMessageEvent(eventPos).getPartnerLink(); + } + + public String getPortType() { + return getMessageEvent(eventPos).getPortType(); + } + + public String getNamespace() { + return getMessageEvent(eventPos).getNamespace(); + } + + public String getOperation() { + return getMessageEvent(eventPos).getOperation(); + } + + public String getVariable() { + return getMessageEvent(eventPos).getVariable(); + } + + public boolean isCreateInstance() { + return pick.isCreateInstance(); + } + + public Collection getCorrelations() { + return getMessageEvent(eventPos).getCorrelations(); + } + + public String getName() { + return pick.getName(); + } + + public ExecutionContext execute(String correlationSetName, Map correla= tion) throws EngineException { + PickEC pickEC =3D (PickEC) pick.execute(correlationSetName, correl= ation); + return new PickECAsReceiveEC(pickEC, eventPos); + } + + public StructuredActivity getContainer() { + return pick; + } + + public AgilaProcess getProcess() { + return null; + } + + public AgilaProcess fetchProcess() { + return pick.fetchProcess(); + } + + public void setPartner(String partner) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setPortType(String portType) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + =20 + public void setNamespace(String namespace) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + =20 + public void setOperation(String operation) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setVariable(String variable) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setCreateInstance(boolean createInstance) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void addCorrelation(CorrelationRef correlationRef) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setName(String name) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public String getJoinCondition() { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setJoinCondition(String expr) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public Set getSourceLinks() { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setSourceLinks(Set sources) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public Set getTargetLinks() { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + public void setTargetLinks(Set targets) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is read only"); + } + + private MessageEvent getMessageEvent(int pos) { + return (MessageEvent) pick.getMessageEvents().get(pos); + } + + public void setReply(boolean reply) { } + + public boolean isReply() { + return false; + } +} Added: incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/a= gila/bpel/engine/priv/messaging/impl/PickECAsReceiveEC.java URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engin= e/core/src/java/org/apache/agila/bpel/engine/priv/messaging/impl/PickECAsRe= ceiveEC.java?rev=3D165042&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/PickECAsReceiveEC.java (added) +++ incubator/agila/trunk/modules/bpel/engine/core/src/java/org/apache/agil= a/bpel/engine/priv/messaging/impl/PickECAsReceiveEC.java Wed Apr 27 13:27:4= 3 2005 @@ -0,0 +1,101 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed 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.agila.bpel.engine.priv.messaging.impl; + +import java.util.Collection; + +import org.dom4j.Document; +import org.apache.agila.bpel.engine.priv.core.definition.Activity; +import org.apache.agila.bpel.engine.priv.core.dynamic.PickEC; +import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance; +import org.apache.agila.bpel.engine.priv.core.dynamic.ReceiveEC; +import org.apache.agila.bpel.engine.priv.core.dynamic.StructuredEC; +import org.apache.agila.bpel.engine.common.monitoring.AuditEntry; + +/** + * Wrapper around a Pick execution context to have it behave like a Receive + * execution context. + * @see PickAsReceive + * @see org.apache.agila.bpel.engine.priv.core.dynamic.PickEC + * @see org.apache.agila.bpel.engine.priv.core.dynamic.ReceiveEC + */ +public class PickECAsReceiveEC implements ReceiveEC { + + private PickEC pickEC; + private int eventPos; + + public PickECAsReceiveEC(PickEC pickEC, int eventPos) { + this.pickEC =3D pickEC; + this.eventPos =3D eventPos; + } + + public Long getId() { + return pickEC.getId(); + } + + public StructuredEC getContainer() { + return pickEC; + } + + public ProcessInstance getInstance() { + return pickEC.getInstance(); + } + + public ProcessInstance fetchInstance() { + return pickEC.fetchInstance(); + } + + public int getStatus() { + return pickEC.getStatus(); + } + + public void execute() { + pickEC.execute(); + } + + public AuditEntry audit() throws Exception { + return pickEC.audit(); + } + + public Document acknowledgeMessage(Document message) { + Activity underlyingActivity =3D (Activity) pickEC.getActivity().ge= tActivities().get(eventPos); + pickEC.acknowledgeMessage(underlyingActivity, message); + return null; + } + + public void setStatus(int status) { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is just a wrapper"); + } + + public Collection getEvents() { + // Useless for our purpose + throw new UnsupportedOperationException("This method shouldn't be = used, this class is just a wrapper"); + } + + public int getEventPos() { + return eventPos; + } + + public void setEventPos(int eventPos) { + this.eventPos =3D eventPos; + } + + public Activity getInitialActivity() { + return null; + } + +}