You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2012/09/13 20:52:21 UTC
svn commit: r1384469 - in
/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService: ./
src/ src/samples/ src/samples/services/ src/samples/services/wrapper/
Author: veithen
Date: Thu Sep 13 18:52:21 2012
New Revision: 1384469
URL: http://svn.apache.org/viewvc?rev=1384469&view=rev
Log:
SYNAPSE-905: Added a JAX-WS version (actually a partial implementation) of the SimpleStockQuoteService. Right now, the primary usage of this is to validate some examples (JAX-WS is stricter with respect to namespaces than Axis2 POJO services).
Added:
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java (with props)
synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java (with props)
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml Thu Sep 13 18:52:21 2012
@@ -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.
+ -->
+<project default="build-service">
+ <property name="builddir" value="build"/>
+ <property name="classes" value="${builddir}/classes"/>
+ <property name="repo" value="../../repository"/>
+
+ <target name="init" depends="clean">
+ <mkdir dir="${builddir}"/>
+ <mkdir dir="${classes}"/>
+ <mkdir dir="${repo}/servicejars"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${builddir}"/>
+ </target>
+
+ <target name="compile-all" depends="init">
+ <javac debug="on" destdir="${classes}" includeantruntime="false">
+ <src path="src"/>
+ <classpath>
+ <fileset dir="../../lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="build-service" depends="compile-all">
+ <jar destfile="${repo}/servicejars/JAXWSStockQuoteService.jar">
+ <fileset dir="${classes}"/>
+ </jar>
+ </target>
+</project>
\ No newline at end of file
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java Thu Sep 13 18:52:21 2012
@@ -0,0 +1,36 @@
+/*
+ * 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 samples.services;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name="GetQuote")
+public class GetQuote {
+ private String symbol;
+
+ @XmlElement(required=true)
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuote.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java Thu Sep 13 18:52:21 2012
@@ -0,0 +1,158 @@
+/*
+ * 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 samples.services;
+
+import javax.xml.bind.annotation.XmlAccessOrder;
+import javax.xml.bind.annotation.XmlAccessorOrder;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name="GetQuoteResponse")
+@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
+public class GetQuoteResponse {
+ private double change;
+ private double earnings;
+ private double high;
+ private double last;
+ private String lastTradeTimestamp;
+ private double low;
+ private double marketCap;
+ private String name;
+ private double open;
+ private double peRatio;
+ private double percentageChange;
+ private double prevClose;
+ private String symbol;
+ private int volume;
+
+ public double getChange() {
+ return change;
+ }
+
+ public void setChange(double value) {
+ this.change = value;
+ }
+
+ public double getEarnings() {
+ return earnings;
+ }
+
+ public void setEarnings(double value) {
+ this.earnings = value;
+ }
+
+ public double getHigh() {
+ return high;
+ }
+
+ public void setHigh(double value) {
+ this.high = value;
+ }
+
+ public double getLast() {
+ return last;
+ }
+
+ public void setLast(double value) {
+ this.last = value;
+ }
+
+ @XmlElement(required=true)
+ public String getLastTradeTimestamp() {
+ return lastTradeTimestamp;
+ }
+
+ public void setLastTradeTimestamp(String value) {
+ this.lastTradeTimestamp = value;
+ }
+
+ public double getLow() {
+ return low;
+ }
+
+ public void setLow(double value) {
+ this.low = value;
+ }
+
+ public double getMarketCap() {
+ return marketCap;
+ }
+
+ public void setMarketCap(double value) {
+ this.marketCap = value;
+ }
+
+ @XmlElement(required=true)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public double getOpen() {
+ return open;
+ }
+
+ public void setOpen(double value) {
+ this.open = value;
+ }
+
+ public double getPeRatio() {
+ return peRatio;
+ }
+
+ public void setPeRatio(double value) {
+ this.peRatio = value;
+ }
+
+ public double getPercentageChange() {
+ return percentageChange;
+ }
+
+ public void setPercentageChange(double value) {
+ this.percentageChange = value;
+ }
+
+ public double getPrevClose() {
+ return prevClose;
+ }
+
+ public void setPrevClose(double value) {
+ this.prevClose = value;
+ }
+
+ @XmlElement(required=true)
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String value) {
+ this.symbol = value;
+ }
+
+ public int getVolume() {
+ return volume;
+ }
+
+ public void setVolume(int value) {
+ this.volume = value;
+ }
+}
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/GetQuoteResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java Thu Sep 13 18:52:21 2012
@@ -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 samples.services;
+
+import java.util.Date;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+@WebService(targetNamespace="http://services.samples", serviceName="JAXWSStockQuoteService")
+public class StockQuoteService {
+ private static double getRandom(double base, double varience, boolean onlypositive) {
+ double rand = Math.random();
+ return (base + ((rand > 0.5 ? 1 : -1) * varience * base * rand))
+ * (onlypositive ? 1 : (rand > 0.5 ? 1 : -1));
+ }
+
+ @WebMethod(action="urn:getQuote")
+ @WebResult(name="return", targetNamespace="http://services.samples")
+ @RequestWrapper(className="samples.services.wrapper.GetQuoteWrapper",
+ localName="getQuote", targetNamespace="http://services.samples")
+ @ResponseWrapper(className="samples.services.wrapper.GetQuoteResponseWrapper",
+ localName="getQuoteResponse", targetNamespace="http://services.samples")
+ public GetQuoteResponse getQuote(
+ @WebParam(name="request", targetNamespace="http://services.samples") GetQuote request) {
+
+ String symbol = request.getSymbol();
+ System.out.println(new Date() + " " + this.getClass().getName() +
+ " :: Generating quote for : " + request.getSymbol());
+ GetQuoteResponse response = new GetQuoteResponse();
+ response.setSymbol(symbol);
+ double last = getRandom(100, 0.9, true);
+ response.setLast(last);
+ response.setLastTradeTimestamp(new Date().toString());
+ double change = getRandom(3, 0.5, false);
+ response.setChange(change);
+ response.setOpen(getRandom(last, 0.05, false));
+ response.setHigh(getRandom(last, 0.05, false));
+ response.setLow(getRandom(last, 0.05, false));
+ response.setVolume((int)getRandom(10000, 1.0, true));
+ response.setMarketCap(getRandom(10E6, 5.0, false));
+ double prevClose = getRandom(last, 0.15, false);
+ response.setPrevClose(prevClose);
+ response.setPercentageChange(change / prevClose * 100);
+ response.setEarnings(getRandom(10, 0.4, false));
+ response.setPeRatio(getRandom(20, 0.30, false));
+ response.setName(symbol + " Company");
+ return response;
+ }
+
+ public static void main(String[] args) {
+ Endpoint.publish("http://localhost:7777/stock", new StockQuoteService());
+ }
+}
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/StockQuoteService.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java Thu Sep 13 18:52:21 2012
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace="http://services.samples/xsd",
+ elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package samples.services;
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java Thu Sep 13 18:52:21 2012
@@ -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 samples.services.wrapper;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import samples.services.GetQuoteResponse;
+
+@XmlRootElement(name="getQuoteResponse")
+@XmlType(name="")
+public class GetQuoteResponseWrapper {
+ // TODO: using _return as field name triggers a bug in Axis2!!!!
+ private GetQuoteResponse fReturn;
+
+ @XmlElement(required=true)
+ public GetQuoteResponse getReturn() {
+ return fReturn;
+ }
+
+ public void setReturn(GetQuoteResponse _return) {
+ this.fReturn = _return;
+ }
+}
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteResponseWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java Thu Sep 13 18:52:21 2012
@@ -0,0 +1,40 @@
+/*
+ * 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 samples.services.wrapper;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import samples.services.GetQuote;
+
+@XmlRootElement(name="getQuote")
+@XmlType(name="")
+public class GetQuoteWrapper {
+ private GetQuote request;
+
+ @XmlElement(required=true)
+ public GetQuote getRequest() {
+ return request;
+ }
+
+ public void setRequest(GetQuote request) {
+ this.request = request;
+ }
+}
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/GetQuoteWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java?rev=1384469&view=auto
==============================================================================
--- synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java (added)
+++ synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java Thu Sep 13 18:52:21 2012
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+@javax.xml.bind.annotation.XmlSchema(namespace="http://services.samples", elementFormDefault=javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package samples.services.wrapper;
Propchange: synapse/trunk/java/modules/samples/services/JAXWSStockQuoteService/src/samples/services/wrapper/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native