You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:35:26 UTC
svn commit: r381694 [22/38] - in /incubator/ode/scratch: bpe/ ode/
ode/bpelTests/ ode/bpelTests/probeService/ ode/bpelTests/test1/
ode/bpelTests/test10/ ode/bpelTests/test12/ ode/bpelTests/test13/
ode/bpelTests/test14/ ode/bpelTests/test15/ ode/bpelTes...
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionNotFoundException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionNotFoundException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionNotFoundException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionNotFoundException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 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.ode.definition.service;
+
+
+
+public class DefinitionNotFoundException extends DefinitionServiceException
+{
+ static final long serialVersionUID = 4768400437887752016L;
+ private String m_definitionID;
+ public DefinitionNotFoundException( String definitionID )
+ {
+ super(definitionID);
+ m_definitionID = definitionID;
+ }
+
+ public String getRootDefinitionID( )
+ {
+ return m_definitionID;
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionService.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionService.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionService.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2006 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.
+*/
+/***********************************************************************
+ * Module: DefinitionService.java
+ * Author: waterman
+ * Purpose: Defines the Interface DefinitionService
+ ***********************************************************************/
+
+package org.apache.ode.definition.service;
+
+import java.util.Collection;
+
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+
+public interface DefinitionService
+{
+ /** Acquires a IPMDRoot implementation from the underlying metadata repository.
+ *
+ *
+ * @param definitionKey A unique identifier for a root process defintion. The identifier is unique within the underlying repository. */
+ IPMDRoot getRootDefinition(ProcessDefinitionKey definitionKey) throws BPException;
+ IPMDRoot getRootDefinition(String definitionKey) throws BPException;
+ /** Acquires a IPMDProcess implementation from the underlying metadata repository.
+ *
+ *
+ * @param processKey a unique identifier to a process definition. The identifier is unique to the underlying metadata repository. */
+ IPMDProcess getProcessDefintion(ProcessDefinitionKey processKey, ProcessDefinitionKey rootKey) throws BPException;
+ /** Generates a new definition identifier in the underlying metadata repository and returns a proxy to populate.
+ * <P>
+ * Is used by deployment tooling to populate the metadata repository. From the IPMDRoot_Mutate interface an entire business process definition graph can be populated.
+ *
+ * @param label - the human readable tag is a required field within the metadata repository
+ * @param version - the root version is a required field in the metadata repository
+ * @param isStateless - the stateless identifier is a required field in the metadata repository
+ * @returns a IPMDRoot_Mutate implementation */
+ IPMDRoot createRootDefinition(java.lang.String label, java.lang.String version, boolean isStateless) throws BPException;
+
+ /** Initializes the definition service. The definition service requires a
+ * UUIDService to create business process definitions.
+ *
+ * @param props - initialization properties
+ * @param us - an implementation of the UUIDService
+ */
+ void init(BPEProperties props, UUIDService us) throws BPException;
+
+ /**
+ * This deletes the process definition tree under the rootkey.
+ * @param rootkey
+ */
+ void deleteDefinition(ProcessDefinitionKey rootkey) throws BPException ;
+ void deleteDefinition(String rootKey) throws BPException;
+
+ /** Returns the collection of root definitions being managed by the definition
+ * service
+ */
+ Collection getRootDefinitions() throws BPException;
+
+ /**
+ * Loads a definition and creats it's registriations. If the key in null all registrations are loaded.
+ * @param defname the defintion name
+ * @param cs the correlation service
+ */
+ public void loadDefintion(ProcessDefinitionKey procKey, IProcessCallBack pcb) throws BPException;
+
+ /**
+ * Get the process instance creating correlation definitions.
+ * @param key
+ * @return
+ */
+ public Collection getCorrelations(IStaticKey key) throws BPException;
+
+ /**
+ * Call to syncronize the defintion service with a persistent repository.
+ * @author charper
+ *
+ */
+ public void update() throws BPException;
+
+ /**
+ * Return the BPEProperties object used at initialization
+ *
+ * @return BPEProperties
+ */
+ public BPEProperties getBPEProperties();
+
+ /**
+ * This will release all the external actions associated with this def service.
+ *
+ */
+ public void releaseExternalActions();
+
+ /**
+ * Get a collection of all the non instance creating operations for
+ * a given static key.
+ * @param key
+ * @return
+ */
+ public Collection getNonInstanceCreatingOps(IStaticKey key)throws BPException;
+
+ public void deactivateDefinition(String id) throws BPException;
+
+ public void activateDefinition(String id) throws BPException;
+
+ public void prepare() throws BPException;
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 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.ode.definition.service;
+
+import org.apache.ode.util.BPException;
+
+/**
+ * @author waterman
+ *
+ *
+ *
+ */
+public class DefinitionServiceException extends BPException {
+
+ static final long serialVersionUID = 7442610552746714334L;
+
+
+ /**
+ * @param message_id
+ * @param msgParams
+ */
+ public DefinitionServiceException(String message_id, Object[] msgParams) {
+ super(message_id, msgParams);
+ }
+
+ /**
+ * @param message_id
+ * @param msgParams
+ * @param cause
+ */
+ public DefinitionServiceException(
+ String message_id,
+ Object[] msgParams,
+ Throwable cause) {
+ super(message_id, msgParams, cause);
+ }
+
+ public DefinitionServiceException(String message)
+ {
+ super(message);
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceFactory.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceFactory.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionServiceFactory.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006 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.ode.definition.service;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+import org.apache.ode.uuid.UUIDServiceException;
+
+/** Creates a DefinitionService implementation from a set of properties.
+ * <P>
+ * A DefinitionService is an abstraction over a metedata repository. A DefinitionService implementation may use EJB, JDO, OODMS technologies. The property list will contain repository specific connection paramaters. */
+public class DefinitionServiceFactory
+{
+
+ private static Logger logger =
+ Logger.getLogger(DefinitionServiceFactory.class.getName());
+
+ public static final String TYPE = "TYPE";
+ public static final String TYPE_EJB = "EJB"; // Entity Bean Implementation
+ public static final String TYPE_IM = "IM"; // In Memory Implementation
+ public static final String TYPE_DEFAULT = TYPE_IM;
+
+
+ /** Uses the input properties list to instantiate a DefinitionService implementation.
+ *
+ * @param properties */
+ public static DefinitionService createDefinitionService(BPEProperties props,
+ UUIDService us) throws DefinitionServiceException, UUIDServiceException
+ {
+
+ DefinitionService ds = null;
+
+ try {
+ // load the implementation
+ Class defClass = java.lang.Class.forName(props.getDefinitionServiceClass());
+ // try to instantiate the subclass
+ ds = (DefinitionService) defClass.newInstance();
+ ds.init(props,us);
+
+ } catch (ClassNotFoundException e) {
+ DefinitionServiceException bpx = new DefinitionServiceException("CLASS_NOT_FOUND",new Object[] {props.getEventDirectorClass()});
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (InstantiationException e) {
+ DefinitionServiceException bpx = new DefinitionServiceException("NATIVE_EXCEPTION",new Object[] {"InstantiationException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (IllegalAccessException e) {
+ DefinitionServiceException bpx = new DefinitionServiceException("NATIVE_EXCEPTION",new Object[] {"IllegalAccessException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (BPException e) {
+ throw new DefinitionServiceException("BPE_EXCEPTION",new Object[]{},e);
+ }
+
+ return ds;
+
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionURIResolver.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionURIResolver.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionURIResolver.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/DefinitionURIResolver.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 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.
+*/
+/*
+ * Created on: Oct 31, 2003
+ * Project: BPEELocal
+ * Package: org.apache.ode.definition.service
+ * Author: waterman
+ */
+package org.apache.ode.definition.service;
+
+import org.apache.ode.action.external.IURIResolver;
+import org.apache.ode.definition.IPMDRoot;
+
+/**
+ *
+ *
+ * @author waterman
+ */
+public class DefinitionURIResolver implements IURIResolver {
+
+ private IPMDRoot m_defRoot;
+
+ /**
+ *
+ */
+ public DefinitionURIResolver(IPMDRoot defRoot) {
+ m_defRoot = defRoot;
+ }
+
+ /**
+ * @see org.apache.ode.action.bpel.external.IURIResolver#getArtifact(java.lang.String)
+ */
+ public Object getArtifact(String uri) {
+ return m_defRoot.getSupportingDocument(uri.toLowerCase());
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/managed/ProcessDefinitionBean.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/managed/ProcessDefinitionBean.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/managed/ProcessDefinitionBean.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/managed/ProcessDefinitionBean.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,356 @@
+/*
+ * Copyright 2006 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.ode.definition.service.managed;
+
+import java.io.ByteArrayInputStream;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.apache.ode.bped.EventDirectorFactory;
+import org.apache.ode.bped.IInternalEventDirector;
+import org.apache.ode.client.DescribedValue;
+import org.apache.ode.client.formats.INativeFormat;
+import org.apache.ode.client.spi.interaction.ISPIInteraction;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.deployment.DefinitionKey;
+import org.apache.ode.deployment.ResourceDeployer;
+import org.apache.ode.deployment.bpel.BPELDeploy;
+import org.apache.ode.deployment.bpel.DeploymentException;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.engine.ProcessService;
+import org.apache.ode.event.BPELStaticKey;
+import org.apache.ode.event.LoadDefinitionEvent;
+import org.apache.ode.event.SimpleRequestMessageEvent;
+import org.apache.ode.info.PackageInfo;
+import org.apache.ode.info.PackageInfoHome;
+import org.apache.ode.interaction.spiadapter.SPIAdapterInteraction;
+import org.apache.ode.interaction.spiimpl.MasterInteractionFactory;
+import org.apache.ode.lang.ResourceGetter;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+
+/**
+ * This bean can put and get definitions from the definition service.
+ * @ejb:bean
+ * type="Stateless"
+ * name="ProcessDefinition"
+ * jndi-name="BPE/ProcessDefinition"
+ * view-type="both"
+ * local-jndi-name="BPE/ProcessDefinitionLocal"
+ * @ejb.transaction type="Required"
+ *
+ * @ejb.env-entry
+ * name="UUID_USE_CONNECTOR_KEY"
+ * value="false"
+ * type="java.lang.Boolean"
+ * @ejb.env-entry
+ * name="UUID_CLASS_KEY"
+ * value="org.apache.ode.uuid.EMFUUIDService"
+ * @ejb.env-entry
+ * name="UUID_SIZE_KEY"
+ * value="200"
+ * type="java.lang.Integer"
+ * @ejb.env-entry
+ * name="DEF_CLASS_KEY"
+ * --value="org.apache.ode.definition.enginestateimpl.DefintionServiceEngineStateImpl"
+ * value="org.apache.ode.definition.serialimpl.DefinitionService_SerImpl"
+ * @ejb.env-entry
+ * name="DEF_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="INST_CLASS_KEY"
+ * --value="org.apache.ode.instance.service.enginestateimpl.InstanceServiceEngineStateImpl"
+ * value="org.apache.ode.instance.beanimpl.InstanceServicePersistentImpl"
+ * @ejb.env-entry
+ * name="INST_PERSISTENT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="ED_CLASS_KEY"
+ * value="org.apache.ode.bped.managed.EventDirectorEjbImpl"
+ * @ejb.env-entry
+ * name="CORL_CLASS_KEY"
+ * --value="org.apache.ode.correlation.enginestateimpl.CorrelationServiceEngineStateImpl"
+ * value="org.apache.ode.correlation.managed.CorrelationServiceEjbImpl"
+ * @ejb.env-entry
+ * name="LOCK_CLASS_KEY"
+ * value="org.apache.ode.locking.DBLockingService"
+ * @ejb.env-entry
+ * name="LOCK_HASH_BUCKETS_KEY"
+ * value="1000"
+ * @ejb.env-entry
+ * name="CTX_CLASS_KEY"
+ * value="org.apache.ode.context.ejb.EJBContextService"
+ * @ejb.env-entry
+ * name="BPEL_COMPLIANT_KEY"
+ * value="TRUE"
+ * @ejb.env-entry
+ * name="DEF_SCHEMA_KEY"
+ * value="BPEL4WS.xsd"
+ * @ejb.env-entry
+ * name="SCOPE_CLASS_KEY"
+ * value="org.apache.ode.scope.service.impl.ScopeServiceImpl"
+ *
+ * @ejb.ejb-ref
+ * --ejb-name="EngineState"
+ * ejb-name="EngineStateCoarse"
+ * view-type="local"
+ * ref-name="theEngineState"
+ * @ejb.ejb-ref
+ * ejb-name="BPE_CMPBLOB"
+ * view-type="local"
+ * ref-name="theCMPObjectBean"
+ * @ejb.ejb-ref
+ * ejb-name="RegistrationEntity"
+ * view-type="local"
+ * ref-name="registrationBean"
+ * @ejb.ejb-ref
+ * ejb-name="PackageInfo"
+ * view-type="remote"
+ * ref-name="thePackageInfo"
+ *
+ * @ejb.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * res-type="javax.sql.DataSource"
+ * res-auth="Container"
+ * @jboss.resource-ref
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="java:/jdbc/JavaCache"
+ * @weblogic.resource-description
+ * res-ref-name="jdbc/theDB"
+ * jndi-name="jdbc/JavaCache"
+ *
+ */
+public class ProcessDefinitionBean implements SessionBean {
+
+ static final long serialVersionUID = 8156751383598063747L;
+
+ private static Logger logger =
+ Logger.getLogger(ProcessDefinitionBean.class.getName());
+// private InitialContext context;
+
+ private DefinitionService ds;
+ private IInternalEventDirector ed;
+
+ private static String[] BPETABLES= {"{0}_BPE_CMPBLOB",
+ "{0}_EngineStateCoarse","{0}_RegistrationEntity"};
+ private static String DROP_TABLE = "DROP TABLE ";
+ private static final String DATASOURCE = "java:comp/env/jdbc/theDB";
+ private static final String PKG_INFO = "java:comp/env/thePackageInfo";
+ private static final String TABLE_PREFIX = "TABLE_PREFIX";
+
+
+ /**
+ * @ejb:interface-method
+ */
+ public void undeploy() {
+
+ Connection conn = null;
+ Statement stmt = null;
+ try {
+
+ InitialContext context = new InitialContext();
+
+ // get the table name
+ PackageInfoHome pih =
+ (PackageInfoHome) context.lookup(PKG_INFO);
+ PackageInfo pi = pih.create();
+ String pkgName = pi.getProperties().getProperty(TABLE_PREFIX);
+
+
+ // get the data source, connectin and statement
+ DataSource datasource = (DataSource)context.lookup(DATASOURCE);
+ conn = datasource.getConnection();
+ stmt = conn.createStatement();
+
+ // drop the BPE tables
+ for ( int i = 0; i < BPETABLES.length ; i++ ) {
+ String table = ResourceGetter.getFormatted(BPETABLES[i],
+ new Object[]{ pkgName });
+ stmt.execute(DROP_TABLE + table);
+ }
+
+ }catch ( Exception e ) {
+ throw new EJBException(e.getLocalizedMessage(),e);
+ } if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException se) {
+
+ // Don't really care if there is a problem closing
+ }
+ stmt = null;
+ }
+
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException se) {
+
+ // Don't really care if there is a problem closing
+ }
+ conn = null;
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void fireBootstrap() {
+ try {
+ BPELStaticKey bsk = new BPELStaticKey();
+ bsk.setTargetNamespace("urn:com:sybase:uo:deployService");
+ bsk.setPortType("deployServicePT");
+ bsk.setOperation("deploy");
+ // now create the message
+ SimpleRequestMessageEvent msgEvent =
+ new SimpleRequestMessageEvent();
+ msgEvent.setStaticKey(bsk);
+ DescribedValue dv = new DescribedValue( "", INativeFormat.ATOMIC, new Properties() );
+ ISPIInteraction spi = MasterInteractionFactory.newInstance().createInteraction(dv);
+ SPIAdapterInteraction spiai =
+ new SPIAdapterInteraction( spi );
+
+ msgEvent.setPart("location", spiai );
+
+ ed.sendEvent(msgEvent,true);
+ } catch ( Exception e ) {
+ throw new EJBException(e.getLocalizedMessage(),e);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Collection deploy(String resource,
+ boolean validating, String schemaPath) {
+ try {
+ ResourceDeployer rd = new ResourceDeployer(new BPELDeploy(ds));
+ Collection keys = rd.deployResource(resource,validating,schemaPath);
+ // load all the defs
+ Iterator it = keys.iterator();
+ while ( it.hasNext() ) {
+
+ DefinitionKey defkey = (DefinitionKey)it.next();
+ IPMDRoot rootDef = ds.getRootDefinition(new ProcessDefinitionKey(defkey.getKey()));
+ // load the keys
+ ed.sendEvent(
+ new LoadDefinitionEvent(
+ rootDef.getProcess().getKey().getValue()),
+ true);
+ }
+ return keys;
+ } catch ( Exception e ) {
+ throw new EJBException(e.getLocalizedMessage(),e);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public Collection deploy(byte[] buff, boolean validating, String schemaPath) {
+ Collection keys = null ;
+ ByteArrayInputStream is = new ByteArrayInputStream(buff);
+ BPELDeploy deployer = new BPELDeploy(ds);
+ try {
+ // deploy
+ keys = deployer.deployJar(is, validating, null);
+
+ // load all the defs
+ Iterator it = keys.iterator();
+ while ( it.hasNext() ) {
+
+ DefinitionKey defkey = (DefinitionKey)it.next();
+ IPMDRoot rootDef = ds.getRootDefinition(new ProcessDefinitionKey(defkey.getKey()));
+ // load the keys
+ ed.sendEvent(
+ new LoadDefinitionEvent(
+ rootDef.getProcess().getKey().getValue()),
+ true);
+ }
+
+
+ } catch (DeploymentException e) {
+ logger.log(Level.SEVERE,"",e);
+ } catch (DefinitionServiceException e) {
+ logger.log(Level.SEVERE,"",e);
+ } catch (BPException e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+ return keys;
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void removeDefinition(String id) {
+ try {
+ ds.deleteDefinition(new ProcessDefinitionKey(id));
+ } catch (BPException e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+ }
+
+ /**
+ * @ejb:interface-method
+ */
+ public void setStateless(String id) {
+ try {
+ IPMDRoot root = ds.getRootDefinition(new ProcessDefinitionKey(id));
+ root.setIsStateless(true);
+ } catch (BPException e) {
+ logger.log(Level.SEVERE,"",e);
+ }
+ }
+
+
+ public void ejbCreate(){
+
+ try {
+
+ InitialContext context = new InitialContext();
+ BPEProperties p = new BPEProperties(true,context);
+ ed = (IInternalEventDirector)EventDirectorFactory.createEventDirector(p);
+ ProcessService ps = ed.getProcessService();
+ ds = (DefinitionService)ps.getInstanceService().getDefinitionService();
+
+
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE,"",ex);
+ }
+
+ }
+ public void setSessionContext(SessionContext
+ ctx) {}
+ public void ejbRemove() {ed.release();}
+ public void ejbActivate() {}
+ public void ejbPassivate() {}
+ public void ejbLoad() {}
+ public void ejbStore() {}
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceBase.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceBase.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceBase.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceBase.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.serialimpl.PMDRoot_SerialImpl;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.lang.ResourceGetter;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+
+
+
+public abstract class DefinitionServiceBase
+ implements DefinitionService
+
+{
+ private static Logger logger =
+ Logger.getLogger(DefinitionServiceBase.class.getName());
+ private UUIDService uuidService;
+ private BPEProperties props;
+ protected HashMap defRegistrations = new HashMap();
+ protected HashMap metaNonInstanceCreatingOperations = new HashMap();
+ // Holds PMDProcess_IMImpl instances where ProcessDefinitionKey is the hash key
+ private Hashtable definitions = new Hashtable();
+ private Hashtable newDefinitions = new Hashtable();
+
+ public void init(BPEProperties props, UUIDService us)
+ {
+ this.props = props;
+ this.uuidService = us;
+ }
+
+ // remove the instance creating operations and
+ // meta non intance creating ops.
+ protected void deleteOperations(IPMDRoot root) throws BPException
+ {
+
+ Iterator it = root.getInstanceCreatingOperations().iterator();
+ while (it.hasNext())
+ {
+ IPMDOperation op = (IPMDOperation) it.next();
+ IStaticKey key = op.getKey();
+ ArrayList al = (ArrayList) defRegistrations.get(key.toString());
+ metaNonInstanceCreatingOperations.remove(key.toString());
+ al.remove(op);
+ }
+ }
+
+ public void deleteDefinition(ProcessDefinitionKey rootKey)
+ throws BPException
+ {
+ IPMDRoot root = getRootDefinition(rootKey);
+ deleteOperations(root);
+ root.clearExternalAction();
+ definitions.remove(rootKey);
+ }
+
+ public void loadDefintion(ProcessDefinitionKey procKey, IProcessCallBack pcb)
+ throws BPException
+ {
+ IPMDRoot root = getRootDefinition(procKey);
+ Iterator it = root.getInstanceCreatingOperations().iterator();
+ while (it.hasNext())
+ {
+ IPMDOperation op = (IPMDOperation) it.next();
+ IStaticKey key = op.getKey();
+ ArrayList al = (ArrayList) defRegistrations.get(key.toString());
+ if (al == null)
+ {
+ al = new ArrayList();
+ defRegistrations.put(key.toString(), al);
+ }
+ al.add(op);
+ }
+ it = root.getMetaNonInstanceCreatingOperations().iterator();
+ while (it.hasNext())
+ {
+ IPMDOperation op = (IPMDOperation) it.next();
+ IStaticKey key = op.getKey();
+ ArrayList al = (ArrayList) metaNonInstanceCreatingOperations
+ .get(key.toString());
+ if (al == null)
+ {
+ al = new ArrayList();
+ metaNonInstanceCreatingOperations.put(key.toString(), al);
+ }
+ al.add(op);
+ }
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#getRootDefinition(java.lang.String)
+ */
+ public IPMDRoot getRootDefinition(String definitionKey) throws BPException
+ {
+ return getRootDefinition(new ProcessDefinitionKey(definitionKey));
+ }
+
+ public IPMDRoot getRootDefinition(ProcessDefinitionKey definitionKey)
+ throws BPException
+ {
+ IPMDRoot root = (IPMDRoot) definitions.get(definitionKey);
+ return root;
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#getProcessDefintion(ProcessDefinitionKey)
+ */
+ public IPMDProcess getProcessDefintion(ProcessDefinitionKey processKey,
+ ProcessDefinitionKey rootKey)
+ throws BPException {
+
+ IPMDProcess ret = null;
+
+ // First find the definition root
+ PMDRoot_SerialImpl root = (PMDRoot_SerialImpl)getRootDefinition(rootKey);
+
+ if ( root != null ) {
+ // get the process index from the root
+ HashMap hm = root.getProcessIndex();
+
+ ret = (IPMDProcess)hm.get(processKey);
+ }
+
+
+ return ret;
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#createRootDefinition(String, String, Boolean)
+ */
+ public IPMDRoot createRootDefinition(
+ String label,
+ String version,
+ boolean isStateless)
+ throws BPException {
+
+ // check to see if this label and version exists
+ Iterator it = getRootDefinitions().iterator();
+ ArrayList defsToDelete = new ArrayList();
+ while ( it.hasNext()){
+ PMDRoot_SerialImpl root = (PMDRoot_SerialImpl)it.next();
+ if ( root.getLabel().equals(label) && root.getVersion().equals(version)) {
+ defsToDelete.add(root);
+ }
+ }
+ // delete the defs
+ it = defsToDelete.iterator();
+ while ( it.hasNext()){
+ PMDRoot_SerialImpl root = (PMDRoot_SerialImpl)it.next();
+ logger.log(Level.WARNING,ResourceGetter.getFormatted("DEF_REPLACE",
+ new Object [] {label,version} ));
+ deleteDefinition(root.getProcess().getKey());
+ }
+
+
+ IPMDRoot ret = new PMDRoot_SerialImpl(label,version,isStateless,uuidService,definitions,newDefinitions);
+
+ // this has been moved into the createProcess of PMDRoot_SerialImpl
+ // because we have to index via the root processes id
+ //definitions.put(ret.getKey(),ret);
+ //newDefinitions.put(ret.getKey(),ret);
+
+ return ret;
+ }
+
+ public Collection getRootDefinitions()
+ throws BPException
+ {
+ return definitions.values();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.definition.service.DefinitionService#getCorrelations(org.apache.ode.event.IStaticKey)
+ */
+ public Collection getCorrelations(IStaticKey key) throws BPException {
+
+ Collection corrls = (Collection)defRegistrations.get(key.toString());
+
+ if ( corrls == null ) {
+ return new ArrayList();
+ } else {
+ return corrls;
+ }
+ }
+
+ /**
+ * Return the BPEProperties object used at initialization
+ *
+ * @return BPEProperties
+ */
+ public BPEProperties getBPEProperties() {
+ return props;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.definition.service.DefinitionService#releaseExternalActions()
+ */
+ public void releaseExternalActions() {
+ Iterator it = definitions.values().iterator();
+ while ( it.hasNext() ) {
+ ((IPMDRoot)it.next()).clearExternalAction();
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ode.definition.service.DefinitionService#getNonInstanceCreatingOps(org.apache.ode.event.IStaticKey)
+ */
+ public Collection getNonInstanceCreatingOps(IStaticKey key) throws BPException{
+ getRootDefinitions();
+
+ Collection ops = (Collection)metaNonInstanceCreatingOperations.get(key.toString());
+
+ if ( ops == null ) {
+ return new ArrayList();
+ } else {
+ return ops;
+ }
+ }
+
+ public void deleteDefinition(String rootKey) throws BPException
+ {
+ deleteDefinition( new ProcessDefinitionKey(rootKey));
+ }
+
+ protected void removeCachedDefinition( String id )
+ {
+ definitions.remove(id);
+ }
+
+ protected void addDefinitionToCache(ProcessDefinitionKey key,
+ IPMDRoot root)
+ {
+ definitions.put(key,root);
+ }
+
+ protected void clearDefinitionCache()
+ {
+ definitions.clear();
+ }
+
+ protected Enumeration getNewDefinitionsCache()
+ {
+ return newDefinitions.elements();
+ }
+
+ protected void clearNewDefinitionsCache()
+ {
+ newDefinitions.clear();
+ }
+
+ protected IPMDRoot getDefinitionFromCache(ProcessDefinitionKey
+ definitionKey )
+ {
+ return (IPMDRoot)definitions.get(definitionKey);
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceProxy.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceProxy.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceProxy.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionServiceProxy.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import java.util.Collection;
+//import java.util.logging.Logger;
+
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+
+public class DefinitionServiceProxy implements DefinitionService
+{
+
+// private static Logger logger = Logger
+// .getLogger(DefinitionService_SerImpl.class.getName());
+
+ private DefinitionService delegate = null;
+
+ public DefinitionServiceProxy()
+ {
+
+ }
+
+ private void createDelegate(BPEProperties props, UUIDService us)
+ throws BPException
+ {
+ if (props.getDefinitionServicePersistence().equals("FALSE"))
+ {
+ delegate = new TransientDefinitionService();
+ } else
+ {
+ delegate = new PersistentDefinitionService();
+ }
+ delegate.init(props, us);
+ }
+
+ public void init(BPEProperties props, UUIDService us) throws BPException
+ {
+ createDelegate(props, us);
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#deleteDefinition(ProcessDefinitionKey)
+ */
+ public void deleteDefinition(ProcessDefinitionKey rootKey)
+ throws BPException
+ {
+ delegate.deleteDefinition(rootKey);
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#getRootDefinition(java.lang.String)
+ */
+ public IPMDRoot getRootDefinition(String definitionKey) throws BPException
+ {
+ return delegate.getRootDefinition(definitionKey);
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#getRootDefinition(ProcessDefinitionKey)
+ */
+ public IPMDRoot getRootDefinition(ProcessDefinitionKey definitionKey)
+ throws BPException
+ {
+ return delegate.getRootDefinition(definitionKey);
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#getProcessDefintion(ProcessDefinitionKey)
+ */
+ public IPMDProcess getProcessDefintion(ProcessDefinitionKey processKey,
+ ProcessDefinitionKey rootKey) throws BPException
+ {
+ return delegate.getProcessDefintion(processKey, rootKey);
+ }
+
+ /**
+ * @see org.apache.ode.definition.service.DefinitionService#createRootDefinition(String,
+ * String, Boolean)
+ */
+ public IPMDRoot createRootDefinition(String label, String version,
+ boolean isStateless) throws BPException
+ {
+
+ return delegate.createRootDefinition(label, version, isStateless);
+ }
+
+ public void update() throws DefinitionServiceException
+ {
+ try
+ {
+ delegate.update();
+ } catch (BPException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.ode.definition.service.DefinitionService#getRootDefinitions()
+ */
+ public Collection getRootDefinitions() throws BPException
+ {
+
+ return delegate.getRootDefinitions();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.ode.definition.service.DefinitionService#loadDefintion(java.lang.String,
+ * org.apache.ode.correlation.CorrelationService)
+ */
+ public void loadDefintion(ProcessDefinitionKey procKey, IProcessCallBack pcb)
+ throws BPException
+ {
+ delegate.loadDefintion(procKey, pcb);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.ode.definition.service.DefinitionService#getCorrelations(org.apache.ode.event.IStaticKey)
+ */
+ public Collection getCorrelations(IStaticKey key) throws BPException
+ {
+
+ return delegate.getCorrelations(key);
+ }
+
+ /**
+ * Return the BPEProperties object used at initialization
+ *
+ * @return BPEProperties
+ */
+ public BPEProperties getBPEProperties()
+ {
+ return delegate.getBPEProperties();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.ode.definition.service.DefinitionService#releaseExternalActions()
+ */
+ public void releaseExternalActions()
+ {
+ delegate.releaseExternalActions();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.ode.definition.service.DefinitionService#getNonInstanceCreatingOps(org.apache.ode.event.IStaticKey)
+ */
+ public Collection getNonInstanceCreatingOps(IStaticKey key)
+ throws BPException
+ {
+ return delegate.getNonInstanceCreatingOps(key);
+ }
+
+ public void deactivateDefinition(String id) throws BPException
+ {
+ delegate.deactivateDefinition(id);
+ }
+
+ public void activateDefinition(String id) throws BPException
+ {
+ delegate.activateDefinition(id);
+ }
+
+ public void deleteDefinition(String rootKey) throws BPException
+ {
+ delegate.deleteDefinition(rootKey);
+ }
+
+ public void prepare()
+ {
+ try
+ {
+ delegate.prepare();
+ } catch (BPException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateCache.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateCache.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateCache.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateCache.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ode.engine.ProcessDefinitionKey;
+
+/**
+ * This cache was added to improve performance on EAServer.
+ * Without this cache a call to the cmp layer was required
+ * for each service request. Even though the cmp caches
+ * the database data when possible, the component invocation
+ * is expensive nonetheless.
+ *
+ * This cache synchronizes the definition state for a single
+ * JVM. In a multiple JVM scenario ( e.g. cluster ), the
+ * clusterred nodes will not see the same cache and the caches
+ * may consequently become out of sync.
+ *
+ * TODO: Document the procedure for changing definition state
+ * in a cluster. Possibly introduce a clusterred caching mode
+ * which hits the cmp layer for each transaction when
+ * the application is running in a cluster.
+ *
+ */
+public class DefinitionStateCache
+{
+ //TODO: move this to an application-local storage location
+ // for performance reasons. Even though several applications
+ // share this cache there is no chance of conflict since
+ // the cache is indexed by a guid.
+ private static Map definitionStateCache =
+ Collections.synchronizedMap(new HashMap());
+
+ public static DefinitionStateEnum getState(
+ ProcessDefinitionKey key)
+ {
+ DefinitionStateEnum definitionState =
+ ( DefinitionStateEnum )
+ definitionStateCache.get(key);
+
+ return definitionState;
+ }
+
+ public static void setState(ProcessDefinitionKey key,
+ DefinitionStateEnum state)
+ {
+ definitionStateCache.put(key, state);
+ }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateEnum.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateEnum.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateEnum.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DefinitionStateEnum.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import java.io.Serializable;
+
+public class DefinitionStateEnum implements Serializable
+{
+
+ static final long serialVersionUID = 7736643918829506957L;
+
+ private DefinitionStateEnum(int state)
+ {
+ mState = state;
+ }
+
+ public int intValue()
+ {
+ return mState;
+ }
+
+ public static DefinitionStateEnum getState(int state)
+ {
+ return states[state];
+ }
+
+ private final int mState;
+ private static final int ACTIVE_CONST = 0;
+ private static final int INACTIVE_CONST = 1;
+ private static final int UNKNOWN_CONST = 2;
+ public static final DefinitionStateEnum ACTIVE = new DefinitionStateEnum(
+ ACTIVE_CONST);
+ public static final DefinitionStateEnum INACTIVE = new DefinitionStateEnum(
+ INACTIVE_CONST);
+ public static final DefinitionStateEnum UNKNOWN = new DefinitionStateEnum(
+ UNKNOWN_CONST);
+ public static final DefinitionStateEnum states[] =
+ { ACTIVE, INACTIVE, UNKNOWN };
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DropTables.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DropTables.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DropTables.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/DropTables.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 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.
+*/
+/*
+ * Created on Apr 12, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.apache.ode.definition.service.unmanaged;
+
+import javax.naming.InitialContext;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.ode.definition.service.managed.ProcessDefinition;
+import org.apache.ode.definition.service.managed.ProcessDefinitionHome;
+
+/**
+ * @author charper
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class DropTables {
+
+ public static void main(String[] args) throws Exception {
+
+ if ( args.length != 1 ) {
+ System.out.println("Usage: DropTables [bpe pkg name]");
+ return;
+ }
+ // get the interface
+ InitialContext ic = new InitialContext();
+
+ Object o = ic.lookup(args[0]+"/ProcessDefinition");
+ ProcessDefinitionHome pdHome = (ProcessDefinitionHome) PortableRemoteObject
+ .narrow(o, ProcessDefinitionHome.class);
+ // get a bean
+ ProcessDefinition pd = pdHome.create();
+
+ pd.undeploy();
+
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/PersistentDefinitionService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/PersistentDefinitionService.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/PersistentDefinitionService.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/PersistentDefinitionService.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,422 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.FinderException;
+import javax.ejb.RemoveException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.ode.context.ejb.BPE_ObjectLocal;
+import org.apache.ode.context.ejb.BPE_ObjectLocalHome;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.serialimpl.PMDOperation_SerialImpl;
+import org.apache.ode.definition.service.DefinitionNotFoundException;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.event.IStaticKey;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+
+
+
+/**
+ * This definition service implementation relies on a CMP
+ * backing store for persistence.
+ * For performance reasons the definitions
+ * and operations are cached whenever possible. When the
+ * defintions or operations are modified the cache is refreshed
+ * and the changes are persisted to the CMP layer.
+ *
+ * Read access to definitions and operations is performed
+ * via a cache lookup whenever possible. The class uses a
+ * prepared indicator called by the engine to indicate that
+ * message routing has begun and that all definitions should
+ * be loaded in the cache.
+ *
+ * TODO: We should eventually use an application-local variable
+ * to store the defintion cache so that cache synchronization
+ * between the definition service instances in the same
+ * application is not necessary.
+ */
+public class PersistentDefinitionService
+ extends DefinitionServiceBase
+{
+ private static Logger logger =
+ Logger.getLogger(PersistentDefinitionService.class.getName());
+
+ private boolean prepared = false;
+ private static final String JNDI_BLOB_NAME =
+ "java:comp/env/theCMPObjectBean";
+ private static final String DEF_REGS_BLOB_NAME =
+ "instanceCreatingRegistrations";
+ private static final String NON_INST_BLOB_NAME =
+ "metaNonInstanceCreatingOperations";
+ private BPE_ObjectLocal regsBlob;
+ private BPE_ObjectLocal nonInstBlob;
+
+
+ public PersistentDefinitionService()
+ {
+ super();
+ }
+
+ public void init(BPEProperties props, UUIDService us)
+ {
+ super.init( props, us );
+ try
+ {
+ InitialContext ic = new InitialContext();
+ BPE_ObjectLocalHome blobHome = (BPE_ObjectLocalHome) ic
+ .lookup(JNDI_BLOB_NAME);
+ try
+ {
+ regsBlob = blobHome.findByPrimaryKey(DEF_REGS_BLOB_NAME);
+ } catch (FinderException e1)
+ {
+ regsBlob = blobHome
+ .create(DEF_REGS_BLOB_NAME, defRegistrations);
+ } catch (EJBException e2)
+ {
+ logger.log(Level.SEVERE, "", e2);
+ }
+ try
+ {
+ nonInstBlob = blobHome.findByPrimaryKey(NON_INST_BLOB_NAME);
+ } catch (FinderException e1)
+ {
+ nonInstBlob = blobHome.create(NON_INST_BLOB_NAME,
+ metaNonInstanceCreatingOperations);
+ } catch (EJBException e2)
+ {
+ logger.log(Level.SEVERE, "", e2);
+ }
+ } catch (NamingException e)
+ {
+ logger.log(Level.SEVERE, "", e);
+ } catch (CreateException e)
+ {
+ logger.log(Level.SEVERE, "", e);
+ }
+
+ }
+
+ public IPMDRoot createRootDefinition(String label, String version,
+ boolean isStateless) throws BPException
+ {
+ refreshCachedMetadata();
+ IPMDRoot retVal = super.createRootDefinition(label, version,
+ isStateless);
+ persistCachedMetadata();
+ return retVal;
+ }
+
+ public void loadDefintion(ProcessDefinitionKey procKey,
+ IProcessCallBack pcb) throws BPException
+ {
+ refreshCachedMetadata();
+ super.loadDefintion(procKey, pcb);
+ persistCachedMetadata();
+ }
+
+ public void deleteDefinition(ProcessDefinitionKey rootKey)
+ throws BPException
+ {
+ refreshCachedMetadata();
+ super.deleteDefinition(rootKey);
+ try
+ {
+ BPE_ObjectLocal blobProxy = getBlob(rootKey.getValue());
+ if (blobProxy != null)
+ {
+ blobProxy.remove();
+ }
+ } catch (RemoveException re)
+ {
+ DefinitionServiceException bpx = new DefinitionServiceException(
+ "NATIVE_EXCEPTION", new Object[]
+ { "RemoveException" }, re);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ persistCachedMetadata();
+ }
+
+ public Collection getCorrelations(IStaticKey key) throws BPException
+ {
+ if ( shouldRefreshCache() )
+ {
+ refreshCachedMetadata();
+ }
+ return super.getCorrelations(key);
+ }
+
+ public IPMDRoot getRootDefinition(ProcessDefinitionKey definitionKey)
+ throws BPException
+ {
+ IPMDRoot root = getDefinitionFromCache( definitionKey );
+ if ( root == null )
+ {
+ BPE_ObjectLocalHome blobHome = null;
+
+ try
+ {
+ InitialContext ic = new InitialContext();
+ blobHome = (BPE_ObjectLocalHome) ic.lookup(JNDI_BLOB_NAME);
+ }
+ catch ( NamingException ne)
+ {
+ DefinitionServiceException bpx =
+ new DefinitionServiceException("NATIVE_EXCEPTION",new Object[]
+ {"NamingException"},ne);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+
+ try
+ {
+ BPE_ObjectLocal blobProxy =
+ blobHome.findByPrimaryKey(definitionKey.getValue());
+
+ root = (IPMDRoot)blobProxy.getObjectForRead();
+
+ addDefinitionToCache(definitionKey, root);
+
+ } catch ( FinderException fe) {
+ root = null;
+ }
+ }
+ return root;
+ }
+
+ /**
+ * Called by the engine prior to routing a message. This gives
+ * the definition service an indication that the definition
+ * creation phase should be complete and that the
+ * complete set of deployed definitions is now available
+ * in the database.
+ */
+ public void prepare() throws BPException
+ {
+ if ( shouldRefreshCache() )
+ {
+ refreshCachedMetadata();
+ prepared=true;
+ }
+ }
+
+ public Collection getRootDefinitions()
+ throws BPException
+ {
+ if ( shouldRefreshCache())
+ {
+ refreshCachedMetadata();
+ }
+
+ return super.getRootDefinitions();
+ }
+
+ public void deactivateDefinition(String id) throws BPException
+ {
+ setDefinitionState(id, DefinitionStateEnum.INACTIVE);
+ }
+
+ public void activateDefinition(String id) throws BPException
+ {
+ setDefinitionState(id, DefinitionStateEnum.ACTIVE);
+ }
+
+ public void update() throws BPException
+ {
+ persistCachedMetadata();
+ }
+
+ protected void persistCachedOperations()
+ {
+ regsBlob.setObject(defRegistrations);
+ nonInstBlob.setObject(metaNonInstanceCreatingOperations);
+ }
+
+ protected void deleteOperations(IPMDRoot root) throws BPException
+ {
+ super.deleteOperations(root);
+ persistCachedOperations();
+ }
+
+ private BPE_ObjectLocal getBlob(String blobID)
+ throws DefinitionServiceException
+ {
+ BPE_ObjectLocalHome blobHome = null;
+ try
+ {
+ InitialContext ic = new InitialContext();
+ blobHome = (BPE_ObjectLocalHome) ic.lookup(JNDI_BLOB_NAME);
+ BPE_ObjectLocal blobProxy = blobHome.findByPrimaryKey(blobID);
+ return blobProxy;
+
+ } catch (NamingException ne)
+ {
+ DefinitionServiceException bpx = new DefinitionServiceException(
+ "NATIVE_EXCEPTION", new Object[]
+ { "NamingException" }, ne);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (FinderException e)
+ {
+ return null;
+ }
+ }
+
+ private void persistCachedMetadata() throws BPException
+ {
+ persistNewDefinitions();
+ persistCachedOperations();
+ }
+
+ private void persistNewDefinitions() throws BPException
+ {
+ try
+ {
+ InitialContext ic = new InitialContext();
+
+ BPE_ObjectLocalHome blobHome = (BPE_ObjectLocalHome) ic
+ .lookup(JNDI_BLOB_NAME);
+
+ // Write new definitions in to the DB
+ Enumeration e = getNewDefinitionsCache();
+ while (e.hasMoreElements())
+ {
+ IPMDRoot rbi = (IPMDRoot) e.nextElement();
+
+ blobHome.create(rbi.getProcess().getKey().getValue(), rbi);
+ }
+
+ regsBlob.setObject(defRegistrations);
+ nonInstBlob.setObject(metaNonInstanceCreatingOperations);
+ // clear the new definitions now that they are in the DB
+ clearNewDefinitionsCache();
+
+ } catch (NamingException e)
+ {
+ DefinitionServiceException bpx = new DefinitionServiceException(
+ "NATIVE_EXCEPTION", new Object[]
+ { "NamingException" }, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ } catch (CreateException e)
+ {
+ DefinitionServiceException bpx = new DefinitionServiceException(
+ "NATIVE_EXCEPTION", new Object[]
+ { "CreateException" }, e);
+ bpx.log(logger, Level.SEVERE);
+ throw bpx;
+ }
+ }
+
+
+ private void refreshCachedMetadata() throws BPException
+ {
+ refreshCachedOperations();
+ refreshCachedDefinitions();
+
+ }
+
+ private boolean shouldRefreshCache()
+ {
+ return !prepared;
+ }
+
+ private void refreshCachedDefinitions() throws BPException
+ {
+ clearDefinitionCache();
+ HashSet rootDefIds = new HashSet();
+ Iterator it = defRegistrations.values().iterator();
+ while (it.hasNext())
+ {
+ ArrayList al = (ArrayList) it.next();
+ Iterator it2 = al.iterator();
+ while (it2.hasNext())
+ {
+ PMDOperation_SerialImpl op = (PMDOperation_SerialImpl) it2.next();
+ rootDefIds.add(op.getRootDefId());
+ }
+ }
+
+ // load all the defs
+ it = rootDefIds.iterator();
+ while (it.hasNext())
+ {
+ String id = (String) it.next();
+ getRootDefinition(new ProcessDefinitionKey(id));
+ }
+ }
+
+ private void refreshCachedOperations()
+ {
+ InitialContext ic;
+ try
+ {
+ ic = new InitialContext();
+ BPE_ObjectLocalHome blobHome = (BPE_ObjectLocalHome) ic
+ .lookup(JNDI_BLOB_NAME);
+ // We have to lookup the entities in each new transaction
+ // because EAS requires this. Otherwise transaction errors
+ // occur when multiple client threads are running.
+ nonInstBlob = blobHome.findByPrimaryKey(NON_INST_BLOB_NAME);
+ regsBlob = blobHome.findByPrimaryKey(DEF_REGS_BLOB_NAME);
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ metaNonInstanceCreatingOperations = (HashMap) nonInstBlob
+ .getObjectForRead();
+
+ defRegistrations = (HashMap) regsBlob.getObjectForRead();
+ }
+
+ private IPMDRoot getRootDefinitionForUpdate( String rootDefinitionID)
+ throws DefinitionServiceException
+ {
+ BPE_ObjectLocal defBlob = getBlob( rootDefinitionID );
+ if ( defBlob == null )
+ {
+ throw new DefinitionNotFoundException( rootDefinitionID );
+ }
+ return ( IPMDRoot )( defBlob.getObjectForReadWrite());
+ }
+
+ private void setDefinitionState( String id,
+ DefinitionStateEnum state ) throws BPException
+ {
+ IPMDRoot rootDef = getRootDefinitionForUpdate( id );
+ rootDef.setState( state.intValue() );
+ removeCachedDefinition(id);
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/TransientDefinitionService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/TransientDefinitionService.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/TransientDefinitionService.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/unmanaged/TransientDefinitionService.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 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.ode.definition.service.unmanaged;
+
+import org.apache.ode.util.BPException;
+
+
+public class TransientDefinitionService extends DefinitionServiceBase
+{
+ public TransientDefinitionService()
+ {
+ super();
+ }
+
+ public void update() throws BPException
+ {
+ }
+
+ public void deactivateDefinition(String id) throws BPException
+ {
+ }
+
+ public void activateDefinition(String id) throws BPException
+ {
+ }
+
+ public void prepare() throws BPException
+ {
+ }
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2006 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.
+*/
+/*
+ * Created on Aug 28, 2003
+ *
+ */
+package org.apache.ode.definition.service.viewer;
+
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collection;
+import java.util.Iterator;
+//import java.util.Properties;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.ode.bped.DeployTypeEnum;
+import org.apache.ode.bped.EventDirector;
+import org.apache.ode.bped.EventDirectorFactory;
+import org.apache.ode.bped.IDeployer;
+import org.apache.ode.bped.IInternalEventDirector;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.serialimpl.PMDRoot_SerialImpl;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.deployment.DefinitionKey;
+
+/**
+ * @author charper
+ *
+ */
+public class DefViewer extends JPanel {
+
+ static final long serialVersionUID = 4444550675865822961L;
+
+ public static void main(String[] args) {
+
+ DefViewer viewer = new DefViewer(args[0]);
+ JFrame f = new JFrame ("Def Tree");
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ f.getContentPane().add (viewer, BorderLayout.CENTER);
+ f.setSize (300, 100);
+ f.show();
+
+ }
+
+ DefViewer(String filename) {
+
+ try {
+ DefinitionService ds = load(filename);
+
+ // Set the layout to hold only one component
+ setLayout(new BorderLayout());
+
+ // Create root node of tree
+ DefaultMutableTreeNode treeRoot =
+ new DefaultMutableTreeNode("Definitions");
+
+ Collection rootdefs = ds.getRootDefinitions();
+ Iterator it = rootdefs.iterator();
+ while ( it.hasNext() ) {
+ IPMDRoot rootdef = (IPMDRoot)it.next();
+ // Create 1st level child
+ DefaultMutableTreeNode level1 =
+ new DefaultMutableTreeNode("IPMDRoot:"+rootdef.getLabel());
+ treeRoot.add(level1);
+
+ IPMDProcess rootProc = rootdef.getProcess();
+ DefaultMutableTreeNode level2 =
+ new DefaultMutableTreeNode("IPMDProcess:"+rootProc.getLabel());
+ level1.add(level2);
+ addChangeConditions(level2,rootProc);
+ addProcess(level2,rootProc);
+
+ DefaultMutableTreeNode level3 =
+ new DefaultMutableTreeNode("All Procs for IPMDRoot:"+rootdef.getLabel());
+ treeRoot.add(level3);
+
+
+ Iterator it2 = ((PMDRoot_SerialImpl)rootdef).getProcessIndex().values().iterator();
+ while ( it2.hasNext()){
+ IPMDProcess proc = (IPMDProcess)it2.next();
+ DefaultMutableTreeNode level4 =
+ new DefaultMutableTreeNode("IPMDProcess:"+proc.getLabel());
+ level3.add(level4);
+ addChangeConditions(level4,proc);
+ addProcess(level4,proc);
+ }
+
+ DefaultMutableTreeNode level5 =
+ new DefaultMutableTreeNode("Instance Creating Ops");
+ level1.add(level5);
+ Iterator it3 = ((PMDRoot_SerialImpl)rootdef).getInstanceCreatingOperations().iterator();
+ while ( it3.hasNext()){
+ IPMDOperation op = (IPMDOperation)it3.next();
+ DefaultMutableTreeNode level6 =
+ new DefaultMutableTreeNode("IPMDOperation:"+op.getOperationId());
+ level5.add(level6);
+
+ }
+
+
+ }
+
+ // Create a tree from the root
+ JTree tree = new JTree(treeRoot);
+
+ // Place tree in JScrollPane
+ JScrollPane pane = new JScrollPane(tree);
+
+ add(pane, BorderLayout.CENTER);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ private DefinitionService load(String filename){
+
+ try {
+ File defJar = new File(filename);
+
+ // get an event director so we can send messages and load definitions
+ EventDirector ed;
+ ed = EventDirectorFactory.createEventDirector();
+
+ // get a bpel deployer which we can use to load and delete defintions
+ IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
+
+ // load the defintion
+ Collection keys =
+ deployer.loadDefinition(new FileInputStream(defJar), false);
+ // we get a key for each definition deployed, so let's print them out
+ Iterator it = keys.iterator();
+ while (it.hasNext()) {
+ DefinitionKey key = (DefinitionKey) it.next();
+ System.out.println(
+ "Id for deployed defintion "
+ + key.getLabel()
+ + " is "
+ + key.getKey());
+ // if this is not remote we want to make sure the process is stateless
+
+ deployer.setStateless(key.getKey());
+
+ return ((IInternalEventDirector)ed).getProcessService().getInstanceService().getDefinitionService();
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private void addProcess(DefaultMutableTreeNode level, IPMDProcess rootProc){
+ Iterator it2 = rootProc.getObserverProcessPC();
+ while ( it2.hasNext() ) {
+ IPMDProcess proc = (IPMDProcess)it2.next();
+ DefaultMutableTreeNode procObserverlevel =
+ new DefaultMutableTreeNode("IPMDProcess:"+proc.getLabel());
+ level.add(procObserverlevel);
+ addChangeConditions(procObserverlevel,proc);
+ addProcess(procObserverlevel,proc);
+ }
+ }
+
+ private void addChangeConditions(DefaultMutableTreeNode level, IPMDProcess proc) {
+ Iterator it = proc.getChangeConditions();
+ while ( it.hasNext()){
+ IPMDChangeCondition cc = (IPMDChangeCondition) it.next();
+ DefaultMutableTreeNode CClevel =
+ new DefaultMutableTreeNode("IPMDChangeCondition:"+proc.getLabel());
+ addActions(CClevel,cc);
+ level.add(CClevel);
+ }
+ IPMDChangeCondition pc = proc.getPrecondition();
+ if ( pc != null ) {
+ DefaultMutableTreeNode CClevel =
+ new DefaultMutableTreeNode("IPMDChangeCondition(PreCond):"+proc.getLabel());
+ addActions(CClevel,pc);
+ level.add(CClevel);
+ }
+ }
+
+ private void addActions(DefaultMutableTreeNode cclevel, IPMDChangeCondition cc){
+ Iterator it2 = cc.getActions();
+ while ( it2.hasNext() ) {
+ IPMDAction action = (IPMDAction)it2.next();
+ DefaultMutableTreeNode level =
+ new DefaultMutableTreeNode("IPMDAction:"+action.getActionClass());
+ cclevel.add(level);
+ }
+ }
+
+// private void addProps(DefaultMutableTreeNode actlevel, IPMDAction act){
+// Properties props = act.getMetadata();
+// }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer2.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer2.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer2.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/definition/service/viewer/DefViewer2.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2006 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.
+*/
+/*
+ * Created on Aug 28, 2003
+ *
+ */
+package org.apache.ode.definition.service.viewer;
+
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+//import java.util.Properties;
+import java.util.Vector;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.ode.action.bpel.MergeAction;
+import org.apache.ode.action.bpel.StartScopeAction;
+import org.apache.ode.action.bpel.StartSequenceAction;
+import org.apache.ode.action.bpel.XPathJaxenExpression;
+import org.apache.ode.action.bpel.XPathSwitchAction;
+import org.apache.ode.action.bpel.XPathSwitchTuple;
+import org.apache.ode.bped.DeployTypeEnum;
+import org.apache.ode.bped.EventDirector;
+import org.apache.ode.bped.EventDirectorFactory;
+import org.apache.ode.bped.IDeployer;
+import org.apache.ode.bped.IInternalEventDirector;
+import org.apache.ode.definition.IPMDAction;
+import org.apache.ode.definition.IPMDChangeCondition;
+import org.apache.ode.definition.IPMDOperation;
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.serialimpl.PMDRoot_SerialImpl;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.deployment.DefinitionKey;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.util.BPException;
+
+/**
+ * @author charper
+ *
+ */
+public class DefViewer2 extends JPanel {
+
+ static final long serialVersionUID = 4444550675865822961L;
+
+ IPMDRoot rootdef;
+ DefinitionService ds;
+
+ public static void main(String[] args) {
+
+ DefViewer2 viewer = new DefViewer2(args[0],null);
+ JFrame f = new JFrame ("Def Tree");
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ f.getContentPane().add (viewer, BorderLayout.CENTER);
+ f.setSize (300, 100);
+ f.show();
+
+ }
+
+ public static void show(DefinitionService ds) {
+
+ }
+
+ DefViewer2(String filename, DefinitionService defService) {
+
+ try {
+
+ if ( defService == null ) {
+ ds = load(filename);
+ } else {
+ ds = defService;
+ }
+
+ // Set the layout to hold only one component
+ setLayout(new BorderLayout());
+
+ // Create root node of tree
+ DefaultMutableTreeNode treeRoot =
+ new DefaultMutableTreeNode("Definitions");
+
+ Collection rootdefs = ds.getRootDefinitions();
+ Iterator it = rootdefs.iterator();
+ while ( it.hasNext() ) {
+ rootdef = (IPMDRoot)it.next();
+ // Create 1st level child
+ DefaultMutableTreeNode level1 =
+ new DefaultMutableTreeNode("Root Definition:"+rootdef.getLabel());
+ treeRoot.add(level1);
+
+ IPMDProcess rootProc = rootdef.getProcess();
+ addProcess("Root Proccess",level1,rootProc);
+
+ DefaultMutableTreeNode level5 =
+ new DefaultMutableTreeNode("Instance Creating Ops");
+ level1.add(level5);
+ Iterator it3 = ((PMDRoot_SerialImpl)rootdef).getInstanceCreatingOperations().iterator();
+ while ( it3.hasNext()){
+ IPMDOperation op = (IPMDOperation)it3.next();
+ DefaultMutableTreeNode level6 =
+ new DefaultMutableTreeNode("IPMDOperation:"+op.getOperationId());
+ level5.add(level6);
+
+ }
+
+
+ }
+
+ // Create a tree from the root
+ JTree tree = new JTree(treeRoot);
+
+ // Place tree in JScrollPane
+ JScrollPane pane = new JScrollPane(tree);
+
+ add(pane, BorderLayout.CENTER);
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+ private DefinitionService load(String filename){
+
+ try {
+ File defJar = new File(filename);
+
+ // get an event director so we can send messages and load definitions
+ EventDirector ed;
+ ed = EventDirectorFactory.createEventDirector();
+
+ // get a bpel deployer which we can use to load and delete defintions
+ IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
+
+ // load the defintion
+ Collection keys =
+ deployer.loadDefinition(new FileInputStream(defJar), false);
+ // we get a key for each definition deployed, so let's print them out
+ Iterator it = keys.iterator();
+ while (it.hasNext()) {
+ DefinitionKey key = (DefinitionKey) it.next();
+ System.out.println(
+ "Id for deployed defintion "
+ + key.getLabel()
+ + " is "
+ + key.getKey());
+ // if this is not remote we want to make sure the process is stateless
+
+ deployer.setStateless(key.getKey());
+ }
+ return ((IInternalEventDirector)ed).getProcessService().getInstanceService().getDefinitionService();
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private void addProcess(String type, DefaultMutableTreeNode level, IPMDProcess rootProc) throws BPException{
+ DefaultMutableTreeNode procLevel =
+ new DefaultMutableTreeNode(type);
+ level.add(procLevel);
+ addChangeConditions(procLevel,rootProc);
+ Iterator it2 = rootProc.getObserverProcessPC();
+ while ( it2.hasNext() ) {
+ IPMDProcess proc = (IPMDProcess)it2.next();
+ addProcess("Observer Process"+" "+ proc.getLabel(),procLevel,proc);
+ }
+ }
+
+ private void addChangeConditions(DefaultMutableTreeNode level, IPMDProcess proc) throws BPException {
+
+ IPMDChangeCondition pc = proc.getPrecondition();
+// String precon = "";
+ if ( pc != null ) {
+ DefaultMutableTreeNode CClevel =
+ new DefaultMutableTreeNode("PC:"+
+ getClass(pc.getConditionalClass())
+ +" - Actions:"+listActions(pc));
+ addActions(CClevel,pc,proc);
+ level.add(CClevel);
+ }
+ Iterator it = proc.getChangeConditions();
+ while ( it.hasNext()){
+ IPMDChangeCondition cc = (IPMDChangeCondition) it.next();
+ DefaultMutableTreeNode CClevel =
+ new DefaultMutableTreeNode(
+ "CC:"+getClass(
+ cc.getConditionalClass())+" - Actions:"+listActions(cc));
+ addActions(CClevel,cc,proc);
+ level.add(CClevel);
+ }
+
+ }
+
+ private String getClass(String clazz){
+ String[] str = clazz.split("\\.");
+ return str[str.length-1];
+ }
+
+ private String listActions(IPMDChangeCondition cc){
+ StringBuffer actions = new StringBuffer();
+ Iterator it2 = cc.getActions();
+ while ( it2.hasNext() ) {
+ IPMDAction action = (IPMDAction)it2.next();
+ actions.append(getClass(action.getActionClass()));
+ if ( action.getActionClass().equals("org.apache.ode.action.bpel.MergeAction")) {
+ actions.append("(Threads to join:"+action.getMetadata()
+ .getProperty(MergeAction.THREAD_COUNT_KEY)+")");
+ }
+ if (it2.hasNext()){
+ actions.append(",");
+ }
+ }
+ return actions.toString();
+ }
+
+ private void addActions(DefaultMutableTreeNode cclevel, IPMDChangeCondition cc,
+ IPMDProcess observerProc) throws BPException{
+ Iterator it2 = cc.getActions();
+ while ( it2.hasNext() ) {
+ IPMDAction action = (IPMDAction)it2.next();
+ if ( action.getActionClass().equals("org.apache.ode.action.bpel.StartSequenceAction") ) {
+ ProcessDefinitionKey startKey = (ProcessDefinitionKey)action.getMetadata().get(StartSequenceAction.START_DEF_KEY);
+ IPMDProcess proc = (IPMDProcess)((PMDRoot_SerialImpl)rootdef).getProcessIndex().get(
+ startKey);
+ XPathJaxenExpression exp = (XPathJaxenExpression)(action.getMetadata().get(StartSequenceAction.JOIN_EXPRESSION_KEY));
+ String expStr = exp == null ? "true" : exp.getSourceExpression();
+ addProcess("Process by StartSequenceAction("+
+ expStr+")"+" "+ proc.getLabel(),cclevel,proc);
+ } else if (action.getActionClass().equals("org.apache.ode.action.bpel.XPathSwitchAction") ) {
+ ProcessDefinitionKey defaultKey = (ProcessDefinitionKey)action.getMetadata().get(XPathSwitchAction.DEFAULT_KEY);
+ IPMDProcess proc = (IPMDProcess)((PMDRoot_SerialImpl)rootdef).
+ getProcessIndex().get(defaultKey);
+ addProcess("Process by XPathSwitchAction(default)"+" "+ proc.getLabel(),cclevel,proc);
+ Vector cases = (Vector)action.getMetadata().get(XPathSwitchAction.CASES_KEY);
+ for ( Iterator i = cases.iterator(); i.hasNext(); ) {
+ XPathSwitchTuple st = (XPathSwitchTuple)i.next();
+ IPMDProcess proc2 = (IPMDProcess)((PMDRoot_SerialImpl)rootdef)
+ .getProcessIndex().get(st.getKey());
+ addProcess("Process by XPathSwitchAction("
+ +st.getExpression().getExpression()+")"+" "+ proc.getLabel(),cclevel,proc2);
+ }
+ } else if ( action.getActionClass().equals("org.apache.ode.action.bpel.StartScopeAction")) {
+ HashMap faultHandlers = (HashMap)action.getMetadata().get(StartScopeAction.FAULT_HANDLERS);
+ if (faultHandlers != null) {
+ Iterator it = faultHandlers.keySet().iterator();
+ while (it.hasNext()) {
+ String name = (String) it.next();
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey((String) faultHandlers.get(name));
+ IPMDProcess fproc = ds.getProcessDefintion(pdk,observerProc.getRootKey());
+ addProcess("faultHandler:"+name,cclevel,fproc);
+ }
+ }
+ }
+ }
+ }
+
+// private void addProps(DefaultMutableTreeNode actlevel, IPMDAction act){
+// Properties props = act.getMetadata();
+// }
+
+}
Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/DefinitionKey.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/DefinitionKey.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/DefinitionKey.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/deployment/DefinitionKey.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 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.
+*/
+/*
+ * Created on Aug 16, 2003
+ *
+ */
+package org.apache.ode.deployment;
+
+/**
+ * A unique key that identifies a business process definition within the BPEngine's
+ * runtime metadata repositry. It is returned from the deployment interface.
+ *
+ *
+ * @author waterman
+ */
+public interface DefinitionKey {
+
+ /**
+ * @return the name of the business process as found in the deployment package
+ */
+ public String getLabel();
+
+ /**
+ * @return the unique key assigned to the business process definition on deployment into the engine
+ */
+ public String getKey();
+}