diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/old/contrib/binding-servicemix |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/old/contrib/binding-servicemix')
50 files changed, 3601 insertions, 0 deletions
diff --git a/sandbox/old/contrib/binding-servicemix/binding/pom.xml.off b/sandbox/old/contrib/binding-servicemix/binding/pom.xml.off new file mode 100644 index 0000000000..12f3840dd0 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/pom.xml.off @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <parent> + <groupId>org.apache.tuscany.sca.services.bindings</groupId> + <artifactId>parent</artifactId> + <version>1.0-incubator-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>binding-servicemix</artifactId> + <name>Apache Tuscany Binding for ServiceMix</name> + <description>Implementation of the SCA JBI Binding</description> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca.kernel</groupId> + <artifactId>tuscany-spi</artifactId> + <version>0.1-pre-spec-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.servicemix</groupId> + <artifactId>servicemix-core</artifactId> + <version>3.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.servicemix</groupId> + <artifactId>servicemix-common</artifactId> + <version>3.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + </dependencies> + +</project> diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java new file mode 100644 index 0000000000..ad407553b4 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaBootstrap.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +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; + +/** + * Base class for components bootstrap. + * + * @author Guillaume Nodet + * @version $Revision$ + * @since 3.0 + */ +public class ScaBootstrap implements Bootstrap { + + protected final transient Log logger = LogFactory.getLog(getClass()); + + protected InstallationContext context; + protected ObjectName mbeanName; + + public ScaBootstrap() { + } + + public ObjectName getExtensionMBeanName() { + return mbeanName; + } + + protected Object getExtensionMBean() throws Exception { + return null; + } + + protected ObjectName createExtensionMBeanName() throws Exception { + return this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap"); + } + + /* (non-Javadoc) + * @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext) + */ + public void init(InstallationContext installContext) throws JBIException { + try { + if (logger.isDebugEnabled()) { + logger.debug("Initializing bootstrap"); + } + this.context = installContext; + doInit(); + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap initialized"); + } + } catch (JBIException e) { + throw e; + } catch (Exception e) { + throw new JBIException("Error calling init", e); + } + } + + protected void doInit() throws Exception { + Object mbean = getExtensionMBean(); + if (mbean != null) { + this.mbeanName = createExtensionMBeanName(); + MBeanServer server = this.context.getContext().getMBeanServer(); + if (server == null) { + throw new JBIException("null mBeanServer"); + } + if (server.isRegistered(this.mbeanName)) { + server.unregisterMBean(this.mbeanName); + } + server.registerMBean(mbean, this.mbeanName); + } + } + + /* (non-Javadoc) + * @see javax.jbi.component.Bootstrap#cleanUp() + */ + public void cleanUp() throws JBIException { + try { + if (logger.isDebugEnabled()) { + logger.debug("Cleaning up bootstrap"); + } + doCleanUp(); + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap cleaned up"); + } + } catch (JBIException e) { + throw e; + } catch (Exception e) { + throw new JBIException("Error calling cleanUp", e); + } + } + + protected void doCleanUp() throws Exception { + if (this.mbeanName != null) { + MBeanServer server = this.context.getContext().getMBeanServer(); + if (server == null) { + throw new JBIException("null mBeanServer"); + } + if (server.isRegistered(this.mbeanName)) { + server.unregisterMBean(this.mbeanName); + } + } + } + + /* (non-Javadoc) + * @see javax.jbi.component.Bootstrap#onInstall() + */ + public void onInstall() throws JBIException { + try { + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap onInstall"); + } + doOnInstall(); + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap onInstall done"); + } + } catch (JBIException e) { + throw e; + } catch (Exception e) { + throw new JBIException("Error calling onInstall", e); + } + } + + protected void doOnInstall() throws Exception { + } + + /* (non-Javadoc) + * @see javax.jbi.component.Bootstrap#onUninstall() + */ + public void onUninstall() throws JBIException { + try { + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap onUninstall"); + } + doOnUninstall(); + if (logger.isDebugEnabled()) { + logger.debug("Bootstrap onUninstall done"); + } + } catch (JBIException e) { + throw e; + } catch (Exception e) { + throw new JBIException("Error calling onUninstall", e); + } + } + + protected void doOnUninstall() throws Exception { + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaComponent.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaComponent.java new file mode 100644 index 0000000000..93470e0707 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaComponent.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import org.apache.servicemix.common.BaseComponent; +import org.apache.servicemix.common.BaseLifeCycle; +import org.apache.servicemix.common.BaseServiceUnitManager; +import org.apache.servicemix.common.Deployer; + +public class ScaComponent extends BaseComponent { + + /* (non-Javadoc) + * @see org.servicemix.common.BaseComponent#createLifeCycle() + */ + protected BaseLifeCycle createLifeCycle() { + return new ScaLifeCycle(this); + } + + /* (non-Javadoc) + * @see org.servicemix.common.BaseComponent#createServiceUnitManager() + */ + public BaseServiceUnitManager createServiceUnitManager() { + Deployer[] deployers = new Deployer[] { new ScaDeployer(this) }; + return new BaseServiceUnitManager(this, deployers); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaDeployer.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaDeployer.java new file mode 100644 index 0000000000..199721cb88 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaDeployer.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import java.io.File; + +import javax.jbi.management.DeploymentException; + +import org.apache.servicemix.common.AbstractDeployer; +import org.apache.servicemix.common.BaseComponent; +import org.apache.servicemix.common.ServiceUnit; + +public class ScaDeployer extends AbstractDeployer { + + public static final String SCA_MODULE_FILE = "sca.module"; + + public ScaDeployer(BaseComponent component) { + super(component); + } + + public boolean canDeploy(String serviceUnitName, String serviceUnitRootPath) { + File module = new File(serviceUnitRootPath, SCA_MODULE_FILE); + return module.exists() && module.isFile(); + } + + public ServiceUnit deploy(String serviceUnitName, String serviceUnitRootPath) + throws DeploymentException { + File module = new File(serviceUnitRootPath, SCA_MODULE_FILE); + if (!module.exists() || !module.isFile()) { + throw failure("deploy", "No sca.module found", null); + } + try { + ScaServiceUnit su = new ScaServiceUnit(); + su.setComponent(component); + su.setName(serviceUnitName); + su.setRootPath(serviceUnitRootPath); + su.init(); + return su; + } catch (Exception e) { + throw failure("deploy", "Error loading sca module", e); + } + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java new file mode 100644 index 0000000000..8da798d26f --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import java.io.StringWriter; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.jbi.component.ComponentContext; +import javax.jbi.messaging.DeliveryChannel; +import javax.jbi.messaging.ExchangeStatus; +import javax.jbi.messaging.MessageExchange; +import javax.jbi.messaging.NormalizedMessage; +import javax.jbi.messaging.MessageExchange.Role; +import javax.jbi.servicedesc.ServiceEndpoint; +import javax.xml.bind.JAXBContext; + +import org.apache.servicemix.common.Endpoint; +import org.apache.servicemix.common.ExchangeProcessor; +import org.apache.servicemix.jbi.jaxp.StringSource; +import org.apache.tuscany.core.context.EntryPointContext; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.EntryPoint; + +/** + * + * @author gnodet + * @version $Revision$ + * @org.apache.xbean.XBean element="endpoint" description="A sca endpoint" + * + */ +public class ScaEndpoint extends Endpoint implements ExchangeProcessor { + + protected ServiceEndpoint activated; + + protected EntryPoint entryPoint; + + protected Map<Class, Method> methodMap; + + protected JAXBContext jaxbContext; + + protected DeliveryChannel channel; + + public ScaEndpoint(EntryPoint entryPoint) { + this.entryPoint = entryPoint; + } + + 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(); + // Get the target service + ConfiguredReference referenceValue = entryPoint.getConfiguredReference(); + ConfiguredService targetServiceEndpoint = referenceValue.getTargetConfiguredServices().get(0); + // Get the business interface + Class serviceInterface = targetServiceEndpoint.getService().getServiceContract().getInterface(); + List<Class> classes = new ArrayList<Class>(); + methodMap = new HashMap<Class, Method>(); + for (Method mth : serviceInterface.getMethods()) { + Class[] params = mth.getParameterTypes(); + if (params.length != 1) { + throw new IllegalStateException("Supports only methods with one parameter"); + } + methodMap.put(params[0], mth); + classes.add(mth.getReturnType()); + classes.add(params[0]); + } + jaxbContext = JAXBContext.newInstance(classes.toArray(new Class[0])); + } + + 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 void process(MessageExchange exchange) throws Exception { + if (exchange.getStatus() == ExchangeStatus.DONE) { + return; + } else if (exchange.getStatus() == ExchangeStatus.ERROR) { + return; + } + Object input = jaxbContext.createUnmarshaller().unmarshal(exchange.getMessage("in").getContent()); + Method method = methodMap.get(input.getClass()); + if (method == null) { + throw new IllegalStateException("Could not determine invoked web method"); + } + boolean oneWay = method.getReturnType() == null; + Object output; + try { + EntryPointContext entryPointContext = (EntryPointContext) ((ScaServiceUnit) serviceUnit) + .getTuscanyRuntime().getModuleContext().getContext(entryPoint.getName()); + InvocationHandler handler = (InvocationHandler) entryPointContext.getImplementationInstance(); + output = handler.invoke(null, method, new Object[] { input }); + } catch (UndeclaredThrowableException e) { + throw e; + } catch (RuntimeException e) { + throw e; + } catch (Error e) { + throw e; + } catch (Exception e) { + throw e; + } catch (Throwable e) { + throw new RuntimeException(e); + } + if (oneWay) { + exchange.setStatus(ExchangeStatus.DONE); + channel.send(exchange); + } else { + NormalizedMessage msg = exchange.createMessage(); + exchange.setMessage(msg, "out"); + StringWriter writer = new StringWriter(); + jaxbContext.createMarshaller().marshal(output, writer); + msg.setContent(new StringSource(writer.toString())); + channel.send(exchange); + } + } + + public void start() throws Exception { + } + + public void stop() throws Exception { + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java new file mode 100644 index 0000000000..499459dc71 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaLifeCycle.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import org.apache.servicemix.common.BaseComponent; +import org.apache.servicemix.common.BaseLifeCycle; + +public class ScaLifeCycle extends BaseLifeCycle { + + public ScaLifeCycle(BaseComponent component) { + super(component); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java new file mode 100644 index 0000000000..e391edf071 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import java.io.File; +import java.io.FilenameFilter; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Iterator; + +import javax.wsdl.Definition; +import javax.wsdl.factory.WSDLFactory; + +import org.apache.servicemix.common.ServiceUnit; +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.servicemix.sca.tuscany.CommonsLoggingMonitorFactory; +import org.apache.servicemix.sca.tuscany.TuscanyRuntime; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.EntryPoint; +import org.apache.tuscany.model.assembly.Module; + +public class ScaServiceUnit extends ServiceUnit { + + protected static final ThreadLocal<ScaServiceUnit> SERVICE_UNIT = new ThreadLocal<ScaServiceUnit>(); + + public static ScaServiceUnit getCurrentScaServiceUnit() { + return SERVICE_UNIT.get(); + } + + protected TuscanyRuntime tuscanyRuntime; + protected ClassLoader classLoader; + + public void init() throws Exception { + SERVICE_UNIT.set(this); + createScaRuntime(); + createEndpoints(); + SERVICE_UNIT.set(null); + } + + protected void createScaRuntime() throws Exception { + File root = new File(getRootPath()); + File[] files = root.listFiles(new JarFileFilter()); + URL[] urls = new URL[files.length + 1]; + for (int i = 0; i < files.length; i++) { + urls[i] = files[i].toURL(); + } + urls[urls.length - 1] = root.toURL(); + classLoader = new URLClassLoader(urls, getClass().getClassLoader()); + + tuscanyRuntime = new TuscanyRuntime(getName(), getRootPath(), classLoader, new CommonsLoggingMonitorFactory()); + } + + protected void createEndpoints() throws Exception { + Module module = tuscanyRuntime.getModuleComponent().getModuleImplementation(); + for (Iterator i = module.getEntryPoints().iterator(); i.hasNext();) { + EntryPoint entryPoint = (EntryPoint) i.next(); + Binding binding = (Binding) entryPoint.getBindings().get(0); + if (binding instanceof JbiBinding) { + JbiBinding jbiBinding = (JbiBinding) binding; + ScaEndpoint endpoint = new ScaEndpoint(entryPoint); + endpoint.setServiceUnit(this); + endpoint.setService(jbiBinding.getServiceName()); + endpoint.setEndpoint(jbiBinding.getEndpointName()); + endpoint.setInterfaceName(jbiBinding.getInterfaceName()); + Definition definition = jbiBinding.getDefinition(); + if (definition != null) { + endpoint.setDefinition(definition); + endpoint.setDescription(WSDLFactory.newInstance().newWSDLWriter().getDocument(definition)); + } + addEndpoint(endpoint); + } + } + } + + private static class JarFileFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith(".jar"); + } + } + + public TuscanyRuntime getTuscanyRuntime() { + return tuscanyRuntime; + } + + @Override + public void start() throws Exception { + tuscanyRuntime.start(); + super.start(); + } + + @Override + public void stop() throws Exception { + super.stop(); + tuscanyRuntime.stop(); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java new file mode 100644 index 0000000000..ef7812f175 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiAssemblyFactory.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.assembly; + +import org.apache.tuscany.model.assembly.AssemblyFactory; + +/** + * The <b>Factory</b> for the model. + */ +public interface JbiAssemblyFactory extends AssemblyFactory { + + /** + * Returns a new JbiBinding + */ + JbiBinding createJbiBinding(); + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java new file mode 100644 index 0000000000..8bfbf80590 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/JbiBinding.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.assembly; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.xml.namespace.QName; + +import org.apache.tuscany.model.assembly.Binding; + +public interface JbiBinding extends Binding { + + /** + * Returns the URI of the WSDL port for this binding. + * @return the URI of the WSDL port for this binding + */ + String getPortURI(); + + /** + * Set the URI of the WSDL port for this binding. + * @param portURI the URI of the WSDL port + */ + void setPortURI(String portURI); + + /** + * Returns the service name. + * @return the service name + */ + QName getServiceName(); + + /** + * Returns the endpoint name. + * @return the endpoint name + */ + String getEndpointName(); + + /** + * Returns the interface name. + * @returnthe interface name + */ + QName getInterfaceName(); + + /** + * Returns the WSDL definition containing the WSDL port. + * @return the WSDL definition containing the WSDL port + */ + Definition getDefinition(); + + /** + * Returns the the WSDL service. + * @return the WSDL service + */ + Service getService(); + + /** + * Returns the WSDL port defining this binding. + * @return the WSDL port defining this binding + */ + Port getPort(); + + /** + * Returns the WSDL port type. + * @return the WSDL port type + */ + PortType getPortType(); + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java new file mode 100644 index 0000000000..4cd6a98689 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiAssemblyFactoryImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.assembly.impl; + +import org.apache.servicemix.sca.assembly.JbiAssemblyFactory; +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl; + +/** + * An implementation of the model <b>Factory</b>. + */ +public class JbiAssemblyFactoryImpl extends AssemblyFactoryImpl implements JbiAssemblyFactory { + + /** + * Creates an instance of the factory. + */ + public JbiAssemblyFactoryImpl() { + super(); + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiAssemblyFactory#createJbiBinding() + */ + public JbiBinding createJbiBinding() { + return new JbiBindingImpl(); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java new file mode 100644 index 0000000000..e44b9c6f45 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/assembly/impl/JbiBindingImpl.java @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.assembly.impl; + +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.PortType; +import javax.wsdl.Service; +import javax.xml.namespace.QName; + +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.tuscany.model.assembly.AssemblyModelContext; +import org.apache.tuscany.model.assembly.impl.BindingImpl; + +/** + * An implementation of the model object '<em><b>Web Service Binding</b></em>'. + */ +public class JbiBindingImpl extends BindingImpl implements JbiBinding { + + private String portURI; + private QName serviceName; + private String endpointName; + private QName interfaceName; + private Definition definition; + private Service service; + private PortType portType; + private Port port; + + + /** + * Constructor + */ + protected JbiBindingImpl() { + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortURI() + */ + public String getPortURI() { + return portURI; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#setPortURI(java.lang.String) + */ + public void setPortURI(String portURI) { + this.portURI = portURI; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getServiceName() + */ + public QName getServiceName() { + return serviceName; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getEndpointName() + */ + public String getEndpointName() { + return endpointName; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getInterfaceName() + */ + public QName getInterfaceName() { + return interfaceName; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getDefinition() + */ + public Definition getDefinition() { + return definition; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getService() + */ + public Service getService() { + return service; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getPort() + */ + public Port getPort() { + return port; + } + + /* (non-Javadoc) + * @see org.apache.servicemix.sca.assembly.JbiBinding#getPortType() + */ + public PortType getPortType() { + return portType; + } + + /** + * @see org.apache.tuscany.model.assembly.impl.BindingImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext) + */ + public void initialize(AssemblyModelContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Get the service name and endpoint name + String[] parts = split(portURI); + serviceName = new QName(parts[0], parts[1]); + endpointName = parts[2]; + + // Load the WSDL definitions for the given namespace + List<Definition> definitions = modelContext.getAssemblyLoader().loadDefinitions(parts[0]); + if (definitions != null) { + for (Definition definition : definitions) { + Service service = definition.getService(serviceName); + if (service != null) { + Port port = service.getPort(endpointName); + if (port != null) { + this.service = service; + this.port = port; + this.portType = port.getBinding().getPortType(); + this.interfaceName = portType.getQName(); + this.definition = definition; + return; + } + } + } + } + } + + protected String[] split(String uri) { + char sep; + uri = uri.trim(); + if (uri.indexOf('/') > 0) { + sep = '/'; + } else { + sep = ':'; + } + int idx1 = uri.lastIndexOf(sep); + 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 }; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java new file mode 100644 index 0000000000..e5a7b59a75 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceBuilder.java @@ -0,0 +1,151 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.builder; + +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory; +import org.apache.servicemix.sca.handler.ExternalJbiServiceClient; +import org.apache.tuscany.core.builder.BuilderException; +import org.apache.tuscany.core.builder.ContextFactoryBuilder; +import org.apache.tuscany.core.config.JavaIntrospectionHelper; +import org.apache.tuscany.core.context.QualifiedName; +import org.apache.tuscany.core.injection.SingletonObjectFactory; +import org.apache.tuscany.core.invocation.InvocationConfiguration; +import org.apache.tuscany.core.invocation.MethodHashMap; +import org.apache.tuscany.core.invocation.ProxyConfiguration; +import org.apache.tuscany.core.invocation.impl.InvokerInterceptor; +import org.apache.tuscany.core.invocation.spi.ProxyFactory; +import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory; +import org.apache.tuscany.core.message.MessageFactory; +import org.apache.tuscany.core.runtime.RuntimeContext; +import org.apache.tuscany.core.system.annotation.Autowire; +import org.apache.tuscany.model.assembly.AssemblyModelObject; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceContract; +import org.apache.tuscany.model.scdl.WebServiceBinding; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +/** + * Creates a <code>RuntimeConfigurationBuilder</code> for an external service configured with the {@link WebServiceBinding} + */ +@Scope("MODULE") +public class ExternalJbiServiceBuilder implements ContextFactoryBuilder { + + private RuntimeContext runtimeContext; + + private ProxyFactoryFactory proxyFactoryFactory; + + private MessageFactory messageFactory; + + private ContextFactoryBuilder policyBuilder; + + public ExternalJbiServiceBuilder() { + } + + @Init(eager = true) + public void init() { + runtimeContext.addBuilder(this); + } + + /** + * @param runtimeContext The runtimeContext to set. + */ + @Autowire + public void setRuntimeContext(RuntimeContext runtimeContext) { + this.runtimeContext = runtimeContext; + } + + /** + * Sets the factory used to construct proxies implmementing the business interface required by a reference + */ + @Autowire + public void setProxyFactoryFactory(ProxyFactoryFactory factory) { + this.proxyFactoryFactory = factory; + } + + /** + * Sets the factory used to construct invocation messages + * + * @param msgFactory + */ + @Autowire + public void setMessageFactory(MessageFactory msgFactory) { + this.messageFactory = msgFactory; + } + + /** + * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The + * reference builder may be hierarchical, containing other child reference builders that operate on specific + * metadata used to construct and invocation chain. + * + * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder + */ + public void setPolicyBuilder(ContextFactoryBuilder builder) { + policyBuilder = builder; + } + + public void build(AssemblyModelObject object) throws BuilderException { + if (!(object instanceof ExternalService)) { + return; + } + ExternalService externalService = (ExternalService) object; + if (externalService.getBindings().size() < 1 || !(externalService.getBindings().get(0) instanceof JbiBinding)) { + return; + } + + ExternalJbiServiceClient externalJbiServiceClient = new ExternalJbiServiceClient(externalService); + ExternalJbiServiceContextFactory config = new ExternalJbiServiceContextFactory(externalService.getName(), new SingletonObjectFactory<ExternalJbiServiceClient>(externalJbiServiceClient)); + + ConfiguredService configuredService = externalService.getConfiguredService(); + Service service = configuredService.getService(); + ServiceContract serviceContract = service.getServiceContract(); + Map<Method, InvocationConfiguration> iConfigMap = new MethodHashMap(); + ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory(); + Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface()); + for (Method method : javaMethods) { + InvocationConfiguration iConfig = new InvocationConfiguration(method); + iConfigMap.put(method, iConfig); + } + QualifiedName qName = new QualifiedName(externalService.getName() + "/" + service.getName()); + ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory); + proxyFactory.setBusinessInterface(serviceContract.getInterface()); + proxyFactory.setProxyConfiguration(pConfiguration); + config.addTargetProxyFactory(service.getName(), proxyFactory); + configuredService.setProxyFactory(proxyFactory); + if (policyBuilder != null) { + // invoke the reference builder to handle additional policy metadata + policyBuilder.build(configuredService); + } + // add tail interceptor + for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) { + iConfig.addTargetInterceptor(new InvokerInterceptor()); + } + + externalService.getConfiguredService().setContextFactory(config); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java new file mode 100644 index 0000000000..1dc7d9f454 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/ExternalJbiServiceWireBuilder.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.builder; + +import org.apache.servicemix.sca.config.ExternalJbiServiceContextFactory; +import org.apache.servicemix.sca.handler.ExternalJbiServiceTargetInvoker; +import org.apache.tuscany.core.builder.BuilderConfigException; +import org.apache.tuscany.core.builder.WireBuilder; +import org.apache.tuscany.core.context.ScopeContext; +import org.apache.tuscany.core.invocation.InvocationConfiguration; +import org.apache.tuscany.core.invocation.spi.ProxyFactory; +import org.apache.tuscany.core.runtime.RuntimeContext; +import org.apache.tuscany.core.system.annotation.Autowire; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("MODULE") +public class ExternalJbiServiceWireBuilder implements WireBuilder { + + private RuntimeContext runtimeContext; + + /** + * Constructs a new ExternalWebServiceWireBuilder. + */ + public ExternalJbiServiceWireBuilder() { + super(); + } + + @Autowire + public void setRuntimeContext(RuntimeContext context) { + runtimeContext = context; + } + + @Init(eager=true) + public void init() { + runtimeContext.addBuilder(this); + } + + public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, ScopeContext targetScopeContext) throws BuilderConfigException { + if (!(ExternalJbiServiceContextFactory.class.isAssignableFrom(targetType))) { + return; + } + for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations().values()) { + ExternalJbiServiceTargetInvoker invoker = new ExternalJbiServiceTargetInvoker(sourceFactory.getProxyConfiguration().getTargetName(), sourceInvocationConfig.getMethod(), targetScopeContext); + sourceInvocationConfig.setTargetInvoker(invoker); + } + } + + public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) + throws BuilderConfigException { + //TODO implement + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java new file mode 100644 index 0000000000..af83c7c714 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/builder/JbiServiceEntryPointBuilder.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.builder; + +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.servicemix.sca.config.JbiServiceEntryPointContextFactory; +import org.apache.tuscany.core.builder.BuilderException; +import org.apache.tuscany.core.builder.ContextFactoryBuilder; +import org.apache.tuscany.core.builder.impl.EntryPointContextFactory; +import org.apache.tuscany.core.config.JavaIntrospectionHelper; +import org.apache.tuscany.core.context.AggregateContext; +import org.apache.tuscany.core.context.QualifiedName; +import org.apache.tuscany.core.invocation.Interceptor; +import org.apache.tuscany.core.invocation.InvocationConfiguration; +import org.apache.tuscany.core.invocation.InvocationRuntimeException; +import org.apache.tuscany.core.invocation.ProxyConfiguration; +import org.apache.tuscany.core.invocation.TargetInvoker; +import org.apache.tuscany.core.invocation.spi.ProxyFactory; +import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory; +import org.apache.tuscany.core.message.Message; +import org.apache.tuscany.core.message.MessageFactory; +import org.apache.tuscany.core.runtime.RuntimeContext; +import org.apache.tuscany.core.system.annotation.Autowire; +import org.apache.tuscany.model.assembly.AssemblyModelObject; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.EntryPoint; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceContract; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("MODULE") +public class JbiServiceEntryPointBuilder implements ContextFactoryBuilder<AggregateContext> { + + private RuntimeContext runtimeContext; + + private ProxyFactoryFactory proxyFactoryFactory; + + private MessageFactory messageFactory; + + private ContextFactoryBuilder policyBuilder; + + public JbiServiceEntryPointBuilder() { + } + + @Init(eager = true) + public void init() { + runtimeContext.addBuilder(this); + } + + /** + * @param runtimeContext The runtimeContext to set. + */ + @Autowire + public void setRuntimeContext(RuntimeContext runtimeContext) { + this.runtimeContext = runtimeContext; + } + + /** + * Sets the factory used to construct proxies implmementing the business interface required by a reference + */ + @Autowire + public void setProxyFactoryFactory(ProxyFactoryFactory factory) { + this.proxyFactoryFactory = factory; + } + + /** + * Sets the factory used to construct invocation messages + * + * @param msgFactory + */ + @Autowire + public void setMessageFactory(MessageFactory msgFactory) { + this.messageFactory = msgFactory; + } + + /** + * Sets a builder responsible for creating source-side and target-side invocation chains for a reference. The + * reference builder may be hierarchical, containing other child reference builders that operate on specific + * metadata used to construct and invocation chain. + * + * @see org.apache.tuscany.core.builder.impl.HierarchicalBuilder + */ + public void setPolicyBuilder(ContextFactoryBuilder builder) { + policyBuilder = builder; + } + + public void build(AssemblyModelObject object) throws BuilderException { + if (!(object instanceof EntryPoint)) { + return; + } + EntryPoint entryPoint = (EntryPoint) object; + if (entryPoint.getBindings().size() < 1 || !(entryPoint.getBindings().get(0) instanceof JbiBinding)) { + return; + } + + EntryPointContextFactory config = new JbiServiceEntryPointContextFactory(entryPoint.getName(), entryPoint.getConfiguredService().getService().getName(), messageFactory); + + ConfiguredService configuredService = entryPoint.getConfiguredService(); + Service service = configuredService.getService(); + ServiceContract serviceContract = service.getServiceContract(); + Map<Method, InvocationConfiguration> iConfigMap = new HashMap<Method, InvocationConfiguration>(); + ProxyFactory proxyFactory = proxyFactoryFactory.createProxyFactory(); + Set<Method> javaMethods = JavaIntrospectionHelper.getAllUniqueMethods(serviceContract.getInterface()); + for (Method method : javaMethods) { + InvocationConfiguration iConfig = new InvocationConfiguration(method); + iConfigMap.put(method, iConfig); + } + QualifiedName qName = new QualifiedName(entryPoint.getConfiguredReference().getTargetConfiguredServices().get(0).getAggregatePart().getName() + "/" + service.getName()); + ProxyConfiguration pConfiguration = new ProxyConfiguration(qName, iConfigMap, serviceContract.getInterface().getClassLoader(), messageFactory); + proxyFactory.setBusinessInterface(serviceContract.getInterface()); + proxyFactory.setProxyConfiguration(pConfiguration); + config.addSourceProxyFactory(service.getName(), proxyFactory); + configuredService.setProxyFactory(proxyFactory); + if (policyBuilder != null) { + // invoke the reference builder to handle additional policy metadata + policyBuilder.build(configuredService); + } + // add tail interceptor + for (InvocationConfiguration iConfig : (Collection<InvocationConfiguration>) iConfigMap.values()) { + iConfig.addTargetInterceptor(new EntryPointInvokerInterceptor()); + } + entryPoint.getConfiguredReference().setContextFactory(config); + } + + //FIXME same as the InvokerInterceptor except that it doesn't throw an exception in setNext + // For some reason another InvokerInterceptor is added after this one, need Jim to look into it + // and figure out why. + public class EntryPointInvokerInterceptor implements Interceptor { + + public EntryPointInvokerInterceptor() { + } + + public Message invoke(Message msg) throws InvocationRuntimeException { + TargetInvoker invoker = msg.getTargetInvoker(); + if (invoker == null) { + throw new InvocationRuntimeException("No target invoker specified on message"); + } + return invoker.invoke(msg); + } + + public void setNext(Interceptor next) { + } + + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java new file mode 100644 index 0000000000..93b846db8a --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/ExternalJbiServiceContextFactory.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.config; + +import org.apache.tuscany.core.builder.ObjectFactory; +import org.apache.tuscany.core.builder.impl.BaseExternalServiceContextFactory; + +public class ExternalJbiServiceContextFactory extends BaseExternalServiceContextFactory { + + public ExternalJbiServiceContextFactory(String name, ObjectFactory objectFactory) { + super(name, objectFactory); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java new file mode 100644 index 0000000000..b6adb6481d --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/config/JbiServiceEntryPointContextFactory.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.config; + +import org.apache.tuscany.core.builder.impl.EntryPointContextFactory; +import org.apache.tuscany.core.message.MessageFactory; + +public class JbiServiceEntryPointContextFactory extends EntryPointContextFactory { + + public JbiServiceEntryPointContextFactory(String name, String referenceName, MessageFactory msgFactory) { + super(name, referenceName, msgFactory); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java new file mode 100644 index 0000000000..22b457687f --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceClient.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.handler; + +import java.io.ByteArrayOutputStream; +import java.lang.reflect.Method; + +import javax.jbi.messaging.DeliveryChannel; +import javax.jbi.messaging.ExchangeStatus; +import javax.jbi.messaging.InOut; +import javax.jbi.messaging.NormalizedMessage; +import javax.xml.bind.JAXBContext; + +import org.apache.servicemix.jbi.jaxp.StringSource; +import org.apache.servicemix.sca.ScaServiceUnit; +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.tuscany.model.assembly.ExternalService; + +public class ExternalJbiServiceClient { + + private ExternalService externalService; + + private JbiBinding jbiBinding; + + private ScaServiceUnit serviceUnit; + + /** + * Constructs a new ExternalWebServiceClient. + * + * @param externalService + * @param wsBinding + */ + public ExternalJbiServiceClient(ExternalService externalService) { + this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit(); + this.externalService = externalService; + this.jbiBinding = (JbiBinding) this.externalService.getBindings().get(0); + } + + /** + * Invoke an operation on the external Web service. + * + * @param method + * @param args + * @return + */ + public Object invoke(Method method, Object[] args) { + if (args == null || args.length != 1) { + throw new IllegalStateException("args should have exactly one object"); + } + try { + Object payload = args[0]; + Class inputClass = method.getParameterTypes()[0]; + Class outputClass = method.getReturnType(); + JAXBContext context = JAXBContext.newInstance(inputClass, outputClass); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + context.createMarshaller().marshal(payload, baos); + + DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel(); + // TODO: in-only case ? + // TODO: interface based routing ? + // TODO: explicit endpoint selection ? + InOut inout = channel.createExchangeFactory().createInOutExchange(); + inout.setService(jbiBinding.getServiceName()); + NormalizedMessage in = inout.createMessage(); + inout.setInMessage(in); + in.setContent(new StringSource(baos.toString())); + boolean sent = channel.sendSync(inout); + // TODO: check for error ? + NormalizedMessage out = inout.getOutMessage(); + Object response = context.createUnmarshaller().unmarshal(out.getContent()); + inout.setStatus(ExchangeStatus.DONE); + channel.send(inout); + return response; + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java new file mode 100644 index 0000000000..cd0560c5b5 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceTargetInvoker.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.handler; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.tuscany.core.context.ExternalServiceContext; +import org.apache.tuscany.core.context.InstanceContext; +import org.apache.tuscany.core.context.QualifiedName; +import org.apache.tuscany.core.context.ScopeContext; +import org.apache.tuscany.core.context.TargetException; +import org.apache.tuscany.core.invocation.Interceptor; +import org.apache.tuscany.core.invocation.TargetInvoker; +import org.apache.tuscany.core.message.Message; + +public class ExternalJbiServiceTargetInvoker implements TargetInvoker { + + private QualifiedName serviceName; + private String esName; + private Method method; + private ScopeContext container; + + private ExternalServiceContext context; + + /** + * Constructs a new ExternalJbiServiceTargetInvoker. + * @param esName + * @param container + */ + public ExternalJbiServiceTargetInvoker(QualifiedName serviceName, Method method, ScopeContext container) { + assert (serviceName != null) : "No service name specified"; + assert (method != null) : "No method specified"; + assert (container != null) : "No scope container specified"; + this.serviceName = serviceName; + this.esName = serviceName.getPartName(); + this.method = method; + this.container = container; + } + + public Object invokeTarget(Object payload) throws InvocationTargetException { + if (context == null) { + InstanceContext iContext = container.getContext(esName); + if (!(iContext instanceof ExternalServiceContext)) { + TargetException te = new TargetException("Unexpected target context type"); + te.setIdentifier(iContext.getClass().getName()); + te.addContextName(iContext.getName()); + throw te; + } + context = (ExternalServiceContext) iContext; + } + ExternalJbiServiceClient client = (ExternalJbiServiceClient) context.getImplementationInstance(true); + if (payload != null) { + return client.invoke(method, (Object[])payload); + } else { + return client.invoke(method, null); + } + } + + public boolean isCacheable() { + return false; + } + + public Message invoke(Message msg) { + try { + Object resp = invokeTarget(msg.getBody()); + msg.setBody(resp); + } catch (InvocationTargetException e) { + msg.setBody(e.getCause()); + } catch (Throwable e) { + msg.setBody(e); + } + return msg; + } + + public void setNext(Interceptor next) { + throw new UnsupportedOperationException(); + } + + public Object clone() { + try { + ExternalJbiServiceTargetInvoker invoker = (ExternalJbiServiceTargetInvoker) super.clone(); + invoker.container = container; + invoker.context = this.context; + invoker.esName = this.esName; + invoker.method = this.method; + invoker.serviceName = this.serviceName; + return invoker; + } catch (CloneNotSupportedException e) { + return null; // will not happen + } + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java new file mode 100644 index 0000000000..ac67433720 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/loader/JbiBindingLoader.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.loader; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.servicemix.sca.assembly.JbiAssemblyFactory; +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.servicemix.sca.assembly.impl.JbiAssemblyFactoryImpl; +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.core.config.ConfigurationLoadException; +import org.apache.tuscany.core.loader.StAXElementLoader; +import org.apache.tuscany.core.loader.StAXLoaderRegistry; +import org.apache.tuscany.core.system.annotation.Autowire; +import org.osoa.sca.annotations.Destroy; +import org.osoa.sca.annotations.Init; +import org.osoa.sca.annotations.Scope; + +@Scope("MODULE") +public class JbiBindingLoader implements StAXElementLoader<JbiBinding>{ + + public static final QName BINDING_JBI = new QName("http://www.osoa.org/xmlns/sca/0.9", "binding.jbi"); + + private static final JbiAssemblyFactory jbiFactory = new JbiAssemblyFactoryImpl(); + + private StAXLoaderRegistry registry; + + @Autowire + public void setRegistry(StAXLoaderRegistry registry) { + this.registry = registry; + } + + @Init(eager = true) + public void start() { + registry.registerLoader(this); + } + + @Destroy + public void stop() { + registry.unregisterLoader(this); + } + + public QName getXMLType() { + return BINDING_JBI; + } + + public Class<JbiBinding> getModelType() { + return JbiBinding.class; + } + + public JbiBinding load(XMLStreamReader reader, ResourceLoader resourceLoader) throws XMLStreamException, ConfigurationLoadException { + JbiBinding binding = jbiFactory.createJbiBinding(); + binding.setURI(reader.getAttributeValue(null, "uri")); + binding.setPortURI(reader.getAttributeValue(null, "port")); + return binding; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java new file mode 100644 index 0000000000..154afe4377 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/BootstrapHelper.java @@ -0,0 +1,125 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.tuscany; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.stream.XMLInputFactory; + +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; +import org.apache.tuscany.core.builder.ContextFactoryBuilder; +import org.apache.tuscany.core.config.ConfigurationException; +import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader; +import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl; +import org.apache.tuscany.core.config.impl.StAXModuleComponentConfigurationLoaderImpl; +import org.apache.tuscany.core.context.AggregateContext; +import org.apache.tuscany.core.context.EventContext; +import org.apache.tuscany.core.context.SystemAggregateContext; +import org.apache.tuscany.core.loader.StAXLoaderRegistry; +import org.apache.tuscany.core.loader.StAXUtil; +import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl; +import org.apache.tuscany.core.system.builder.SystemContextFactoryBuilder; +import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder; +import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder; +import org.apache.tuscany.core.system.loader.SystemSCDLModelLoader; +import org.apache.tuscany.model.assembly.AssemblyFactory; +import org.apache.tuscany.model.assembly.AssemblyModelContext; +import org.apache.tuscany.model.assembly.ModuleComponent; +import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl; +import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader; +import org.apache.tuscany.model.scdl.loader.SCDLModelLoader; +import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl; + +public class BootstrapHelper { + + /** + * Returns a default AssemblyModelContext. + * + * @param classLoader the classloader to use for application artifacts + * @return a default AssemblyModelContext + */ + public static AssemblyModelContext getModelContext(ClassLoader classLoader) { + // Create an assembly model factory + AssemblyFactory modelFactory = new SystemAssemblyFactoryImpl(); + + // Create a default assembly model loader + List<SCDLModelLoader> scdlLoaders = new ArrayList<SCDLModelLoader>(); + scdlLoaders.add(new SystemSCDLModelLoader()); + AssemblyModelLoader modelLoader = new SCDLAssemblyModelLoaderImpl(scdlLoaders); + + // Create a resource loader from the supplied classloader + ResourceLoader resourceLoader = new ResourceLoaderImpl(classLoader); + + // Create an assembly model context + return new AssemblyModelContextImpl(modelFactory, modelLoader, resourceLoader); + } + + /** + * Returns a default list of configuration builders. + * + * @return a default list of configuration builders + */ + public static List<ContextFactoryBuilder> getBuilders() { + List<ContextFactoryBuilder> configBuilders = new ArrayList<ContextFactoryBuilder>(); + configBuilders.add((new SystemContextFactoryBuilder())); + configBuilders.add(new SystemEntryPointBuilder()); + configBuilders.add(new SystemExternalServiceBuilder()); + return configBuilders; + } + + private static final boolean useStax = true; + private static final String SYSTEM_LOADER_COMPONENT = "tuscany.loader"; + + /** + * Returns the default module configuration loader. + * + * @param systemContext the runtime's system context + * @param modelContext the model context the loader will use + * @return the default module configuration loader + */ + public static ModuleComponentConfigurationLoader getConfigurationLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException { + if (useStax) { + // Bootstrap the StAX loader module + bootstrapStaxLoader(systemContext, modelContext); + return new StAXModuleComponentConfigurationLoaderImpl(modelContext, XMLInputFactory.newInstance(), systemContext.resolveInstance(StAXLoaderRegistry.class)); + } else { + return new ModuleComponentConfigurationLoaderImpl(modelContext); + } + } + + private static AggregateContext bootstrapStaxLoader(SystemAggregateContext systemContext, AssemblyModelContext modelContext) throws ConfigurationException { + AggregateContext loaderContext = (AggregateContext) systemContext.getContext(SYSTEM_LOADER_COMPONENT); + if (loaderContext == null) { + ModuleComponent loaderComponent = StAXUtil.bootstrapLoader(SYSTEM_LOADER_COMPONENT, modelContext); + loaderContext = registerModule(systemContext, loaderComponent); + loaderContext.fireEvent(EventContext.MODULE_START, null); + } + return loaderContext; + } + + public static AggregateContext registerModule(AggregateContext parent, ModuleComponent component) throws ConfigurationException { + // register the component + parent.registerModelObject(component); + + // Get the aggregate context representing the component + return (AggregateContext) parent.getContext(component.getName()); + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java new file mode 100644 index 0000000000..04bcc0bcea --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/CommonsLoggingMonitorFactory.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.tuscany; + +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Map; +import java.util.WeakHashMap; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tuscany.common.monitor.MonitorFactory; + +public class CommonsLoggingMonitorFactory implements MonitorFactory { + + private final Map<Class<?>, WeakReference<?>> proxies = new WeakHashMap<Class<?>, WeakReference<?>>(); + + public CommonsLoggingMonitorFactory() { + } + + public <T> T getMonitor(Class<T> monitorInterface) { + T proxy = getCachedMonitor(monitorInterface); + if (proxy == null) { + proxy = createMonitor(monitorInterface); + proxies.put(monitorInterface, new WeakReference<T>(proxy)); + } + return proxy; + } + + private <T>T getCachedMonitor(Class<T> monitorInterface) { + WeakReference<T> ref = (WeakReference<T>) proxies.get(monitorInterface); + return (ref != null) ? ref.get() : null; + } + + private <T>T createMonitor(Class<T> monitorInterface) { + String className = monitorInterface.getName(); + Log logger = LogFactory.getLog(className); + InvocationHandler handler = new LoggingHandler(logger); + return (T) Proxy.newProxyInstance(monitorInterface.getClassLoader(), new Class<?>[]{monitorInterface}, handler); + } + + private static final class LoggingHandler implements InvocationHandler { + private final Log logger; + + public LoggingHandler(Log logger) { + this.logger = logger; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String sourceMethod = method.getName(); + if (logger.isDebugEnabled()) { + // if the only argument is a Throwable use the special logger for it + if (args != null && args.length == 1 && args[0] instanceof Throwable) { + logger.debug(sourceMethod, (Throwable) args[0]); + } else { + StringBuilder sb = new StringBuilder(); + sb.append(sourceMethod); + sb.append("("); + for (int i = 0; i < args.length; i++) { + if (i > 0) { + sb.append(", "); + } + sb.append(args[i]); + } + sb.append(")"); + logger.debug(sb.toString()); + } + } + return null; + } + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java new file mode 100644 index 0000000000..ee5960dfb5 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/servicemix/sca/tuscany/TuscanyRuntime.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.tuscany; + +import java.util.List; + +import org.apache.tuscany.common.monitor.MonitorFactory; +import org.apache.tuscany.common.monitor.impl.NullMonitorFactory; +import org.apache.tuscany.core.builder.ContextFactoryBuilder; +import org.apache.tuscany.core.builder.impl.DefaultWireBuilder; +import org.apache.tuscany.core.config.ConfigurationException; +import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader; +import org.apache.tuscany.core.context.AggregateContext; +import org.apache.tuscany.core.context.CoreRuntimeException; +import org.apache.tuscany.core.context.EventContext; +import org.apache.tuscany.core.context.SystemAggregateContext; +import org.apache.tuscany.core.runtime.RuntimeContext; +import org.apache.tuscany.core.runtime.RuntimeContextImpl; +import org.apache.tuscany.model.assembly.AssemblyModelContext; +import org.apache.tuscany.model.assembly.ModuleComponent; +import org.apache.tuscany.model.scdl.loader.SCDLModelLoader; +import org.osoa.sca.ModuleContext; +import org.osoa.sca.SCA; +import org.osoa.sca.ServiceRuntimeException; + +public class TuscanyRuntime extends SCA { + private final TuscanyRuntime.Monitor monitor; + private final Object sessionKey = new Object(); + + private final RuntimeContext runtime; + private final AggregateContext moduleContext; + + private final ModuleComponent moduleComponent; + + private static final String SYSTEM_MODULE_COMPONENT = "org.apache.tuscany.core.system"; + + /** + * Construct a runtime using a null MonitorFactory. + * + * @param name the name of the module component + * @param uri the URI to assign to the module component + * @throws ConfigurationException if there was a problem loading the SCA configuration + * @see TuscanyRuntime#TuscanyRuntime(String, String, org.apache.tuscany.common.monitor.MonitorFactory) + */ + public TuscanyRuntime(String name, String uri) throws ConfigurationException { + this(name, uri, + Thread.currentThread().getContextClassLoader(), + new NullMonitorFactory()); + } + + /** + * Construct a runtime containing a single module component with the + * specified name. The module definition is loaded from a "/sca.module" + * resource found on the classpath of the current Thread context classloader. + * + * @param name the name of the module component + * @param uri the URI to assign to the module component + * @param classLoader the class loader to use for the assembly + * @param monitorFactory the MonitorFactory for this runtime + * @throws ConfigurationException if there was a problem loading the SCA configuration + */ + public TuscanyRuntime(String name, String uri, ClassLoader classLoader, MonitorFactory monitorFactory) throws ConfigurationException { + this.monitor = monitorFactory.getMonitor(TuscanyRuntime.Monitor.class); + + // Create an assembly model context + AssemblyModelContext modelContext = BootstrapHelper.getModelContext(classLoader); + + // Create a runtime context and start it + List<SCDLModelLoader> loaders = modelContext.getAssemblyLoader().getLoaders(); + List<ContextFactoryBuilder> configBuilders = BootstrapHelper.getBuilders(); + runtime = new RuntimeContextImpl(monitorFactory, loaders, configBuilders, new DefaultWireBuilder()); + runtime.start(); + monitor.started(runtime); + + // Load and start the system configuration + SystemAggregateContext systemContext = runtime.getSystemContext(); + ModuleComponentConfigurationLoader loader = BootstrapHelper.getConfigurationLoader(systemContext, modelContext); + ModuleComponent systemModuleComponent = loader.loadSystemModuleComponent(SYSTEM_MODULE_COMPONENT, SYSTEM_MODULE_COMPONENT); + AggregateContext context = BootstrapHelper.registerModule(systemContext, systemModuleComponent); + context.fireEvent(EventContext.MODULE_START, null); + + // Load the SCDL configuration of the application module + AggregateContext rootContext = runtime.getRootContext(); + moduleComponent = loader.loadModuleComponent(name, uri); + moduleContext = BootstrapHelper.registerModule(rootContext, moduleComponent); + } + + public ModuleComponent getModuleComponent() { + return moduleComponent; + } + + public AggregateContext getModuleContext() { + return moduleContext; + } + + /** + * Start the runtime and associate the module context with the calling thread. + */ + @Override + public void start() { + setModuleContext((ModuleContext) moduleContext); + try { + //moduleContext.start(); + moduleContext.fireEvent(EventContext.MODULE_START, null); + moduleContext.fireEvent(EventContext.REQUEST_START, null); + moduleContext.fireEvent(EventContext.SESSION_NOTIFY, sessionKey); + monitor.started(moduleContext); + } catch (CoreRuntimeException e) { + setModuleContext(null); + monitor.startFailed(moduleContext, e); + //FIXME throw a better exception + throw new ServiceRuntimeException(e); + } + } + + /** + * Disassociate the module context from the current thread and shut down the runtime. + */ + @Override + public void stop() { + setModuleContext(null); + moduleContext.fireEvent(EventContext.REQUEST_END, null); + moduleContext.fireEvent(EventContext.SESSION_END, sessionKey); + moduleContext.fireEvent(EventContext.MODULE_STOP, null); + moduleContext.stop(); + monitor.stopped(moduleContext); + runtime.stop(); + monitor.stopped(runtime); + } + + /** + * Monitor interface for a TuscanyRuntime. + */ + public static interface Monitor { + /** + * Event emitted after the runtime has been started. + * + * @param ctx the runtime's module component context + */ + void started(AggregateContext ctx); + + /** + * Event emitted when an attempt to start the runtime failed. + * + * @param ctx the runtime's module component context + * @param e the exception that caused the failure + */ + void startFailed(AggregateContext ctx, CoreRuntimeException e); + + /** + * Event emitted after the runtime has been stopped. + * + * @param ctx the runtime's module component context + */ + void stopped(AggregateContext ctx); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java new file mode 100644 index 0000000000..04781d6d69 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBinding.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import org.apache.tuscany.spi.model.Binding; + +/** + * Represents a JBI binding + */ +public class JBIBinding extends Binding { + + private String uri; + + private String port; + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java new file mode 100644 index 0000000000..8b6806a731 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/JBIBindingLoader.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.spi.annotation.Autowire; +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.LoaderExtension; +import org.apache.tuscany.spi.loader.LoaderException; +import org.apache.tuscany.spi.loader.LoaderRegistry; +import org.apache.tuscany.spi.loader.LoaderUtil; +import org.osoa.sca.annotations.Scope; + +/** + * Loader for handling <binding.jbi> elements. + */ +@Scope("MODULE") +public class JBIBindingLoader extends LoaderExtension<JBIBinding> { + + public static final QName BINDING_JBI = new QName("http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.jbi"); + + public JBIBindingLoader(@Autowire LoaderRegistry registry) { + super(registry); + } + + public QName getXMLType() { + return BINDING_JBI; + } + + public JBIBinding load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, + LoaderException { + + String port = reader.getAttributeValue(null, "port"); + String uri = reader.getAttributeValue(null, "uri"); + LoaderUtil.skipToEndElement(reader); + + JBIBinding binding = new JBIBinding(); + binding.setPort(port); + binding.setURI(uri); + + return binding; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java new file mode 100644 index 0000000000..227d56d0b7 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixBuilder.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing pejbissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.component.SCAObject; +import org.apache.tuscany.spi.deployer.DeploymentContext; +import org.apache.tuscany.spi.extension.BindingBuilderExtension; +import org.apache.tuscany.spi.model.BoundReferenceDefinition; +import org.apache.tuscany.spi.model.BoundServiceDefinition; + +/** + * Builds a Service or Reference for a JBI binding. + */ +public class ServiceMixBuilder extends BindingBuilderExtension<JBIBinding> { + + protected Class<JBIBinding> getBindingType() { + return JBIBinding.class; + } + + @SuppressWarnings( { "unchecked" }) + public SCAObject build(CompositeComponent parent, BoundServiceDefinition<JBIBinding> boundServiceDefinition, DeploymentContext deploymentContext) { + + String name = boundServiceDefinition.getName(); + + ServiceMixService serviceMixService = new ServiceMixService(name, parent, wireService, null); + + return serviceMixService; + } + + @SuppressWarnings( { "unchecked" }) + public ServiceMixReference build(CompositeComponent parent, BoundReferenceDefinition<JBIBinding> boundReferenceDefinition, + DeploymentContext deploymentContext) { + + + ServiceMixReference serviceMixReference = new ServiceMixReference(null, parent, wireService, null, null); + + return serviceMixReference; + + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java new file mode 100644 index 0000000000..5ad2aae7b5 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixInvoker.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import java.lang.reflect.InvocationTargetException; + +import javax.jbi.messaging.DeliveryChannel; +import javax.jbi.messaging.ExchangeStatus; +import javax.jbi.messaging.InOut; +import javax.jbi.messaging.MessagingException; +import javax.jbi.messaging.NormalizedMessage; +import javax.xml.namespace.QName; + +import org.apache.servicemix.jbi.jaxp.StringSource; +import org.apache.servicemix.sca.ScaServiceUnit; +import org.apache.tuscany.spi.extension.TargetInvokerExtension; + +/** + * Invoke a JBI reference. + */ +public class ServiceMixInvoker extends TargetInvokerExtension { + + private QName serviceName; + + private ScaServiceUnit serviceUnit; + + public ServiceMixInvoker(QName serviceName) { + this.serviceName = serviceName; + this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit(); + } + + public Object invokeTarget(Object payload) throws InvocationTargetException { + try { + DeliveryChannel channel = serviceUnit.getComponent().getComponentContext().getDeliveryChannel(); + + // TODO: in-only case ? + // TODO: interface based routing ? + // TODO: explicit endpoint selection ? + + InOut inout = channel.createExchangeFactory().createInOutExchange(); + inout.setService(serviceName); + NormalizedMessage in = inout.createMessage(); + inout.setInMessage(in); + in.setContent(new StringSource(payload.toString())); + + boolean sent = channel.sendSync(inout); + // TODO: check for error ? + + NormalizedMessage out = inout.getOutMessage(); + Object response = out.getContent(); + inout.setStatus(ExchangeStatus.DONE); + channel.send(inout); + + return response; + + } catch (MessagingException e) { + throw new InvocationTargetException(e); + } + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java new file mode 100644 index 0000000000..e9898f8f15 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixReference.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import java.lang.reflect.Method; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.extension.ReferenceExtension; +import org.apache.tuscany.spi.wire.TargetInvoker; +import org.apache.tuscany.spi.wire.WireService; + +/** + * + */ +public class ServiceMixReference<T> extends ReferenceExtension<T> { + + private final String uri; + + public ServiceMixReference(String name, + CompositeComponent<?> parent, + WireService wireService, + String uri, + Class<T> service) + { + super(name, service, parent, wireService); + setInterface(service); + this.uri = uri; + } + + public TargetInvoker createTargetInvoker(Method arg0) { + QName serviceName = null; + ServiceMixInvoker invoker = new ServiceMixInvoker(serviceName); + return invoker; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java new file mode 100644 index 0000000000..ae7e9e3f1b --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/java/org/apache/tuscany/servicemix/ServiceMixService.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.servicemix; + +import org.apache.tuscany.spi.component.CompositeComponent; +import org.apache.tuscany.spi.extension.ServiceExtension; +import org.apache.tuscany.spi.wire.WireService; + +/** + * + */ +public class ServiceMixService<T> extends ServiceExtension<T> { + + public ServiceMixService(String name, CompositeComponent parent, WireService wireService, Class<T> service) { + super(name, service, parent, wireService); + } + + public void start() { + super.start(); + } + + public void stop() { + super.stop(); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/DISCLAIMER b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/DISCLAIMER new file mode 100644 index 0000000000..14eddf5d92 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/DISCLAIMER @@ -0,0 +1,6 @@ +Apache ServiceMix is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Geronimo PMC. +Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, +communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or stability of the code, it does +indicate that the project has yet to be fully endorsed by the ASF. diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/LICENSE b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/LICENSE new file mode 100644 index 0000000000..6b0b1270ff --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/NOTICE b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/NOTICE new file mode 100644 index 0000000000..c035229231 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/main/jbi/META-INF/NOTICE @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Apache ServiceMix distribution. == + ========================================================================= + + This product includes software developed by + The Apache Software Foundation (http://www.apache.org/). + + Additional copyright notices and license terms applicable are + present in the licenses directory of this distribution. diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java new file mode 100644 index 0000000000..2edf9882ec --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/AssemblyLoaderTest.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.servicemix.sca.assembly.JbiBinding; +import org.apache.servicemix.sca.tuscany.TuscanyRuntime; +import org.apache.tuscany.common.monitor.impl.NullMonitorFactory; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.Component; +import org.apache.tuscany.model.assembly.EntryPoint; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.Module; + +/** + * @author delfinoj + */ +public class AssemblyLoaderTest extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + } + + public void testLoader() throws Exception { + String name = "bigbank"; + String uri = getClass().getResource("bigbank/sca.module").toString(); + + URL url = getClass().getResource("bigbank/sca.module"); + URL parentUrl = new File(url.toURI()).getParentFile().toURL(); + ClassLoader cl = new URLClassLoader(new URL[] { parentUrl }, getClass().getClassLoader()); + + TuscanyRuntime rt = new TuscanyRuntime(name, uri, cl, new NullMonitorFactory()); + assertNotNull(rt); + + Module module = rt.getModuleComponent().getModuleImplementation(); + + Assert.assertTrue(module.getName().equals("org.apache.servicemix.sca.bigbank")); + + Component component = module.getComponent("AccountServiceComponent"); + Assert.assertTrue(component != null); + + EntryPoint entryPoint = module.getEntryPoint("AccountService"); + Assert.assertTrue(entryPoint != null); + + ExternalService externalService = module.getExternalService("StockQuoteService"); + Assert.assertTrue(externalService != null); + + Binding binding = externalService.getBindings().get(0); + Assert.assertTrue(binding instanceof JbiBinding); + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java new file mode 100644 index 0000000000..bd6c4b3e88 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.net.URL; + +import javax.naming.InitialContext; +import javax.xml.bind.JAXBContext; +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.servicemix.client.DefaultServiceMixClient; +import org.apache.servicemix.client.ServiceMixClient; +import org.apache.servicemix.components.util.MockServiceComponent; +import org.apache.servicemix.jbi.container.ActivationSpec; +import org.apache.servicemix.jbi.container.JBIContainer; +import org.apache.servicemix.jbi.jaxp.SourceTransformer; +import org.apache.servicemix.jbi.jaxp.StringSource; +import org.apache.servicemix.jbi.resolver.ServiceNameEndpointResolver; +import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse; +import org.w3c.dom.Node; + +public class ScaComponentTest extends TestCase { + + private static Log log = LogFactory.getLog(ScaComponentTest.class); + + protected JBIContainer container; + + protected void setUp() throws Exception { + container = new JBIContainer(); + container.setUseMBeanServer(false); + container.setCreateMBeanServer(false); + container.setMonitorInstallationDirectory(false); + container.setNamingContext(new InitialContext()); + container.setEmbedded(true); + container.init(); + } + + protected void tearDown() throws Exception { + if (container != null) { + container.shutDown(); + } + } + + public void testDeploy() throws Exception { + ScaComponent component = new ScaComponent(); + container.activateComponent(component, "JSR181Component"); + + MockServiceComponent mock = new MockServiceComponent(); + mock.setService(new QName("http://www.quickstockquote.com", "StockQuoteService")); + mock.setEndpoint("StockQuoteServiceJBI"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + StockQuoteResponse r = new StockQuoteResponse(); + r.setResult(8.23f); + JAXBContext.newInstance(StockQuoteResponse.class).createMarshaller().marshal(r, baos); + mock.setResponseXml(baos.toString()); + ActivationSpec as = new ActivationSpec(); + as.setComponent(mock); + container.activateComponent(as); + + // Start container + container.start(); + + // Deploy SU + component.getServiceUnitManager().deploy("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank")); + component.getServiceUnitManager().init("su", getServiceUnitPath("org/apache/servicemix/sca/bigbank")); + component.getServiceUnitManager().start("su"); + + ServiceMixClient client = new DefaultServiceMixClient(container); + Source req = new StringSource("<AccountReportRequest><CustomerID>id</CustomerID></AccountReportRequest>"); + Object rep = client.request(new ServiceNameEndpointResolver( + new QName("http://sca.servicemix.apache.org/Bigbank/Account", "AccountService")), + null, null, req); + if (rep instanceof Node) { + rep = new DOMSource((Node) rep); + } + log.info(new SourceTransformer().toString((Source) rep)); + } + + protected String getServiceUnitPath(String name) { + URL url = getClass().getClassLoader().getResource(name + "/sca.module"); + File path = new File(url.getFile()); + path = path.getParentFile(); + return path.getAbsolutePath(); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java new file mode 100644 index 0000000000..00c55aeffc --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.account; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { "customerID" }) +@XmlRootElement(name = "AccountReportRequest") +public class AccountReportRequest { + + @XmlElement(name = "CustomerID") + private String customerID; + + public String getCustomerID() { + return customerID; + } + + public void setCustomerID(String customerID) { + this.customerID = customerID; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java new file mode 100644 index 0000000000..f52985d2c1 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.account; + +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { "accountSummaries" }) +@XmlRootElement(name = "AccountReportResponse") +public class AccountReportResponse { + + @XmlElement(name = "AccountSummaries") + private List<AccountSummary> accountSummaries; + + public List<AccountSummary> getAccountSummaries() { + return accountSummaries; + } + + public void setAccountSummaries(List<AccountSummary> accountSummaries) { + this.accountSummaries = accountSummaries; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java new file mode 100644 index 0000000000..5c2997f2c3 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.account; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface AccountService { + + public AccountReportResponse getAccountReport(AccountReportRequest request); +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..f0cad13f5c --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.account; + +import java.util.ArrayList; + +import org.apache.servicemix.sca.bigbank.accountdata.AccountDataService; +import org.apache.servicemix.sca.bigbank.accountdata.CheckingAccount; +import org.apache.servicemix.sca.bigbank.accountdata.SavingsAccount; +import org.apache.servicemix.sca.bigbank.accountdata.StockAccount; +import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteRequest; +import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse; +import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(interfaces=AccountService.class) +public class AccountServiceImpl implements AccountService { + + @Property + public String currency = "USD"; + + @Reference + public AccountDataService accountDataService; + @Reference + public StockQuoteService stockQuoteService; + + public AccountServiceImpl() { + } + + public AccountReportResponse getAccountReport(AccountReportRequest request) { + AccountReportResponse report = new AccountReportResponse(); + String customerID = request.getCustomerID(); + report.setAccountSummaries(new ArrayList<AccountSummary>()); + report.getAccountSummaries().add(getCheckAccountSummary(customerID)); + report.getAccountSummaries().add(getSavingsAccountSummary(customerID)); + report.getAccountSummaries().add(getStockAccountSummary(customerID)); + return report; + } + + private AccountSummary getCheckAccountSummary(String customerID) { + CheckingAccount checking = accountDataService.getCheckingAccount(customerID); + AccountSummary summary = new AccountSummary(); + summary.setAccountNumber(checking.getAccountNumber()); + summary.setAccountType("Checking"); + summary.setBalance(checking.getBalance()); + return summary; + } + + private AccountSummary getSavingsAccountSummary(String customerID) { + SavingsAccount savings = accountDataService.getSavingsAccount(customerID); + AccountSummary summary = new AccountSummary(); + summary.setAccountNumber(savings.getAccountNumber()); + summary.setAccountType("Savings"); + summary.setBalance(savings.getBalance()); + return summary; + } + + private AccountSummary getStockAccountSummary(String customerID) { + StockAccount stock = accountDataService.getStockAccount(customerID); + AccountSummary summary = new AccountSummary(); + summary.setAccountNumber(stock.getAccountNumber()); + summary.setAccountType("Stock"); + float quote = getQuote(stock.getSymbol()); + summary.setBalance(quote * stock.getQuantity()); + return summary; + } + + private float getQuote(String symbol) { + StockQuoteRequest req = new StockQuoteRequest(); + req.setSymbol(symbol); + StockQuoteResponse rep = stockQuoteService.getQuote(req); + return rep.getResult(); + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java new file mode 100644 index 0000000000..f6e5a060af --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.account; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { "accountNumber", "accountType", "balance" }) +@XmlRootElement(name = "AccountSummary") +public class AccountSummary { + + @XmlElement(name = "AccountNumber") + private String accountNumber; + + @XmlElement(name = "AccountType") + private String accountType; + + @XmlElement(name = "Balance") + private float balance; + + public AccountSummary() { + } + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public String getAccountType() { + return accountType; + } + + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + public float getBalance() { + return balance; + } + + public void setBalance(float balance) { + this.balance = balance; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java new file mode 100644 index 0000000000..972b9dc704 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.accountdata; + +public interface AccountDataService { + + CheckingAccount getCheckingAccount(String customerID); + + SavingsAccount getSavingsAccount(String customerID); + + StockAccount getStockAccount(String customerID); +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..f9d0c08df7 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/AccountDataServiceImpl.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.accountdata; + +public class AccountDataServiceImpl implements AccountDataService { + + public CheckingAccount getCheckingAccount(String customerID) { + + CheckingAccount checkingAccount = new CheckingAccount(); + checkingAccount.setAccountNumber(customerID + "_" + "CHA12345"); + checkingAccount.setBalance(1500.0f); + + return checkingAccount; + } + + public SavingsAccount getSavingsAccount(String customerID) { + + SavingsAccount savingsAccount = new SavingsAccount(); + savingsAccount.setAccountNumber(customerID + "_" + "SAA12345"); + savingsAccount.setBalance(1500.0f); + + return savingsAccount; + } + + public StockAccount getStockAccount(String customerID) { + + StockAccount stockAccount = new StockAccount(); + stockAccount.setAccountNumber(customerID + "_" + "STA12345"); + stockAccount.setSymbol("IBM"); + stockAccount.setQuantity(100); + + return stockAccount; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..596dcc8d06 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/CheckingAccount.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.accountdata; + +public class CheckingAccount { + + private String accountNumber; + private float balance; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public float getBalance() { + return balance; + } + + public void setBalance(float balance) { + this.balance = balance; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..c208788ca8 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/SavingsAccount.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.accountdata; + +public class SavingsAccount { + + private String accountNumber; + private float balance; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public float getBalance() { + return balance; + } + + public void setBalance(float balance) { + this.balance = balance; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java new file mode 100644 index 0000000000..1005bceb91 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/accountdata/StockAccount.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.accountdata; + +public class StockAccount { + + private String accountNumber; + private String symbol; + private int quantity; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java new file mode 100644 index 0000000000..4f12b18601 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.stockquote; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { "symbol" }) +@XmlRootElement(name = "StockQuoteRequest") +public class StockQuoteRequest { + + @XmlElement(name = "Symbol") + private String symbol; + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java new file mode 100644 index 0000000000..bf2d7c7c00 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.stockquote; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { "result" }) +@XmlRootElement(name = "StockQuoteResponse") +public class StockQuoteResponse { + + @XmlElement(name = "Result") + private float result; + + public float getResult() { + return result; + } + + public void setResult(float result) { + this.result = result; + } + +} diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..3fa1558907 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.servicemix.sca.bigbank.stockquote; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface StockQuoteService { + + public StockQuoteResponse getQuote(StockQuoteRequest stockQuote); +} + + diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j-tests.properties b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j-tests.properties new file mode 100644 index 0000000000..bb7170437c --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j-tests.properties @@ -0,0 +1,21 @@ +# +# The logging properties used during tests.. +# +log4j.rootLogger=DEBUG, out + +log4j.logger.org.apache.activemq=INFO +log4j.logger.org.apache.activemq.spring=WARN +log4j.logger.org.apache.activemq.store.journal=INFO +log4j.logger.org.activeio.journal=INFO + +# CONSOLE appender not used by default +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# File appender +log4j.appender.out=org.apache.log4j.FileAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +log4j.appender.out.file=target/servicemix-test.log +log4j.appender.out.append=true diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j.properties b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j.properties new file mode 100644 index 0000000000..18c99eb990 --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/log4j.properties @@ -0,0 +1,21 @@ +# +# The logging properties used during tests.. +# +log4j.rootLogger=DEBUG, stdout + +log4j.logger.org.apache.activemq=INFO +log4j.logger.org.apache.activemq.spring=WARN +log4j.logger.org.apache.activemq.store.journal=INFO +log4j.logger.org.activeio.journal=INFO + +# CONSOLE appender not used by default +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# File appender +log4j.appender.out=org.apache.log4j.FileAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +log4j.appender.out.file=target/servicemix-test.log +log4j.appender.out.append=true diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl new file mode 100644 index 0000000000..9797a5739c --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:tns="http://sca.servicemix.apache.org/Bigbank/Account" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account" + name="AccountService"> + + <wsdl:types> + <xsd:schema targetNamespace="http://sca.servicemix.apache.org/Bigbank/Account" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="getAccountReportRequest" type="tns:AccountReportRequest"/> + <xsd:complexType name="AccountReportRequest"> + <xsd:sequence> + <xsd:element name="CustomerID" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="getAccountReportResponse" type="tns:AccountReportResponse"/> + + <xsd:complexType name="AccountReportResponse"> + <xsd:sequence> + <xsd:element name="AccountSummaries"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="AccountSummary" + type="tns:AccountSummary" maxOccurs="unbounded" minOccurs="0"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="AccountSummary"> + <xsd:sequence> + <xsd:element name="AccountNumber" type="xsd:string"/> + <xsd:element name="AccountType" type="xsd:string"/> + <xsd:element name="Balance" type="xsd:float"/> + </xsd:sequence> + </xsd:complexType> + + </xsd:schema> + </wsdl:types> + <wsdl:message name="getAccountReportRequest"> + <wsdl:part element="tns:getAccountReportRequest" name="getAccountReportRequest"/> + </wsdl:message> + <wsdl:message name="getAccountReportResponse"> + <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/> + </wsdl:message> + <wsdl:portType name="AccountService"> + <wsdl:operation name="getAccountReport"> + <wsdl:input message="tns:getAccountReportRequest"/> + <wsdl:output message="tns:getAccountReportResponse"/> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="AccountServiceJBI" type="tns:AccountService"> + </wsdl:binding> + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountServiceJBI" + name="AccountServiceJBI"> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module new file mode 100644 index 0000000000..ae520dd54e --- /dev/null +++ b/sandbox/old/contrib/binding-servicemix/binding/src/test/resources/org/apache/servicemix/sca/bigbank/sca.module @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9" + + name="org.apache.servicemix.sca.bigbank"> + + <entryPoint name="AccountService"> + <interface.java interface="org.apache.servicemix.sca.bigbank.account.AccountService"/> + <interface.wsdl interface="http://sca.servicemix.apache.org/Bigbank/Account#AccountService"/> + <binding.jbi port="http://sca.servicemix.apache.org/Bigbank/Account/AccountService/AccountServiceJBI"/> + <reference>AccountServiceComponent</reference> + </entryPoint> + + <component name="AccountServiceComponent"> + <implementation.java class="org.apache.servicemix.sca.bigbank.account.AccountServiceImpl"/> + <properties> + <v:currency>EURO</v:currency> + </properties> + <references> + <v:accountDataService>AccountDataServiceComponent</v:accountDataService> + <v:stockQuoteService>StockQuoteService</v:stockQuoteService> + </references> + </component> + + <component name="AccountDataServiceComponent"> + <implementation.java class="org.apache.servicemix.sca.bigbank.accountdata.AccountDataServiceImpl"/> + </component> + + <externalService name="StockQuoteService"> + <interface.java interface="org.apache.servicemix.sca.bigbank.stockquote.StockQuoteService"/> + <binding.jbi port="http://www.quickstockquote.com/StockQuoteService/StockQuoteServiceJBI"/> + </externalService> + + <import.wsdl + location="org/apache/servicemix/sca/bigbank/account/AccountService.wsdl" + namespace="http://sca.servicemix.apache.org/Bigbank/Account" /> + +</module> + |