merged from trunk

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-gcore-stubs/1.0@91159 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
fabio.simeoni 2014-02-07 16:44:20 +00:00
parent 719f80c0dd
commit b0c584b977
29 changed files with 10 additions and 1610 deletions

View File

@ -22,21 +22,15 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-sources/stubs">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -2,8 +2,11 @@
<Changeset component="common-gcore-stubs-1.0.0" date="2013-01-11"> <Changeset component="common-gcore-stubs-1.0.0" date="2013-01-11">
<Change>First Release</Change> <Change>First Release</Change>
</Changeset> </Changeset>
<Changeset component="${build.finalName}" date="2013-07-01"> <Changeset component="common-gcore-stubs-1.1.0" date="2013-07-01">
<Change>Modular handler discovery and delegation</Change> <Change>Modular handler discovery and delegation</Change>
<Change>Fix: WSDL cache now releases the lock it acquires when clearing</Change> <Change>Fix: WSDL cache now releases the lock it acquires when clearing</Change>
</Changeset> </Changeset>
<Changeset component="${build.finalName}" date="2013-11-06">
<Change>Moved tests to separate suite</Change>
</Changeset>
</ReleaseNotes> </ReleaseNotes>

103
pom.xml
View File

@ -8,7 +8,7 @@
</parent> </parent>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-gcore-stubs</artifactId> <artifactId>common-gcore-stubs</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>1.1.1-SNAPSHOT</version>
<name>GCore Stubs</name> <name>GCore Stubs</name>
<description>JAXWS Stub Support for gCore Service</description> <description>JAXWS Stub Support for gCore Service</description>
@ -39,15 +39,6 @@
<!-- test dependencies --> <!-- test dependencies -->
<!-- provided because it is needed to build test resources -->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>
<version>[1.5.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
@ -55,23 +46,6 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- my-container runtime for integration testing -->
<dependency>
<groupId>org.gcube.tools</groupId>
<artifactId>my-container</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- my-container distribution for integration testing -->
<dependency>
<groupId>org.gcube.tools</groupId>
<artifactId>my-container</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>tar.gz</type>
<classifier>distro</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
@ -124,81 +98,6 @@
</executions> </executions>
</plugin> </plugin>
<!-- test logic -->
<plugin>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-service-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<basePackage>org.acme.sample</basePackage>
<wsdlDirectory>src/test/resources/test-service/wsdl</wsdlDirectory>
<configurationDirectory>src/test/resources/test-service/etc</configurationDirectory>
<wsdls>
<wsdl>
<name>Stateless</name>
<namespace>http://acme.org</namespace>
</wsdl>
<wsdl>
<name>Stateful</name>
<namespace>http://acme.org</namespace>
</wsdl>
</wsdls>
</configuration>
<executions>
<execution>
<id>generate-stubs</id>
<phase>generate-test-resources</phase>
<goals>
<goal>stub-gen</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Adds stub folder as source folder after stub generation -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/target/generated-sources/stubs</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- installs my-container distribution for integration testing -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>install-my-container</id>
<phase>generate-test-resources</phase><!-- runs before tests -->
<configuration>
<includeArtifactIds>my-container</includeArtifactIds>
<includeTypes>tar.gz</includeTypes>
<overWriteIfNewer>false</overWriteIfNewer>
<outputDirectory>${project.basedir}</outputDirectory>
<markersDirectory>${project.basedir}</markersDirectory>
</configuration>
<goals>
<goal>unpack-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -1,55 +0,0 @@
package org.acme;
import static org.acme.jaxws.stubs.StatelessStub.*;
import static org.gcube.common.clients.stubs.jaxws.StubFactory.*;
import static org.junit.Assert.*;
import java.net.URI;
import org.acme.jaxws.stubs.StatelessStub;
import org.gcube.common.clients.stubs.jaxws.handlers.HandlerRegistry;
import org.gcube.common.mycontainer.Deployment;
import org.gcube.common.mycontainer.Gar;
import org.gcube.common.mycontainer.MyContainerTestRunner;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(MyContainerTestRunner.class)
public class ConfigTest {
@Deployment
static Gar testservice = new Gar("test-service").addConfigurations("src/test/resources/test-service/etc").addInterfaces("src/test/resources/test-service/wsdl");
static StatelessStub stub;
@BeforeClass
public static void setup() {
ScopeProvider.instance.set("/gcube/devsec");
stub = stubFor(stateless).at(URI.create("http://localhost:9999/wsrf/services/acme/service/stateless"));
}
@Test
public void handlerTest() {
TestHandler handler = new TestHandler();
assertTrue(HandlerRegistry.handlers().contains(handler));
String input = "input";
String output = stub.foo(input);
assertEquals(input, output);
handler.called=true;
assertTrue(HandlerRegistry.handlers().contains(handler));
}
}

View File

@ -1,258 +0,0 @@
package org.acme;
import static org.acme.jaxws.stubs.StatefulStub.*;
import static org.acme.jaxws.stubs.StatelessStub.*;
import static org.gcube.common.clients.stubs.jaxws.StubFactory.*;
import static org.junit.Assert.*;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.soap.SOAPFaultException;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.acme.jaxws.stubs.BarInput;
import org.acme.jaxws.stubs.BarOutput;
import org.acme.jaxws.stubs.FooException;
import org.acme.jaxws.stubs.StatefulStub;
import org.acme.jaxws.stubs.StatelessStub;
import org.acme.jaxws.stubs.Types.AnyElement;
import org.acme.jaxws.stubs.Types.ChoiceOne;
import org.acme.jaxws.stubs.Types.PolyWrapped;
import org.acme.jaxws.stubs.Types.Sometype;
import org.acme.jaxws.stubs.Types.Subone;
import org.acme.jaxws.stubs.Types.Subtwo;
import org.acme.jaxws.stubs.VoidWrapper;
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils;
import org.gcube.common.mycontainer.Deployment;
import org.gcube.common.mycontainer.Gar;
import org.gcube.common.mycontainer.MyContainerTestRunner;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@RunWith(MyContainerTestRunner.class)
public class StubTest {
@Deployment
static Gar testservice = new Gar("test-service").addConfigurations("src/test/resources/test-service/etc").addInterfaces("src/test/resources/test-service/wsdl");
static StatelessStub stub;
@BeforeClass
public static void setup() {
//setProxy("localhost",8081); //comment after on-the-wire analysis
ScopeProvider.instance.set("/gcube/devsec");
stub = stubFor(stateless).at(URI.create("http://localhost:9999/wsrf/services/acme/service/stateless"));
}
@Test
public void fooTest() {
String input = "input";
String output = stub.foo(input);
assertEquals(input, output);
}
@Test
public void fooWrappedTest() {
String input = "input";
String output = stub.fooWrapped(input);
assertEquals(input, output);
}
@Test
public void fooMixedTest() {
String input = "input";
String output = stub.fooMixed(input).ret;
assertEquals(input, output);
}
@Test
public void fooBulkTest() {
String[] input = new String[]{"1","2","3"};
String output = stub.fooBulk(Arrays.asList(input));
assertEquals(Arrays.deepToString(input), output);
}
@Test
public void fooContingencyTest() {
try {
stub.fooFault("contingency");
fail();
}
catch(FooException e) {
}
}
@Test
public void fooOutageTest() throws Exception {
try {
stub.fooFault("outage");
fail();
}
catch(SOAPFaultException e) {
}
}
@Test
public void fooProperOutageTest() throws Exception {
try {
stub.fooFault("proper");
fail();
}
catch(SOAPFaultException e) {
new RuntimeException(JAXWSUtils.remoteCause(e)).printStackTrace();
}
}
@Test
public void barTest() throws Exception {
String input = "input";
BarInput request = new BarInput();
request.in1 = input;
request.in2 = 3;
BarOutput response = stub.bar(request);
List<String> expected = Arrays.asList(input,input);
assertEquals(expected, response.output);
}
@Test
public void bazTest() {
String response = stub.baz(new VoidWrapper());
assertNotNull(response);
}
@Test
public void nothingTest() {
stub.nothing();
}
@Test
public void barWrappedTest() throws Exception {
String in1 = "input";
Integer in2 = 3;
List<String> response = stub.barWrapped(in1,in2);
List<String> expected = Arrays.asList(in1,in1);
assertEquals(expected, response);
}
@Test
public void createWithEPRTest() throws Exception {
W3CEndpointReference ref = stub.create("input");
assertNotNull(ref);
}
@Test
public void callsTest() throws Exception {
EndpointReference ref = stub.create("input");
StatefulStub stub = stubFor(stateful).at(ref);
assertNotNull(stub.calls());
}
@Test
public void anyTypeTest() throws Exception {
String ref = stub.any("input");
assertEquals(String.class.getName(),ref);
Sometype st = new Sometype();
st.some="hello";
ref = stub.any(st);
assertEquals(org.acme.sample.stubs.Sometype.class.getName(),ref);
}
@Test
public void anyElementTest() throws Exception {
Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = d.createElement("root");
root.appendChild(d.createElement("empty"));
root.setAttribute("foo", "val");
AnyElement e = new AnyElement();
e.some=root;
stub.anyElement(e);
}
@Test
public void poly() throws Exception {
stub.poly(new Subone());
stub.poly(new Subtwo());
}
@Test
public void polyWrapped() throws Exception {
Subone one = new Subone();
one.one="one";
PolyWrapped wrapped = new PolyWrapped();
wrapped.param=one;
stub.polyWrapped(wrapped);
}
@Test
public void choice() throws Exception {
Subone sub = new Subone();
ChoiceOne one = new ChoiceOne();
one.one=sub;
stub.choice(one);
}
}

View File

@ -1,41 +0,0 @@
package org.acme;
import javax.xml.soap.SOAPHeader;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.gcube.common.clients.stubs.jaxws.GCoreService;
import org.gcube.common.clients.stubs.jaxws.handlers.AbstractHandler;
public class TestHandler extends AbstractHandler {
public boolean called=false;
@Override
public void handleRequest(GCoreService<?> target, SOAPHeader header, SOAPMessageContext context) throws Exception {
called=true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (called ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TestHandler other = (TestHandler) obj;
if (called != other.called)
return false;
return true;
}
}

View File

@ -1,15 +0,0 @@
package org.acme.jaxws.stubs;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class BarInput {
@XmlElement
public String in1;
@XmlElement
public int in2;
}

View File

@ -1,13 +0,0 @@
package org.acme.jaxws.stubs;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class BarOutput {
@XmlElement
public List<String> output;
}

View File

@ -1,13 +0,0 @@
package org.acme.jaxws.stubs;
import javax.xml.ws.WebFault;
@WebFault(name="SampleFault")
public class FooException extends Exception {
private static final long serialVersionUID = 1L;
public FooException(String s) {
super(s);
}
}

View File

@ -1,33 +0,0 @@
package org.acme.jaxws.stubs;
import static org.acme.jaxws.stubs.StatefulStub.*;
import static org.gcube.common.clients.stubs.jaxws.GCoreServiceBuilder.*;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.namespace.QName;
import org.gcube.common.clients.stubs.jaxws.GCoreService;
@WebService(name=porttype,targetNamespace=porttypeNS)
public interface StatefulStub {
public static final String namespace = "http://acme.org/service";
public static final String localname = "StatefulService";
public static final QName name = new QName(namespace,localname);
public static final String porttypeNS = "http://acme.org";
static final String porttype = "StatefulPortType";
static final String port = "StatefulPortTypePort";
public static String service_class="samples";
public static String service_name="test-service";
static final GCoreService<StatefulStub> stateful = service().
withName(name).
coordinates(service_class,service_name).
andInterface(StatefulStub.class);
@WebResult(name="output")
String calls();
}

View File

@ -1,90 +0,0 @@
package org.acme.jaxws.stubs;
import static javax.jws.soap.SOAPBinding.ParameterStyle.*;
import static org.acme.jaxws.stubs.StatelessStub.*;
import static org.gcube.common.clients.stubs.jaxws.GCoreServiceBuilder.*;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.namespace.QName;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.acme.jaxws.stubs.Types.AnyElement;
import org.acme.jaxws.stubs.Types.Base;
import org.acme.jaxws.stubs.Types.Choice;
import org.acme.jaxws.stubs.Types.MixedWrapper;
import org.acme.jaxws.stubs.Types.PolyWrapped;
import org.acme.jaxws.stubs.Types.Sometype;
import org.gcube.common.clients.stubs.jaxws.GCoreService;
@WebService(name=porttypeLN,targetNamespace=porttypeNS)
@SOAPBinding(parameterStyle=BARE)
@XmlSeeAlso(Sometype.class)
public interface StatelessStub {
public class AcmeConstants {
public static final String serviceNS = "http://acme.org";
public static final String porttypeNS = "http://acme.org";
public static final QName name = new QName(serviceNS,"AcmeService");
public static final String porttypeLN = "AcmePortType";
}
public static final QName name = new QName("http://acme.org/service","StatelessService");
public static final String porttypeNS = "http://acme.org";
static final String porttypeLN = "StatelessPortType";
public static String service_class="samples";
public static String service_name="test-service";
static final GCoreService<StatelessStub> stateless = service().
withName(name).
coordinates(service_class,service_name).
andInterface(StatelessStub.class);
String foo(String s);
@SOAPBinding(parameterStyle=WRAPPED)
@WebResult(name="anything")
String fooWrapped(@WebParam(name="param") String s);
MixedWrapper fooMixed(String s);
@SOAPBinding(parameterStyle=WRAPPED)
@WebResult(name="return")
String fooBulk(@WebParam(name="param") List<String> elements);
String fooFault(String s) throws FooException;
String baz(VoidWrapper v);
@SOAPBinding(parameterStyle=WRAPPED)
void nothing();
BarOutput bar(BarInput s);
@SOAPBinding(parameterStyle=WRAPPED)
@WebMethod(operationName="bar")
@WebResult(name="output")
List<String> barWrapped(@WebParam(name="in1")String s,@WebParam(name="in2")int i);
W3CEndpointReference create(String s);
String any(Object o);
void anyElement(AnyElement e);
void poly(Base one);
void polyWrapped(PolyWrapped one);
public void choice(Choice c);
}

View File

@ -1,61 +0,0 @@
package org.acme.jaxws.stubs;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.w3c.dom.Element;
public class Types {
public static class MixedWrapper{
@XmlElement(name="anything")
public String ret;
}
public static class AnyElement {
@XmlAnyElement
public Element some;
}
public static class Sometype {
@XmlElement
public String some;
}
public static class SomeElement {
@XmlAnyElement
public Element some;
}
@XmlRootElement
public static class PolyWrapped {
@XmlElement
public Base param;
}
@XmlSeeAlso({Subone.class,Subtwo.class})
public static class Base{}
@XmlRootElement
public static class Subone extends Base {
@XmlElement
public String one;
}
@XmlRootElement
public static class Subtwo extends Base {
@XmlElement
public String two;
}
@XmlSeeAlso({ChoiceOne.class})
public static abstract class Choice {}
public static class ChoiceOne extends Choice {
@XmlElement
public Subone one;
}
}

View File

@ -1,8 +0,0 @@
package org.acme.jaxws.stubs;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class VoidWrapper {
}

View File

@ -1,39 +0,0 @@
package org.acme.service;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBEStatefulPortTypeContext;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.faults.GCUBEUnrecoverableException;
import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.state.GCUBEWSHome;
import org.gcube.common.core.state.GCUBEWSResource;
import org.gcube.common.core.state.GCUBEWSResourceKey;
import org.gcube.common.core.utils.logging.GCUBELog;
public class Factory extends GCUBEPortType {
GCUBELog logger = new GCUBELog(this);
@Override
protected ServiceContext getServiceContext() {
return ServiceContext.getContext();
}
public EndpointReferenceType create(String name) throws GCUBEFault {
//create/reuse the resource
try {
GCUBEStatefulPortTypeContext ptcxt = StatefulContext.getContext();
GCUBEWSHome home = ptcxt.getWSHome();
GCUBEWSResourceKey key = ptcxt.makeKey(name);
GCUBEWSResource ws = home.create(key,name);
ws.store();
return ws.getEPR();
} catch (Exception e) {
logger.error("unable to logon", e);
throw new GCUBEUnrecoverableException(e).toFault();
}
}
}

View File

@ -1,11 +0,0 @@
package org.acme.service;
import org.gcube.common.core.contexts.GCUBEStatefulPortTypeContext;
import org.gcube.common.core.state.GCUBEWSHome;
public class Home extends GCUBEWSHome {
@Override
public GCUBEStatefulPortTypeContext getPortTypeContext() {return StatefulContext.getContext();}
}

View File

@ -1,50 +0,0 @@
package org.acme.service;
import org.gcube.common.core.state.GCUBEWSResource;
import org.globus.wsrf.ResourceProperty;
public class Resource extends GCUBEWSResource {
private static final String NAME_RP_NAME = "Name";
/** Client visits.*/
int calls;
/** Client name. */
String name;
/**{@inheritDoc}*/
public void initialise(Object... args) throws Exception {
if (args == null || args.length!=1) throw new IllegalArgumentException();
this.setName((String) args[0]);
}
/** Returns the number of client visits.
* @return the visits.*/
public synchronized int getVisits() {return calls;}
/** Returns the client name.
* @return the name.*/
public synchronized String getName() {
return (String) this.getResourcePropertySet().get(NAME_RP_NAME).get(0);
}
/** Sets the client name.
* @params the name.*/
public synchronized void setName(String name) {
ResourceProperty property = this.getResourcePropertySet().get(NAME_RP_NAME);
property.clear();
property.add(name);
}
/**Sets the number of client visits.
* the visits.*/
protected synchronized void addVisit() {this.calls++;}
@Override
protected String[] getPropertyNames() {
return new String[]{NAME_RP_NAME};
}
}

View File

@ -1,25 +0,0 @@
package org.acme.service;
import static org.acme.service.Utils.*;
import org.gcube.common.core.contexts.GCUBEServiceContext;
public class ServiceContext extends GCUBEServiceContext {
/** Single context instance, created eagerly */
private static ServiceContext cache = new ServiceContext();
/** Returns cached instance */
public static ServiceContext getContext() {return cache;}
/** Prevents accidental creation of more instances */
private ServiceContext(){};
/** {@inheritDoc} */
protected String getJNDIName() {return NAME;}
}

View File

@ -1,35 +0,0 @@
package org.acme.service;
import org.acme.sample.stubs.CallsResponse;
import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.types.VOID;
import org.globus.wsrf.ResourceException;
public class Stateful extends GCUBEPortType {
@Override
protected ServiceContext getServiceContext() {return ServiceContext.getContext();}
public CallsResponse calls(VOID voidType) {
try {
Resource resource = this.getResource();
return new CallsResponse(resource.getVisits()+" for "+resource.getName());
}
catch (Exception e) {
throw new RuntimeException("problem",e);
}
}
/**
*
* @return the stateful resource
* @throws ResourceException if no resource was found in the current context
*/
private Resource getResource() throws ResourceException {
return (Resource) StatefulContext.getContext().getWSHome().find();
}
}

View File

@ -1,34 +0,0 @@
package org.acme.service;
import static org.acme.service.Utils.*;
import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.common.core.contexts.GCUBEStatefulPortTypeContext;
public class StatefulContext extends GCUBEStatefulPortTypeContext {
/** Single context instance, created eagerly */
private static GCUBEStatefulPortTypeContext cache = new StatefulContext();
/**Create an instance, privately */
private StatefulContext(){}
/** Returns singleton context.
* @return the context. */
public static GCUBEStatefulPortTypeContext getContext() {return cache;}
/** {@inheritDoc} **/
public String getJNDIName() {return STATEFUL_NAME;}
/** {@inheritDoc} **/
public String getNamespace() {return NS;}
/** {@inheritDoc} **/
public GCUBEServiceContext getServiceContext() {return ServiceContext.getContext();}
}

View File

@ -1,158 +0,0 @@
/**
*
*/
package org.acme.service;
import java.io.StringWriter;
import java.util.Arrays;
import javax.xml.namespace.QName;
import org.acme.sample.stubs.AnyElement;
import org.acme.sample.stubs.AnyElementResponse;
import org.acme.sample.stubs.Bar;
import org.acme.sample.stubs.BarResponse;
import org.acme.sample.stubs.Base;
import org.acme.sample.stubs.Choice;
import org.acme.sample.stubs.ChoiceResponse;
import org.acme.sample.stubs.FooBulk;
import org.acme.sample.stubs.FooBulkResponse;
import org.acme.sample.stubs.FooWrapped;
import org.acme.sample.stubs.FooWrappedResponse;
import org.acme.sample.stubs.Nothing;
import org.acme.sample.stubs.PolyResponse;
import org.acme.sample.stubs.PolyWrapped;
import org.acme.sample.stubs.SampleFault;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBEServiceContext;
import org.gcube.common.core.contexts.GCUBEStatefulPortTypeContext;
import org.gcube.common.core.faults.FaultUtils;
import org.gcube.common.core.faults.GCUBEFault;
import org.gcube.common.core.porttypes.GCUBEPortType;
import org.gcube.common.core.state.GCUBEWSHome;
import org.gcube.common.core.state.GCUBEWSResource;
import org.gcube.common.core.state.GCUBEWSResourceKey;
import org.gcube.common.core.types.VOID;
import org.globus.wsrf.encoding.ObjectSerializer;
/**
* @author Fabio Simeoni
*
*/
public class Stateless extends GCUBEPortType {
public String foo(String s) {
return s;
}
public FooWrappedResponse fooWrapped(FooWrapped wrapped) {
return new FooWrappedResponse(wrapped.getParam());
}
public FooWrappedResponse fooMixed(String s) {
return new FooWrappedResponse(s);
}
public FooBulkResponse fooBulk(FooBulk bulk) {
System.out.println(Arrays.asList(bulk.getParam()));
return new FooBulkResponse(Arrays.deepToString(bulk.getParam()));
}
public Nothing nothing(Nothing n) {
System.err.println("invoked NOTHING "+n);
return new Nothing();
}
public String fooFault(String flag) throws SampleFault, GCUBEFault {
if (flag.equals("contingency"))
throw new SampleFault();
else if (flag.equals("proper"))
throw FaultUtils.newFault(new GCUBEFault(), new RuntimeException("generic problem"));
else
throw new RuntimeException("generic problem");
}
public BarResponse bar(Bar s) {
return new BarResponse(new String[] { s.getIn1(), s.getIn1() });
}
public String baz(VOID v) {
return "called";
}
public EndpointReferenceType create(String input) {
try {
GCUBEStatefulPortTypeContext ptcxt = StatefulContext.getContext();
GCUBEWSHome home = ptcxt.getWSHome();
GCUBEWSResourceKey key = ptcxt.makeKey(input);
GCUBEWSResource ws = home.create(key, input);
ws.store();
return ws.getEPR();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String createAsString(String input) {
try {
GCUBEStatefulPortTypeContext ptcxt = StatefulContext.getContext();
GCUBEWSHome home = ptcxt.getWSHome();
GCUBEWSResourceKey key = ptcxt.makeKey(input);
GCUBEWSResource ws = home.create(key, input);
ws.store();
StringWriter w = new StringWriter();
ObjectSerializer.serialize(w,ws.getEPR(), new QName("http://foo","test"));
return w.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String any(Object o) {
System.err.println(o);
return o.getClass().getName();
}
public AnyElementResponse anyElement(AnyElement o) {
System.out.println(Arrays.deepToString(o.get_any()));
return new AnyElementResponse();
}
public PolyResponse poly(Base b) {
System.err.println(b.getClass());
return new PolyResponse();
}
public PolyResponse polyWrapped(PolyWrapped w) {
System.err.println(w.getParam().getClass());
return new PolyResponse();
}
public ChoiceResponse choice(Choice c) {
System.err.println("one:"+c.getOne());
System.err.println("two:"+c.getTwo());
return new ChoiceResponse();
}
/** {@inheritDoc} */
@Override
public GCUBEServiceContext getServiceContext() {
return ServiceContext.getContext();
}
}

View File

@ -1,28 +0,0 @@
package org.acme.service;
import static org.acme.service.Utils.*;
import org.gcube.common.core.contexts.GCUBEPortTypeContext;
import org.gcube.common.core.contexts.GCUBEServiceContext;
public class StatelessContext extends GCUBEPortTypeContext {
/** Single context instance, created eagerly */
private static StatelessContext cache = new StatelessContext();
private StatelessContext(){}
/** Returns cached instance */
public static StatelessContext getContext() {return cache;}
/**{@inheritDoc}*/
public String getJNDIName() {return STATELESS_NAME;}
/** {@inheritDoc}*/
public String getNamespace() {return NS;}
/** {@inheritDoc}*/
public GCUBEServiceContext getServiceContext() {return ServiceContext.getContext();}
}

View File

@ -1,17 +0,0 @@
/**
*
*/
package org.acme.service;
/**
* @author Fabio Simeoni
*
*/
public class Utils {
public static final String NS="http://acme.org/service";
public static final String NAME="acme/service";
public static final String STATELESS_NAME="acme/service/stateless";
public static final String STATEFUL_NAME="acme/service/stateful";
}

View File

@ -1,10 +0,0 @@
log4j.appender.ROOT=org.apache.log4j.ConsoleAppender
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
log4j.appender.ROOT.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c{2} [%t,%M:%L] %m%n
log4j.rootLogger=DEBUG,ROOT
log4j.appender.SAMPLE=org.apache.log4j.ConsoleAppender
log4j.appender.SAMPLE.layout=org.apache.log4j.PatternLayout
log4j.appender.SAMPLE.layout.ConversionPattern=[SAMPLE] %d{HH:mm:ss,SSS} %-5p %c{2} [%t,%M:%L] %m%n
log4j.category.org.acme=TRACE,SAMPLE

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<jndiConfig xmlns="http://wsrf.globus.org/jndi/config">
<service name="acme/service">
<environment name="configDir" value="@config.dir@" type="java.lang.String"
override="false" />
</service>
<service name="acme/service/stateless"/>
<service name="acme/service/stateful">
<resource name="home" type="org.acme.service.Home">
<resourceParams>
<parameter>
<name>factory</name>
<value>org.globus.wsrf.jndi.BeanFactory</value>
</parameter>
<parameter>
<name>resourceClass</name>
<value>org.acme.service.Resource</value>
</parameter>
</resourceParams>
</resource>
</service>
</jndiConfig>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultServerConfig" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<service name="acme/service/stateless" provider="Handler" use="literal"
style="document">
<parameter name="className" value="org.acme.service.Stateless" />
<wsdlFile>share/schema/test-service/Stateless_service.wsdl
</wsdlFile>
<parameter name="allowedMethods" value="*" />
<parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider" />
<parameter name="scope" value="Application" />
<parameter name="loadOnStartup" value="true" />
<beanMapping xmlns:ns="http://acme.org" qname="ns:subone" type="java:org.acme.sample.stubs.Subone" />
<beanMapping xmlns:ns="http://acme.org" qname="ns:subtwo" type="java:org.acme.sample.stubs.Subtwo" />
<beanMapping xmlns:ns="http://acme.org" qname="ns:sometype" type="java:org.acme.sample.stubs.Sometype" />
</service>
<service name="acme/service/stateful" provider="Handler" use="literal"
style="document">
<parameter name="className" value="org.acme.service.Stateful" />
<wsdlFile>share/schema/test-service/Stateful_service.wsdl</wsdlFile>
<parameter name="allowedMethods" value="*" />
<parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider" />
<parameter name="scope" value="Application" />
<parameter name="loadOnStartup" value="true" />
<parameter name="providers" value="GCUBEProvider" />
</service>
</deployment>

View File

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource>
<ID></ID>
<Type>Service</Type>
<Profile>
<Class>samples</Class>
<Name>test-service</Name>
<Version>1.0.0</Version>
<Packages>
<Main>
<Name>test-service</Name>
<Version>1.0.0-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.samples</groupId>
<artifactId>test-service</artifactId>
<version>1.0.0-SNAPSHOT</version>
</MavenCoordinates>
<GARArchive>test-service-1.0.0-SNAPSHOT.gar</GARArchive>
<PortType>
<Name>acme/sample/stateless</Name>
</PortType>
</Main>
<Software>
<Name>test-service-stubs</Name>
<Version>1.0.0-SNAPSHOT</Version>
<MavenCoordinates>
<groupId>org.gcube.samples</groupId>
<artifactId>test-service-stubs</artifactId>
<version>1.0.0-SNAPSHOT</version>
</MavenCoordinates>
<Type>library</Type>
<Files>
<File>test-service-stubs-1.0.0-SNAPSHOT.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Stateful"
targetNamespace="http://acme.org"
xmlns:tns="http://acme.org"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdlpp="http://www.globus.org/namespaces/2004/10/WSDLPreprocessor"
xmlns:wsrp="http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ResourceProperties-1.2-draft-01.xsd"
xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types"
xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults"
xmlns:provider="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider">
<import namespace="http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider" location="../gcube/common/core/providers/GCUBEProvider.wsdl"/>
<import namespace="http://gcube-system.org/namespaces/common/core/faults" location="../gcube/common/core/faults/GCUBEFaults.wsdl"/>
<types>
<xsd:schema targetNamespace="http://acme.org">
<xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/>
<xsd:element name="calls" type="coretypes:VOID" />
<xsd:element name="callsResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="output" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="callsInputMessage">
<part name="request" element="tns:calls"/>
</message>
<message name="callsOutputMessage">
<part name="response" element="tns:callsResponse"/>
</message>
<portType name="StatefulPortType" wsdlpp:extends="provider:GCUBEProvider">
<operation name="calls">
<input message="tns:callsInputMessage"/>
<output message="tns:callsOutputMessage"/>
</operation>
</portType>
</definitions>

View File

@ -1,352 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Stateless"
targetNamespace="http://acme.org"
xmlns:tns="http://acme.org"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:coretypes="http://gcube-system.org/namespaces/common/core/types"
xmlns:corefaults="http://gcube-system.org/namespaces/common/core/faults"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing">
<import namespace="http://gcube-system.org/namespaces/common/core/faults" location="../gcube/common/core/faults/GCUBEFaults.wsdl"/>
<types>
<xsd:schema targetNamespace="http://acme.org">
<xsd:import namespace="http://schemas.xmlsoap.org/ws/2004/03/addressing" schemaLocation="../ws/addressing/WS-Addressing.xsd" />
<xsd:import namespace="http://gcube-system.org/namespaces/common/core/types" schemaLocation="../gcube/common/core/types/GCUBETypes.xsd"/>
<xsd:element name="foo" type="xsd:string" />
<xsd:element name="fooResponse" type="xsd:string" />
<xsd:element name="fooWrapped">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="param" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="fooWrappedResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="anything" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="fooMixed" type="xsd:string" />
<xsd:element name="fooMixedResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="fooBulk">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="param" maxOccurs="unbounded" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="fooBulkResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="return" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="bar">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in1" type="xsd:string"/>
<xsd:element name="in2" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="barResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="output" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="baz" type="coretypes:VOID" />
<xsd:element name="bazResponse" type="xsd:string"/>
<xsd:element name="nothing">
<xsd:complexType />
</xsd:element>
<xsd:element name="create" type="xsd:string" />
<xsd:element name="createResponse" type="wsa:EndpointReferenceType"/>
<xsd:element name="createAsStringResponse" type="xsd:string"/>
<xsd:element name="SampleFault">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="corefaults:GCUBEUnrecoverableFault"/>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="any" type="xsd:anyType" />
<xsd:element name="anyResponse" type="xsd:string"/>
<xsd:element name="poly" type="tns:base"/>
<xsd:element name="polyResponse">
<xsd:complexType />
</xsd:element>
<xsd:element name="polyWrapped">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="param" type="tns:base"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="base" abstract="true" />
<xsd:complexType name="subone">
<xsd:complexContent>
<xsd:extension base="tns:base">
<xsd:sequence>
<xsd:element name="one" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="subtwo">
<xsd:complexContent>
<xsd:extension base="tns:base">
<xsd:sequence>
<xsd:element name="two" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="Sometype">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="some" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="anyElement">
<xsd:complexType>
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="anyElementResponse">
<xsd:complexType />
</xsd:element>
<xsd:element name="choice">
<xsd:complexType>
<xsd:choice>
<xsd:element name="one" type="tns:subone"/>
<xsd:element name="two" type="tns:subtwo"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:element name="choiceResponse">
<xsd:complexType />
</xsd:element>
</xsd:schema>
</types>
<message name="fooWrappedInputMessage">
<part name="request" element="tns:fooWrapped"/>
</message>
<message name="fooWrappedOutputMessage">
<part name="response" element="tns:fooWrappedResponse"/>
</message>
<message name="fooMixedInputMessage">
<part name="request" element="tns:fooMixed"/>
</message>
<message name="fooMixedOutputMessage">
<part name="response" element="tns:fooMixedResponse"/>
</message>
<message name="fooInputMessage">
<part name="request" element="tns:foo"/>
</message>
<message name="fooOutputMessage">
<part name="response" element="tns:fooResponse"/>
</message>
<message name="fooBulkInputMessage">
<part name="request" element="tns:fooBulk"/>
</message>
<message name="fooBulkOutputMessage">
<part name="response" element="tns:fooBulkResponse"/>
</message>
<message name="fooFaultInputMessage">
<part name="request" element="tns:foo"/>
</message>
<message name="fooFaultOutputMessage">
<part name="response" element="tns:fooResponse"/>
</message>
<message name="barInputMessage">
<part name="request" element="tns:bar"/>
</message>
<message name="barOutputMessage">
<part name="response" element="tns:barResponse"/>
</message>
<message name="bazInputMessage">
<part name="request" element="tns:baz"/>
</message>
<message name="bazOutputMessage">
<part name="response" element="tns:bazResponse"/>
</message>
<message name="emptyMessage">
<part name="part" element="tns:nothing"/>
</message>
<message name="createInputMessage">
<part name="request" element="tns:create"/>
</message>
<message name="createOutputMessage">
<part name="response" element="tns:createResponse"/>
</message>
<message name="createAsStringOutputMessage">
<part name="response" element="tns:createAsStringResponse"/>
</message>
<message name="anyElementInputMessage">
<part name="response" element="tns:anyElement"/>
</message>
<message name="anyElementOutputMessage">
<part name="response" element="tns:anyElementResponse"/>
</message>
<message name="polyInputMessage">
<part name="response" element="tns:poly"/>
</message>
<message name="polyOutputMessage">
<part name="response" element="tns:polyResponse"/>
</message>
<message name="polyWrappedInputMessage">
<part name="request" element="tns:polyWrapped"/>
</message>
<message name="anyInputMessage">
<part name="request" element="tns:any"/>
</message>
<message name="anyOutputMessage">
<part name="response" element="tns:anyResponse"/>
</message>
<message name="SampleFaultMessage">
<part name="fault" element="tns:SampleFault"/>
</message>
<message name="choiceInputMessage">
<part name="request" element="tns:choice"/>
</message>
<message name="choiceOutputMessage">
<part name="response" element="tns:choiceResponse"/>
</message>
<portType name="StatelessPortType">
<operation name="foo">
<input message="tns:fooInputMessage"/>
<output message="tns:fooOutputMessage"/>
</operation>
<operation name="fooWrapped">
<input message="tns:fooWrappedInputMessage"/>
<output message="tns:fooWrappedOutputMessage"/>
</operation>
<operation name="fooMixed">
<input message="tns:fooMixedInputMessage"/>
<output message="tns:fooMixedOutputMessage"/>
</operation>
<operation name="fooBulk">
<input message="tns:fooBulkInputMessage"/>
<output message="tns:fooBulkOutputMessage"/>
</operation>
<operation name="fooFault">
<input message="tns:fooFaultInputMessage"/>
<output message="tns:fooFaultOutputMessage"/>
<fault name="sampleFault" message="tns:SampleFaultMessage"/>
</operation>
<operation name="bar">
<input message="tns:barInputMessage"/>
<output message="tns:barOutputMessage"/>
</operation>
<operation name="baz">
<input message="tns:bazInputMessage"/>
<output message="tns:bazOutputMessage"/>
</operation>
<operation name="nothing">
<input message="tns:emptyMessage"/>
<output message="tns:emptyMessage"/>
</operation>
<operation name="create">
<input message="tns:createInputMessage"/>
<output message="tns:createOutputMessage"/>
</operation>
<operation name="createAsString">
<input message="tns:createInputMessage"/>
<output message="tns:createAsStringOutputMessage"/>
</operation>
<operation name="any">
<input message="tns:anyInputMessage"/>
<output message="tns:anyOutputMessage"/>
</operation>
<operation name="poly">
<input message="tns:polyInputMessage"/>
<output message="tns:polyOutputMessage"/>
</operation>
<operation name="polyWrapped">
<input message="tns:polyWrappedInputMessage"/>
<output message="tns:polyOutputMessage"/>
</operation>
<operation name="anyElement">
<input message="tns:anyElementInputMessage"/>
<output message="tns:anyElementOutputMessage"/>
</operation>
<operation name="choice">
<input message="tns:choiceInputMessage"/>
<output message="tns:choiceOutputMessage"/>
</operation>
</portType>
</definitions>