You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2010/05/25 11:13:39 UTC
svn commit: r947975 - in
/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference: ./
src/ src/main/ src/main/java/ src/main/java/calculator/ src/main/resources/
src/main/resources/META-INF/ src/main/resources/META-INF/spring/ src/test/
sr...
Author: slaws
Date: Tue May 25 09:13:38 2010
New Revision: 947975
URL: http://svn.apache.org/viewvc?rev=947975&view=rev
Log:
A sample that calls the add component (from the calculator-ws-basicauth-service-webapp samples) with basic authentication configured.
Added:
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/README (with props)
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/pom.xml
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddService.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddServiceImpl.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorClient.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorService.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorServiceImpl.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideService.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideServiceImpl.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyService.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyServiceImpl.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractService.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractServiceImpl.java
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/Calculator.composite
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/CalculatorService-context.xml
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/definitions.xml
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/
tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/CalculatorTestCase.java
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/README
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/README?rev=947975&view=auto
==============================================================================
Binary file - no diff available.
Propchange: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/README
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/pom.xml?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/pom.xml (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/pom.xml Tue May 25 09:13:38 2010
@@ -0,0 +1,98 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-ws-basicauth-reference</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator WS basic authentication</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2-policy</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-runtime</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddService.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddService.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddService.java Tue May 25 09:13:38 2010
@@ -0,0 +1,31 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * The Add service interface
+ */
+@Remotable
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddServiceImpl.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/AddServiceImpl.java Tue May 25 09:13:38 2010
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Adding " + n1 + " and " + n2);
+ return n1 + n2;
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorClient.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorClient.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorClient.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorClient.java Tue May 25 09:13:38 2010
@@ -0,0 +1,48 @@
+/*
+ * 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 calculator;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class CalculatorClient {
+ public static void main(String[] args) throws Exception {
+
+ SCANodeFactory factory = SCANodeFactory.newInstance();
+ SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorClient.class.getClassLoader());
+ node.start();
+
+ CalculatorService calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // Calculate
+ System.out.println("3 + 2=" + calculatorService.add(3, 2));
+ System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
+ System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
+ System.out.println("3 / 2=" + calculatorService.divide(3, 2));
+
+ node.stop();
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorService.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorService.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorService.java Tue May 25 09:13:38 2010
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorServiceImpl.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/CalculatorServiceImpl.java Tue May 25 09:13:38 2010
@@ -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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideService.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideService.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideService.java Tue May 25 09:13:38 2010
@@ -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 calculator;
+
+/**
+ * The divide service interface
+ */
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideServiceImpl.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/DivideServiceImpl.java Tue May 25 09:13:38 2010
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2);
+ return n1 / n2;
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyService.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyService.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyService.java Tue May 25 09:13:38 2010
@@ -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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyServiceImpl.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/MultiplyServiceImpl.java Tue May 25 09:13:38 2010
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2);
+ return n1 * n2;
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractService.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractService.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractService.java Tue May 25 09:13:38 2010
@@ -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 calculator;
+
+/**
+ * The interface for the multiply service
+ */
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractServiceImpl.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractServiceImpl.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/java/calculator/SubtractServiceImpl.java Tue May 25 09:13:38 2010
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ Logger logger = Logger.getLogger("calculator");
+ logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2);
+ return n1 - n2;
+ }
+
+}
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/Calculator.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/Calculator.composite?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/Calculator.composite (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/Calculator.composite Tue May 25 09:13:38 2010
@@ -0,0 +1,53 @@
+<?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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="CalculatorServiceComponent">
+ <!--implementation.java class="calculator.CalculatorServiceImpl"/-->
+ <implementation.spring location="META-INF/spring/CalculatorService-context.xml"/>
+ <reference name="addService" >
+ <interface.java interface="calculator.AddService" />
+ <binding.ws requires="authentication" uri="http://localhost:8080/sample-calculator-ws-webapp/AddServiceComponent"/>
+ </reference>
+ <reference name="subtractService" target="SubtractServiceComponent" />
+ <reference name="multiplyService" target="MultiplyServiceComponent" />
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/CalculatorService-context.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/CalculatorService-context.xml?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/CalculatorService-context.xml (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/META-INF/spring/CalculatorService-context.xml Tue May 25 09:13:38 2010
@@ -0,0 +1,39 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sca="http://www.springframework.org/schema/sca"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/sca http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd">
+
+ <bean id="CalculatorServiceBean" class="calculator.CalculatorServiceImpl">
+ <property name="addService" ref="addService"/>
+ <property name="subtractService" ref="subtractService"/>
+ <property name="multiplyService" ref="multiplyService"/>
+ <property name="divideService" ref="divideService"/>
+ </bean>
+
+ <sca:reference name="addService" type="calculator.AddService"/>
+ <sca:reference name="subtractService" type="calculator.SubtractService"/>
+ <sca:reference name="multiplyService" type="calculator.MultiplyService"/>
+ <sca:reference name="divideService" type="calculator.DivideService"/>
+
+</beans>
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/definitions.xml?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/definitions.xml (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/main/resources/definitions.xml Tue May 25 09:13:38 2010
@@ -0,0 +1,37 @@
+<?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.
+-->
+<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://itest/policy"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:ip="http://itest/policy" >
+
+
+ <sca:policySet name="BasicAuthenticationPolicySet"
+ provides="authentication"
+ appliesTo="sca:binding.ws">
+ <tuscany:basicAuthentication>
+ <tuscany:userName>tuscanyuser</tuscany:userName>
+ <tuscany:password>tuscanypwd</tuscany:password>
+ </tuscany:basicAuthentication>
+ </sca:policySet>
+
+
+</definitions>
\ No newline at end of file
Added: tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/CalculatorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/CalculatorTestCase.java?rev=947975&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/CalculatorTestCase.java (added)
+++ tuscany/sca-java-1.x/trunk/samples/calculator-ws-basicauth-reference/src/test/java/calculator/CalculatorTestCase.java Tue May 25 09:13:38 2010
@@ -0,0 +1,56 @@
+/*
+ * 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 calculator;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestCase extends TestCase {
+
+ private CalculatorService calculatorService;
+ private SCANode node;
+
+ @Override
+ protected void setUp() throws Exception {
+ SCANodeFactory factory = SCANodeFactory.newInstance();
+ node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader());
+ node.start();
+
+ calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+ }
+}