You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:05:47 UTC
svn commit: r381686 [36/40] - in /incubator/ode/scratch/bpe: ./ bpelTests/
bpelTests/probeService/ bpelTests/test1/ bpelTests/test10/
bpelTests/test12/ bpelTests/test13/ bpelTests/test14/ bpelTests/test15/
bpelTests/test16/ bpelTests/test17/ bpelTests/...
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEProperties.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEProperties.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEProperties.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEProperties.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,680 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.info.PackageInfo;
+import com.sybase.bpe.info.PackageInfoHome;
+import com.sybase.bpe.interaction.spiimpl.atomic.AtomicInteractionFactory;
+import com.sybase.bpe.interaction.spiimpl.document.DocumentInteractionFactory;
+
+/**
+ * @author waterman
+ *
+ * A BPE convience wrapper around a Properties object. This class also abstracts
+ * properties from their location ( i.e. JNDI, .properties )
+ *
+ */
+public class BPEProperties extends Properties
+{
+ static final long serialVersionUID = -5037951613080178324L;
+
+
+ private static Logger logger =
+ Logger.getLogger(BPEProperties.class.getName());
+
+ // UUID Generation Properties
+ public static final String UUID_USE_CONNECTOR_KEY = "UUID_USE_CONNECTOR_KEY";
+ public static final String UUID_USE_CONNECTOR_DEFAULT = "false";
+ public static final String UUID_CLASS_KEY = "UUID_CLASS_KEY";
+ public static final String UUID_CLASS_DEFAULT =
+ "com.sybase.bpe.uuid.AXISUUIDService";
+ public static final String UUID_SIZE_KEY = "UUID_SIZE_KEY";
+ public static final int UUID_SIZE_DEFAULT = 200;
+
+ // Definition Service Properties
+ public static final String DEF_CLASS_KEY = "DEF_CLASS_KEY";
+ public static final String DEF_CLASS_DEFAULT =
+ "com.sybase.bpe.definition.serialimpl.DefinitionService_SerImpl";
+ public static final String DEF_PERSISTENT_KEY = "DEF_PERSISTENT_KEY";
+ public static final String DEF_PERSISTENT_DEFAULT = "FALSE";
+ public static final String DEF_SCHEMA_KEY = "DEF_SCHEMA_KEY";
+ public static final String DEF_SCHEMA_DEFAULT = "BPEL4WS.XSD";
+
+ // Instance Service Properties
+ public static final String INST_CLASS_KEY = "INST_CLASS_KEY";
+ public static final String INST_CLASS_DEFAULT =
+ "com.sybase.bpe.instance.beanimpl.InstanceServicePersistentImpl";
+ public static final String INST_PERSISTENT_KEY = "INST_PERSISTENT_KEY";
+ public static final String INST_PERSISTENT_DEFAULT = "FALSE";
+
+ // Instance Service Properties
+ public static final String SCOPE_CLASS_KEY = "SCOPE_CLASS_KEY";
+ public static final String SCOPE_CLASS_DEFAULT =
+ "com.sybase.bpe.scope.service.impl.ScopeServiceImpl";
+
+ // Event Director Properties
+ public static final String ED_CLASS_KEY = "ED_CLASS_KEY";
+ public static final String ED_CLASS_DEFAULT =
+ "com.sybase.bpe.bped.EventDirectorSLImpl";
+
+ // Correlation Service Properties
+ public static final String CORL_CLASS_KEY = "CORL_CLASS_KEY";
+ public static final String CORL_CLASS_DEFAULT =
+ "com.sybase.bpe.correlation.CorrelationServiceSLImpl";
+
+ // Locking Service Properties
+ public static final String LOCK_CLASS_KEY = "LOCK_CLASS_KEY";
+ public static final String LOCK_CLASS_DEFAULT =
+ "com.sybase.bpe.locking.IMLockingService";
+ public static final String LOCK_HASH_BUCKETS_KEY = "LOCK_HASH_BUCKETS_KEY";
+ public static final String LOCK_HASH_BUCKETS_DEFAULT = "1000";
+
+ // default the engine is
+ public static final String BPEL_COMPLIANT_KEY = "BPEL_COMPLIANT_KEY";
+ public static final String BPEL_COMPLIANT_DEFAULT = "TRUE";
+
+ // Context Service Properties
+ public static final String CTX_CLASS_TRANSIENT_KEY =
+ "CTX_CLASS_TRANSIENT_KEY";
+ public static final String CTX_CLASS_TRANSIENT_DEFAULT =
+ "com.sybase.bpe.context.nonpersistent.TransientContextService";
+ public static final String CTX_CLASS_PERSISTENT_KEY =
+ "CTX_CLASS_PERSISTENT_KEY";
+ public static final String CTX_CLASS_PERSISTENT_DEFAULT =
+ "com.sybase.bpe.context.persistent.PersistentContextService";
+
+ public static final String CTX_PERSISTENCE_KEY = "CTX_PERSISTENCE_KEY";
+ public static final String CTX_PERSISTENT = "CTX_PERSISTENT";
+ public static final String CTX_TRANSIENT = "CTX_TRANSIENT";
+ public static final String CTX_PERSISTENCE_GRANULARITY_KEY = "CTX_PERSISTENCE_GRANULARITY_KEY";
+ public static final String CTX_MONOLITHIC = "CTX_MONOLITHIC";
+ public static final String CTX_INTERMEDIATE = "CTX_INTERMEDIATE";
+ public static final String CTX_FINE = "CTX_FINE";
+
+ // Data Object Factory Properties
+ public static final String DOF_CLASS_PERSISTENT_KEY =
+ "DOF_CLASS_PERSISTENT_KEY";
+ public static final String DOF_CLASS_PERSISTENT_DEFAULT =
+ "com.sybase.bpe.context.ejb.EJBDataObjectFactory";
+
+ // Data Object Factory Properties
+ public static final String DOF_CMP_HOME = "java:comp/env/theCMPObjectBean";
+ public static final String DOF_BMP_HOME = "java:comp/env/theBMPObjectBean";
+ public static final String DOF_EJB_HOME_KEY = "DOF_EJB_HOME_KEY";
+ public static final String DOF_EJB_HOME_DEFAULT =
+ DOF_CMP_HOME;
+
+ public static final String INTERACTION_FACTORIES_KEY =
+ "INTERACTION_FACTORIES_KEY";
+ public static final String INTERACTION_FACTORIES_DEFAULT =
+ DocumentInteractionFactory.class.getName() + "," +
+ AtomicInteractionFactory.class.getName();
+
+ public static final String EXTERNAL_INTERACTION_FACTORIES_KEY =
+ "EXTERNAL_INTERACTION_FACTORIES_KEY";
+ public static final String EXTERNAL_INTERACTION_FACTORIES_DEFAULT =
+ "";
+
+
+
+ private Context jndiContext;
+
+ // private compare type values
+ private static final String STRING_TYPE = "java.lang.String";
+ private static final String INTEGER_TYPE = "java.lang.Integer";
+ private static final String BOOLEAN_TYPE = "java.lang.Boolean";
+
+ private static Map propertiesCache =
+ Collections.synchronizedMap(new HashMap());
+
+
+ public static BPEProperties getCachedProperties()
+ {
+ //TODO: change the propertiesCache to use
+ //application-local storage instead of a static.
+ //For now index the global cache ( credit harper )
+ //by the context classloader which should never be the same
+ //for two different j2ee applications.
+ ClassLoader contextClassLoader =
+ Thread.currentThread().getContextClassLoader();
+ BPEProperties properties = (BPEProperties)
+ (propertiesCache.get(contextClassLoader));
+ if ( properties == null )
+ {
+ InitialContext initialContext= null;
+ try
+ {
+ initialContext = new InitialContext();
+ } catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ properties = new BPEProperties(true, initialContext);
+ propertiesCache.put(contextClassLoader, properties);
+ }
+ return properties;
+ }
+
+ public BPEProperties()
+ {
+ super();
+ loadStandAloneProperties();
+ }
+
+ static public boolean IsRunningStandAlone()
+ {
+ boolean runningStandAlone = false;
+ String jnfi_value = System.getProperty(EventDirectorFactory.JNFI);
+ if (jnfi_value == null || jnfi_value.compareTo(EventDirectorFactory.IMJNFI) == 0)
+ {
+ runningStandAlone = true;
+ }
+
+ return runningStandAlone;
+ }
+
+ protected void loadStandAloneProperties()
+ {
+ if ( IsRunningStandAlone() )
+ {
+ File file = new File(EventDirectorFactory.IM_ENGINE_PROPERTY_FILE_NAME);
+ if (file.exists() == true)
+ {
+ FileInputStream ifstrm;
+ try
+ {
+ ifstrm = new FileInputStream(
+ EventDirectorFactory.IM_ENGINE_PROPERTY_FILE_NAME);
+
+ load(ifstrm);
+ } catch (IOException e1)
+ {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ }
+ }
+
+ /**
+ * Constructor for BPEProperties using program based defaults.
+ * @param initalize - true = populate the properties file ( recommended )
+ * @param initCtx - initial jndi context object
+ *
+ */
+ public BPEProperties(boolean initalize, Context initCtx)
+ {
+ super();
+ loadStandAloneProperties();
+
+ try
+ {
+ try {
+ jndiContext = (Context) initCtx.lookup("java:comp/env");
+ } catch (Exception e) {
+ logger.warning(e.getLocalizedMessage());
+ }
+
+ if (initalize)
+ {
+
+ if (jndiContext != null)
+ {
+ // Rip through the environment naming context and
+ // override anything in the properties file
+ NamingEnumeration e = initCtx.listBindings("java:comp/env");
+ while (e.hasMore())
+ {
+ Binding b = (Binding) e.next();
+ setProperty(
+ b.getName(),
+ b.getObject(),
+ b.getClassName());
+ if (logger.isLoggable(Level.FINE))
+ {
+ logger.log(
+ Level.FINE,
+ "- Found JNDI Binding:"
+ + b.getName()
+ + " Value: "
+ + getProperty(b.getName()));
+ }
+
+ }
+ }
+
+ // Set default lookups
+
+ }
+
+ }
+ catch (NamingException ne)
+ {
+ logger.log(Level.SEVERE, "", ne);
+ }
+
+ }
+
+ /**
+ * A boolean describing whether or not to use a connector implementation for UUID generation.
+ */
+ public boolean getUUIDUseConnector()
+ {
+ return lookupBoolean(UUID_USE_CONNECTOR_KEY, UUID_USE_CONNECTOR_DEFAULT);
+ }
+ public void setUUIDUseConnector(boolean value)
+ {
+ setProperty(UUID_USE_CONNECTOR_KEY, String.valueOf(value));
+ }
+ /**
+ * A class name that implements the UUIDService interface
+ */
+ public String getUUIDServiceClass()
+ {
+ return lookupString(UUID_CLASS_KEY, UUID_CLASS_DEFAULT);
+ }
+ public void setUUIDServiceClass(String value)
+ {
+ setProperty(UUID_CLASS_KEY, value);
+ }
+ /**
+ * The size of the UUID cache. A UUIDService implementation may implement
+ * and internal cache and this attribute defines the number of uuid values
+ * to maintain in the cache.
+ */
+ public int getUUIDCacheSize()
+ {
+ return lookupInt(UUID_SIZE_KEY, UUID_SIZE_DEFAULT);
+ }
+ public void setUUIDCacheSize(int value)
+ {
+ setProperty(UUID_SIZE_KEY, String.valueOf(value));
+ }
+
+ /**
+ * A class name that implements the DefinitionService interface
+ */
+ public String getDefinitionServiceClass()
+ {
+ return lookupString(DEF_CLASS_KEY, DEF_CLASS_DEFAULT);
+ }
+ public void setDefinitionServiceClass(String value)
+ {
+ setProperty(DEF_CLASS_KEY, value);
+ }
+
+ /**
+ * if the def service is peristent or not
+ */
+ public String getDefinitionServicePersistence()
+ {
+ return lookupString(DEF_PERSISTENT_KEY, DEF_PERSISTENT_DEFAULT);
+ }
+ public void setDefinitionServicePersistence(String value)
+ {
+ setProperty(DEF_PERSISTENT_KEY, value);
+ }
+
+ /**
+ * The location of the process definition validating schema
+ *
+ */
+ public String getDefinitionSchema() {
+ return lookupString(DEF_SCHEMA_KEY, DEF_SCHEMA_DEFAULT);
+ }
+ public void setDefinitionSchema(String value) {
+ setProperty(DEF_SCHEMA_KEY, value);
+ }
+
+
+ /**
+ * A class name that implements the InstanceSerivce interface
+ */
+ public String getInstanceServiceClass()
+ {
+ return lookupString(INST_CLASS_KEY, INST_CLASS_DEFAULT);
+ }
+ public void setInstanceServiceClass(String value)
+ {
+ setProperty(INST_CLASS_KEY, value);
+ }
+
+ /**
+ * if the inst service is peristent or not
+ */
+ public boolean getInstanceServicePersistence()
+ {
+ return lookupBoolean(INST_PERSISTENT_KEY, INST_PERSISTENT_DEFAULT);
+ }
+ public void setInstanceServicePersistence(String value)
+ {
+ setProperty(INST_PERSISTENT_KEY, value);
+ }
+
+
+ /**
+ * A class name that implements the ScopeSerivce interface
+ */
+ public String getScopeServiceClass()
+ {
+ return lookupString(SCOPE_CLASS_KEY, SCOPE_CLASS_DEFAULT);
+ }
+ public void setScopeServiceClass(String value)
+ {
+ setProperty(SCOPE_CLASS_KEY, value);
+ }
+
+ /**
+ * TRUE if the engine is BPEL compliant
+ */
+ public String getBPELCompliant()
+ {
+ return lookupString(BPEL_COMPLIANT_KEY, BPEL_COMPLIANT_DEFAULT);
+ }
+ public void setBPELCompliant(String value)
+ {
+ setProperty(BPEL_COMPLIANT_KEY, value);
+ }
+
+ /**
+ * A class name that implements the InstanceSerivce interface
+ */
+ public String getEventDirectorClass()
+ {
+ return lookupString(ED_CLASS_KEY, ED_CLASS_DEFAULT);
+ }
+ public void setEventDirectorClass(String value)
+ {
+ setProperty(ED_CLASS_KEY, value);
+ }
+
+ /**
+ * A class name that implements the InstanceSerivce interface
+ */
+ public String getCorrelationServiceClass()
+ {
+ return lookupString(CORL_CLASS_KEY, CORL_CLASS_DEFAULT);
+ }
+ public void setCorrelationServiceClass(String value)
+ {
+ setProperty(CORL_CLASS_KEY, value);
+ }
+
+ /**
+ * A class name that implements the LockingService interface
+ */
+ public String getLockingServiceClass()
+ {
+ return lookupString(LOCK_CLASS_KEY, LOCK_CLASS_DEFAULT);
+ }
+ public void setLockingServiceClass(String value)
+ {
+ setProperty(LOCK_CLASS_KEY, value);
+ }
+
+ /**
+ * A class name that implements the LockingService interface
+ */
+ public String getLockingServiceHashBuckets()
+ {
+ return lookupString(LOCK_HASH_BUCKETS_KEY, LOCK_HASH_BUCKETS_DEFAULT);
+ }
+ public void setLockingServiceHashBuckets(String value)
+ {
+ setProperty(LOCK_HASH_BUCKETS_KEY, value);
+ }
+
+ /**
+ * A class name that implements the IContextService interface
+ */
+ public String getTransientContextServiceClass()
+ {
+ return lookupString(
+ CTX_CLASS_TRANSIENT_KEY,
+ CTX_CLASS_TRANSIENT_DEFAULT);
+ }
+ public void setTransientContextServiceClass(String value)
+ {
+ setProperty(CTX_CLASS_TRANSIENT_KEY, value);
+ }
+
+ /**
+ * A class name that implements the IContextService interface
+ */
+ public String getPersistentContextServiceClass()
+ {
+ return lookupString(
+ CTX_CLASS_PERSISTENT_KEY,
+ CTX_CLASS_PERSISTENT_DEFAULT);
+ }
+ public void setPersistentContextServiceClass(String value)
+ {
+ setProperty(CTX_CLASS_PERSISTENT_KEY, value);
+ }
+
+ /**
+ * A class name that implements the IDataObjectFactory interface
+ */
+ public String getDataObjectFactoryClass()
+ {
+ return lookupString(
+ DOF_CLASS_PERSISTENT_KEY,
+ DOF_CLASS_PERSISTENT_DEFAULT);
+ }
+ public void setDataObjectFactoryClass(String value)
+ {
+ setProperty(DOF_CLASS_PERSISTENT_KEY, value);
+ }
+
+ public String getInteractionFactories()
+ {
+ return lookupString(
+ INTERACTION_FACTORIES_KEY,
+ INTERACTION_FACTORIES_DEFAULT );
+ }
+
+ public String getExternalInteractionFactories()
+ {
+ return lookupString(
+ EXTERNAL_INTERACTION_FACTORIES_KEY,
+ EXTERNAL_INTERACTION_FACTORIES_DEFAULT );
+ }
+
+ /**
+ * The JNDI name of an entity bean dataobject's local home.
+ */
+ public String getDataObjectFactoryEJBHome()
+ {
+ return lookupString(DOF_EJB_HOME_KEY, DOF_EJB_HOME_DEFAULT);
+ }
+ public void setDataObjectFactoryEJBHome(String value)
+ {
+ setProperty(DOF_EJB_HOME_KEY, value);
+ }
+
+
+ private Properties packageProperties;
+ public Properties getPackageProperties()
+ {
+ if (packageProperties == null)
+ {
+ try
+ {
+ synchronized (this)
+ {
+ if (packageProperties == null)
+ {
+ InitialContext ic = new InitialContext();
+ Object o = ic.lookup("java:comp/env/thePackageInfo");
+ PackageInfoHome pilh = (PackageInfoHome) PortableRemoteObject
+ .narrow(o, PackageInfoHome.class);
+ PackageInfo pil = pilh.create();
+ packageProperties = pil.getProperties();
+ }
+ }
+ } catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return packageProperties;
+ }
+ /**
+ * Get a String value
+ */
+ private String lookupString(String key, String defaultValue)
+ {
+ String ret = null;
+
+ ret = getProperty(key);
+
+ if (ret == null)
+ {
+ if (jndiContext != null)
+ {
+ try
+ {
+ ret = (String) jndiContext.lookup(key);
+ }
+ catch (Exception e)
+ {
+ logger.warning(e.getLocalizedMessage());
+ }
+ }
+ }
+
+ return (ret == null) ? defaultValue : ret;
+ }
+
+ /** get an int value */
+ private int lookupInt(String key, int defaultValue)
+ {
+ Integer ret = null;
+
+ String value = getProperty(key);
+
+ if (value == null)
+ {
+ if (jndiContext != null)
+ {
+ try
+ {
+ ret = (Integer) jndiContext.lookup(key);
+ }
+ catch (Exception e)
+ {
+ logger.warning(e.getLocalizedMessage());
+ }
+ }
+ }
+ else
+ {
+ ret = new Integer(value);
+ }
+
+ return (ret == null) ? defaultValue : ret.intValue();
+ }
+
+ private boolean lookupBoolean(String key, String defaultValue)
+ {
+ Boolean ret = null;
+
+ String value = getProperty(key);
+
+ if (value == null)
+ {
+ if (jndiContext != null)
+ {
+ try
+ {
+ ret = (Boolean) jndiContext.lookup(key);
+ }
+ catch (Exception e)
+ {
+ logger.warning(e.getLocalizedMessage());
+ }
+ }
+ }
+ else
+ {
+ ret = new Boolean(value);
+ }
+
+ return (ret == null) ? Boolean.getBoolean(defaultValue) : ret.booleanValue();
+ }
+
+ private void setProperty(String key, Object value, String type)
+ {
+
+ // Sets property from JNDI object
+ if ( type == null ) {
+ return;
+ }
+
+ if (type.equals(STRING_TYPE))
+ {
+
+ String putValue = (String) value;
+
+ // This code is specific to dealing with a comma delimiter
+ // within the binding value. In particular the EAServer
+ // JNDI service will escape the comma.
+ // Need to look for a "\," and replace with ","
+ putValue = ((String) value).replaceAll("\\\\", "");
+
+ setProperty(key, putValue);
+ return;
+ }
+
+ if (type.equals(INTEGER_TYPE))
+ {
+ setProperty(key, ((Integer) value).toString());
+ return;
+ }
+
+ if (type.equals(BOOLEAN_TYPE))
+ {
+ setProperty(key, ((Boolean) value).toString());
+ return;
+ }
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutMsg.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutMsg.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutMsg.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutMsg.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,133 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 18, 2003
+ *
+ */
+package com.sybase.bpe.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import com.sybase.bpe.event.BPELStaticKey;
+import com.sybase.bpe.event.SimpleRequestMessageEvent;
+import com.sybase.bpe.interaction.IInteraction;
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.InteractionFactory;
+
+/**
+ * @author charper
+ *
+ */
+public class BPEPutMsg {
+
+ public static void main(String[] args) {
+
+ try {
+ InitialContext context = new InitialContext();
+
+ // create the queue objects
+ QueueConnectionFactory qcf = (QueueConnectionFactory)
+ context.lookup("XAConnectionFactory");
+ QueueConnection qConnection = qcf.createQueueConnection();
+ QueueSession qSession = qConnection.createQueueSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = (Queue) context.lookup ("queue/BPED_IN");
+ QueueSender qSender = qSession.createSender(queue);
+
+ InteractionFactory interactionfactory =
+ InteractionFactory.newInstance();
+
+ // create the message
+ Properties msg = new Properties();
+ msg.load(new FileInputStream(args[0]));
+
+ // bpel message are routed based on webservice type information
+ // so we build a key to tack on to our message
+ BPELStaticKey bsk = new BPELStaticKey();
+ bsk.setTargetNamespace(msg.getProperty("target.name.space"));
+ bsk.setPortType(msg.getProperty("port.type"));
+ bsk.setOperation(msg.getProperty("operation"));
+
+ // now create the message
+ SimpleRequestMessageEvent msgEvent =
+ new SimpleRequestMessageEvent();
+ // set the key
+ msgEvent.setStaticKey(bsk);
+
+ //now set the parts of the message, specified as part1, part2, ... in the file
+ int i = 1;
+ while ( true ) {
+ String partName = msg.getProperty("part"+String.valueOf(i++));
+ if ( partName == null ) break;
+ String[] partSplit = partName.split("\\.");
+ if ( partSplit.length < 2 ) {
+ System.out.println("part name requires a type prefix");
+ break;
+ }
+ IInteraction ior = null;
+ if ( partSplit[0].equals("xml")) {
+ ior = interactionfactory.createXMLInteraction(msg.getProperty(partName).getBytes());
+ } else {
+ if ( partSplit[0].equals("str")) {
+ ior = interactionfactory.createObjectInteraction(msg.getProperty(partName));
+ }
+ }
+
+ msgEvent.setPart(partSplit[1],ior);
+ }
+
+ ObjectMessage objmsg = qSession.createObjectMessage();
+ objmsg.setObject((Serializable)msgEvent);
+ qSender.send(objmsg);
+
+ } catch (NamingException e) {
+ e.printStackTrace();
+ } catch (JMSException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InteractionException e) {
+ e.printStackTrace();
+ } catch (BPException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutTxtMsg.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutTxtMsg.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutTxtMsg.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPEPutTxtMsg.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,133 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 18, 2003
+ *
+ */
+package com.sybase.bpe.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * @author charper
+ *
+ */
+public class BPEPutTxtMsg {
+
+ public static void main(String[] args) {
+
+ try {
+
+ String qcfName = "XAConnectionFactory";
+ String qName = "queue/BPED_IN";
+ String optParser = "JUNK";
+ String optMsgType = "testMessage";
+
+ int numMsgs = 1;
+ boolean sendMarker = false;
+ if ( args.length > 2 ) {
+ numMsgs = Integer.parseInt(args[1]);
+ } if ( args.length >= 4 ) {
+ qcfName = args[2];
+ qName = args[3];
+ } if ( args.length >= 5 && args[4].equals("-marker") ) {
+ sendMarker = true;
+ } if ( args.length == 7 ) {
+ optParser = args[5];
+ optMsgType = args[6];
+ }
+
+ InitialContext context = new InitialContext();
+
+ // create the queue objects
+ QueueConnectionFactory qcf = (QueueConnectionFactory)
+ context.lookup(qcfName);
+ QueueConnection qConnection = qcf.createQueueConnection();
+ QueueSession qSession = qConnection.createQueueSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = (Queue) context.lookup (qName);
+ QueueSender qSender = qSession.createSender(queue);
+
+ // create the message
+ Properties msg = new Properties();
+ msg.load(new FileInputStream(args[0]));
+
+ // bpel message are routed based on webservice type information
+ System.out.println("Target namespace:"+msg.getProperty("target.name.space"));
+ System.out.println("PortType:"+msg.getProperty("port.type"));
+ System.out.println("Operation:"+msg.getProperty("operation"));
+
+ String partName = msg.getProperty("part1");
+// String[] partSplit = partName.split("\\.");
+ String msgtxt = msg.getProperty(partName);
+
+ //message that should cause a logging statement
+ TextMessage marker = null;
+ if (sendMarker) {
+ marker = qSession.createTextMessage();
+ marker.setText("marker");
+ qSender.send(marker);
+ }
+
+ TextMessage txtmsg = qSession.createTextMessage();
+ txtmsg.setText(msgtxt);
+ txtmsg.setStringProperty("OPT_PARSER",optParser);
+ txtmsg.setStringProperty("OPT_MSG_TYPE",optMsgType);
+
+ for ( int i = 0; i<numMsgs ; i++ ) {
+ qSender.send(txtmsg);
+ }
+ if (sendMarker) {
+ qSender.send(marker);
+ }
+
+ qSender.close();
+ qSession.close();
+ qConnection.close();
+
+ } catch (NamingException e) {
+ e.printStackTrace();
+ } catch (JMSException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BPException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,98 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.util;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.lang.ResourceGetter;
+
+
+public class BPException extends Exception
+{
+ static final long serialVersionUID = -7677943938505833212L;
+
+ /**
+ * A BP exception requires a localized message
+ */
+ public BPException(String message_id, Object[] msgParams) {
+ super(init(message_id,msgParams));
+ }
+
+ /**
+ * A BP exception requires a localized message
+ */
+
+ public BPException(String message_id, Object[] msgParams, Throwable cause) {
+ super(init(message_id,msgParams,cause),cause);
+ }
+
+
+ /**
+ * @param detailMessage
+ */
+ public BPException(String detailMessage)
+ {
+ super( detailMessage );
+ }
+
+ /**
+ * @param cause
+ */
+ public BPException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ private static String init(String message_id, Object[] msgParams) {
+ return ResourceGetter.getFormatted(message_id, msgParams);
+ }
+
+ private static String init(String message_id, Object[] msgParams, Throwable cause) {
+
+ // Tack the native error message into the BP message Param list.
+ // This allows the native message to be used in any BP localized messages.
+ Object[] newParamList = msgParams;
+
+ if ( cause != null ) {
+ if ( newParamList != null ) {
+ newParamList = new Object[msgParams.length + 1];
+ System.arraycopy(msgParams,0,newParamList,0,msgParams.length);
+ newParamList[msgParams.length] = cause.getLocalizedMessage();
+ } else {
+ newParamList = new Object[] { cause.getLocalizedMessage() };
+ }
+ }
+
+ return init(message_id, newParamList);
+ }
+
+ /**
+ * A helper function
+ * @param logger
+ * @param level
+ */
+ public void log(Logger logger,Level level) {
+ logger.log(level,getMessage(),this);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BenchMarkUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BenchMarkUtil.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BenchMarkUtil.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/BenchMarkUtil.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,243 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 13, 2003
+ *
+ */
+package com.sybase.bpe.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+//import java.util.logging.Logger;
+
+import com.sybase.bpe.bped.DeployTypeEnum;
+import com.sybase.bpe.bped.EventDirectorException;
+import com.sybase.bpe.bped.EventDirectorFactory;
+import com.sybase.bpe.bped.IDeployer;
+import com.sybase.bpe.bped.EventDirector;
+import com.sybase.bpe.deployment.DefinitionKey;
+import com.sybase.bpe.event.BPELStaticKey;
+import com.sybase.bpe.event.IResponseMessage;
+import com.sybase.bpe.event.SimpleRequestMessageEvent;
+import com.sybase.bpe.interaction.IInteraction;
+import com.sybase.bpe.interaction.InteractionFactory;
+
+
+/**
+ * @author charper
+ *
+ * This app will test the throughput of the BPE.
+ * - The engine is configured as an in-memory engine
+ * - No threads are used
+ * - No queues are used
+ * - A single instance creating message is sent to the engine
+ * - The engine uses Jaxen XPATH for rule evaluation ( the BPEL switch statement )
+ * - Based on the switch conditional an xslt transformation is invoked.
+ *
+ */
+public class BenchMarkUtil {
+
+// private static Logger logger =
+// Logger.getLogger(BenchMarkUtil.class.getName());
+
+ private static InteractionFactory interactionfactory =
+ InteractionFactory.newInstance();
+
+ private File defJar;
+ private boolean remote;
+// private String defId;
+ private ArrayList messages = new ArrayList();
+// private boolean delete;
+ private int iterations = 500;
+
+ public static void main(String[] args) {
+ BenchMarkUtil eu = new BenchMarkUtil();
+ eu.run(args);
+ }
+
+ private void run(String[] args){
+ // parse the comand line
+ parseCmdLine(args);
+
+ try {
+
+ // get an event director so we can send messages and load definitions
+ EventDirector ed;
+ if ( remote ) {
+ // all the engine properties are specified in the app server
+ ed = EventDirectorFactory.createRemoteEventDirector();
+ } else {
+ // all the engine properties are specified in the property file
+ ed = EventDirectorFactory.createEventDirector();
+ }
+
+ // get a bpel deployer which we can use to load and delete defintions
+ IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
+
+ // if there is a jar deploy it
+ if ( defJar != null ) {
+ // 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
+ if ( ! remote ) {
+ deployer.setStateless(key.getKey());
+ }
+ }
+ }
+
+ // if any messages were specified send them to the engine
+ Iterator it = messages.iterator();
+ SimpleRequestMessageEvent msgEvent = null;
+ if ( it.hasNext() ) {
+ // each message is passed in a properties file for this utility
+ Properties msg = new Properties();
+ msg.load(new FileInputStream((File)it.next()));
+
+ // bpel message are routed based on webservice type information
+ // so we build a key to tack on to our message
+ BPELStaticKey bsk = new BPELStaticKey();
+ bsk.setTargetNamespace(msg.getProperty("target.name.space"));
+ bsk.setPortType(msg.getProperty("port.type"));
+ bsk.setOperation(msg.getProperty("operation"));
+
+ // now create the message
+ msgEvent = new SimpleRequestMessageEvent();
+ // set the key
+ msgEvent.setStaticKey(bsk);
+
+ //now set the parts of the message, specified as part1, part2, ... in the file
+ int i = 1;
+ while ( true ) {
+ String partName = msg.getProperty("part"+String.valueOf(i++));
+ if ( partName == null ) break;
+ String[] partSplit = partName.split("\\.");
+ if ( partSplit.length < 2 ) {
+ System.out.println("part name requires a type prefix");
+ break;
+ }
+ IInteraction ior = null;
+ if ( partSplit[0].equals("xml")) {
+ ior = interactionfactory.createXMLInteraction(msg.getProperty(partName).getBytes());
+ } else {
+ if ( partSplit[0].equals("str")) {
+ ior = interactionfactory.createObjectInteraction(msg.getProperty(partName));
+ }
+ }
+
+ msgEvent.setPart(partSplit[1],ior);
+ }
+ }
+
+ profile();
+ IResponseMessage er = ed.sendEvent(msgEvent,true);
+ //System.out.println("Sending " + iterations + " messages to the engine ....");
+ PerfTimer timer = new PerfTimer();
+ timer.start();
+// long startTime = System.currentTimeMillis();
+ for ( int i=0; i<iterations; i++ ) {
+ // send the event syncronously
+ ed.sendEvent(msgEvent,true);
+ }
+// System.out.println("Elapsed time - Milliseconds: " + (System.currentTimeMillis() - startTime));
+ System.out.println(timer.getTimeSum("BenchMarkUtil", iterations));
+ // print out the last result we get back
+ System.out.println();
+ System.out.println("Return message:");
+ System.out.println(er.toString());
+
+ } catch (EventDirectorException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (BPException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void parseCmdLine(String[] args){
+
+ try {
+ for ( int i = 0; i < args.length ; i++) {
+ if ( args[i].equals("-h")) {
+ help();
+ } else if ( args[i].equals("-d")){
+ defJar = new File(args[++i]);
+ if ( ! ( defJar.isFile() && defJar.canRead() ) ) {
+ help();
+ }
+ } else if ( args[i].equals("-r")) {
+ remote = true;
+ } else if ( args[i].equals("-x")) {
+// delete = true;
+// defId = args[++i];
+ }
+ else if ( args[i].equals("-t")) {
+
+ iterations = Integer.parseInt(args[++i]);
+ }
+ else {
+
+ // the rest have to be message files
+ for ( ; i < args.length ; i++ ) {
+ File f = new File(args[i]);
+ if ( f.isFile() && f.canRead() ) {
+ messages.add(f);
+ } else {
+ help();
+ }
+ }
+
+ }
+ }
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ help();
+ }
+ }
+ private void help(){
+ System.out.println("EnginUtil [-d deployFile][-r] [-x defId] [msgFile]...");
+ //System.out.println("EnginUtil [-d deployFile] [-s schemaFileName][-r] [-x defId] [msgFile]...");
+ System.out.println("-d deployFile - the definition deploy zip file ");
+ //System.out.println("-s schemaFileName - the location of the definition schema");
+ System.out.println("-r - specifiy if you are connecting to a remote engine");
+ System.out.println("-t - specifiy the number of times the message is sent");
+ System.out.println("-x defId - delete a defintion out of the defintion repository");
+ System.out.println("Specifiy 0..n message to send");
+ System.exit(0);
+ }
+
+ private void profile() {}
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ContextLocalStorage.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ContextLocalStorage.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ContextLocalStorage.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ContextLocalStorage.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,100 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.util;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * This class provides storage which is local to the classloader
+ * context which invokes it. It is useful for holding information
+ * which should be shared by all instances of a certain j2ee component
+ * since those instances share the same context classloader.
+ */
+public class ContextLocalStorage
+{
+
+ //TODO: This global map should really be held in application-local
+ //storage to ensure that it is cleaned up when an application is
+ //undeployed. As it stands, only a server bounce will clean up
+ //this cache.
+ private static Map globalMap =
+ Collections.synchronizedMap(new HashMap());
+
+ public static Object Get( Object key )
+ {
+ Object value = GetContextLocalMap().get( key );
+ return value;
+ }
+
+ public static void Put( Object key, Object value)
+ {
+ GetContextLocalMap().put(key, value);
+ }
+
+ public static void Remove( Object key )
+ {
+ GetContextLocalMap().remove( key );
+ }
+
+ public static void Clear()
+ {
+ GetContextLocalMap().clear();
+ }
+
+ private static Map GetContextLocalMap()
+ {
+ Object key = getContextMapKey();
+ Map localMap = (Map)globalMap.get( key );
+ if ( localMap == null )
+ {
+ localMap = CreateContextLocalMap();
+ }
+ return localMap;
+ }
+
+ private static synchronized Map CreateContextLocalMap()
+ {
+ Object key = getContextMapKey();
+ Map localMap = (Map)globalMap.get( key );
+ if ( localMap == null )
+ {
+ localMap =
+ Collections.synchronizedMap(new HashMap());
+ globalMap.put(key, localMap);
+ }
+ return localMap;
+ }
+
+ private static Object getContextMapKey()
+ {
+ Object key = Thread.currentThread().getContextClassLoader();
+ if ( key == null )
+ {
+ throw new UnsupportedOperationException();
+ }
+ return key;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/EngineUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/EngineUtil.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/EngineUtil.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/EngineUtil.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,35 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 13, 2003
+ *
+ */
+package com.sybase.bpe.util;
+public class EngineUtil
+{
+ public static void main(String[] args)
+ {
+ com.sybase.bpe.client.util.EngineUtil eu = new com.sybase.bpe.client.util.EngineUtil(
+ args);
+ eu.run();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEDecoder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEDecoder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEDecoder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEDecoder.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,30 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.util;
+
+
+public interface IBPEDecoder
+{
+ public Object readObject();
+ public void close();
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEEncoder.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEEncoder.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEEncoder.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/IBPEEncoder.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,31 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.util;
+
+
+public interface IBPEEncoder
+{
+ public void writeObject( Object iObject );
+ public void close();
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/LoggerInformation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/LoggerInformation.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/LoggerInformation.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/LoggerInformation.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,101 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Jun 6, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sybase.bpe.util;
+import java.util.Enumeration;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+
+/**
+ * @author charper
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class LoggerInformation {
+
+ public static void getInfo() {
+ // Get the Log Manager
+ LogManager manager = LogManager.getLogManager();
+ // Get all defined loggers
+ Enumeration names = manager.getLoggerNames();
+
+ System.out.println("***Begin Logger Information");
+ // For each logger: show name, level, handlers etc.
+ while (names.hasMoreElements()) {
+ String loggername = (String)names.nextElement();
+ Logger logger = manager.getLogger(loggername);
+ System.out.println("-----------------------");
+ System.out.println("Logger name: >" + logger.getName() + "<");
+ System.out.println("Logger level: " + logger.getLevel());
+
+ // See if a filter is defined
+ if (logger.getFilter() != null)
+ System.out.println("Using a filter");
+ else
+ System.out.println("No filter used");
+
+ // For each handler: show formatter, level, etc.
+ Handler[] h = logger.getHandlers();
+ if (h.length == 0) System.out.println("No handlers defined");
+ for (int i = 0; i < h.length; i++) {
+ if (i == 0) System.out.println("Handlers:");
+ Formatter f = h[i].getFormatter();
+ System.out.println(h[i].getClass().getName());
+ System.out.println(" using formatter: " + f.getClass().getName());
+ System.out.println(" using level: " + h[i].getLevel());
+ if (h[i].getFilter() != null)
+ System.out.println(" using a filter");
+ else
+ System.out.println(" no filter");
+ }
+
+ // See if a parent exists
+ Logger parent = logger.getParent();
+ if (parent != null)
+ System.out.println("Parent: >" + parent.getName() + "<");
+ else
+ System.out.println("No parent");
+ }
+ System.out.println("*** End Logger Information");
+ }
+
+ // Send all message types to the logger
+ public static void tryLevels(Logger logger) {
+ logger.severe("severe message");
+ logger.warning("warning message");
+ logger.info("info message");
+ logger.config("config message");
+ logger.fine("fine message");
+ logger.finer("finer message");
+ logger.finest("finest message");
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/NamespaceUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/NamespaceUtil.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/NamespaceUtil.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/NamespaceUtil.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,94 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.util;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+
+import org.apache.xml.utils.XMLChar;
+
+public class NamespaceUtil
+{
+ /**
+ * Extract the namespace prefixes from an xpath expression.
+ * This routine does not do xpath validation.
+ *
+ * @param iXPathExpression
+ * The xpath expression.
+ *
+ * @return
+ * A collection of strings. Each string holds a namespace prefix.
+ */
+ public static Collection getNamespacePrefixes( String iXPathExpression )
+ {
+ HashMap prefixMap = new HashMap();
+ String potentialPrefix = "";
+
+ int length = iXPathExpression.length();
+ int currentIndex = 0;
+ int quote = '"';
+ int tick = '\'';
+
+ while( currentIndex < length )
+ {
+ int currentChar = iXPathExpression.charAt( currentIndex );
+
+ //Skip past any literals contained in the expression.
+ if ( currentChar == quote || currentChar == tick)
+ {
+ int closeIndex =
+ iXPathExpression.indexOf( currentChar, currentIndex + 1 );
+ if ( closeIndex >= 0 )
+ {
+ currentIndex = closeIndex + 1;
+ }
+ else
+ {
+ break;
+ }
+ }
+ else if ( currentChar == ':')
+ {
+ if ( potentialPrefix.length() > 0 )
+ {
+ // Use a map to ensure uniqueness.
+ prefixMap.put( new String( potentialPrefix ),
+ new String(potentialPrefix) );
+ potentialPrefix = "";
+ }
+ }
+ else if( XMLChar.isName(currentChar) )
+ {
+ potentialPrefix += (char)currentChar;
+ }
+ else
+ {
+ potentialPrefix = "";
+ }
+
+ currentIndex++;
+ }
+
+ return prefixMap.values();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ObjectInputStreamContextClassLoader.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ObjectInputStreamContextClassLoader.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ObjectInputStreamContextClassLoader.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/ObjectInputStreamContextClassLoader.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,70 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Jun 17, 2005
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.sybase.bpe.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
+
+/**
+ * @author charper
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public class ObjectInputStreamContextClassLoader extends ObjectInputStream {
+ ClassLoader cl;
+
+ public ObjectInputStreamContextClassLoader(InputStream in)
+ throws IOException
+ {
+ super(in);
+ this.cl = Thread.currentThread().getContextClassLoader();
+ }
+
+ protected Class resolveClass(ObjectStreamClass osc)
+ throws IOException, ClassNotFoundException
+ {
+ return cl.loadClass(osc.getName());
+ }
+
+ protected Class resolveProxyClass(String[] interfaces)
+ throws IOException, ClassNotFoundException
+ {
+ Class[] interfacesClass = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ interfacesClass[i] = Class.forName(interfaces[i], false, cl);
+ }
+ return Proxy.getProxyClass(cl, interfacesClass);
+
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/PerfTimer.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/PerfTimer.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/PerfTimer.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/PerfTimer.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,63 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.util;
+
+/**
+ * @author charper
+ *
+ * Timer for tests
+ */
+public class PerfTimer {
+
+ private long startTime = 0;
+ private boolean isAdditive = false;
+ private long totalTime = 0;
+
+ public static void main(String[] args) {
+ }
+ public void start() {
+ startTime=System.currentTimeMillis();
+ }
+ public void stop(){
+ isAdditive = true;
+ totalTime += getTime();
+ }
+ private long getTime() {
+ if ( startTime == 0 ) return 0;
+ return System.currentTimeMillis() - startTime;
+ }
+ public String getTimeSum(String name, int iterations) {
+ long time;
+ if ( isAdditive ) {
+ time = totalTime;
+ } else {
+ time = getTime();
+ }
+ String s = ("****************************" + name+ " run complete.\n"+
+ "Iterations = " + iterations+"\n"+
+ "Total time in milliseconds = " + time+"\n"+
+ "Total time in seconds = " + (double)time/(double)1000 +"\n"+
+ "Iterations/second = " + (double)iterations/((double)time/(double)1000));
+ return s;
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/TraceLog.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/TraceLog.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/TraceLog.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/TraceLog.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,92 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.util;
+
+import java.util.logging.LogManager;
+//import java.util.logging.Logger;
+
+
+public class TraceLog {
+
+//private static Logger logger =
+// Logger.getLogger(TraceLog.class.getName());
+
+ private static String TRACE_LOG = "bpe.trace.log";
+ private static boolean enabled =
+ Boolean.valueOf(
+ LogManager.getLogManager().getProperty(TRACE_LOG)).booleanValue();
+
+ public static void println(String iValue)
+ {
+ if (enabled())
+ {
+ System.out.println("TRACELOG: " + iValue);
+ }
+ }
+
+ public static void println(Class iClass, String iValue)
+ {
+ if (enabled())
+ {
+ println("Inside " + iClass.getName() + " : " + iValue);
+ }
+ }
+
+ public static void printlnInside( Class iClass, String iFunction, String iValue )
+ {
+ if ( enabled() )
+ {
+ println( iClass, "function = " + iFunction + " : " + iValue );
+ }
+ }
+
+ public static void printlnInsideID( Class iClass, String iFunction, String iID, String iValue )
+ {
+ if ( enabled() )
+ {
+ printlnInside( iClass, iFunction, "id = " + iID + " : " + iValue );
+ }
+ }
+
+ public static void printRefCount( Class iClass, String iFunction, String iID, long iRefCount )
+ {
+ if ( enabled() )
+ {
+ printlnInsideID( iClass, iFunction, iID, " refCount = " + iRefCount );
+ }
+ }
+
+ public static void printUpdateCount( Class iClass, String iFunction, String iID, long iUpdateCount )
+ {
+ if ( enabled() )
+ {
+ printlnInsideID( iClass, iFunction, iID, " updateCount = " + iUpdateCount );
+ }
+ }
+
+ public static boolean enabled()
+ {
+ //return logger.isLoggable(Level.FINEST);
+ return enabled;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/XMLDocBuilderByThread.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/XMLDocBuilderByThread.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/XMLDocBuilderByThread.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/XMLDocBuilderByThread.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,79 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Oct 27, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.sybase.bpe.util;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import com.sybase.bpe.interaction.InteractionException;
+import com.sybase.bpe.interaction.XMLInteractionObject;
+
+public class XMLDocBuilderByThread {
+
+ private static final Logger logger =
+ Logger.getLogger(XMLInteractionObject.class.getName());
+ private static Map _threadToXMLDocBuilder = Collections.synchronizedMap(new HashMap());
+
+ public static DocumentBuilder getDocBuilder() throws InteractionException {
+ DocumentBuilder retValue = null;
+
+ // get current thread object
+ Thread currThread = Thread.currentThread();
+
+ // check to see if the tread object link already exists
+ if (_threadToXMLDocBuilder.containsKey(currThread) == false) {
+ // has no doc builder factory associate with this thread
+ // create the doc builder factory
+ DocumentBuilderFactory xmlDocBuilderFactory = DocumentBuilderFactory.newInstance();
+ xmlDocBuilderFactory.setNamespaceAware(true);
+
+ try {
+ retValue = xmlDocBuilderFactory.newDocumentBuilder();
+ } catch (ParserConfigurationException e) {
+ InteractionException bpx = new InteractionException("NATIVE_EXCEPTION",new Object[] {"ParserConfigurationException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+ // add the link to the map
+ _threadToXMLDocBuilder.put(currThread, retValue);
+ } else {
+ // has doc builder factory associated with this thread
+ // get the doc builder factory
+ retValue = (DocumentBuilder)(_threadToXMLDocBuilder.get(currThread));
+ }
+ return retValue;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/xpath/XPathBoolean.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/xpath/XPathBoolean.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/xpath/XPathBoolean.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/util/xpath/XPathBoolean.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,109 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Jun 27, 2003
+ *
+ */
+package com.sybase.bpe.util.xpath;
+
+import java.io.Serializable;
+
+/**
+ * @author waterman
+ *
+ */
+public class XPathBoolean implements Serializable {
+
+ static final long serialVersionUID = -9008019265809713280L;
+
+ private Boolean delegate;
+
+ public XPathBoolean( boolean value ) {
+ delegate = new Boolean(value);
+ }
+ public XPathBoolean( String value ) {
+ delegate = new Boolean(value);
+ }
+
+
+
+ /**
+ * @param name
+ * @return
+ */
+ public static boolean getBoolean(String name) {
+ return Boolean.getBoolean(name);
+ }
+
+ /**
+ * @param b
+ * @return
+ */
+ public static String toString(boolean b) {
+ return Boolean.toString(b)+"()";
+ }
+
+ /**
+ * @param b
+ * @return
+ */
+ public static Boolean valueOf(boolean b) {
+ return Boolean.valueOf(b);
+ }
+
+ /**
+ * @param s
+ * @return
+ */
+ public static Boolean valueOf(String s) {
+ return Boolean.valueOf(s);
+ }
+
+ /**
+ * @return
+ */
+ public boolean booleanValue() {
+ return delegate.booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ return delegate.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return delegate.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return delegate.toString()+"()";
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/AXISUUIDService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/AXISUUIDService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/AXISUUIDService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/AXISUUIDService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,46 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.uuid;
+
+import org.apache.axis.components.uuid.UUIDGen;
+import org.apache.axis.components.uuid.UUIDGenFactory;
+
+import com.sybase.bpe.util.BPEProperties;
+
+public class AXISUUIDService implements UUIDService {
+
+ private UUIDGen _generator;
+
+ public String getUUID() {
+ return _generator.nextUUID();
+ }
+
+ public void init(BPEProperties props) throws UUIDServiceException {
+ _generator = UUIDGenFactory.getUUIDGen();
+
+ }
+
+ public void close() {
+ _generator = null;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/ConnectorUUIDService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/ConnectorUUIDService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/ConnectorUUIDService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/ConnectorUUIDService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,80 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+
+package com.sybase.bpe.uuid;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.resource.ResourceException;
+import javax.resource.cci.ConnectionFactory;
+
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.uuid.connector.IUUIDConnection;
+
+/**
+ * @author charper
+ */
+public class ConnectorUUIDService implements UUIDService {
+
+ private static Logger logger =
+ Logger.getLogger(ConnectorUUIDService.class.getName());
+
+ private IUUIDConnection conn;
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.uuid.UUIDService#getUUID()
+ */
+ public String getUUID() {
+ try {
+ InitialContext ic = new InitialContext();
+ ConnectionFactory cf =
+ (ConnectionFactory)ic.lookup("java:comp/env/theUUIDService");
+ conn = (IUUIDConnection)cf.getConnection();
+ String uuid = conn.getUUID();
+ conn.close();
+ return uuid;
+
+ } catch ( ResourceException re ) {
+ logger.log(Level.SEVERE,"",re);
+ } catch ( NamingException ne ) {
+ logger.log(Level.SEVERE,"",ne);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.uuid.UUIDService#init(com.sybase.bpe.util.BPEProperties)
+ */
+ public void init(BPEProperties props) throws UUIDServiceException {
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.uuid.UUIDService#close()
+ */
+ public void close() {
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,40 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.uuid;
+
+import com.sybase.bpe.util.BPEProperties;
+
+/**
+ * @author waterman
+ *
+ * Generates UUID values
+ *
+ */
+public interface UUIDService {
+
+ public String getUUID();
+
+ public void init(BPEProperties props) throws UUIDServiceException;
+
+ public void close();
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,57 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.uuid;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author waterman
+ *
+ *
+ *
+ */
+public class UUIDServiceException extends BPException {
+
+ static final long serialVersionUID = -632552333835451373L;
+
+
+ /**
+ * @param message_id
+ * @param msgParams
+ */
+ public UUIDServiceException(String message_id, Object[] msgParams) {
+ super(message_id, msgParams);
+ }
+
+ /**
+ * @param message_id
+ * @param msgParams
+ * @param cause
+ */
+ public UUIDServiceException(
+ String message_id,
+ Object[] msgParams,
+ Throwable cause) {
+ super(message_id, msgParams, cause);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/UUIDServiceFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,110 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.uuid;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.uuid.UUIDService;
+import com.sybase.bpe.uuid.UUIDServiceException;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author waterman
+ *
+ * Instantiates an implementation of UUIDService
+ *
+ */
+public class UUIDServiceFactory {
+
+private static Logger logger =
+ Logger.getLogger(UUIDServiceFactory.class.getName());
+private static String IM_UUID_PROPERTY_FILE_NAME = "theUUIDService.properties";
+
+ public static UUIDService createUUIDService(BPEProperties props)
+ throws UUIDServiceException {
+ UUIDService uuidService;
+
+ if (props.getUUIDUseConnector()) {
+ uuidService = new ConnectorUUIDService();
+ uuidService.init(props);
+ } else {
+ try {
+ // load the implementation
+ Class uuidClass = java.lang.Class.forName(props
+ .getUUIDServiceClass());
+ // try to instantiate the subclass
+ uuidService = (UUIDService) uuidClass.newInstance();
+ uuidService.init(props);
+
+ } catch (ClassNotFoundException e) {
+ UUIDServiceException use = new UUIDServiceException(
+ "CLASS_NOT_FOUND", new Object[] { props
+ .getEventDirectorClass() });
+ use.log(logger, Level.SEVERE);
+ throw use;
+ } catch (InstantiationException e) {
+ UUIDServiceException use = new UUIDServiceException(
+ "NATIVE_EXCEPTION",
+ new Object[] { "InstantiationException" }, e);
+ use.log(logger, Level.SEVERE);
+ throw use;
+ } catch (IllegalAccessException e) {
+ UUIDServiceException use = new UUIDServiceException(
+ "NATIVE_EXCEPTION",
+ new Object[] { "IllegalAccessException" }, e);
+ use.log(logger, Level.SEVERE);
+ throw use;
+ } catch (BPException e) {
+ throw new UUIDServiceException("BPE_EXCEPTION",
+ new Object[] {}, e);
+ }
+ }
+
+ return uuidService;
+ }
+
+ // LLW: 10-22-03
+ // Init UUID service from properties file
+ public static UUIDService createUUIDService()
+ throws UUIDServiceException {
+ BPEProperties props = new BPEProperties();
+ try {
+ File file = new File(IM_UUID_PROPERTY_FILE_NAME);
+ if (file.exists() == true) {
+ FileInputStream ifstrm = new FileInputStream(IM_UUID_PROPERTY_FILE_NAME);
+ props.load(ifstrm);
+ }
+ } catch (IOException e) {
+ UUIDServiceException se = new UUIDServiceException("NATIVE_EXCEPTION",new Object[] {"IOException"},e);
+ se.log(logger,Level.SEVERE);
+ throw se;
+ }
+
+ return createUUIDService(props);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/connector/IUUIDConnection.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/connector/IUUIDConnection.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/connector/IUUIDConnection.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/uuid/connector/IUUIDConnection.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,41 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 15, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sybase.bpe.uuid.connector;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.Connection;
+
+/**
+ * @author jjin
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface IUUIDConnection extends Connection{
+ public String getUUID() throws ResourceException;
+}