servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r359954 - in /incubator/servicemix/trunk/servicemix-sca/src: main/java/org/apache/servicemix/sca/ main/java/org/apache/servicemix/sca/handler/ test/java/org/apache/servicemix/sca/ test/java/org/apache/servicemix/sca/bigbank/account/ test/ja...
Date Fri, 30 Dec 2005 01:11:31 GMT
Author: gnodet
Date: Thu Dec 29 17:11:14 2005
New Revision: 359954

URL: http://svn.apache.org/viewcvs?rev=359954&view=rev
Log:
Add a limited sca support with jaxb2 binding for both inbound and outbound endpoints

Added:
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
      - copied, changed from r359607, incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReport.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
    incubator/servicemix/trunk/servicemix-sca/src/test/resources/log4j.properties
Removed:
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReport.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteWebService.wsdl
Modified:
    incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
    incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
    incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceHandler.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
    incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
    incubator/servicemix/trunk/servicemix-sca/src/test/resources/org/apache/servicemix/sca/bigbank/tuscany-model.config

Modified: incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaEndpoint.java
Thu Dec 29 17:11:14 2005
@@ -15,20 +15,43 @@
  */
 package org.apache.servicemix.sca;
 
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+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.tuscany.core.runtime.webapp.TuscanyWebAppRuntime;
-import org.apache.tuscany.model.assembly.EntryPoint;
 import org.apache.servicemix.common.Endpoint;
 import org.apache.servicemix.common.ExchangeProcessor;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.EntryPoint;
+import org.apache.tuscany.model.assembly.Interface;
+import org.apache.tuscany.model.types.InterfaceType;
+import org.apache.tuscany.model.types.OperationType;
+import org.apache.tuscany.model.types.java.JavaOperationType;
 
 public class ScaEndpoint extends Endpoint implements ExchangeProcessor {
 
     protected ServiceEndpoint activated;
     protected EntryPoint entryPoint;
+    protected Object proxy;
+    protected Map<Class, Method> methodMap;
+    protected JAXBContext jaxbContext;
+    protected DeliveryChannel channel;
 	
 	public ScaEndpoint(EntryPoint entryPoint) {
 		this.entryPoint = entryPoint;
@@ -42,13 +65,36 @@
         logger = this.serviceUnit.getComponent().getLogger();
         ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
         activated = ctx.activateEndpoint(service, endpoint);
-        getProcessor().start();
+        channel = ctx.getDeliveryChannel();
+        // Get the target service
+        ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
+        ConfiguredService targetServiceEndpoint = referenceValue.getConfiguredServices().get(0);
+        // Create a proxy
+        ProxyFactory proxyFactory = (ProxyFactory) targetServiceEndpoint.getProxyFactory();
+        proxy = proxyFactory.createProxy();
+        // Get the business interface
+        Interface targetInterface = targetServiceEndpoint.getService().getInterfaceContract();
+        InterfaceType targetInterfaceType = targetInterface.getInterfaceType();
+        List<Class> classes = new ArrayList<Class>();
+        methodMap = new HashMap<Class, Method>();
+        for (OperationType oper : targetInterfaceType.getOperationTypes()) {
+        	if (oper instanceof JavaOperationType) {
+        		Method mth = ((JavaOperationType) oper).getJavaMethod();
+        		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;
-        getProcessor().stop();
         ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
         ctx.deactivateEndpoint(ep);
 	}
@@ -58,19 +104,48 @@
 	}
 
 	public void process(MessageExchange exchange) throws Exception {
-		TuscanyWebAppRuntime sca = ((ScaServiceUnit) getServiceUnit()).getTuscanyRuntime();
-		Object mth = sca.getModuleComponentContext().locateService(entryPoint.getName());
-		
+		if (exchange.getStatus() == ExchangeStatus.DONE) {
+			return;
+		} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+			exchange.setStatus(ExchangeStatus.DONE);
+			channel.send(exchange);
+			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 {
+			output = method.invoke(proxy, new Object[] { input });
+		} catch (InvocationTargetException e) {
+			if (e.getCause() instanceof Exception) {
+				throw (Exception) e.getCause();
+			} else if (e.getCause() instanceof Error) {
+				throw (Error) e.getCause();
+			} else {
+				throw new RuntimeException(e.getCause());
+			}
+		}
+		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 {
-		// TODO Auto-generated method stub
-		
 	}
 
 	public void stop() throws Exception {
-		// TODO Auto-generated method stub
-		
 	}
 
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/ScaServiceUnit.java
Thu Dec 29 17:11:14 2005
@@ -17,19 +17,17 @@
 
 import java.io.File;
 import java.io.FilenameFilter;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.Iterator;
-import java.util.Map;
 
-import javax.jbi.messaging.MessageExchange.Role;
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 
+import org.apache.servicemix.common.ServiceUnit;
 import org.apache.tuscany.common.resource.loader.ResourceLoader;
 import org.apache.tuscany.common.resource.loader.ResourceLoaderFactory;
 import org.apache.tuscany.core.runtime.EventContext;
@@ -50,11 +48,16 @@
 import org.apache.tuscany.model.types.wsdl.WSDLTypeHelper;
 import org.osoa.sca.model.Binding;
 import org.osoa.sca.model.JbiBinding;
-import org.apache.servicemix.common.ServiceUnit;
 import org.w3c.dom.Document;
 
 public class ScaServiceUnit extends ServiceUnit {
 
+	protected static final ThreadLocal<ScaServiceUnit> SERVICE_UNIT = new ThreadLocal<ScaServiceUnit>();
+	
+	public static ScaServiceUnit getCurrentScaServiceUnit() {
+		return SERVICE_UNIT.get();
+	}
+	
 	protected TuscanyWebAppRuntime tuscanyRuntime;
 	protected ClassLoader classLoader;
 	
@@ -148,6 +151,32 @@
 
 	public TuscanyWebAppRuntime getTuscanyRuntime() {
 		return tuscanyRuntime;
+	}
+
+	@Override
+	public void start() throws Exception {
+		tuscanyRuntime.start();
+		try {
+			SERVICE_UNIT.set(this);
+			tuscanyRuntime.getModuleComponentContext().start();
+			tuscanyRuntime.getModuleComponentContext().fireEvent(EventContext.MODULE_START, null);
+		} finally {
+			tuscanyRuntime.stop();
+			SERVICE_UNIT.set(null);
+		}
+		super.start();
+	}
+
+	@Override
+	public void stop() throws Exception {
+		super.stop();
+		tuscanyRuntime.start();
+		try {
+			tuscanyRuntime.getModuleComponentContext().fireEvent(EventContext.MODULE_STOP, null);
+			tuscanyRuntime.getModuleComponentContext().stop();
+		} finally {
+			tuscanyRuntime.stop();
+		}
 	}
 
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceHandler.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceHandler.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceHandler.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/main/java/org/apache/servicemix/sca/handler/ExternalJbiServiceHandler.java
Thu Dec 29 17:11:14 2005
@@ -15,27 +15,89 @@
  */
 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 javax.xml.namespace.QName;
+
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.sca.ScaServiceUnit;
 import org.apache.tuscany.core.addressing.EndpointReference;
 import org.apache.tuscany.core.message.Message;
 import org.apache.tuscany.core.message.handler.MessageHandler;
 import org.apache.tuscany.core.runtime.TuscanyModuleComponentContext;
 import org.apache.tuscany.model.assembly.ExternalService;
 import org.apache.tuscany.model.types.OperationType;
+import org.apache.tuscany.model.types.java.JavaOperationType;
 import org.osoa.sca.model.JbiBinding;
 
 public class ExternalJbiServiceHandler implements MessageHandler {
 
+	private TuscanyModuleComponentContext context;
+	private OperationType type;
+	private ExternalService externalService;
+	private JbiBinding jbiBinding;
+	private EndpointReference endpointReference;
+	private ScaServiceUnit serviceUnit;
+	
 	public ExternalJbiServiceHandler(TuscanyModuleComponentContext context, 
 									 OperationType type, 
 									 ExternalService externalService, 
 									 JbiBinding jbiBinding, 
 									 EndpointReference endpointReference) {
-		// TODO Auto-generated constructor stub
+		this.context = context;
+		this.type = type;
+		this.externalService = externalService;
+		this.jbiBinding = jbiBinding;
+		this.endpointReference = endpointReference;
+		this.serviceUnit = ScaServiceUnit.getCurrentScaServiceUnit();
 	}
 
 	public boolean processMessage(Message message) {
-		// TODO Auto-generated method stub
-		return false;
+		try {
+			QName interfaceName;
+			String[] parts = jbiBinding.getPort().split("#");
+			if (parts.length > 1) {
+				interfaceName = new QName(parts[0], parts[1]);
+			} else {
+				interfaceName = new QName(parts[0]);
+			}
+			
+			Object payload = message.getPayload();
+			if (payload instanceof Object[]) {
+				payload = ((Object[]) payload)[0];
+			}
+			
+			Method method = ((JavaOperationType) type).getJavaMethod();
+			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 ?
+			InOut inout = channel.createExchangeFactory(interfaceName).createInOutExchange();
+			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());
+			message.setPayload(response);
+			message.getCallbackChannel().send(message);
+			inout.setStatus(ExchangeStatus.DONE);
+			channel.send(inout);
+			return false;
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
 	}
 
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/ScaComponentTest.java
Thu Dec 29 17:11:14 2005
@@ -15,10 +15,14 @@
  */
 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 junit.framework.TestCase;
 
@@ -33,13 +37,21 @@
 import org.apache.tuscany.model.assembly.Module;
 import org.osoa.sca.CurrentModuleContext;
 import org.osoa.sca.ModuleContext;
+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.ScaComponent;
 import org.apache.servicemix.sca.bigbank.account.AccountService;
+import org.apache.servicemix.sca.bigbank.stockquote.StockQuoteResponse;
 
 public class ScaComponentTest extends TestCase {
 
-    private static Log logger =  LogFactory.getLog(ScaComponentTest.class);
+    private static Log log =  LogFactory.getLog(ScaComponentTest.class);
     
     protected JBIContainer container;
     
@@ -63,6 +75,19 @@
         ScaComponent component = new ScaComponent();
         container.activateComponent(component, "JSR181Component");
 
+        MockServiceComponent mock = new MockServiceComponent();
+        mock.setService(new QName("StockQuoteService"));
+        mock.setEndpoint("Mock");
+        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.setInterfaceName(new QName("http://www.quickstockquote.com/StockQuoteService",
"StockQuoteServiceJBI"));
+        as.setComponent(mock);
+        container.activateComponent(as);
+        
         // Start container
         container.start();
         
@@ -70,6 +95,13 @@
         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>");
+        Source rep = (Source) client.request(new ServiceNameEndpointResolver(
+        										new QName("http://www.bigbank.com/AccountService/", "AccountService")),
+        			   						 null, null, req);
+        log.info(new SourceTransformer().toString(rep));
     }
      
     protected String getServiceUnitPath(String name) {
@@ -79,28 +111,4 @@
         return path.getAbsolutePath();
     }
     
-    public static final void main(String[] args) throws Exception {
-
-        //Obtain Tuscany runtime
-        TuscanyRuntime tuscany = new TuscanyRuntime("hello", null);
-
-        tuscany.start(); //Start the runtime.
-
-        //Obtain SCA module context.
-        ModuleContext moduleContext = CurrentModuleContext.getContext();
-        TuscanyModuleComponentContext tModuleContext = (TuscanyModuleComponentContext) moduleContext;

-        Module module = tModuleContext.getModuleComponent().getModuleImplementation();
-        for (EntryPoint entryPoint : module.getEntryPoints()) {
-            ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
-            ConfiguredService targetServiceEndpoint = referenceValue.getConfiguredServices().get(0);
-        	ProxyFactory proxyFactory = (ProxyFactory) targetServiceEndpoint.getProxyFactory();
-            Object proxy = proxyFactory.createProxy();
-            AccountService svc = (AccountService) proxy;
-            svc.getAccountReport("customer");
-		}
-        
-        tuscany.stop();
-    }
-	
-	
 }

Added: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java?rev=359954&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
(added)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportRequest.java
Thu Dec 29 17:11:14 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.sca.bigbank.account;
+
+import javax.xml.bind.annotation.AccessType;
+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(AccessType.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;
+	}
+	
+}

Copied: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
(from r359607, incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReport.java)
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java?p2=incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java&p1=incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReport.java&r1=359607&r2=359954&rev=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReport.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountReportResponse.java
Thu Dec 29 17:11:14 2005
@@ -17,15 +17,26 @@
 
 import java.util.List;
 
-/**
- * @model
- */
+import javax.xml.bind.annotation.AccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
 
-public interface AccountReport {
+@XmlAccessorType(AccessType.FIELD)
+@XmlType(name = "", propOrder = { "accountSummaries" })
+@XmlRootElement(name = "AccountReportResponse")
+public class AccountReportResponse {
 
-    /**
-     * @model type="services.account.AccountSummary"
-     */
+	@XmlElement(name = "AccountSummaries")
+	private List<AccountSummary> accountSummaries;
+	
+	public List<AccountSummary> getAccountSummaries() {
+		return accountSummaries;
+	}
 
-    List getAccountSummaries();
+	public void setAccountSummaries(List<AccountSummary> accountSummaries) {
+		this.accountSummaries = accountSummaries;
+	} 
+	
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.java
Thu Dec 29 17:11:14 2005
@@ -20,5 +20,5 @@
 @Remotable
 public interface AccountService {
 
-    public AccountReport getAccountReport(String customerID);
+    public AccountReportResponse getAccountReport(AccountReportRequest request);
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountService.wsdl
Thu Dec 29 17:11:14 2005
@@ -25,26 +25,39 @@
     <wsdl:types>
         <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
-            <xsd:element name="customerID" type="xsd:string"/>
-            <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
-
-            <xsd:complexType name="AccountReport">
+			<xsd:element name="getAccountReportRequest" type="tns:AccountReportRequest"/>
+            <xsd:complexType name="AccountReportRequest">
                 <xsd:sequence>
-                    <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+            		<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: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:customerID" name="getAccountReportRequest"/>
+        <wsdl:part element="tns:getAccountReportRequest" name="getAccountReportRequest"/>
     </wsdl:message>
     <wsdl:message name="getAccountReportResponse">
         <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/>

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountServiceImpl.java
Thu Dec 29 17:11:14 2005
@@ -15,7 +15,14 @@
  */
 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;
@@ -33,9 +40,49 @@
     public AccountServiceImpl() {
     }
 
-    public AccountReport getAccountReport(String customerID) {
-    	stockQuoteService.getQuote("IBM");
-        return null;
+    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();
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/account/AccountSummary.java
Thu Dec 29 17:11:14 2005
@@ -15,31 +15,45 @@
  */
 package org.apache.servicemix.sca.bigbank.account;
 
-/**
- * @model
- */
-
-public interface AccountSummary {
-
-    /**
-     * @model
-     */
-    String getAccountNumber();
-
-    void setAccountNumber(String accountNumber);
-
-    /**
-     * @model
-     */
-    String getAccountType();
-
-    void setAccountType(String accountType);
-
-    /**
-     * @model
-     */
-    float getBalance();
-
-    void setBalance(float balance);
+import javax.xml.bind.annotation.AccessType;
+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(AccessType.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;
+	}
+	
 }
 

Added: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java?rev=359954&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
(added)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteRequest.java
Thu Dec 29 17:11:14 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.AccessType;
+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(AccessType.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;
+	}
+	
+}

Added: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java?rev=359954&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
(added)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteResponse.java
Thu Dec 29 17:11:14 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.sca.bigbank.stockquote;
+
+import javax.xml.bind.annotation.AccessType;
+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(AccessType.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;
+	}
+	
+}

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/java/org/apache/servicemix/sca/bigbank/stockquote/StockQuoteService.java
Thu Dec 29 17:11:14 2005
@@ -20,7 +20,7 @@
 @Remotable
 public interface StockQuoteService {
 
-    public float getQuote(String symbol);
+    public StockQuoteResponse getQuote(StockQuoteRequest stockQuote);
 }
 
  

Added: incubator/servicemix/trunk/servicemix-sca/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/resources/log4j.properties?rev=359954&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/resources/log4j.properties (added)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/resources/log4j.properties Thu Dec
29 17:11:14 2005
@@ -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

Modified: incubator/servicemix/trunk/servicemix-sca/src/test/resources/org/apache/servicemix/sca/bigbank/tuscany-model.config
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-sca/src/test/resources/org/apache/servicemix/sca/bigbank/tuscany-model.config?rev=359954&r1=359953&r2=359954&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-sca/src/test/resources/org/apache/servicemix/sca/bigbank/tuscany-model.config
(original)
+++ incubator/servicemix/trunk/servicemix-sca/src/test/resources/org/apache/servicemix/sca/bigbank/tuscany-model.config
Thu Dec 29 17:11:14 2005
@@ -16,6 +16,6 @@
  -->
 <config:modelConfiguration xmlns:config="http://org.apache.tuscany/xmlns/model/config/0.9">
 
-    <dynamicPackage location="org/servicemix/sca/bigbank/account/AccountService.wsdl"
uri="http://www.bigbank.com/AccountService/"/>
+    <dynamicPackage location="org/apache/servicemix/sca/bigbank/account/AccountService.wsdl"
uri="http://www.bigbank.com/AccountService/"/>
 
 </config:modelConfiguration>



Mime
View raw message