fabio.simeoni 11 years ago
commit b49b7c2500

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>common-gcube-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,7 @@
#Thu Oct 10 15:14:03 CEST 2013
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

@ -0,0 +1,6 @@
#Thu Oct 10 15:14:03 CEST 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

@ -0,0 +1,5 @@
#Thu Oct 10 15:14:02 CEST 2013
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -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="2013-10-10">
<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,125 @@
<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-generic-clients</artifactId>
<version>1.0.0-SNAPSHOT</version>
<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,136 @@
package org.gcube.common.clients;
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.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 query for service endpoints published as {@link GCoreEndpoint}s.
* @author Fabio Simeoni
*
*/
public class LegacyQuery 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 statusFormat = "$resource/Profile/DeploymentData/Status/text() eq 'ready'";
private static String containsFormat = "contains($entry/string(),'%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 LegacyQuery(Plugin<?,?> plugin) {
query = ICFactory.queryFor(GCoreEndpoint.class)
.addCondition(format(classFormat,plugin.serviceClass()))
.addCondition(format(nameFormat,plugin.serviceName()))
.addCondition(format(statusFormat))
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
.addCondition(format(containsFormat,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 LegacyQuery 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 LegacyQuery 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 LegacyQuery 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;
LegacyQuery other = (LegacyQuery) obj;
if (query == null) {
if (other.query != null)
return false;
} else if (!query.equals(other.query))
return false;
return true;
}
}

@ -0,0 +1,17 @@
package org.gcube.common.clients;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.delegates.ProxyPlugin;
/**
* Plugs into the framework to provide information about target endpoints.
*
* @author Fabio Simeoni
*
* @param <S> the type of endpoint stubs
* @param <P> the type of endpoint proxies
*/
public interface Plugin<S,P> extends ProxyPlugin<EndpointReference, S, P> {
}

@ -0,0 +1,12 @@
package org.gcube.common.clients;
import org.gcube.common.clients.builders.StatelessBuilderAPI.Builder;
/**
* Builds proxies for target endpoints.
*
* @author Fabio Simeoni
*
* @param <P> the type of built proxies
*/
public interface ProxyBuilder<P> extends Builder<P> {}

@ -0,0 +1,72 @@
package org.gcube.common.clients;
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.queries.Query;
/**
* Default implementation of {@link ProxyBuilder}.
*
* @author Fabio Simeoni
*
* @param <S>
* @param <P>
*/
public class ProxyBuilderImpl<S,P> extends AbstractStatelessBuilder<EndpointReference,S,P> implements ProxyBuilder<P> {
/**
* Creates 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 ProxyBuilderImpl(Plugin<S,P> plugin, Property<?> ... properties) {
this(plugin,new LegacyQuery(plugin),Utils.globalCache,properties);
}
/**
* Creates an instance with a given {@link Plugin}, a {@link Query}, and zero or more default {@link Property}s.
* @param plugin the {@link Plugin}
* @param query the {@link StatelessQuery}
* @param properties the properties
*/
public ProxyBuilderImpl(Plugin<S,P> plugin, Query<EndpointReference> query, Property<?> ... properties) {
this(plugin,query,Utils.globalCache,properties);
}
/**
* Creates 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 ProxyBuilderImpl(Plugin<S,P> plugin,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
this(plugin,new LegacyQuery(plugin),cache,properties);
}
/**
* Creates an instance with a given {@link Plugin},a {@link Query}, 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 ProxyBuilderImpl(Plugin<S,P> plugin,Query<EndpointReference> query,EndpointCache<EndpointReference> cache,Property<?> ... properties) {
super(plugin,cache,query,properties);
}
@Override
protected EndpointReference convertAddress(W3CEndpointReference address) {
return address;
}
@Override
protected String contextPath() {
return "/";
}
}

@ -0,0 +1,20 @@
package org.gcube.common.clients;
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>();
}
Loading…
Cancel
Save