1.x branch (first created for gCube 2.12)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-fw-clients/1.0@67140 82a268e6-3cf1-43bd-a215-b396298e98cf
smartgears_4
fabio.simeoni 11 years ago
commit ef81c27e1d

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<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">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>common-fw-clients</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -0,0 +1,6 @@
gCube System - License
------------------------------------------------------------
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
The software and documentation is provided by its authors/distributors "as is" and no expressed or
implied warranty is given for its use, quality or fitness for a particular case.

@ -0,0 +1,2 @@
* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy
* Rena Tsantouli (e.tsantoylh@di.uoa.gr), University of Athens, Greece

@ -0,0 +1,38 @@
The gCube System - ${name}
----------------------
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2), D4Science (FP7-INFRA-2007-1.2.2),
D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2), and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).
Authors
-------
* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy.
Version and Release Date
------------------------
${version}
Description
-----------
${description}
Download information
--------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from:
Documentation
-------------
Documentation is available on-line from the Projects Documentation Wiki:
https://https://gcube.wiki.gcube-system.org/gcube/index.php/Integration_and_Interoperability_Facilities_Framework:_Client_Libraries_Framework
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

@ -0,0 +1,5 @@
<ReleaseNotes>
<Changeset component="${build.finalName}" date="11/01/2013">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

@ -0,0 +1,42 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID />
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>Common</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

@ -0,0 +1 @@
${scm.url}

@ -0,0 +1,126 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.gcube.tools</groupId>
<artifactId>maven-parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.gcube.core</groupId>
<artifactId>common-fw-clients</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Common Featherweight gCore Client</name>
<description>A binding of the CL Framework to the Featherwieght Stack for gCore service clients.</description>
<properties>
<distroDirectory>distro</distroDirectory>
</properties>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</connection>
<developerConnection>scm:svn:https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/${project.artifactId}</url>
</scm>
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-clients</artifactId>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>discovery-client</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,25 @@
package org.gcube.common.clients.fw;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.cache.DefaultEndpointCache;
import org.gcube.common.clients.cache.EndpointCache;
/**
* Library-wide utilities
*
* @author Fabio Simeoni
*
*/
public class Utils {
/**
* Shared endpoint cache.
*/
public static EndpointCache<EndpointReference> globalCache = new DefaultEndpointCache<EndpointReference>();
/**
* Context path for gCore services
*/
public static String contextPath = "/wsrf/services/";
}

@ -0,0 +1,15 @@
package org.gcube.common.clients.fw.builders;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.builders.SingletonBuilderAPI.Builder;
/**
* A {@link Builder} for singleton gCore services.
*
*
* @author Fabio Simeoni
*
* @param <P> the type of service proxies
*/
public interface SingletonBuilder<P> extends Builder<EndpointReference,P> {}

@ -0,0 +1,51 @@
package org.gcube.common.clients.fw.builders;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.gcube.common.clients.builders.AbstractSingletonBuilder;
import org.gcube.common.clients.cache.EndpointCache;
import org.gcube.common.clients.config.Property;
import org.gcube.common.clients.fw.Utils;
import org.gcube.common.clients.fw.plugin.Plugin;
/**
* Default implementation of {@link SingletonBuilder}.
*
* @author Fabio Simeoni
*
* @param <S> the type of service stubs
* @param <P> the type of service proxies
*/
public final class SingletonBuilderImpl<S,P> extends AbstractSingletonBuilder<EndpointReference,S,P> implements SingletonBuilder<P> {
/**
* Constructs an instance with a given {@link Plugin} and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param properties the properties
*/
public SingletonBuilderImpl(Plugin<S,P> plugin,Property<?> ... properties) {
this(plugin,Utils.globalCache,properties);
}
/**
* Constructs an instance with a given {@link Plugin}, an {@link EndpointCache}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param cache the cache
* @param properties the properties
*/
public SingletonBuilderImpl(Plugin<S,P> plugin,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
super(plugin,cache,properties);
}
@Override
protected EndpointReference convertAddress(W3CEndpointReference address) {
return address;
}
@Override
protected String contextPath() {
return Utils.contextPath;
}
}

@ -0,0 +1,14 @@
package org.gcube.common.clients.fw.builders;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.builders.StatefulBuilderAPI.Builder;
/**
* A {@link Builder} for stateful gCore services.
*
* @author Fabio Simeoni
*
* @param <P> the type of service proxies
*/
public interface StatefulBuilder<P> extends Builder<EndpointReference,P> {}

@ -0,0 +1,51 @@
package org.gcube.common.clients.fw.builders;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.gcube.common.clients.builders.AbstractStatefulBuilder;
import org.gcube.common.clients.cache.EndpointCache;
import org.gcube.common.clients.config.Property;
import org.gcube.common.clients.fw.Utils;
import org.gcube.common.clients.fw.plugin.Plugin;
/**
* Default implementation of {@link StatefulBuilder}.
*
* @author Fabio Simeoni
*
* @param <S> the type of service stubs
* @param <P> the type of service proxies
*/
public final class StatefulBuilderImpl<S,P> extends AbstractStatefulBuilder<EndpointReference,S,P> implements StatefulBuilder<P> {
/**
* Constructs an instance with a given {@link Plugin} and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param properties the properties
*/
public StatefulBuilderImpl(Plugin<S,P> plugin,Property<?> ... properties) {
this(plugin,Utils.globalCache,properties);
}
/**
* Constructs an instance with a given {@link Plugin}, an {@link EndpointCache}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param cache the cache
* @param properties the properties
*/
public StatefulBuilderImpl(Plugin<S,P> plugin,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
super(plugin,cache,properties);
}
@Override
protected EndpointReference convertAddress(W3CEndpointReference address) {
return address;
}
@Override
protected String contextPath() {
return Utils.contextPath;
}
}

@ -0,0 +1,12 @@
package org.gcube.common.clients.fw.builders;
import org.gcube.common.clients.builders.StatelessBuilderAPI.Builder;
/**
* A {@link Builder} for stateless gCore services.
*
* @author Fabio Simeoni
*
* @param <P> the type of service proxies
*/
public interface StatelessBuilder<P> extends Builder<P> {}

@ -0,0 +1,76 @@
package org.gcube.common.clients.fw.builders;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.gcube.common.clients.builders.AbstractStatelessBuilder;
import org.gcube.common.clients.cache.EndpointCache;
import org.gcube.common.clients.config.Property;
import org.gcube.common.clients.fw.Utils;
import org.gcube.common.clients.fw.plugin.Plugin;
import org.gcube.common.clients.fw.queries.StatelessQuery;
/**
* Default implementation of {@link StatelessBuilder}.
*
* @author Fabio Simeoni
*
* @param <S> the type of service stubs
* @param <P> the type of service proxies
*/
public class StatelessBuilderImpl<S,P> extends AbstractStatelessBuilder<EndpointReference,S,P> implements StatelessBuilder<P> {
/**
* Constructs an instance with a given {@link Plugin} and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param properties the properties
*/
public StatelessBuilderImpl(Plugin<S,P> plugin, Property<?> ... properties) {
this(plugin,new StatelessQuery(plugin),Utils.globalCache,properties);
}
/**
* Constructs an instance with a given {@link Plugin}, a {@link StatelessQuery}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param query the {@link StatelessQuery}
* @param properties the properties
*/
public StatelessBuilderImpl(Plugin<S,P> plugin, StatelessQuery query, Property<?> ... properties) {
this(plugin,query,Utils.globalCache,properties);
}
/**
* Constructs an instance with a given {@link Plugin}, an {@link EndpointCache}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param cache the {@link EndpointCache}
* @param properties the properties
*/
public StatelessBuilderImpl(Plugin<S,P> plugin,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
this(plugin,new StatelessQuery(plugin),cache,properties);
}
/**
* Constructs an instance with a given {@link Plugin},a {@link StatelessQuery}, an {@link EndpointCache}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param query the {@link StatelessQuery}
* @param cache the {@link EndpointCache}
* @param properties the properties
*/
public StatelessBuilderImpl(Plugin<S,P> plugin,StatelessQuery query,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
super(plugin,cache,query,properties);
}
@Override
protected EndpointReference convertAddress(W3CEndpointReference address) {
return address;
}
@Override
protected String contextPath() {
return Utils.contextPath;
}
}

@ -0,0 +1,30 @@
package org.gcube.common.clients.fw.plugin;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.delegates.ProxyPlugin;
/**
* A {@link ProxyPlugin} for gCore services.
*
* @author Fabio Simeoni
*
* @param <S> the type of service stubs
* @param <P> the type of service proxies
*/
public interface Plugin<S,P> extends ProxyPlugin<EndpointReference, S,P> {
/**
* Returns the gCube class of the service.
*
* @return the gCube class of the service
*/
String serviceClass();
/**
* Returns the gCube name of the service.
*
* @return the gCube name of the service
*/
String serviceName();
}

@ -0,0 +1,140 @@
package org.gcube.common.clients.fw.queries;
import static java.lang.String.*;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.common.clients.fw.plugin.Plugin;
import org.gcube.common.clients.queries.Query;
import org.gcube.common.resources.gcore.ServiceInstance;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
/**
* A {@link Query} for stateful gCore services.
*
* @author Fabio Simeoni
*
*/
public class StatefulQuery implements Query<EndpointReference> {
private static String classFormat = "$resource/Data/gcube:ServiceClass/text() eq '%1s'";
private static String nameFormat = "$resource/Data/gcube:ServiceName/text() eq '%1s'";
private static String entryFormat = "$resource/Source/text()[ends-with(.,'%1s')]";
private static DiscoveryClient<ServiceInstance> client = ICFactory.clientFor(ServiceInstance.class);
private final SimpleQuery query;
/**
* Creates an instance with a given proxy {@link Plugin}.
*
* @param plugin the plugin
*/
public StatefulQuery(Plugin<?,?> plugin) {
query = ICFactory.queryFor(ServiceInstance.class)
.addCondition(format(classFormat,plugin.serviceClass()))
.addCondition(format(nameFormat,plugin.serviceName()))
.addCondition(format(entryFormat,plugin.name()));
}
/**
* Adds a variable to the query.
*
* @param name the name of the variable
* @param range the range of the variable
* @return the query
*
* @see SimpleQuery#addVariable(String, String)
*
*/
public StatefulQuery addVariable(String name, String range) {
query.addVariable(name, range);
return this;
}
/**
* Adds a free-form condition on query results.
*
* @param condition the condition
* @return the query
* @see SimpleQuery#addCondition(String)
*/
public StatefulQuery addCondition(String condition) {
query.addCondition(condition);
return this;
}
/**
* Adds a namespace to the query.
* @param prefix the namespace prefix
* @param uri the namespace URI
* @return the query
* @see SimpleQuery#addNamespace(String, URI)
*/
public StatefulQuery addNamespace(String prefix, URI uri) {
query.addNamespace(prefix, uri);
return this;
}
@Override
public List<EndpointReference> fire() throws DiscoveryException {
List<EndpointReference> refs = new ArrayList<EndpointReference>();
List<ServiceInstance> instances = null;
try {
instances = client.submit(query);
}
catch(org.gcube.resources.discovery.client.api.DiscoveryException ex) {
throw new DiscoveryException(ex);
}
for(ServiceInstance instance : instances)
refs.add(instance.reference());
return refs;
}
@Override
public String toString() {
return query.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((query == null) ? 0 : query.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StatefulQuery other = (StatefulQuery) obj;
if (query == null) {
if (other.query != null)
return false;
} else if (!query.equals(other.query))
return false;
return true;
}
}

@ -0,0 +1,139 @@
package org.gcube.common.clients.fw.queries;
import static java.lang.String.*;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.common.clients.fw.plugin.Plugin;
import org.gcube.common.clients.queries.Query;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
/**
* A {@link Query} for stateless gCore services.
*
* @author Fabio Simeoni
*
*/
public class StatelessQuery implements Query<EndpointReference> {
private static String classFormat = "$resource/Profile/ServiceClass/text() eq '%1s'";
private static String nameFormat = "$resource/Profile/ServiceName/text() eq '%1s'";
private static String entryFormat = "$entry/@EntryName/string() eq '%1s'";
private static DiscoveryClient<String> client = ICFactory.client();
private final SimpleQuery query;
/**
* Creates an instance with a given proxy {@link Plugin}.
*
* @param plugin the plugin
*/
public StatelessQuery(Plugin<?,?> plugin) {
query = ICFactory.queryFor(GCoreEndpoint.class)
.addCondition(format(classFormat,plugin.serviceClass()))
.addCondition(format(nameFormat,plugin.serviceName()))
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
.addCondition(format(entryFormat,plugin.name()))
.setResult("$entry/text()");
}
/**
* Adds a variable to the query.
*
* @param name the name of the variable
* @param range the range of the variable
* @return the query
*
* @see SimpleQuery#addVariable(String, String)
*
*/
public StatelessQuery addVariable(String name, String range) {
query.addVariable(name, range);
return this;
}
/**
* Adds a free-form condition on query results.
*
* @param condition the condition
* @return the query
* @see SimpleQuery#addCondition(String)
*/
public StatelessQuery addCondition(String condition) {
query.addCondition(condition);
return this;
}
/**
* Adds a namespace to the query.
* @param prefix the namespace prefix
* @param uri the namespace URI
* @return the query
* @see SimpleQuery#addNamespace(String, URI)
*/
public StatelessQuery addNamespace(String prefix, URI uri) {
query.addNamespace(prefix, uri);
return this;
}
@Override
public List<EndpointReference> fire() throws DiscoveryException {
List<EndpointReference> refs = new ArrayList<EndpointReference>();
try {
List<String> addresses = client.submit(query);
for(String address : addresses)
refs.add(new W3CEndpointReferenceBuilder().address(address).build());
}
catch(org.gcube.resources.discovery.client.api.DiscoveryException ex) {
throw new DiscoveryException(ex);
}
return refs;
}
@Override
public String toString() {
return query.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((query == null) ? 0 : query.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StatelessQuery other = (StatelessQuery) obj;
if (query == null) {
if (other.query != null)
return false;
} else if (!query.equals(other.query))
return false;
return true;
}
}

@ -0,0 +1,85 @@
package org.acme;
import static org.junit.Assert.*;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.config.ProxyConfig;
import org.gcube.common.clients.delegates.ProxyDelegate;
import org.gcube.common.clients.exceptions.DiscoveryException;
import org.gcube.common.clients.fw.plugin.Plugin;
import org.gcube.common.clients.fw.queries.StatefulQuery;
import org.gcube.common.clients.fw.queries.StatelessQuery;
import org.gcube.common.scope.api.ScopeProvider;
import org.junit.BeforeClass;
import org.junit.Test;
public class QueryClient {
@BeforeClass
public static void setup() {
ScopeProvider.instance.set("/gcube/devsec");
}
static Plugin<Object,Object> plugin = new Plugin<Object, Object>() {
@Override
public String name() {
return "gcube/data/tm/binder";
}
@Override
public String namespace() {
return "http://gcube-system.org/namespaces/data/tm";
}
@Override
public Exception convert(Exception fault, ProxyConfig<?, ?> config) {
return fault;
}
@Override
public Object resolve(EndpointReference address, ProxyConfig<?, ?> config) throws Exception {
return null;
}
@Override
public Object newProxy(ProxyDelegate<Object> delegate) {
return null;
}
@Override
public String serviceClass() {
return "DataAccess";
}
@Override
public String serviceName() {
return "tree-manager-service";
}
};
@Test
public void stateless() {
StatelessQuery query = new StatelessQuery(plugin);
System.out.println(query);
assertFalse(query.fire().isEmpty());
}
@Test
public void stateful() {
StatefulQuery query = new StatefulQuery(plugin);
System.out.println(query);
assertFalse(query.fire().isEmpty());
}
@Test(expected=DiscoveryException.class)
public void statelessError() {
assertFalse(new StatelessQuery(plugin).addCondition("malformed").fire().isEmpty());
}
}

@ -0,0 +1,5 @@
<service-map scope='/gcube/devsec'>
<services>
<service name='XQueryAccessService' endpoint='http://dlib01.isti.cnr.it:8080/wsrf/services/gcube/informationsystem/collector/XQueryAccess' />
</services>
</service-map>
Loading…
Cancel
Save