You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/04/07 23:21:30 UTC
svn commit: r526486 - in
/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src:
main/java/org/apache/servicemix/bpe/
main/java/org/apache/servicemix/bpe/external/
main/java/org/apache/servicemix/bpe/timer/ main/java/org/apache/servi...
Author: gnodet
Date: Sat Apr 7 14:21:29 2007
New Revision: 526486
URL: http://svn.apache.org/viewvc?view=rev&rev=526486
Log:
Fix checkstyle and pmd violations
Modified:
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEBootstrap.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEComponent.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEDeployer.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPELifeCycle.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEServiceUnit.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiExternalAction.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerJdk.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerServiceJdk.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/util/FileSystemJarInputStream.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/uuid/ActiveMQUUIDService.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/Bank.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/CreditAgency.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEDeployerTest.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPESpringComponentTest.java
incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/util/FileSystemJarInputStreamTest.java
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEBootstrap.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEBootstrap.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEBootstrap.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEBootstrap.java Sat Apr 7 14:21:29 2007
@@ -16,15 +16,15 @@
*/
package org.apache.servicemix.bpe;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.jbi.JBIException;
import javax.jbi.component.Bootstrap;
import javax.jbi.component.InstallationContext;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* Base class for components bootstrap.
*
@@ -35,13 +35,14 @@
public class BPEBootstrap implements Bootstrap {
protected final transient Log logger = LogFactory.getLog(getClass());
-
+
protected InstallationContext context;
+
protected ObjectName mbeanName;
-
+
public BPEBootstrap() {
}
-
+
public ObjectName getExtensionMBeanName() {
return mbeanName;
}
@@ -49,7 +50,7 @@
protected Object getExtensionMBean() throws Exception {
return null;
}
-
+
protected ObjectName createExtensionMBeanName() throws Exception {
return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
}
@@ -88,7 +89,7 @@
server.registerMBean(mbean, this.mbeanName);
}
}
-
+
/* (non-Javadoc)
* @see javax.jbi.component.Bootstrap#cleanUp()
*/
@@ -141,7 +142,7 @@
protected void doOnInstall() throws Exception {
}
-
+
/* (non-Javadoc)
* @see javax.jbi.component.Bootstrap#onUninstall()
*/
@@ -163,5 +164,5 @@
protected void doOnUninstall() throws Exception {
}
-
+
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEComponent.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEComponent.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEComponent.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEComponent.java Sat Apr 7 14:21:29 2007
@@ -16,29 +16,27 @@
*/
package org.apache.servicemix.bpe;
+import org.apache.ode.bpe.bped.EventDirector;
import org.apache.servicemix.common.BaseComponent;
import org.apache.servicemix.common.BaseLifeCycle;
import org.apache.servicemix.common.BaseServiceUnitManager;
import org.apache.servicemix.common.Deployer;
-import org.apache.ode.bpe.bped.EventDirector;
-
public class BPEComponent extends BaseComponent {
- public static String PART_PAYLOAD = "payload";
-
+ public static final String PART_PAYLOAD = "payload";
+
public BPEComponent() {
}
-
- protected BaseLifeCycle createLifeCycle() {
- return new BPELifeCycle(this);
- }
-
- protected BaseServiceUnitManager createServiceUnitManager() {
- return new BaseServiceUnitManager(this,
- new Deployer[] { new BPEDeployer(this) });
- }
-
+
+ protected BaseLifeCycle createLifeCycle() {
+ return new BPELifeCycle(this);
+ }
+
+ protected BaseServiceUnitManager createServiceUnitManager() {
+ return new BaseServiceUnitManager(this, new Deployer[] {new BPEDeployer(this) });
+ }
+
public EventDirector getEventDirector() {
return ((BPELifeCycle) getLifeCycle()).getEventDirector();
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEDeployer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEDeployer.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEDeployer.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEDeployer.java Sat Apr 7 14:21:29 2007
@@ -38,9 +38,14 @@
import javax.wsdl.xml.WSDLReader;
import javax.wsdl.xml.WSDLWriter;
+import org.w3c.dom.Document;
+
+import com.ibm.wsdl.Constants;
+
import org.apache.ode.bpe.bped.DeployTypeEnum;
import org.apache.ode.bpe.bped.EventDirector;
import org.apache.ode.bpe.bped.IDeployer;
+import org.apache.ode.bpe.deployment.bpel.BPELDefinitionKey;
import org.apache.ode.bpe.wsdl.extensions.BPEAction;
import org.apache.ode.bpe.wsdl.extensions.BPEActionSerializer;
import org.apache.ode.bpe.wsdl.extensions.BPEFault;
@@ -56,37 +61,34 @@
import org.apache.ode.bpe.wsdl.extensions.BPEVariableMap;
import org.apache.ode.bpe.wsdl.extensions.BPEVariableMapSerializer;
import org.apache.ode.bpe.wsdl.extensions.ExtentionConstants;
-import org.apache.ode.bpe.deployment.bpel.BPELDefinitionKey;
import org.apache.servicemix.bpe.util.FileSystemJarInputStream;
import org.apache.servicemix.common.AbstractDeployer;
import org.apache.servicemix.common.ServiceUnit;
import org.apache.servicemix.common.tools.wsdl.WSDLFlattener;
-import org.w3c.dom.Document;
-
-import com.ibm.wsdl.Constants;
public class BPEDeployer extends AbstractDeployer {
protected FilenameFilter filter;
-
+
public BPEDeployer(BPEComponent component) {
- super(component);
+ super(component);
filter = new BpelFilter();
- }
+ }
- public boolean canDeploy(String serviceUnitName, String serviceUnitRootPath) {
+ public boolean canDeploy(String serviceUnitName, String serviceUnitRootPath) {
File[] bpels = new File(serviceUnitRootPath).listFiles(filter);
return bpels != null && bpels.length == 1;
- }
+ }
- public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException {
- try {
- EventDirector ed = ((BPEComponent) component).getEventDirector();
- IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
- Collection defKeys = deployer.loadDefinition(new FileSystemJarInputStream(new File(serviceUnitRootPath)), false);
- // Build the Service Unit
- BPEServiceUnit su = new BPEServiceUnit();
- su.setComponent(component);
+ public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException {
+ try {
+ EventDirector ed = ((BPEComponent) component).getEventDirector();
+ IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
+ Collection defKeys = deployer.loadDefinition(new FileSystemJarInputStream(new File(serviceUnitRootPath)),
+ false);
+ // Build the Service Unit
+ BPEServiceUnit su = new BPEServiceUnit();
+ su.setComponent(component);
su.setName(serviceUnitName);
su.setRootPath(serviceUnitRootPath);
su.setDefinitionKeys(defKeys);
@@ -96,38 +98,38 @@
WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
WSDLFlattener flattener = new WSDLFlattener(rootDef);
for (Iterator it = rootDef.getServices().values().iterator(); it.hasNext();) {
- Service svc = (Service) it.next();
- for (Iterator it2 = svc.getPorts().values().iterator(); it2.hasNext();) {
- Port pt = (Port) it2.next();
- BPEEndpoint ep = new BPEEndpoint();
- ep.setServiceUnit(su);
- ep.setInterfaceName(pt.getBinding().getPortType().getQName());
- ep.setService(svc.getQName());
- ep.setEndpoint(pt.getName());
+ Service svc = (Service) it.next();
+ for (Iterator it2 = svc.getPorts().values().iterator(); it2.hasNext();) {
+ Port pt = (Port) it2.next();
+ BPEEndpoint ep = new BPEEndpoint();
+ ep.setServiceUnit(su);
+ ep.setInterfaceName(pt.getBinding().getPortType().getQName());
+ ep.setService(svc.getQName());
+ ep.setEndpoint(pt.getName());
Definition def = flattener.getDefinition(ep.getInterfaceName());
Document desc = writer.getDocument(def);
ep.setDefinition(def);
ep.setDescription(desc);
// Retrieve wsdl
validate(ep);
- su.addEndpoint(ep);
- }
- }
- return su;
- } catch (DeploymentException e) {
- throw e;
- } catch (Exception e) {
- throw new DeploymentException(e);
- }
- }
+ su.addEndpoint(ep);
+ }
+ }
+ return su;
+ } catch (DeploymentException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ }
+ }
public void undeploy(ServiceUnit su) throws DeploymentException {
try {
- BPEServiceUnit bpeSU = (BPEServiceUnit)su;
+ BPEServiceUnit bpeSU = (BPEServiceUnit) su;
EventDirector ed = ((BPEComponent) component).getEventDirector();
IDeployer deployer = ed.getDeployer(DeployTypeEnum.BPEL);
- for (Iterator i = bpeSU.getDefinitionKeys().iterator(); i.hasNext(); ) {
- deployer.removeDefinition(((BPELDefinitionKey)i.next()).getKey());
+ for (Iterator i = bpeSU.getDefinitionKeys().iterator(); i.hasNext();) {
+ deployer.removeDefinition(((BPELDefinitionKey) i.next()).getKey());
}
su.shutDown();
} catch (DeploymentException e) {
@@ -143,12 +145,10 @@
for (Iterator iter = msgs.iterator(); iter.hasNext();) {
Message msg = (Message) iter.next();
if (msg.isUndefined()) {
- throw failure("deploy",
- "WSDL Message '" + msg.getQName() + "' is undefined. Check namespaces.", null);
+ throw failure("deploy", "WSDL Message '" + msg.getQName() + "' is undefined. Check namespaces.", null);
}
if (msg.getParts().size() > 1) {
- throw failure("deploy",
- "WSDL Message '" + msg.getQName() + "' has more than one part", null);
+ throw failure("deploy", "WSDL Message '" + msg.getQName() + "' has more than one part", null);
}
}
// Check imported wsdls
@@ -166,106 +166,64 @@
File[] bpels = new File(serviceUnitRootPath).listFiles(filter);
String bpel = bpels[0].getAbsoluteFile().toURI().toString();
String wsdl = bpel.substring(0, bpel.length() - 4) + "wsdl";
- WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
- reader.setFeature(Constants.FEATURE_VERBOSE, false);
- reader.setExtensionRegistry(getExtentionRegistry());
- // Parse the document and include any imported WSDL documents
- Definition ret = reader.readWSDL(null, wsdl);
- return ret;
- }
-
- private ExtensionRegistry getExtentionRegistry() {
-
- // Use IBM's implementation as a base registry. They have implemented
- // extensibility objects for SOAP,HTTP,MIME and we should not
- // loose these functions.
- ExtensionRegistry er = new com.ibm.wsdl.extensions.PopulatedExtensionRegistry();
-
- BPELPropertySerializer bpelPropSerializer = new BPELPropertySerializer();
- BPELPropertyAliasSerializer bpelPropAliasSerializer = new BPELPropertyAliasSerializer();
- BPEActionSerializer bpeActionSerializer = new BPEActionSerializer();
- BPEInputSerializer bpeInputSerializer = new BPEInputSerializer();
- BPEOutputSerializer bpeOutputSerializer = new BPEOutputSerializer();
- BPEFaultSerializer bpeFaultSerializer = new BPEFaultSerializer();
- BPEVariableMapSerializer bpeVariableSerializer = new BPEVariableMapSerializer();
-
- // Register the BPEL extension points
- er.registerSerializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY,
- bpelPropSerializer);
- er.registerDeserializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY,
- bpelPropSerializer);
- er.mapExtensionTypes(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY,
- BPELProperty.class);
- er.registerSerializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS,
- bpelPropAliasSerializer);
- er.registerDeserializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS,
- bpelPropAliasSerializer);
- er.mapExtensionTypes(Definition.class,
- ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS,
- BPELPropertyAlias.class);
-
- // register the BPE extension points
- er.registerSerializer(BindingOperation.class,
- ExtentionConstants.Q_ELEM_BPE_ACTION,
- bpeActionSerializer);
- er.registerDeserializer(BindingOperation.class,
- ExtentionConstants.Q_ELEM_BPE_ACTION,
- bpeActionSerializer);
- er.mapExtensionTypes(BindingOperation.class,
- ExtentionConstants.Q_ELEM_BPE_ACTION,
- BPEAction.class);
- er.registerSerializer(BindingInput.class,
- ExtentionConstants.Q_ELEM_BPE_INPUT,
- bpeInputSerializer);
- er.registerDeserializer(BindingInput.class,
- ExtentionConstants.Q_ELEM_BPE_INPUT,
- bpeInputSerializer);
- er.mapExtensionTypes(BindingInput.class,
- ExtentionConstants.Q_ELEM_BPE_INPUT,
- BPEInput.class);
- er.registerSerializer(BindingOutput.class,
- ExtentionConstants.Q_ELEM_BPE_OUTPUT,
- bpeOutputSerializer);
- er.registerDeserializer(BindingOutput.class,
- ExtentionConstants.Q_ELEM_BPE_OUTPUT,
- bpeOutputSerializer);
- er.mapExtensionTypes(BindingOutput.class,
- ExtentionConstants.Q_ELEM_BPE_OUTPUT,
- BPEOutput.class);
-
- er.registerSerializer(BindingFault.class,
- ExtentionConstants.Q_ELEM_BPE_FAULT,
- bpeFaultSerializer);
- er.registerDeserializer(BindingFault.class,
- ExtentionConstants.Q_ELEM_BPE_FAULT,
- bpeFaultSerializer);
- er.mapExtensionTypes(BindingFault.class,
- ExtentionConstants.Q_ELEM_BPE_FAULT,
- BPEFault.class);
-
- er.registerSerializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPE_VAR,
- bpeVariableSerializer);
- er.registerDeserializer(Definition.class,
- ExtentionConstants.Q_ELEM_BPE_VAR,
- bpeVariableSerializer);
- er.mapExtensionTypes(Definition.class,
- ExtentionConstants.Q_ELEM_BPE_VAR,
- BPEVariableMap.class);
-
- return er;
- }
-
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ reader.setFeature(Constants.FEATURE_VERBOSE, false);
+ reader.setExtensionRegistry(getExtentionRegistry());
+ // Parse the document and include any imported WSDL documents
+ return reader.readWSDL(null, wsdl);
+ }
+
+ private ExtensionRegistry getExtentionRegistry() {
+
+ // Use IBM's implementation as a base registry. They have implemented
+ // extensibility objects for SOAP,HTTP,MIME and we should not
+ // loose these functions.
+ ExtensionRegistry er = new com.ibm.wsdl.extensions.PopulatedExtensionRegistry();
+
+ BPELPropertySerializer bpelPropSerializer = new BPELPropertySerializer();
+ BPELPropertyAliasSerializer bpelPropAliasSerializer = new BPELPropertyAliasSerializer();
+ BPEActionSerializer bpeActionSerializer = new BPEActionSerializer();
+ BPEInputSerializer bpeInputSerializer = new BPEInputSerializer();
+ BPEOutputSerializer bpeOutputSerializer = new BPEOutputSerializer();
+ BPEFaultSerializer bpeFaultSerializer = new BPEFaultSerializer();
+ BPEVariableMapSerializer bpeVariableSerializer = new BPEVariableMapSerializer();
+
+ // Register the BPEL extension points
+ er.registerSerializer(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY, bpelPropSerializer);
+ er.registerDeserializer(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY, bpelPropSerializer);
+ er.mapExtensionTypes(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY, BPELProperty.class);
+ er.registerSerializer(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS, bpelPropAliasSerializer);
+ er.registerDeserializer(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS,
+ bpelPropAliasSerializer);
+ er.mapExtensionTypes(Definition.class, ExtentionConstants.Q_ELEM_BPEL_PROPERTY_ALIAS, BPELPropertyAlias.class);
+
+ // register the BPE extension points
+ er.registerSerializer(BindingOperation.class, ExtentionConstants.Q_ELEM_BPE_ACTION, bpeActionSerializer);
+ er.registerDeserializer(BindingOperation.class, ExtentionConstants.Q_ELEM_BPE_ACTION, bpeActionSerializer);
+ er.mapExtensionTypes(BindingOperation.class, ExtentionConstants.Q_ELEM_BPE_ACTION, BPEAction.class);
+ er.registerSerializer(BindingInput.class, ExtentionConstants.Q_ELEM_BPE_INPUT, bpeInputSerializer);
+ er.registerDeserializer(BindingInput.class, ExtentionConstants.Q_ELEM_BPE_INPUT, bpeInputSerializer);
+ er.mapExtensionTypes(BindingInput.class, ExtentionConstants.Q_ELEM_BPE_INPUT, BPEInput.class);
+ er.registerSerializer(BindingOutput.class, ExtentionConstants.Q_ELEM_BPE_OUTPUT, bpeOutputSerializer);
+ er.registerDeserializer(BindingOutput.class, ExtentionConstants.Q_ELEM_BPE_OUTPUT, bpeOutputSerializer);
+ er.mapExtensionTypes(BindingOutput.class, ExtentionConstants.Q_ELEM_BPE_OUTPUT, BPEOutput.class);
+
+ er.registerSerializer(BindingFault.class, ExtentionConstants.Q_ELEM_BPE_FAULT, bpeFaultSerializer);
+ er.registerDeserializer(BindingFault.class, ExtentionConstants.Q_ELEM_BPE_FAULT, bpeFaultSerializer);
+ er.mapExtensionTypes(BindingFault.class, ExtentionConstants.Q_ELEM_BPE_FAULT, BPEFault.class);
+
+ er.registerSerializer(Definition.class, ExtentionConstants.Q_ELEM_BPE_VAR, bpeVariableSerializer);
+ er.registerDeserializer(Definition.class, ExtentionConstants.Q_ELEM_BPE_VAR, bpeVariableSerializer);
+ er.mapExtensionTypes(Definition.class, ExtentionConstants.Q_ELEM_BPE_VAR, BPEVariableMap.class);
+
+ return er;
+ }
+
public static class BpelFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return name.endsWith(".bpel");
}
-
+
}
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEEndpoint.java Sat Apr 7 14:21:29 2007
@@ -26,14 +26,16 @@
import javax.jbi.messaging.InOptionalOut;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchange.Role;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.messaging.RobustInOnly;
-import javax.jbi.messaging.MessageExchange.Role;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.wsdl.Operation;
import javax.wsdl.PortType;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Document;
+
import org.apache.ode.bpe.bped.EventDirector;
import org.apache.ode.bpe.client.IFormattableValue;
import org.apache.ode.bpe.event.BPELStaticKey;
@@ -47,53 +49,52 @@
import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.ExchangeProcessor;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.w3c.dom.Document;
public class BPEEndpoint extends Endpoint implements ExchangeProcessor {
+ private static final ThreadLocal<BPEEndpoint> ENDPOINT = new ThreadLocal<BPEEndpoint>();
+
protected ServiceEndpoint activated;
protected DeliveryChannel channel;
protected SourceTransformer transformer = new SourceTransformer();
-
- private static final ThreadLocal ENDPOINT = new ThreadLocal();
-
+
public static BPEEndpoint getCurrent() {
- return (BPEEndpoint) ENDPOINT.get();
+ return ENDPOINT.get();
}
-
+
public static void setCurrent(BPEEndpoint endpoint) {
ENDPOINT.set(endpoint);
}
-
- public Role getRole() {
- return Role.PROVIDER;
- }
- public void activate() throws Exception {
+ public Role getRole() {
+ return Role.PROVIDER;
+ }
+
+ public void activate() throws Exception {
logger = this.serviceUnit.getComponent().getLogger();
ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
activated = ctx.activateEndpoint(service, endpoint);
channel = ctx.getDeliveryChannel();
- }
+ }
- public void deactivate() throws Exception {
+ public void deactivate() throws Exception {
ServiceEndpoint ep = activated;
activated = null;
ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
ctx.deactivateEndpoint(ep);
- }
+ }
- public ExchangeProcessor getProcessor() {
- return this;
- }
+ public ExchangeProcessor getProcessor() {
+ return this;
+ }
- public void process(MessageExchange exchange) throws Exception {
+ public void process(MessageExchange exchange) throws Exception {
if (exchange.getStatus() == ExchangeStatus.DONE) {
return;
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
return;
}
-
+
String inputPartName = BPEComponent.PART_PAYLOAD;
String outputPartName = BPEComponent.PART_PAYLOAD;
if (exchange.getOperation() != null) {
@@ -101,27 +102,15 @@
Operation oper = pt.getOperation(exchange.getOperation().getLocalPart(), null, null);
if (oper.getInput() != null && oper.getInput().getMessage() != null) {
Map parts = oper.getInput().getMessage().getParts();
- inputPartName = (String) parts.keySet().iterator().next();
+ inputPartName = (String) parts.keySet().iterator().next();
}
if (oper.getOutput() != null && oper.getOutput().getMessage() != null) {
Map parts = oper.getOutput().getMessage().getParts();
- outputPartName = (String) parts.keySet().iterator().next();
+ outputPartName = (String) parts.keySet().iterator().next();
}
}
-
-
- BPELStaticKey bsk = new BPELStaticKey();
- bsk.setTargetNamespace(getInterfaceName().getNamespaceURI());
- bsk.setPortType(getInterfaceName().getLocalPart());
- if (exchange.getOperation() != null) {
- bsk.setOperation(exchange.getOperation().getLocalPart());
- }
- SimpleRequestMessageEvent msg = new SimpleRequestMessageEvent();
- msg.setStaticKey(bsk);
- XMLInteractionObject interaction = new XMLInteractionObject();
- interaction.setDocument(transformer.toDOMDocument(exchange.getMessage("in")));
- msg.setPart(inputPartName, interaction);
-
+
+ SimpleRequestMessageEvent msg = createEvent(exchange, inputPartName);
EventDirector ed = ((BPEComponent) getServiceUnit().getComponent()).getEventDirector();
try {
IResponseMessage response;
@@ -141,7 +130,8 @@
throw new BPRuntimeException(response.getFault().getFaultString(), "");
} else if (exchange instanceof InOnly || exchange instanceof RobustInOnly) {
if (payload != null) {
- throw new UnsupportedOperationException("Did not expect return value for in-only or robust-in-only");
+ throw new UnsupportedOperationException(
+ "Did not expect return value for in-only or robust-in-only");
}
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
@@ -157,7 +147,7 @@
}
} else if (exchange instanceof InOut) {
if (payload == null) {
- throw new UnsupportedOperationException("Expected return data for in-out");
+ throw new UnsupportedOperationException("Expected return data for in-out");
}
NormalizedMessage out = exchange.createMessage();
out.setContent(new DOMSource(getDocument(payload)));
@@ -185,24 +175,38 @@
}
channel.send(exchange);
}
- }
+ }
+
+ protected SimpleRequestMessageEvent createEvent(MessageExchange exchange, String inputPartName) throws Exception {
+ BPELStaticKey bsk = new BPELStaticKey();
+ bsk.setTargetNamespace(getInterfaceName().getNamespaceURI());
+ bsk.setPortType(getInterfaceName().getLocalPart());
+ if (exchange.getOperation() != null) {
+ bsk.setOperation(exchange.getOperation().getLocalPart());
+ }
+ SimpleRequestMessageEvent msg = new SimpleRequestMessageEvent();
+ msg.setStaticKey(bsk);
+ XMLInteractionObject interaction = new XMLInteractionObject();
+ interaction.setDocument(transformer.toDOMDocument(exchange.getMessage("in")));
+ msg.setPart(inputPartName, interaction);
+ return msg;
+ }
+
+ public void start() throws Exception {
+ }
- public void start() throws Exception {
- }
+ public void stop() throws Exception {
+ }
- public void stop() throws Exception {
- }
-
- protected Document getDocument(IInteraction interaction) throws InteractionException {
- Object obj = interaction.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
+ protected Document getDocument(IInteraction interaction) throws InteractionException {
+ Object obj = interaction.invoke(InvocationFactory.newInstance().createGetObjectInvocation());
if (obj instanceof Document) {
- return (Document) obj;
+ return (Document) obj;
} else if (obj instanceof IFormattableValue) {
- return (Document) ((IFormattableValue) obj).getValueAs(Document.class);
+ return (Document) ((IFormattableValue) obj).getValueAs(Document.class);
} else {
- throw new IllegalStateException("Unable to handle object of type: " + obj.getClass().getName());
+ throw new IllegalStateException("Unable to handle object of type: " + obj.getClass().getName());
}
- }
-
+ }
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPELifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPELifeCycle.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPELifeCycle.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPELifeCycle.java Sat Apr 7 14:21:29 2007
@@ -16,22 +16,21 @@
*/
package org.apache.servicemix.bpe;
-import org.apache.servicemix.common.BaseComponent;
-import org.apache.servicemix.common.BaseLifeCycle;
-
import org.apache.ode.bpe.bped.EventDirector;
import org.apache.ode.bpe.bped.EventDirectorFactory;
import org.apache.ode.bpe.util.BPEProperties;
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
public class BPELifeCycle extends BaseLifeCycle {
public static final String IM_ENGINE_PROPERTY_FILE_NAME = "bpeEngine.properties";
-
+
private EventDirector eventDirector;
-
- public BPELifeCycle(BaseComponent component) {
- super(component);
- }
+
+ public BPELifeCycle(BaseComponent component) {
+ super(component);
+ }
public EventDirector getEventDirector() {
return eventDirector;
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEServiceUnit.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEServiceUnit.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/BPEServiceUnit.java Sat Apr 7 14:21:29 2007
@@ -16,11 +16,11 @@
*/
package org.apache.servicemix.bpe;
+import java.util.Collection;
+
import javax.wsdl.Definition;
import org.apache.servicemix.common.ServiceUnit;
-
-import java.util.Collection;
public class BPEServiceUnit extends ServiceUnit {
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiExternalAction.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiExternalAction.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiExternalAction.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiExternalAction.java Sat Apr 7 14:21:29 2007
@@ -34,28 +34,28 @@
public class JbiExternalAction extends ExternalServiceAction {
- private static Log log = LogFactory.getLog(JbiExternalAction.class);
-
public static final String SM_NS = "http://servicemix.apache.org/schemas/bpe/1.0";
public static final String SM_ENDPOINT = "endpoint";
public static final String SM_SERVICE = "service";
public static final String SM_MEP = "mep";
+ private static final Log LOG = LogFactory.getLog(JbiExternalAction.class);
+
public JbiExternalAction() {
super();
}
public void init(Properties props) throws BPException {
- if (log.isDebugEnabled()) {
- log.debug("init");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("init");
}
extractInformations(props);
// Do not store informations about operation
props.remove(ExternalServiceAction.OPERATION_KEY);
super.init(props);
- if (log.isDebugEnabled()) {
- log.debug("properties: " + props);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("properties: " + props);
}
}
@@ -103,7 +103,7 @@
String epName = uri.substring(idx1 + 1);
String svcName = uri.substring(idx2 + 1, idx1);
String nsUri = uri.substring(0, idx2);
- return new String[] { nsUri, svcName, epName };
+ return new String[] {nsUri, svcName, epName };
}
protected String[] split2(String uri) {
@@ -116,7 +116,7 @@
int idx1 = uri.lastIndexOf(sep);
String svcName = uri.substring(idx1 + 1);
String nsUri = uri.substring(0, idx1);
- return new String[] { nsUri, svcName };
+ return new String[] {nsUri, svcName };
}
public boolean execute(
@@ -124,8 +124,7 @@
IEvaluationContext ec,
IProcessCallBack pcb,
IPMIProcess processInstance,
- IPMDProcess processDefinition)
- throws BPException {
+ IPMDProcess processDefinition) throws BPException {
return super.execute(resolver, ec, pcb, processInstance, processDefinition);
}
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/external/JbiInvokeAction.java Sat Apr 7 14:21:29 2007
@@ -28,6 +28,7 @@
import javax.jbi.messaging.MessageExchangeFactory;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
import javax.wsdl.Definition;
import javax.wsdl.Fault;
import javax.wsdl.Operation;
@@ -37,6 +38,9 @@
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpe.action.external.ActionSystemException;
@@ -52,8 +56,6 @@
import org.apache.servicemix.jbi.jaxp.BytesSource;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
public class JbiInvokeAction implements IExternalAction {
@@ -67,9 +69,14 @@
public static final String ACTION = "action";
public static final String ENDPOINT = "endpoint";
public static final String MEP = "mep";
-
- private static Log log = LogFactory.getLog(JbiInvokeAction.class);
-
+
+ private static final Log LOG = LogFactory.getLog(JbiInvokeAction.class);
+
+ /**
+ * Generated serial version UID
+ */
+ private static final long serialVersionUID = -8522450752525724302L;
+
private Properties properties;
private QName interfaceName;
private QName serviceName;
@@ -80,31 +87,26 @@
private URI mep;
private SourceTransformer transformer;
private Operation wsdlOperation;
-
- /**
- * Generated serial version UID
- */
- private static final long serialVersionUID = -8522450752525724302L;
-
+
public JbiInvokeAction() {
transformer = new SourceTransformer();
}
- public void init(Properties props) throws BPRuntimeException, ActionSystemException {
- if (log.isDebugEnabled()) {
- log.debug("init");
+ public void init(Properties props) throws BPRuntimeException, ActionSystemException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("init");
}
this.properties = props;
extractInformations();
- if (serviceName == null && interfaceName == null) {
+ if (serviceName == null && interfaceName == null) {
throw new BPRuntimeException("Interface, Service or Endpoint should be specified", "");
}
- if (log.isDebugEnabled()) {
- log.debug("properties: " + props);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("properties: " + props);
}
- }
+ }
- protected void extractInformations() {
+ protected void extractInformations() {
String action = properties.getProperty(ACTION);
if (action != null) {
String[] parts = split(action);
@@ -122,7 +124,7 @@
operationName = new QName(operationNamespace, operationLocalName);
}
}
- String endpoint = properties.getProperty(ENDPOINT);
+ String endpoint = properties.getProperty(ENDPOINT);
if (endpoint != null) {
String[] parts = split(action);
serviceName = new QName(parts[0], parts[1]);
@@ -135,45 +137,44 @@
}
endpointName = properties.getProperty(ENDPOINT_NAME);
}
- String mep = properties.getProperty(MEP);
- if (mep == null) {
+ String mepStr = properties.getProperty(MEP);
+ if (mepStr == null) {
BPEEndpoint ep = BPEEndpoint.getCurrent();
Definition def = ((BPEServiceUnit) ep.getServiceUnit()).getDefinition();
PortType pt = def.getPortType(interfaceName);
Operation oper = pt != null ? pt.getOperation(operationName.getLocalPart(), null, null) : null;
if (oper != null) {
- boolean output = oper.getOutput() != null &&
- oper.getOutput().getMessage() != null &&
- oper.getOutput().getMessage().getParts().size() > 0;
+ boolean output = oper.getOutput() != null && oper.getOutput().getMessage() != null
+ && oper.getOutput().getMessage().getParts().size() > 0;
boolean faults = oper.getFaults().size() > 0;
if (output) {
- mep = "in-out";
+ mepStr = "in-out";
} else if (faults) {
- mep = "robust-in-only";
+ mepStr = "robust-in-only";
} else {
- mep = "in-only";
+ mepStr = "in-only";
}
if (oper.getInput() != null && oper.getInput().getMessage() != null) {
Map parts = oper.getInput().getMessage().getParts();
- inputPartName = (String) parts.keySet().iterator().next();
+ inputPartName = (String) parts.keySet().iterator().next();
}
if (oper.getOutput() != null && oper.getOutput().getMessage() != null) {
Map parts = oper.getOutput().getMessage().getParts();
- outputPartName = (String) parts.keySet().iterator().next();
+ outputPartName = (String) parts.keySet().iterator().next();
}
wsdlOperation = oper;
}
}
- if (mep == null) {
- mep = "in-out";
+ if (mepStr == null) {
+ mepStr = "in-out";
}
- this.mep = URI.create("http://www.w3.org/2004/08/wsdl/" + mep);
+ this.mep = URI.create("http://www.w3.org/2004/08/wsdl/" + mepStr);
}
- public void execute(HashMap input, HashMap output, IURIResolver resolver)
- throws BPRuntimeException, ActionSystemException {
- if (log.isDebugEnabled()) {
- log.debug("execute");
+ public void execute(HashMap input, HashMap output,
+ IURIResolver resolver) throws BPRuntimeException, ActionSystemException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("execute");
}
Object payload = input.get(inputPartName);
Source inputSource = getSourceFromPayload(payload);
@@ -187,6 +188,10 @@
MessageExchange me = factory.createExchange(this.mep);
me.setInterfaceName(interfaceName);
me.setService(serviceName);
+ if (endpointName != null) {
+ ServiceEndpoint ep = component.getComponentContext().getEndpoint(serviceName, endpointName);
+ me.setEndpoint(ep);
+ }
// TODO: set endpoint
me.setOperation(operationName);
NormalizedMessage nm = me.createMessage();
@@ -260,11 +265,11 @@
} catch (MessagingException e) {
throw new ActionSystemException(e);
}
- if (log.isDebugEnabled()) {
- log.debug("Request: " + payload);
- log.debug("Response: " + output.get(outputPartName));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Request: " + payload);
+ LOG.debug("Response: " + output.get(outputPartName));
}
- }
+ }
protected Source getSourceFromPayload(Object payload) {
Source inputSource;
@@ -293,26 +298,23 @@
}
return inputSource;
}
-
- public void release() {
- if (log.isDebugEnabled()) {
- log.debug("release");
+
+ public void release() {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("release");
}
- }
+ }
public void process(MessageExchange exchange) throws Exception {
// TODO Auto-generated method stub
-
}
public void start() throws Exception {
// TODO Auto-generated method stub
-
}
public void stop() throws Exception {
// TODO Auto-generated method stub
-
}
protected String[] split(String uri) {
@@ -326,7 +328,7 @@
int idx2 = uri.lastIndexOf(sep, idx1 - 1);
String epName = uri.substring(idx1 + 1);
String svcName = uri.substring(idx2 + 1, idx1);
- String nsUri = uri.substring(0, idx2);
- return new String[] { nsUri, svcName, epName };
+ String nsUri = uri.substring(0, idx2);
+ return new String[] {nsUri, svcName, epName };
}
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerJdk.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerJdk.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerJdk.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerJdk.java Sat Apr 7 14:21:29 2007
@@ -21,12 +21,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.servicemix.bpe.BPEComponent;
-import org.apache.servicemix.bpe.BPEEndpoint;
-
import org.apache.ode.bpe.bped.EventDirector;
import org.apache.ode.bpe.event.ITimerEvent;
import org.apache.ode.bpe.timerservice.IBPETimer;
+import org.apache.servicemix.bpe.BPEComponent;
+import org.apache.servicemix.bpe.BPEEndpoint;
public class BPETimerJdk extends TimerTask implements IBPETimer {
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerServiceJdk.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerServiceJdk.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerServiceJdk.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/timer/BPETimerServiceJdk.java Sat Apr 7 14:21:29 2007
@@ -31,7 +31,8 @@
public class BPETimerServiceJdk implements IBPETimerService {
- private static final Log log = LogFactory.getLog(BPETimerServiceJdk.class);
+ private static final Log LOG = LogFactory.getLog(BPETimerServiceJdk.class);
+
private static Timer timer;
public BPETimerServiceJdk() {
@@ -39,8 +40,8 @@
}
public IBPETimer createTimer(long startDuration, ITimerEvent timerEvent) throws BPException {
- if (log.isDebugEnabled()) {
- log.debug("Schedule timer " + timerEvent + " for " + startDuration);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Schedule timer " + timerEvent + " for " + startDuration);
}
BPETimerJdk tt = new BPETimerJdk(timerEvent, BPEEndpoint.getCurrent());
timer.schedule(tt, startDuration);
@@ -48,19 +49,19 @@
}
public IBPETimer createTimer(Date startTime, ITimerEvent timerEvent) throws BPException {
- if (log.isDebugEnabled()) {
- log.debug("Schedule timer " + timerEvent + " at " + startTime);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Schedule timer " + timerEvent + " at " + startTime);
}
BPETimerJdk tt = new BPETimerJdk(timerEvent, BPEEndpoint.getCurrent());
timer.schedule(tt, startTime);
return tt;
}
- public void removeTimer(IBPETimer timer) throws BPException {
- if (log.isDebugEnabled()) {
- log.debug("Timer " + timer.getTimerEvent() + " cancelled");
+ public void removeTimer(IBPETimer tmr) throws BPException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Timer " + tmr.getTimerEvent() + " cancelled");
}
- ((BPETimerJdk) timer).cancel();
+ ((BPETimerJdk) tmr).cancel();
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/util/FileSystemJarInputStream.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/util/FileSystemJarInputStream.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/util/FileSystemJarInputStream.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/util/FileSystemJarInputStream.java Sat Apr 7 14:21:29 2007
@@ -27,43 +27,47 @@
public class FileSystemJarInputStream extends InputStream implements Runnable {
- private File root;
- private PipedInputStream input;
- private PipedOutputStream output;
- private Thread runner;
- private IOException exception;
-
- public FileSystemJarInputStream(File root) throws IOException {
- this.root = root;
- input = new PipedInputStream();
- output = new PipedOutputStream(input);
- }
-
- public int read() throws IOException {
- if (runner == null) {
- runner = new Thread(this);
- runner.setDaemon(true);
- runner.start();
- }
- if (exception != null) {
- throw exception;
- }
- return input.read();
- }
-
- public void run() {
- try {
- JarOutputStream jos = new JarOutputStream(output);
- FileUtil.zipDir(root.getAbsolutePath(), jos, "");
- jos.close();
- } catch (IOException e) {
- exception = e;
+ private File root;
+
+ private PipedInputStream input;
+
+ private PipedOutputStream output;
+
+ private Thread runner;
+
+ private IOException exception;
+
+ public FileSystemJarInputStream(File root) throws IOException {
+ this.root = root;
+ input = new PipedInputStream();
+ output = new PipedOutputStream(input);
+ }
+
+ public int read() throws IOException {
+ if (runner == null) {
+ runner = new Thread(this);
+ runner.setDaemon(true);
+ runner.start();
+ }
+ if (exception != null) {
+ throw exception;
+ }
+ return input.read();
+ }
+
+ public void run() {
+ try {
+ JarOutputStream jos = new JarOutputStream(output);
+ FileUtil.zipDir(root.getAbsolutePath(), jos, "");
+ jos.close();
+ } catch (IOException e) {
+ exception = e;
try {
output.close();
} catch (IOException e2) {
e2.printStackTrace();
}
- }
- }
+ }
+ }
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/uuid/ActiveMQUUIDService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/uuid/ActiveMQUUIDService.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/uuid/ActiveMQUUIDService.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/main/java/org/apache/servicemix/bpe/uuid/ActiveMQUUIDService.java Sat Apr 7 14:21:29 2007
@@ -21,11 +21,10 @@
import org.apache.ode.bpe.uuid.UUIDServiceException;
import org.apache.servicemix.id.IdGenerator;
-
public class ActiveMQUUIDService implements UUIDService {
private IdGenerator idGenerator;
-
+
public ActiveMQUUIDService() {
idGenerator = new IdGenerator();
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/Bank.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/Bank.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/Bank.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/Bank.java Sat Apr 7 14:21:29 2007
@@ -43,7 +43,8 @@
}
System.err.println(getService().getLocalPart() + " requested");
try {
- String output = "<getLoanQuoteResponse xmlns=\"urn:logicblaze:soa:bank\"><rate>" + (Math.ceil(1000 * Math.random()) / 100) + "</rate></getLoanQuoteResponse>";
+ String output = "<getLoanQuoteResponse xmlns=\"urn:logicblaze:soa:bank\"><rate>"
+ + (Math.ceil(1000 * Math.random()) / 100) + "</rate></getLoanQuoteResponse>";
NormalizedMessage answer = inOut.createMessage();
answer.setContent(new StringSource(output));
answer(inOut, answer);
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/CreditAgency.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/CreditAgency.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/CreditAgency.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/loanbroker/CreditAgency.java Sat Apr 7 14:21:29 2007
@@ -25,11 +25,6 @@
import javax.xml.namespace.QName;
import javax.xml.transform.TransformerException;
-import org.apache.servicemix.MessageExchangeListener;
-import org.apache.servicemix.components.util.ComponentSupport;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
-import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.jbi.util.DOMUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -37,6 +32,12 @@
import com.sun.org.apache.xpath.internal.CachedXPathAPI;
+import org.apache.servicemix.MessageExchangeListener;
+import org.apache.servicemix.components.util.ComponentSupport;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.util.DOMUtil;
+
public class CreditAgency extends ComponentSupport implements MessageExchangeListener {
public CreditAgency() {
@@ -60,7 +61,9 @@
}
if (!ssn.startsWith("1")) {
Fault fault = inOut.createFault();
- fault.setContent(new StringSource("<invalidSSNFault xmlns=\"urn:logicblaze:soa:creditagency:types\"><ssn>" + ssn + "</ssn></invalidSSNFault>"));
+ fault.setContent(new StringSource(
+ "<invalidSSNFault xmlns=\"urn:logicblaze:soa:creditagency:types\"><ssn>"
+ + ssn + "</ssn></invalidSSNFault>"));
fail(inOut, fault);
} else {
String operation = null;
@@ -71,9 +74,11 @@
}
String output;
if ("getCreditScore".equals(operation)) {
- output = "<getCreditScoreResponse xmlns=\"urn:logicblaze:soa:creditagency\"><score>" + getCreditScore(ssn) + "</score></getCreditScoreResponse>";
+ output = "<getCreditScoreResponse xmlns=\"urn:logicblaze:soa:creditagency\"><score>"
+ + getCreditScore(ssn) + "</score></getCreditScoreResponse>";
} else if ("getCreditHistoryLength".equals(operation)) {
- output = "<getCreditHistoryLengthResponse xmlns=\"urn:logicblaze:soa:creditagency\"><length>" + getCreditHistoryLength(ssn) + "</length></getCreditHistoryLengthResponse>";
+ output = "<getCreditHistoryLengthResponse xmlns=\"urn:logicblaze:soa:creditagency\"><length>"
+ + getCreditHistoryLength(ssn) + "</length></getCreditHistoryLengthResponse>";
} else {
throw new UnsupportedOperationException(operation);
}
@@ -103,10 +108,8 @@
if (element == null) {
return "";
}
- String text = DOMUtil.getElementText(element);
- return text;
- }
- else if (root != null) {
+ return DOMUtil.getElementText(element);
+ } else if (root != null) {
return root.getNodeValue();
} else {
return null;
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEComponentTest.java Sat Apr 7 14:21:29 2007
@@ -34,8 +34,8 @@
import org.apache.servicemix.client.DefaultServiceMixClient;
import org.apache.servicemix.client.ServiceMixClient;
-import org.apache.servicemix.http.HttpEndpoint;
import org.apache.servicemix.http.HttpComponent;
+import org.apache.servicemix.http.HttpEndpoint;
import org.apache.servicemix.jbi.container.ActivationSpec;
import org.apache.servicemix.jbi.container.JBIContainer;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
@@ -45,9 +45,11 @@
public class BPEComponentTest extends TestCase {
private JBIContainer jbi;
+
private BPEComponent bpe;
+
private ServiceMixClient client;
-
+
protected void setUp() throws Exception {
jbi = new JBIContainer();
jbi.setEmbedded(true);
@@ -56,20 +58,20 @@
bpe = new BPEComponent();
jbi.activateComponent(bpe, "bpe");
}
-
+
protected void tearDown() throws Exception {
if (jbi != null) {
jbi.shutDown();
}
}
-
+
protected void registerCreditAgency() throws Exception {
ActivationSpec creditAgency = new ActivationSpec();
creditAgency.setInterfaceName(new QName("urn:logicblaze:soa:creditagency", "CreditAgency"));
creditAgency.setComponent(new CreditAgency());
jbi.activateComponent(creditAgency);
}
-
+
protected void registerBanks() throws Exception {
for (int i = 1; i <= 5; i++) {
ActivationSpec bank = new ActivationSpec();
@@ -78,8 +80,7 @@
jbi.activateComponent(bank);
}
}
-
-
+
protected void registerHttp() throws Exception {
HttpComponent http = new HttpComponent();
HttpEndpoint ep = new HttpEndpoint();
@@ -89,30 +90,33 @@
ep.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
ep.setEndpoint("loanbroker");
ep.setLocationURI("http://localhost:8192");
- http.setEndpoints(new HttpEndpoint[] { ep });
+ http.setEndpoints(new HttpEndpoint[] {ep });
jbi.activateComponent(http, "http");
}
-
+
public static void copyInputStream(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
- int len;
- while ((len = in.read(buffer)) >= 0) {
+ for (;;) {
+ int len = in.read(buffer);
+ if (len < 0) {
+ break;
+ }
out.write(buffer, 0, len);
}
}
-
+
public void testWithHttp() throws Exception {
registerCreditAgency();
registerBanks();
registerHttp();
jbi.start();
-
+
URL url = getClass().getClassLoader().getResource("loanbroker/loanbroker.bpel");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
bpe.getServiceUnitManager().start("loanbroker");
-
+
HttpURLConnection con = (HttpURLConnection) new URL("http://localhost:8192").openConnection();
con.setDoOutput(true);
con.setDoInput(true);
@@ -121,25 +125,28 @@
copyInputStream(is, os);
copyInputStream(con.getInputStream(), System.out);
}
-
+
public void testBPEOk() throws Exception {
registerCreditAgency();
registerBanks();
jbi.start();
-
+
URL url = getClass().getClassLoader().getResource("loanbroker/loanbroker.bpel");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
bpe.getServiceUnitManager().start("loanbroker");
-
+
//
// Message for bank1 and bank2
//
MessageExchange me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>1234341</ssn><amount>100000.0</amount><duration>12</duration></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
+ + "<ssn>1234341</ssn><amount>100000.0</amount><duration>12</duration>"
+ + "</getLoanQuoteRequest>"));
long t0 = System.currentTimeMillis();
client.sendSync(me);
long t1 = System.currentTimeMillis();
@@ -151,14 +158,17 @@
System.err.println(out);
System.err.println("Time: " + (t1 - t0));
client.done(me);
-
+
//
// Message for bank3 and bank4
//
me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>1234341</ssn><amount>50000.0</amount><duration>12</duration></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
+ + "<ssn>1234341</ssn><amount>50000.0</amount><duration>12</duration>"
+ + "</getLoanQuoteRequest>"));
t0 = System.currentTimeMillis();
client.sendSync(me);
t1 = System.currentTimeMillis();
@@ -170,14 +180,17 @@
System.err.println(out);
System.err.println("Time: " + (t1 - t0));
client.done(me);
-
+
//
// Message for bank5
//
me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>1234341</ssn><amount>1200.0</amount><duration>12</duration></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
+ + "<ssn>1234341</ssn><amount>1200.0</amount><duration>12</duration>"
+ + "</getLoanQuoteRequest>"));
t0 = System.currentTimeMillis();
client.sendSync(me);
t1 = System.currentTimeMillis();
@@ -190,21 +203,23 @@
System.err.println("Time: " + (t1 - t0));
client.done(me);
}
-
+
public void testBPEWithFault() throws Exception {
registerCreditAgency();
jbi.start();
-
+
URL url = getClass().getClassLoader().getResource("loanbroker/loanbroker.bpel");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
bpe.getServiceUnitManager().start("loanbroker");
-
+
MessageExchange me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>234341</ssn></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
+ + "<ssn>234341</ssn></getLoanQuoteRequest>"));
client.sendSync(me);
if (me.getError() != null) {
throw me.getError();
@@ -213,24 +228,26 @@
assertNotNull(me.getFault());
client.done(me);
}
-
+
public void testBPEWithException() throws Exception {
registerCreditAgency();
jbi.start();
-
+
URL url = getClass().getClassLoader().getResource("loanbroker/loanbroker.bpel");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
bpe.getServiceUnitManager().deploy("loanbroker", path.getAbsolutePath());
bpe.getServiceUnitManager().start("loanbroker");
-
+
MessageExchange me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn></ssn></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\">"
+ + "<ssn></ssn></getLoanQuoteRequest>"));
client.sendSync(me);
assertEquals(ExchangeStatus.ERROR, me.getStatus());
assertNotNull(me.getError());
}
-
+
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEDeployerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEDeployerTest.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEDeployerTest.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPEDeployerTest.java Sat Apr 7 14:21:29 2007
@@ -22,24 +22,22 @@
import junit.framework.TestCase;
-import org.apache.servicemix.bpe.BPEComponent;
-import org.apache.servicemix.bpe.BPEDeployer;
import org.apache.servicemix.common.ServiceUnit;
public class BPEDeployerTest extends TestCase {
- public void testDeploy() throws Exception {
+ public void testDeploy() throws Exception {
URL url = getClass().getClassLoader().getResource("loanbroker/loanbroker.bpel");
File path = new File(new URI(url.toString()));
path = path.getParentFile();
-
+
BPEComponent bpe = new BPEComponent();
((BPELifeCycle) bpe.getLifeCycle()).doInit();
- BPEDeployer deployer = new BPEDeployer(bpe);
- assertTrue(deployer.canDeploy("loanbroker", path.getAbsolutePath()));
-
- ServiceUnit su = deployer.deploy("loanbroker", path.getAbsolutePath());
- assertNotNull(su);
- }
-
+ BPEDeployer deployer = new BPEDeployer(bpe);
+ assertTrue(deployer.canDeploy("loanbroker", path.getAbsolutePath()));
+
+ ServiceUnit su = deployer.deploy("loanbroker", path.getAbsolutePath());
+ assertNotNull(su);
+ }
+
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPESpringComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPESpringComponentTest.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPESpringComponentTest.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/BPESpringComponentTest.java Sat Apr 7 14:21:29 2007
@@ -35,7 +35,9 @@
MessageExchange me = client.createInOutExchange();
me.setService(new QName("urn:logicblaze:soa:loanbroker", "LoanBrokerService"));
me.setOperation(new QName("getLoanQuote"));
- me.getMessage("in").setContent(new StringSource("<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>1234341</ssn><amount>100000.0</amount><duration>12</duration></getLoanQuoteRequest>"));
+ me.getMessage("in").setContent(new StringSource(
+ "<getLoanQuoteRequest xmlns=\"urn:logicblaze:soa:loanbroker\"><ssn>1234341</ssn>"
+ + "<amount>100000.0</amount><duration>12</duration></getLoanQuoteRequest>"));
long t0 = System.currentTimeMillis();
client.sendSync(me);
long t1 = System.currentTimeMillis();
@@ -48,9 +50,9 @@
System.err.println("Time: " + (t1 - t0));
client.done(me);
}
-
+
protected AbstractXmlApplicationContext createBeanFactory() {
return new ClassPathXmlApplicationContext("org/apache/servicemix/bpe/spring.xml");
}
-
+
}
Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/util/FileSystemJarInputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/util/FileSystemJarInputStreamTest.java?view=diff&rev=526486&r1=526485&r2=526486
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/util/FileSystemJarInputStreamTest.java (original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-bpe/src/test/java/org/apache/servicemix/bpe/util/FileSystemJarInputStreamTest.java Sat Apr 7 14:21:29 2007
@@ -25,42 +25,44 @@
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
-import org.apache.servicemix.bpe.util.FileSystemJarInputStream;
-
import junit.framework.TestCase;
public class FileSystemJarInputStreamTest extends TestCase {
- private static final int BUFFER = 2048;
+ private static final int BUFFER = 2048;
+
+ public void testInputStream() throws Exception {
+ File f = new File("target/test-data");
+ f.mkdirs();
+ Writer w = new OutputStreamWriter(new FileOutputStream(new File(f, "test.txt")));
+ w.write("<hello>world</hello>");
+ w.close();
+
+ FileSystemJarInputStream fsjis = new FileSystemJarInputStream(f);
+ JarInputStream jis = new JarInputStream(fsjis);
+
+ JarEntry entry = jis.getNextJarEntry();
+ assertNotNull(entry);
+ assertEquals("test.txt", entry.getName());
+
+ // Copy data from jar file into byte array
+ BufferedOutputStream dest = null;
+ ByteArrayOutputStream baos = null;
+ int count; // buffer counter
+ byte data[] = new byte[BUFFER];
+ baos = new ByteArrayOutputStream();
+ dest = new BufferedOutputStream(baos, BUFFER);
+ for (;;) {
+ count = jis.read(data, 0, BUFFER);
+ if (count == -1) {
+ break;
+ }
+ dest.write(data, 0, count);
+ }
+ dest.close();
+ System.out.println(entry.getName() + ": " + baos.toString());
- public void testInputStream() throws Exception {
- File f = new File("target/test-data");
- f.mkdirs();
- Writer w = new OutputStreamWriter(new FileOutputStream(new File(f, "test.txt")));
- w.write("<hello>world</hello>");
- w.close();
-
- FileSystemJarInputStream fsjis = new FileSystemJarInputStream(f);
- JarInputStream jis = new JarInputStream(fsjis);
-
- JarEntry entry = jis.getNextJarEntry();
- assertNotNull(entry);
- assertEquals("test.txt", entry.getName());
-
- // Copy data from jar file into byte array
- BufferedOutputStream dest = null;
- ByteArrayOutputStream baos = null;
- int count; // buffer counter
- byte data[] = new byte[BUFFER];
- baos = new ByteArrayOutputStream();
- dest = new BufferedOutputStream(baos, BUFFER);
- while ((count = jis.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, count);
- }
- dest.close();
- System.out.println(entry.getName() + ": " + baos.toString());
-
- assertEquals("<hello>world</hello>", baos.toString());
- }
+ assertEquals("<hello>world</hello>", baos.toString());
+ }
}