Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/SplittedQueryExecutor.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/SplittedQueryExecutor.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/SplittedQueryExecutor.java	(revision 51874)
@@ -0,0 +1,171 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.miscutils.collections.PositionalStringMapGenerator;
+
+/**
+ * Utility class which interacts with a lookup, performs a query and fills a java domain object splitting the result into constructor
+ * arguments.
+ * 
+ * @author marko
+ * 
+ */
+public class SplittedQueryExecutor {
+
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * default constructor. lookupLocator has to be injected.
+	 */
+	public SplittedQueryExecutor() {
+		// empty
+	}
+
+	/**
+	 * Commodity constructor for constructor injection.
+	 * 
+	 * @param lookupLocator
+	 *            lookup locator
+	 */
+	public SplittedQueryExecutor(final UniqueServiceLocator serviceLocator) {
+		super();
+		this.serviceLocator = serviceLocator;
+	}
+
+	/**
+	 * Performs the query, splits the result at ":-:".
+	 * 
+	 * @param <X>
+	 *            domain class type
+	 * @param clazz
+	 *            domain class
+	 * @param query
+	 *            xquery
+	 * @return iterable of domain class instances
+	 */
+	public <X> Iterable<X> query(final Class<X> clazz, final String query) {
+		return query(clazz, query, ":-:");
+	}
+
+	/**
+	 * Performs the query, splits the result at separator
+	 * 
+	 * @param <X>
+	 *            domain class type
+	 * @param clazz
+	 *            domain class
+	 * @param query
+	 *            xquery
+	 * @param separator
+	 *            split separator
+	 * @return iterable of domain class instances
+	 */
+	public <X> Iterable<X> query(final Class<X> clazz, final String query, final String separator) {
+		return new PositionalStringMapGenerator<String>().split(clazz, performQuery(query), separator);
+	}
+
+	/**
+	 * Return a list of maps of splitted query results
+	 * 
+	 * @param query
+	 *            xquery
+	 * @param keys
+	 *            list of keys
+	 * @return collection of key/value pairs
+	 */
+	public Iterable<Map<String, String>> query(final String query, final String... keys) {
+		return new PositionalStringMapGenerator<String>(keys).split(performQuery(query), ":-:");
+	}
+
+	/**
+	 * Like query(String, String..) but returns a container that whose values can be modified.
+	 * 
+	 * @param query
+	 *            xquery
+	 * @param keys
+	 *            list of keys
+	 * @return mutable collection of key/value pairs
+	 */
+	public Iterable<Map<String, String>> mutableQuery(final String query, final String... keys) {
+		return Lists.newArrayList(query(query, keys));
+	}
+
+	/**
+	 * Like query(Class, String), but returns a container which can be modified.
+	 * 
+	 * @param <X>
+	 *            some domain class
+	 * @param clazz
+	 *            domain class
+	 * @param query
+	 *            xquery
+	 * @return mutable collection of X
+	 */
+	public <X> Iterable<X> mutableQuery(final Class<X> clazz, final String query) {
+		return Lists.newArrayList(query(clazz, query));
+	}
+
+	/**
+	 * Like query(Class, String, String), but returns a container which can be modified.
+	 * 
+	 * @param <X>
+	 *            some domain class
+	 * @param clazz
+	 *            domain class
+	 * @param query
+	 *            xquery
+	 * @param separator
+	 *            separator
+	 * @return mutable collection of X
+	 */
+	public <X> Iterable<X> mutableQuery(final Class<X> clazz, final String query, final String separator) {
+		return Lists.newArrayList(query(clazz, query, separator));
+	}
+
+	public List<String> performQuery(final String query) {
+		try {
+			return serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+		} catch (final ISLookUpException e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	/**
+	 * Fetch only one string result.
+	 * 
+	 * @param query
+	 * @return null if no such result
+	 */
+	public String queryFirst(final String query) {
+		try {
+			return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query);
+		} catch (ISLookUpDocumentNotFoundException e) {
+			return null;
+		} catch (final ISLookUpException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StaticServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StaticServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StaticServiceLocator.java	(revision 51874)
@@ -0,0 +1,91 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import eu.dnetlib.enabling.tools.registration.ServiceRegistrationManager;
+
+/**
+ * This service locator returns always one service instance.
+ * 
+ * Usually declared as a spring bean an injected in service when a static configuration is needed.
+ * 
+ * @author marko
+ * 
+ * @param <T>
+ *            the type of the service
+ */
+@Deprecated
+public class StaticServiceLocator<T> extends AbstractServiceLocator<T> implements ApplicationContextAware {
+
+	/**
+	 * static service reference.
+	 */
+	private T service;
+
+	private ApplicationContext applicationContext;
+	
+	/**
+	 * default constructor. initialize with setter.
+	 */
+	public StaticServiceLocator() {
+		// no operation
+	}
+	
+	/**
+	 * construct a static service locator pointing at a given service.
+	 * 
+	 * @param service
+	 *            service
+	 */
+	public StaticServiceLocator(final T service) {
+		this.service = service;
+	}
+
+	/** 
+	 * The usual usage pattern of service locators is to call chain a direct call
+	 * on the result of this method. In order to avoid nullpointer exception, this method throws an exception
+	 * with a better explanation, in case the service is null. 
+	 * 
+	 * TODO: consider using checked exceptions.
+	 * 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.ServiceLocator#getService()
+	 */
+	@Override
+	public T getService() {
+		if (service == null) {
+			throw new IllegalStateException("cannot find service, check configuration");
+		}
+		return service;
+	}
+
+	@Override
+	public String getServiceId() {
+		final Map<String, ServiceRegistrationManager> beans = applicationContext.getBeansOfType(ServiceRegistrationManager.class);
+		
+		if (beans != null) {
+			for (ServiceRegistrationManager r : beans.values()) {
+				if (r.getService() == getService()) {
+					return r.getServiceProfile().getResourceId();
+				}
+			}
+		}
+		throw new IllegalStateException("cannot find service, check configuration");
+	}
+	
+	@Required
+	public void setService(final T service) {
+		this.service = service;
+	}
+
+	@Override
+	public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
+		this.applicationContext = applicationContext;	
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DefaultServiceLocatorLocationScorer.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DefaultServiceLocatorLocationScorer.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DefaultServiceLocatorLocationScorer.java	(revision 51874)
@@ -0,0 +1,107 @@
+package eu.dnetlib.enabling.tools;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.annotation.Resource;
+
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+/**
+ * Assign better scores for near services. Can be configured.
+ * 
+ * @author marko
+ *
+ */
+@Deprecated
+public class DefaultServiceLocatorLocationScorer implements DynamicServiceLocatorLocationScorer {
+
+	/**
+	 * default score assigned when the other service has the same host.
+	 */
+	private static final int LOCAL_HOST_SCORE = 5;
+
+	/**
+	 * default score assigned when the other service has the same host and port (same container).
+	 */
+	private static final int LOCAL_PORT_SCORE = 10;
+
+	/**
+	 * default score assigned when the other service has the same host and port (same container and context).
+	 */
+	private static final int LOCAL_SRV_SCORE = 15;
+	
+	
+	/**
+	 * score assigned when the other service has the same host.
+	 */
+	private int localHostScore = LOCAL_HOST_SCORE;
+	
+	/**
+	 * score assigned when the other service has the same host and port (same container).
+	 */
+	private int localPortScore = LOCAL_PORT_SCORE;
+	
+	/**
+	 * score assigned when the other service has the same host and port (same container and context).
+	 */
+	private int localSrvScore = LOCAL_SRV_SCORE; 
+
+	/**
+	 * build epr.
+	 */
+	@Resource
+	private StandaloneCxfEndpointReferenceBuilder eprBuilder;
+	
+	/** 
+	 * {@inheritDoc}
+	 * @throws MalformedURLException 
+	 * @see eu.dnetlib.enabling.tools.DynamicServiceLocatorLocationScorer#score(java.net.URL)
+	 */
+	@Override
+	public int score(final URL url) throws MalformedURLException {
+		final URL localBase = new URL(eprBuilder.getBaseAddress());
+		if (url.toString().startsWith(localBase.toString()))
+			return localSrvScore;
+
+		if (localBase.getHost().equals(url.getHost())) {
+			if (localBase.getPort() == url.getPort())
+				return localPortScore;
+			return localHostScore;
+		}
+		return 0;
+	}
+
+	public StandaloneCxfEndpointReferenceBuilder getEprBuilder() {
+		return eprBuilder;
+	}
+
+	public void setEprBuilder(final StandaloneCxfEndpointReferenceBuilder eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public int getLocalHostScore() {
+		return localHostScore;
+	}
+
+	public void setLocalHostScore(final int localHostScore) {
+		this.localHostScore = localHostScore;
+	}
+
+	public int getLocalPortScore() {
+		return localPortScore;
+	}
+
+	public void setLocalPortScore(final int localPortScore) {
+		this.localPortScore = localPortScore;
+	}
+
+	public int getLocalSrvScore() {
+		return localSrvScore;
+	}
+
+	public void setLocalSrvScore(final int localSrvScore) {
+		this.localSrvScore = localSrvScore;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceResolverChain.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceResolverChain.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceResolverChain.java	(revision 51874)
@@ -0,0 +1,61 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ * This resolver chains a list of resolvers.
+ * 
+ * @author marko
+ * 
+ */
+public class ServiceResolverChain implements ServiceResolver {
+
+	/**
+	 * service resolvers in decreasing order or priority.
+	 */
+	private List<ServiceResolver> resolvers = new ArrayList<ServiceResolver>();
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.ServiceResolver#getService(java.lang.Class,
+	 *      javax.xml.ws.wsaddressing.W3CEndpointReference)
+	 */
+	@Override
+	public <T> T getService(final Class<T> clazz, final W3CEndpointReference epr) {
+		for (ServiceResolver resolver : getResolvers()) {
+			final T service = resolver.getService(clazz, epr);
+
+			if (service != null)
+				return service;
+		}
+		return null;
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.ServiceResolver#getResourceIdentifier(javax.xml.ws.wsaddressing.W3CEndpointReference)
+	 */
+	@Override
+	public String getResourceIdentifier(final W3CEndpointReference epr) {
+		for (ServiceResolver resolver : getResolvers()) {
+			final String rsId = resolver.getResourceIdentifier(epr);
+
+			if (rsId != null)
+				return rsId;
+		}
+		return null;	
+	}
+	
+	public List<ServiceResolver> getResolvers() {
+		return resolvers;
+	}
+
+	public void setResolvers(final List<ServiceResolver> resolvers) {
+		this.resolvers = resolvers;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StreamOpaqueResource.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StreamOpaqueResource.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StreamOpaqueResource.java	(revision 51874)
@@ -0,0 +1,54 @@
+package eu.dnetlib.enabling.tools; // NOPMD
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.commons.io.IOUtils;
+import org.xml.sax.SAXException;
+
+/**
+ * implements a possibly optimized OpaqueResource constructed from a stream containing the xml source.
+ * 
+ * <p>the optimization consists of postponing the parsing as possibly and parse the profile passing the stream
+ * directly to the xml parser.<p>
+ * 
+ * <p>
+ * TODO: implement the optimization, currenly converts to string and reuses StringOpaqueResource
+ * </p>
+ * 
+ * @author marko
+ *
+ */
+public class StreamOpaqueResource extends StringOpaqueResource {
+
+	/**
+	 * construct with an input stream.
+	 * 
+	 * @param source source stream of xml text
+	 * @throws XPathExpressionException shouldn't happen
+	 * @throws SAXException could happen
+	 * @throws IOException could happen
+	 * @throws ParserConfigurationException shouldn't happen
+	 */
+	public StreamOpaqueResource(final InputStream source) throws XPathExpressionException, SAXException, IOException, ParserConfigurationException {
+		super(stringify(source));
+	}
+
+	/**
+	 * helper method: reads a stream to a string.
+	 * 
+	 * @param source input stream
+	 * @return string containing the whole stream content.
+	 * @throws IOException could happen.
+	 */
+	private static String stringify(final InputStream source) throws IOException {
+		final StringWriter writer = new StringWriter();
+		IOUtils.copy(source, writer);
+		return writer.getBuffer().toString();
+	}
+	
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceEnumerator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceEnumerator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceEnumerator.java	(revision 51874)
@@ -0,0 +1,182 @@
+package eu.dnetlib.enabling.tools;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
+import eu.dnetlib.miscutils.collections.EnsureCollection;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+/**
+ * Enumerates all services of a given type.
+ *
+ * @author marko
+ *
+ * @param <T>
+ *            service class
+ */
+@Deprecated
+public class DynamicServiceEnumerator<T> implements ServiceEnumerator<T> {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(DynamicServiceEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * service class
+	 */
+	private Class<T> clazz;
+
+	/**
+	 * lookup locator.
+	 */
+	private ServiceLocator<ISLookUpService> lookUpLocator;
+
+	/**
+	 * service name resolver.
+	 */
+	@Resource
+	private ServiceNameResolver serviceNameResolver; // NOPMD
+
+	/**
+	 * build epr.
+	 */
+	@Resource
+	private StandaloneCxfEndpointReferenceBuilder eprBuilder;
+
+	/**
+	 * default constructor, useful for spring based instantiation.
+	 */
+	public DynamicServiceEnumerator() {
+		// default
+	}
+
+	/**
+	 * Build a dynamic service enumerator for a given class
+	 *
+	 * @param clazz
+	 *            class
+	 */
+	public DynamicServiceEnumerator(final Class<T> clazz) {
+		super();
+		this.clazz = clazz;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.ServiceEnumerator#getServices()
+	 */
+	@Override
+	public List<ServiceRunningInstance<T>> getServices() {
+		final String serviceName = serviceNameResolver.getName(clazz);
+		log.debug("searching for service: " + serviceName);
+
+		final String xquery = "for $x in collection('/db/DRIVER/ServiceResources')//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value/string() = '"
+				+ serviceName
+				+ "ResourceType'] return <service><id>{$x//RESOURCE_IDENTIFIER/@value/string()}</id><url>{$x//PROTOCOL[@name = 'SOAP']/@address/string()}</url><properties>{$x//SERVICE_PROPERTIES/PROPERTY}</properties></service>";
+		log.debug(xquery);
+
+		final XPathFactory factory = XPathFactory.newInstance();
+		final XPath xpath = factory.newXPath();
+
+		final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+
+		try {
+			final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+			final List<String> services = lookUpLocator.getService().quickSearchProfile(xquery);
+			final List<ServiceRunningInstance<T>> instances = new ArrayList<ServiceRunningInstance<T>>();
+
+			for (final String source : EnsureCollection.list(services)) {
+				final Document doc = docBuilder.parse(new InputSource(new StringReader(source)));
+				final String url = xpath.evaluate("//url", doc);
+				final String serviceId = xpath.evaluate("//id", doc);
+
+				final NodeList propElements = (NodeList) xpath.evaluate("//PROPERTY", doc, XPathConstants.NODESET);
+				Map<String, String> props = new HashMap<String, String>();
+
+				for (int i = 0; i < propElements.getLength(); i++) {
+					Element propElement = (Element) propElements.item(i);
+					props.put(propElement.getAttribute("key"), propElement.getAttribute("value"));
+				}
+
+				final W3CEndpointReference epr = eprBuilder.getEndpointReference(url, null, null, url + "?wsdl", null, null);
+
+				instances.add(new ServiceRunningInstance<T>(epr, serviceId, url, props));
+			}
+
+			return instances;
+		} catch (final ISLookUpException e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		} catch (final XPathExpressionException e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		} catch (final SAXException e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		} catch (final IOException e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		} catch (final ParserConfigurationException e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		}
+	}
+
+	public Class<T> getClazz() {
+		return clazz;
+	}
+
+	@Required
+	public void setClazz(final Class<T> clazz) {
+		this.clazz = clazz;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookUpLocator() {
+		return lookUpLocator;
+	}
+
+	public void setLookUpLocator(final ServiceLocator<ISLookUpService> lookUpLocator) {
+		this.lookUpLocator = lookUpLocator;
+	}
+
+	public ServiceNameResolver getServiceNameResolver() {
+		return serviceNameResolver;
+	}
+
+	public void setServiceNameResolver(final ServiceNameResolver serviceNameResolver) {
+		this.serviceNameResolver = serviceNameResolver;
+	}
+
+	public StandaloneCxfEndpointReferenceBuilder getEprBuilder() {
+		return eprBuilder;
+	}
+
+	public void setEprBuilder(StandaloneCxfEndpointReferenceBuilder eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureProfileEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureProfileEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureProfileEndpointReferenceBuilder.java	(revision 51874)
@@ -0,0 +1,76 @@
+package eu.dnetlib.enabling.soap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.soap.AbstractEndpointReferenceBuilder;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+import eu.dnetlib.soap.cxf.CxfEndpointReferenceBuilder;
+
+/**
+ * Build an epr from a data structure.
+ *
+ * @author marko
+ *
+ */
+public class DataStructureProfileEndpointReferenceBuilder extends AbstractEndpointReferenceBuilder<OpaqueResource> implements
+		EndpointReferenceBuilder<OpaqueResource> {
+
+	private static final Log log = LogFactory.getLog(DataStructureProfileEndpointReferenceBuilder.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/**
+	 * low level epr builder used to create the actual epr.
+	 *
+	 * TODO: factor out the address based epr building out of CXF specific code.
+	 *
+	 */
+	private transient CxfEndpointReferenceBuilder lowEprBuilder = new CxfEndpointReferenceBuilder();
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getAddress(java.lang.Object)
+	 */
+	@Override
+	public String getAddress(OpaqueResource profile) {
+		return profile.getResourceUri().replace("?wsdl", "");
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.AbstractEndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.util.Map)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(OpaqueResource profile, Map<QName, Object> attrs) {
+		return getEndpointReference(profile, profile.getResourceId(), attrs);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.AbstractEndpointReferenceBuilder#getEndpointReference(java.lang.Object)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(OpaqueResource profile) {
+		log.info("GETTING EPR short");
+
+		return getEndpointReference(profile, profile.getResourceId());
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.lang.String, java.util.Map)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(OpaqueResource profile, String referenceParam, Map<QName, Object> attrs) {
+		return lowEprBuilder.getEndpointReference(getAddress(profile), null, null, getAddress(profile) + "?wsdl", referenceParam,
+				new HashMap<QName, Object>());
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceRunningInstance.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceRunningInstance.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceRunningInstance.java	(revision 51874)
@@ -0,0 +1,95 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+/**
+ * This bean packages the minimum information for describing a service running instance.
+ *
+ * @author marko
+ *
+ */
+@Deprecated
+public class ServiceRunningInstance<T> {
+	/**
+	 * service endpoint.
+	 */
+	private W3CEndpointReference epr;
+
+	/**
+	 * service resource id.
+	 */
+	private String serviceId;
+
+	/**
+	 * service endpoint url.
+	 */
+	private String url;
+
+	/**
+	 * arbitrary service properties stored in the profile.
+	 */
+	private Map<String, String> serviceProperties;
+
+	/**
+	 * Create a service running instance.
+	 *
+	 * @param epr service epr
+	 * @param serviceId service profile resource id
+	 * @param url service endpoint url
+	 */
+	public ServiceRunningInstance(final W3CEndpointReference epr, final String serviceId, final String url) {
+		this(epr, serviceId, url, new HashMap<String, String>());
+	}
+
+	/**
+	 * Create a service running instance.
+	 *
+	 * @param epr service epr
+	 * @param serviceId service profile resource id
+	 * @param url service endpoint url
+	 * @param serviceProperties service property map
+	 */
+	public ServiceRunningInstance(final W3CEndpointReference epr, final String serviceId, final String url, final Map<String, String> serviceProperties) {
+		super();
+		this.epr = epr;
+		this.serviceId = serviceId;
+		this.url = url;
+		this.serviceProperties = serviceProperties;
+	}
+
+	public W3CEndpointReference getEpr() {
+		return epr;
+	}
+
+	public void setEpr(final W3CEndpointReference epr) {
+		this.epr = epr;
+	}
+
+	public String getServiceId() {
+		return serviceId;
+	}
+
+	public void setServiceId(final String serviceId) {
+		this.serviceId = serviceId;
+	}
+
+	public Map<String, String> getServiceProperties() {
+		return serviceProperties;
+	}
+
+	public void setServiceProperties(final Map<String, String> serviceProperties) {
+		this.serviceProperties = serviceProperties;
+	}
+
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/pom.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/pom.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/pom.xml	(revision 51874)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet45-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-service-common</artifactId>
+	<packaging>jar</packaging>
+	<version>2.1.7</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/cnr-service-common/tags/cnr-service-common-2.1.7</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>${mockito.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.antlr</groupId>
+			<artifactId>stringtemplate</artifactId>
+			<version>3.2</version>
+		</dependency>
+		<dependency>
+			<groupId>org.quartz-scheduler</groupId>
+			<artifactId>quartz</artifactId>
+			<version>${quartz.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-tx</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-spring-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-runtime</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocator.java	(revision 51874)
@@ -0,0 +1,205 @@
+package eu.dnetlib.enabling.tools;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+/**
+ * Locates a service through dynamic service discovery.
+ *
+ * @author marko
+ *
+ * @param <T>
+ */
+@Deprecated
+public class DynamicServiceLocator<T> extends AbstractServiceLocator<T> {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(DynamicServiceLocator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * service interface.
+	 */
+	private Class<T> clazz;
+
+	/**
+	 * lookup locator.
+	 */
+	private ServiceLocator<ISLookUpService> lookUpLocator;
+
+	/**
+	 * service name resolver.
+	 */
+	@Resource
+	private ServiceNameResolver serviceNameResolver; // NOPMD
+
+	/**
+	 * build epr.
+	 * TODO: obsolete, replace by full enumerator injection
+	 */
+	@Resource
+	private StandaloneCxfEndpointReferenceBuilder eprBuilder;
+
+	/**
+	 * service resolver. used to create proxies for discovered services.
+	 */
+	private ServiceResolver serviceResolver;
+
+	/**
+	 * delegate the score computation to this component. By default use a DefaultServiceLocatorLocationScorer.
+	 */
+	private DynamicServiceLocatorLocationScorer scorer;
+
+	/**
+	 * service enumerator.
+	 */
+	private ServiceEnumerator<T> enumerator;
+
+	/**
+	 * By default use a DefaultServiceLocatorLocationScorer if no scorer is defined.
+	 */
+	@PostConstruct
+	protected void init() {
+		if (scorer == null) {
+			final DefaultServiceLocatorLocationScorer tmp = new DefaultServiceLocatorLocationScorer();
+			tmp.setEprBuilder(eprBuilder);
+			scorer = tmp;
+		}
+
+		if (enumerator == null) {
+			final DynamicServiceEnumerator<T> tmp = new DynamicServiceEnumerator<T>(clazz);
+			tmp.setLookUpLocator(lookUpLocator);
+			tmp.setServiceNameResolver(serviceNameResolver);
+			tmp.setEprBuilder(eprBuilder);
+			enumerator = tmp;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.ServiceLocator#getService()
+	 */
+	@Override
+	public T getService() {
+		return serviceResolver.getService(clazz, findFirstCandidate().getEpr());
+	}
+
+	@Override
+	public String getServiceId() {
+		return findFirstCandidate().getServiceId();
+	}
+	
+	private ServiceRunningInstance<T> findFirstCandidate() {
+		final String serviceName = serviceNameResolver.getName(clazz);
+		log.debug("searching for service: " + serviceName);
+
+		// TODO: backward compat hack
+		if(enumerator == null) {
+			log.warn("Enumerator is null in " + this + ". Postconstruct not called by spring, please check. Now called manually to workaround this problem");
+			init();
+		}
+
+
+		final List<ServiceRunningInstance<T>> candidates = enumerator.getServices();
+		if (candidates == null || candidates.isEmpty())
+			throw new IllegalStateException("cannot locate service " + serviceName + ", no matching service profile found");
+
+		Collections.sort(candidates, new Comparator<ServiceRunningInstance<T>>() {
+			@Override
+			public int compare(final ServiceRunningInstance<T> o1, final ServiceRunningInstance<T> o2) {
+				try {
+					final Integer u1Score = computeScore(new URL(o1.getUrl()));
+					final Integer u2Score = computeScore(new URL(o2.getUrl()));
+					return -u1Score.compareTo(u2Score);
+				} catch (MalformedURLException e) {
+					log.warn("ignoring service with malformed url", e);
+					return 0;
+				}
+			}
+		});
+		log.debug(candidates);
+		
+		return candidates.get(0);
+	}
+
+	/**
+	 * compute the score for a given service url.
+	 *
+	 * @param url
+	 *            url to be scored
+	 * @return score
+	 * @throws MalformedURLException
+	 *             happens
+	 */
+	protected int computeScore(final URL url) throws MalformedURLException {
+		return scorer.score(url);
+	}
+
+	public Class<T> getClazz() {
+		return clazz;
+	}
+
+	@Required
+	public void setClazz(final Class<T> clazz) {
+		this.clazz = clazz;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookUpLocator() {
+		return lookUpLocator;
+	}
+
+	@Required
+	public void setLookUpLocator(final ServiceLocator<ISLookUpService> lookUpLocator) {
+		this.lookUpLocator = lookUpLocator;
+	}
+
+	public ServiceNameResolver getServiceNameResolver() {
+		return serviceNameResolver;
+	}
+
+	public void setServiceNameResolver(final ServiceNameResolver serviceNameResolver) { // NOPMD
+		this.serviceNameResolver = serviceNameResolver;
+	}
+
+	public StandaloneCxfEndpointReferenceBuilder getEprBuilder() {
+		return eprBuilder;
+	}
+
+	public void setEprBuilder(final StandaloneCxfEndpointReferenceBuilder eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	@Required
+	public ServiceResolver getServiceResolver() {
+		return serviceResolver;
+	}
+
+	public void setServiceResolver(final ServiceResolver serviceResolver) {
+		this.serviceResolver = serviceResolver;
+	}
+
+	public DynamicServiceLocatorLocationScorer getScorer() {
+		return scorer;
+	}
+
+	public void setScorer(final DynamicServiceLocatorLocationScorer scorer) {
+		this.scorer = scorer;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileTemplate.st
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileTemplate.st	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileTemplate.st	(revision 51874)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value=""/>
+		<RESOURCE_TYPE value="$resourceType$"/>
+		<RESOURCE_KIND value="PendingServiceResources"/>
+		<RESOURCE_URI value="$address$?wsdl"/>
+		<PARENT_ID value="$parentId$" type="HNM"/>
+		<DATE_OF_CREATION value=""/>
+		<PROTOCOLS>
+			<PROTOCOL name="SOAP" address="$address$"/>
+			$protocols.keys:{k|<PROTOCOL name="$k$" address="$protocols.(k)$" />}$
+		</PROTOCOLS>
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<TYPOLOGY/>
+			<MAX_SIZE_OF_DATASTRUCTURE>0</MAX_SIZE_OF_DATASTRUCTURE>
+			<AVAILABLE_DISKSPACE>0</AVAILABLE_DISKSPACE>
+			<MAX_NUMBER_OF_DATASTRUCTURE>0</MAX_NUMBER_OF_DATASTRUCTURE>
+			<SERVICE_PROPERTIES>
+				$properties.keys:{k|<PROPERTY key="$k$" value="$properties.(k)$" />}$
+			</SERVICE_PROPERTIES>
+		</CONFIGURATION>
+		<STATUS>
+			<HANDLED_DATASTRUCTURE>0</HANDLED_DATASTRUCTURE>
+			<USED_DISKSPACE>0</USED_DISKSPACE>
+      <LAST_UPDATE value="2000-01-01T00:00:00+00:00"/>
+		</STATUS>
+		<QOS>
+			<AVAILABILITY/>
+			<CAPACITY/>
+			<RESPONSE_TIME>0</RESPONSE_TIME>
+			<THROUGHPUT>0</THROUGHPUT>
+		</QOS>
+		<SECURITY_PARAMETERS/>
+		<BLACKBOARD>
+      <LAST_REQUEST/>
+      <LAST_RESPONSE/>
+    </BLACKBOARD>
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/soap/applicationContext-common-eprbuilders.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/soap/applicationContext-common-eprbuilders.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/soap/applicationContext-common-eprbuilders.xml	(revision 51874)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
+	xmlns:util="http://www.springframework.org/schema/util"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+		http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
+		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+
+	<bean id="dsProfileEprBuilder"
+		class="eu.dnetlib.enabling.soap.DataStructureProfileEndpointReferenceBuilder" />
+
+	<bean id="dsIdEprBuilder"
+		class="eu.dnetlib.enabling.soap.DataStructureLookupEndpointReferenceBuilder"
+		p:dsEprBuilder-ref="dsProfileEprBuilder" p:serviceLocator-ref="uniqueServiceLocator" />
+</beans>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DOMOpaqueResource.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DOMOpaqueResource.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DOMOpaqueResource.java	(revision 51874)
@@ -0,0 +1,264 @@
+package eu.dnetlib.enabling.tools;
+
+import java.io.StringWriter;
+import java.util.Date;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+/**
+ * OpaqueResource holding a plain old DOM document.
+ *
+ * @author marko
+ *
+ */
+public class DOMOpaqueResource implements OpaqueResource {
+	/**
+	 * xpath expression error message.
+	 */
+	private static final String XPATH_ERROR = "cannot compile xpath expression";
+
+	/**
+	 * value attribute.
+	 */
+	private static final String VALUE_ATTR = "value";
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(DOMOpaqueResource.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * resource identifier.
+	 */
+	private String resourceId;
+
+	/**
+	 * resource type.
+	 */
+	private String resourceType;
+
+	/**
+	 * resource kind.
+	 */
+	private String resourceKind;
+
+	/**
+	 * resource uri.
+	 */
+	private String resourceUri;
+
+	/**
+	 * modification time stamp.
+	 */
+	private Date modificationDate;
+
+	/**
+	 * original document DOM.
+	 */
+	private Document dom;
+
+	/**
+	 * xslt transformer instance.
+	 */
+	private Transformer transformer;
+
+	/**
+	 * construct a DOMOpaqueInstance from a W3C DOM document.
+	 *
+	 * @param dom
+	 *            DOM document
+	 * @throws XPathExpressionException
+	 *             happens
+	 */
+	public DOMOpaqueResource(final Document dom) throws XPathExpressionException {
+		this.dom = dom;
+
+		try {
+			transformer = TransformerFactory.newInstance().newTransformer();
+		} catch (TransformerConfigurationException e) {
+			throw new IllegalStateException("transformer configuration", e);
+		} catch (TransformerFactoryConfigurationError e) {
+			throw new IllegalStateException("transformer configuration", e);
+		}
+
+		final XPath xpath = XPathFactory.newInstance().newXPath();
+
+		this.resourceId = xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_IDENTIFIER/@value", dom);
+		this.resourceType = xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_TYPE/@value", dom);
+		this.resourceKind = xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_KIND/@value", dom);
+		this.resourceUri = xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_URI/@value", dom);
+
+		String modificationDateSource = xpath.evaluate("/RESOURCE_PROFILE/HEADER/DATE_OF_CREATION/@value", dom);
+
+		try {
+			this.modificationDate = new DateUtils().parse(modificationDateSource);
+		} catch (IllegalStateException e) {
+			log.debug("invalid date '" + modificationDateSource + "'", e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#asDom()
+	 */
+	@Override
+	public Document asDom() {
+		return getDom();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#asString()
+	 */
+	@Override
+	public String asString() {
+		final StringWriter writer = new StringWriter();
+
+		try {
+			transformer.transform(new DOMSource(getDom()), new StreamResult(writer));
+		} catch (TransformerException e) {
+			log.fatal("cannot serialize document", e);
+			return null;
+		}
+		return writer.toString();
+	}
+
+	public Document getDom() {
+		return dom;
+	}
+
+	public void setDom(final Document dom) {
+		this.dom = dom;
+	}
+
+	@Override
+	public String getResourceId() {
+		return resourceId;
+	}
+
+	@Override
+	public String getResourceType() {
+		return resourceType;
+	}
+
+	public void setResourceType(final String resourceType) {
+		this.resourceType = resourceType;
+	}
+
+	@Override
+	public String getResourceKind() {
+		return resourceKind;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#setResourceKind(java.lang.String)
+	 */
+	@Override
+	public void setResourceKind(final String resourceKind) {
+		try {
+			final XPath xpath = XPathFactory.newInstance().newXPath();
+			final Element kindEl = (Element) xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_KIND", asDom(), XPathConstants.NODE);
+			kindEl.setAttribute(VALUE_ATTR, resourceKind);
+			this.resourceKind = resourceKind;
+		} catch (XPathExpressionException e) {
+			throw new IllegalStateException(XPATH_ERROR, e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#setResourceId(java.lang.String)
+	 */
+	@Override
+	public void setResourceId(final String identifier) {
+		try {
+			final XPath xpath = XPathFactory.newInstance().newXPath();
+			final Element idEl = (Element) xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_IDENTIFIER", asDom(), XPathConstants.NODE);
+			idEl.setAttribute(VALUE_ATTR, identifier);
+			resourceId = identifier;
+		} catch (XPathExpressionException e) {
+			throw new IllegalStateException(XPATH_ERROR, e);
+		}
+	}
+
+	@Override
+	public Date getModificationDate() {
+		return modificationDate;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#setModificationDate(java.util.Date)
+	 */
+	@Override
+	public void setModificationDate(final Date modificationDate) {
+		try {
+			final XPath xpath = XPathFactory.newInstance().newXPath();
+			final Element idEl = (Element) xpath.evaluate("/RESOURCE_PROFILE/HEADER/DATE_OF_CREATION", asDom(), XPathConstants.NODE);
+			if (idEl == null) {
+				log.warn("resource with type " + getResourceType() + " has no date of creation element");
+				return;
+			}
+			idEl.setAttribute(VALUE_ATTR, new DateUtils(modificationDate).getDateAsISO8601String());
+			this.modificationDate = modificationDate;
+		} catch (XPathExpressionException e) {
+			throw new IllegalStateException(XPATH_ERROR, e);
+		}
+
+	}
+
+	@Override
+	public String getResourceUri() {
+		return resourceUri;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.OpaqueResource#setResourceUri(java.lang.String)
+	 */
+	@Override
+	public void setResourceUri(final String resourceUri) {
+		try {
+			final XPath xpath = XPathFactory.newInstance().newXPath();
+			final Element uriEl = (Element) xpath.evaluate("/RESOURCE_PROFILE/HEADER/RESOURCE_URI", asDom(), XPathConstants.NODE);
+			uriEl.setAttribute(VALUE_ATTR, resourceUri);
+			this.resourceUri = resourceUri;
+		} catch (XPathExpressionException e) {
+			throw new IllegalStateException(XPATH_ERROR, e);
+		}
+	}
+
+	public Transformer getTransformer() {
+		return transformer;
+	}
+
+	public void setTransformer(final Transformer transformer) {
+		this.transformer = transformer;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StringOpaqueResource.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StringOpaqueResource.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/StringOpaqueResource.java	(revision 51874)
@@ -0,0 +1,48 @@
+package eu.dnetlib.enabling.tools; // NOPMD
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Opaque resource initialized from a string.
+ * 
+ * Currently it extends a DOMOpaqueResource, but in future it should postpone xml parsing as late as possible.
+ * 
+ * @author marko
+ *
+ */
+public class StringOpaqueResource extends DOMOpaqueResource {
+
+	/**
+	 * construct an opaque resource from a xml source string.
+	 * 
+	 * @param source xml source
+	 * @throws XPathExpressionException happens
+	 * @throws SAXException happens
+	 * @throws IOException happens
+	 * @throws ParserConfigurationException happens
+	 */
+	public StringOpaqueResource(final String source) throws XPathExpressionException, SAXException, IOException, ParserConfigurationException {
+		super(getBuilderFactory().newDocumentBuilder().parse(new InputSource(new StringReader(source))));
+		
+	}
+
+	/**
+	 * get a namespace aware document builder factory. 
+	 * 
+	 * @return document builder factory.
+	 */
+	private static DocumentBuilderFactory getBuilderFactory() {
+		final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		factory.setNamespaceAware(true);
+		return factory;
+	}
+	
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocator.java	(revision 51874)
@@ -0,0 +1,264 @@
+package eu.dnetlib.enabling.locators;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.*;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import eu.dnetlib.common.rmi.BaseService;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
+import eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl;
+import eu.dnetlib.miscutils.collections.EnsureCollection;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+public class DefaultUniqueServiceLocator implements UniqueServiceLocator, ApplicationContextAware {
+
+	private ApplicationContext appContext;
+
+	private Comparator<ServiceRunningInstance> defaultComparator; // = new
+	// PreferLocalRunningInstanceComparator();
+
+	/**
+	 * An instance of isLookupService (local or stub)
+	 */
+	@Autowired
+	private ISLookUpService isLookupService;
+
+	@Autowired
+	private ServiceNameResolver serviceNameResolver;
+
+	/**
+	 * XML Parser
+	 */
+	private SAXReader reader = new SAXReader();
+
+	/**
+	 * build epr.
+	 */
+	@Autowired
+	private StandaloneCxfEndpointReferenceBuilder eprBuilder;
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(DefaultUniqueServiceLocator.class);
+
+	@Override
+	public <T extends BaseService> T getService(final Class<T> clazz) {
+		return getService(clazz, true);
+	}
+
+	@Override
+	public <T extends BaseService> T getService(final Class<T> clazz, final Comparator<ServiceRunningInstance> comparator) {
+		final String serviceName = serviceNameResolver.getName(clazz);
+		return findRunningInstances(serviceName, comparator).get(0).obtainClient(clazz, eprBuilder);
+	}
+
+	@Override
+	public <T extends BaseService> T getService(final Class<T> clazz, final String profileId) {
+		final String profile = obtainServiceProfile(profileId);
+
+		try {
+			return obtainRunningInstance(profile, obtainLocalServices()).obtainClient(clazz, eprBuilder);
+		} catch (Exception e) {
+			log.error("cannot instantiate service from id: " + profileId, e);
+			throw new IllegalStateException("cannot instantiate service from id: " + profileId, e);
+		}
+	}
+
+	@Override
+	public <T extends BaseService> T getService(final Class<T> clazz, final boolean local) {
+		if (clazz.isInstance(isLookupService)) return clazz.cast(isLookupService);
+
+		if (local) {
+			try {
+				final Map<String, T> beans = appContext.getBeansOfType(clazz);
+				if ((beans != null) && !beans.isEmpty()) return beans.values().iterator().next();
+			} catch (Throwable e) {
+				log.warn("No beans found in context, class " + clazz);
+			}
+		}
+
+		return getService(clazz, defaultComparator);
+	}
+
+	@Override
+	public <T extends BaseService> String getServiceId(final Class<T> clazz) {
+		return getServiceId(clazz, defaultComparator);
+	}
+
+	@Override
+	public <T extends BaseService> String getServiceId(final Class<T> clazz, final Comparator<ServiceRunningInstance> comparator) {
+		return findRunningInstances(serviceNameResolver.getName(clazz), comparator).get(0).getServiceId();
+	}
+
+	@Override
+	public <T extends BaseService> String getServiceId(final Class<T> clazz, final String profileId) {
+		final String profile = obtainServiceProfile(profileId);
+		final ServiceRunningInstance instance = obtainRunningInstance(profile, obtainLocalServices());
+		return instance.getServiceId();
+	}
+
+	@Override
+	public <T extends BaseService> Set<T> getAllServices(final Class<T> clazz) {
+		final Set<T> res = Sets.newHashSet();
+		for (ServiceRunningInstance instance : findRunningInstances(serviceNameResolver.getName(clazz), null)) {
+			res.add(instance.obtainClient(clazz, eprBuilder));
+		}
+		return res;
+	}
+
+	@Override
+	public <T extends BaseService> Set<String> getAllServiceIds(final Class<T> clazz) {
+		final Set<String> res = Sets.newHashSet();
+		for (ServiceRunningInstance instance : findRunningInstances(serviceNameResolver.getName(clazz), null)) {
+			res.add(instance.getServiceId());
+		}
+		return res;
+	}
+
+	private synchronized <T extends BaseService> ServiceRunningInstance obtainRunningInstance(final String profile, final Map<String, BaseService> locals) {
+		try {
+			final Document doc = reader.read(new StringReader(profile));
+			final String url = doc.valueOf("//PROTOCOL[@name = 'SOAP']/@address");
+			final String id = doc.valueOf("//RESOURCE_IDENTIFIER/@value");
+			final Map<String, String> props = Maps.newHashMap();
+			final BaseService local = locals.containsKey(id) ? locals.get(id) : null;
+			final int usedDiskpace = NumberUtils.toInt(doc.valueOf("//USED_DISKSPACE"), 0);
+			final int handledDatastructures = NumberUtils.toInt(doc.valueOf("//HANDLED_DATASTRUCTURE"), 0);;
+
+			for (Object o : doc.selectNodes("//SERVICE_PROPERTIES/PROPERTY")) {
+				final Element p = (Element) o;
+				props.put(p.valueOf("@key"), p.valueOf("@value"));
+			}
+
+			return new ServiceRunningInstance(id, url, local, usedDiskpace, handledDatastructures, props);
+		} catch (DocumentException e) {
+			log.error("Error parsing profile: " + profile, e);
+			throw new RuntimeException("Error parsing profile: " + profile, e);
+		}
+	}
+
+	private List<ServiceRunningInstance> findRunningInstances(final String serviceName, final Comparator<ServiceRunningInstance> comparator) {
+		final List<ServiceRunningInstance> list = findRegisteredServices(serviceName);
+
+		if (list.isEmpty()) {
+			log.error("Service not found, name: " + serviceName);
+			throw new RuntimeException("Service not found, name: " + serviceName);
+		}
+
+		if (comparator != null) {
+			Collections.sort(list, comparator);
+		}
+
+		return list;
+	}
+
+	private List<ServiceRunningInstance> findRegisteredServices(final String serviceName) {
+		log.debug("searching for service: " + serviceName);
+
+		final String xquery = "for $x in collection('/db/DRIVER/ServiceResources/" + serviceName + "ResourceType') return $x";
+		log.debug(xquery);
+
+		try {
+			final List<String> services = isLookupService.quickSearchProfile(xquery);
+			final List<ServiceRunningInstance> instances = Lists.newArrayList();
+			final Map<String, BaseService> locals = obtainLocalServices();
+
+			for (final String source : EnsureCollection.list(services)) {
+				final ServiceRunningInstance instance = obtainRunningInstance(source, locals);
+				instances.add(instance);
+			}
+			return instances;
+		} catch (final Exception e) {
+			throw new IllegalStateException("cannot locate service " + serviceName, e);
+		}
+	}
+
+	private Map<String, BaseService> obtainLocalServices() {
+		final Map<String, BaseService> locals = Maps.newHashMap();
+
+		for (ValidatingServiceRegistrationManagerImpl r : appContext.getBeansOfType(ValidatingServiceRegistrationManagerImpl.class).values()) {
+			if (r.getService() instanceof BaseService) {
+				if (!StringUtils.isBlank(r.getProfileId())) {
+					final BaseService baseService = (BaseService) r.getService();
+					if (baseService != null) {
+						locals.put(r.getProfileId(), baseService);
+						log.debug(" -> Service: " + r.getService().getClass().getName() + " has id " + r.getServiceProfile().getResourceId());
+					}
+				}
+			}
+		}
+		return locals;
+	}
+
+	private String obtainServiceProfile(final String profileId) {
+		final StringWriter sw = new StringWriter();
+		sw.append("let $uri:=/RESOURCE_PROFILE/HEADER[./RESOURCE_IDENTIFIER/@value='");
+		sw.append(profileId);
+		sw.append("']/RESOURCE_URI/@value/string()");
+		sw.append("\n\n");
+		sw.append("for $x in collection('/db/DRIVER/ServiceResources')");
+		sw.append("\n");
+		sw.append("where $x/RESOURCE_PROFILE/HEADER/RESOURCE_URI/@value = $uri");
+		sw.append("\n");
+		sw.append("return $x");
+
+		final String xq = sw.toString();
+
+		try {
+			return isLookupService.getResourceProfileByQuery(xq);
+		} catch (ISLookUpException e) {
+			log.error("cannot locate service using query: " + xq, e);
+			throw new IllegalStateException("cannot locate service using query: " + xq, e);
+		}
+	}
+
+	@Override
+	public void setApplicationContext(final ApplicationContext appContext) throws BeansException {
+		this.appContext = appContext;
+	}
+
+	public Comparator<ServiceRunningInstance> getDefaultComparator() {
+		return defaultComparator;
+	}
+
+	@Required
+	public void setDefaultComparator(final Comparator<ServiceRunningInstance> defaultComparator) {
+		this.defaultComparator = defaultComparator;
+	}
+
+	public ISLookUpService getIsLookupService() {
+		return isLookupService;
+	}
+
+	public void setIsLookupService(final ISLookUpService isLookupService) {
+		this.isLookupService = isLookupService;
+	}
+
+	public ServiceNameResolver getServiceNameResolver() {
+		return serviceNameResolver;
+	}
+
+	public void setServiceNameResolver(final ServiceNameResolver serviceNameResolver) {
+		this.serviceNameResolver = serviceNameResolver;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureLookupEndpointReferenceBuilder.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureLookupEndpointReferenceBuilder.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/soap/DataStructureLookupEndpointReferenceBuilder.java	(revision 51874)
@@ -0,0 +1,88 @@
+package eu.dnetlib.enabling.soap;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.enabling.tools.StringOpaqueResource;
+import eu.dnetlib.soap.AbstractEndpointReferenceBuilder;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+/**
+ * Builds an epr given an ID to a datastructure.
+ * 
+ * @author marko
+ * 
+ */
+public class DataStructureLookupEndpointReferenceBuilder extends AbstractEndpointReferenceBuilder<String> implements EndpointReferenceBuilder<String> {
+
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * underlying ds epr builder.
+	 */
+	private DataStructureProfileEndpointReferenceBuilder dsEprBuilder;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getAddress(java.lang.Object)
+	 */
+	@Override
+	public String getAddress(final String pid) {
+		return dsEprBuilder.getAddress(getProfile(pid));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.soap.EndpointReferenceBuilder#getEndpointReference(java.lang.Object, java.lang.String, java.util.Map)
+	 */
+	@Override
+	public W3CEndpointReference getEndpointReference(final String pid, final String referenceParam, final Map<QName, Object> attrs) {
+		return dsEprBuilder.getEndpointReference(getProfile(pid), attrs);
+	}
+
+	/**
+	 * obtain the ds profile
+	 * 
+	 * @param pid
+	 *            datastructure profile
+	 * @return resource
+	 */
+	private OpaqueResource getProfile(final String pid) {
+		try {
+			return new StringOpaqueResource(serviceLocator.getService(ISLookUpService.class).getResourceProfile(pid));
+		} catch (Exception e) { // TODO: remove this hack (conversion to unchecked exception)
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public DataStructureProfileEndpointReferenceBuilder getDsEprBuilder() {
+		return dsEprBuilder;
+	}
+
+	@Required
+	public void setDsEprBuilder(final DataStructureProfileEndpointReferenceBuilder dsEprBuilder) {
+		this.dsEprBuilder = dsEprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/ServiceRunningInstance.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/ServiceRunningInstance.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/ServiceRunningInstance.java	(revision 51874)
@@ -0,0 +1,102 @@
+package eu.dnetlib.enabling.locators;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import eu.dnetlib.common.rmi.BaseService;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+/**
+ * This bean packages the minimum information for describing a service running instance.
+ */
+public class ServiceRunningInstance {
+
+	private String serviceId;
+	private String url;
+	private BaseService localService;
+	private int usedDiskSpace = 0;
+	private int handledDatastructures = 0;
+	private Map<String, String> serviceProperties = new HashMap<String, String>();
+
+	public ServiceRunningInstance() {}
+
+	public ServiceRunningInstance(final String serviceId, final String url) {
+		this.serviceId = serviceId;
+		this.url = url;
+	}
+
+	public ServiceRunningInstance(final String serviceId, final String url, final BaseService localService, final int usedDiskSpace,
+			final int handledDatastructures, final Map<String, String> serviceProperties) {
+		this.serviceId = serviceId;
+		this.url = url;
+		this.localService = localService;
+		this.usedDiskSpace = usedDiskSpace;
+		this.handledDatastructures = handledDatastructures;
+		this.serviceProperties = serviceProperties;
+	}
+
+	public boolean isLocal() {
+		return localService != null;
+	}
+
+	synchronized public <T extends BaseService> T obtainClient(final Class<T> clazz, final StandaloneCxfEndpointReferenceBuilder eprBuilder) {
+		if (isLocal() && clazz.isInstance(localService)) {
+			return clazz.cast(localService);
+		} else {
+			final W3CEndpointReference epr = eprBuilder.getEndpointReference(url, null, null, url + "?wsdl", null, null);
+			return epr.getPort(clazz, new WebServiceFeature[] {});
+		}
+	}
+
+	public String getServiceId() {
+		return serviceId;
+	}
+
+	public void setServiceId(final String serviceId) {
+		this.serviceId = serviceId;
+	}
+
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(final String url) {
+		this.url = url;
+	}
+
+	public BaseService getLocalService() {
+		return localService;
+	}
+
+	public void setLocalService(final BaseService localService) {
+		this.localService = localService;
+	}
+
+	public Map<String, String> getServiceProperties() {
+		return serviceProperties;
+	}
+
+	public void setServiceProperties(final Map<String, String> serviceProperties) {
+		this.serviceProperties = serviceProperties;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/StoppableDetails.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/StoppableDetails.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/StoppableDetails.java	(revision 51874)
@@ -0,0 +1,45 @@
+package eu.dnetlib.enabling.common;
+
+public class StoppableDetails {
+
+	public enum StopStatus {
+		RUNNING, STOPPED, STOPPING
+	}
+
+	private String name;
+	private String message;
+	private StopStatus status;
+	
+	public StoppableDetails() {}
+	
+	public StoppableDetails(String name, String message, StopStatus status) {
+		this.name = name;
+		this.message = message;
+		this.status = status;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public StopStatus getStatus() {
+		return status;
+	}
+
+	public void setStatus(StopStatus status) {
+		this.status = status;
+	}
+	
+}
\ No newline at end of file
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparatorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparatorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparatorTest.java	(revision 51874)
@@ -0,0 +1,44 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+
+@RunWith(MockitoJUnitRunner.class)
+public class HandledDatastructuresComparatorTest {
+
+	/**
+	 * Class Under test.
+	 */
+	private HandledDatastructuresComparator comparator;
+	
+	@Mock
+	private ServiceRunningInstance s1;
+	@Mock
+	private ServiceRunningInstance s2;
+	@Mock
+	private ServiceRunningInstance s3;
+	
+	@Before
+	public void setUp() throws Exception {
+		comparator = new HandledDatastructuresComparator();
+		when(s1.getHandledDatastructures()).thenReturn(0);
+		when(s2.getHandledDatastructures()).thenReturn(0);
+		when(s3.getHandledDatastructures()).thenReturn(10);
+	}
+
+	@Test
+	public void testCompare() {
+		assertEquals(0, comparator.compare(s1, s2));
+		assertEquals(-1, comparator.compare(s1, s3));
+		assertEquals(1, comparator.compare(s3, s1));
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparator.java	(revision 51874)
@@ -0,0 +1,20 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import java.util.Comparator;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+
+public class PreferLocalRunningInstanceComparator implements Comparator<ServiceRunningInstance> {
+
+	@Override
+	public int compare(final ServiceRunningInstance s1, final ServiceRunningInstance s2) {
+		if (s1.isLocal()) {
+			return -1;
+		} else if (s2.isLocal()) {
+			return 1;
+		} else {
+			return 0;
+		}
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/HandledDatastructuresComparator.java	(revision 51874)
@@ -0,0 +1,14 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import java.util.Comparator;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+
+public class HandledDatastructuresComparator implements Comparator<ServiceRunningInstance> {
+
+	@Override
+	public int compare(final ServiceRunningInstance s1, final ServiceRunningInstance s2) {
+		return Integer.compare(s1.getHandledDatastructures(), s2.getHandledDatastructures());
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.properties
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.properties	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.properties	(revision 51874)
@@ -0,0 +1 @@
+services.registration.disabled=false
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.properties
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.properties	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.properties	(revision 51874)
@@ -0,0 +1 @@
+default.service.comparator = preferLocalRunningInstanceComparator
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparator.java	(revision 51874)
@@ -0,0 +1,14 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import java.util.Comparator;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+
+public class DiskSpaceComparator implements Comparator<ServiceRunningInstance> {
+
+	@Override
+	public int compare(final ServiceRunningInstance s0, ServiceRunningInstance s1) {
+		return Integer.compare(s0.getUsedDiskSpace(), s1.getUsedDiskSpace());
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/UniqueServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/UniqueServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/locators/UniqueServiceLocator.java	(revision 51874)
@@ -0,0 +1,20 @@
+package eu.dnetlib.enabling.locators;
+
+import java.util.Comparator;
+import java.util.Set;
+
+import eu.dnetlib.common.rmi.BaseService;
+
+public interface UniqueServiceLocator {
+	<T extends BaseService> T getService(Class<T> clazz);
+	<T extends BaseService> T getService(Class<T> clazz, Comparator<ServiceRunningInstance> comparator);
+	<T extends BaseService> T getService(Class<T> clazz, String profileId);
+	<T extends BaseService> T getService(Class<T> clazz, boolean local);
+	
+	<T extends BaseService> String getServiceId(Class<T> clazz);
+	<T extends BaseService> String getServiceId(Class<T> clazz, Comparator<ServiceRunningInstance> comparator);
+	<T extends BaseService> String getServiceId(Class<T> clazz, String profileId);
+
+	<T extends BaseService> Set<T> getAllServices(Class<T> clazz);
+	<T extends BaseService> Set<String> getAllServiceIds(Class<T> clazz);
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparatorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparatorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/PreferLocalRunningInstanceComparatorTest.java	(revision 51874)
@@ -0,0 +1,44 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PreferLocalRunningInstanceComparatorTest {
+
+	/**
+	 * Class Under test.
+	 */
+	private PreferLocalRunningInstanceComparator comparator;
+	
+	@Mock
+	private ServiceRunningInstance s1;
+	@Mock
+	private ServiceRunningInstance s2;
+	@Mock
+	private ServiceRunningInstance s3;
+	
+	@Before
+	public void setUp() throws Exception {
+		comparator = new PreferLocalRunningInstanceComparator();
+		when(s1.isLocal()).thenReturn(true);
+		when(s2.isLocal()).thenReturn(false);
+		when(s3.isLocal()).thenReturn(false);
+	}
+
+	@Test
+	public void testCompare() {
+		assertEquals(-1, comparator.compare(s1, s3));
+		assertEquals(1, comparator.compare(s3, s1));
+		assertEquals(0, comparator.compare(s2, s3));
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/applicationContext-registration.xml	(revision 51874)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!--
+		Depends on: jaxwsEndpointReferenceBuilder (declared in
+		applicationContext-epr.xml), lookupLocator, registryLocator
+	-->
+
+	<!-- service registrator -->
+	<bean id="serviceRegistrator"
+		class="eu.dnetlib.enabling.tools.registration.ServiceRegistrator"
+		p:serviceLocator-ref="uniqueServiceLocator"	p:serviceNameResolver-ref="defaultServiceNameResolver"
+		p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" p:hnmLocator-ref="${services.registration.default.hnmlocator}" />
+
+	<bean id="blackboardServiceRegistrator"
+		class="eu.dnetlib.enabling.tools.registration.BlackboardServiceRegistrator"
+		p:serviceLocator-ref="uniqueServiceLocator"
+		p:serviceNameResolver-ref="defaultServiceNameResolver"
+		p:eprBuilder-ref="jaxwsEndpointReferenceBuilder"
+		p:hnmLocator-ref="${services.registration.default.hnmlocator}" />
+
+	<bean id="dynamicHNMLocator" class="eu.dnetlib.enabling.tools.DynamicHNMLocator"
+		p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="nullHNMLocator" class="eu.dnetlib.enabling.tools.NullHNMLocator" />
+
+	<bean id="defaultServiceNameResolver"
+		class="eu.dnetlib.enabling.tools.registration.InterfaceServiceNameResolverCompatibility">
+		<property name="mapping">
+			<map>
+				<entry key="ISStoreService" value="IS_StoreService" />
+				<entry key="ISRegistryService" value="IS_RegistryService" />
+				<entry key="ISLookUpService" value="IS_LookUpService" />
+				<entry key="ISSNService" value="IS_SNService" />
+				<entry key="MSROService" value="MS_ROService" />
+				<entry key="MSRMService" value="MS_RMService" />
+				<entry key="DlmService" value="DLMService" />
+				<entry key="MDStoreService" value="MDStoreService" />
+				<entry key="IndexService" value="IndexService" />
+<!--				<entry key="IHarvestingManagerService" value="HarvestingManagerService" />-->
+<!--				<entry key="ITransformationManagerService" value="TransformationManagerService" />-->
+			</map>
+		</property>
+	</bean>
+
+	<template:define name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl"
+		t:serviceRegistrator="serviceRegistrator">
+
+		<bean t:id="$name$" class="dummy" t:class="$serviceRegistrationManagerClass$"
+			p:service-ref="$service$" p:endpoint-ref="$endpoint$"
+			p:disabled="\${services.registration.disabled}" lazy-init="true"
+			p:serviceLocator-ref="uniqueServiceLocator" p:registrator-ref="$serviceRegistrator$" />
+
+		<bean t:id="$name$TriggerDetails"
+			class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
+			p:targetBeanName="$name$" p:targetMethod="tick" />
+
+		<bean t:id="$name$Trigger"
+			class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"
+			p:startDelay="\${services.registration.delay}" p:repeatInterval="2000"
+			p:jobDetail-ref="$name$TriggerDetails" />
+
+		<bean t:id="$name$Triggers"
+			class="eu.dnetlib.springutils.beans.factory.SingleListFactoryBean"
+			p:value-ref="$name$Trigger" />
+
+		<bean t:id="$name$jobSchedulerAccessor"
+			class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
+			p:scheduler-ref="$jobScheduler$" p:triggers-ref="$name$Triggers">
+		</bean>
+
+	</template:define>
+
+</beans>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest.java	(revision 51874)
@@ -0,0 +1,77 @@
+package eu.dnetlib.enabling.tools;
+
+import static org.junit.Assert.*; // NOPMD
+import static org.mockito.Mockito.*; // NOPMD
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
+
+/**
+ * Test dynamic service locator.
+ *
+ * @author marko
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class DynamicServiceLocatorTest {
+
+	/**
+	 * instance under test.
+	 */
+	@Autowired
+	private transient DynamicServiceLocator<ResultSetService> serviceLocator;
+
+	/**
+	 * list of mock service profiles saved in files.
+	 */
+
+	@javax.annotation.Resource(name = "serviceProfiles")
+	private transient List<String> serviceUris;
+
+	/**
+	 * service resolver mock.
+	 */
+	private transient ServiceResolver serviceResolver;
+
+	/**
+	 * setup.
+	 *
+	 * @throws ISLookUpException
+	 *             mock
+	 */
+	@Before
+	public void setUp() throws ISLookUpException {
+//		final ISLookUpService lookupService = mock(ISLookUpService.class);
+//		serviceLocator.setLookUpLocator(new StaticServiceLocator<ISLookUpService>(lookupService));
+
+		serviceResolver = mock(ServiceResolver.class);
+		serviceLocator.setServiceResolver(serviceResolver);
+
+		final ISLookUpService lookupService = serviceLocator.getLookUpLocator().getService();
+		when(lookupService.quickSearchProfile(anyString())).thenReturn(serviceUris);
+	}
+
+	/**
+	 * test get service.
+	 */
+	@Test
+	public void testGetService() {
+		assertNull("dummy", serviceLocator.getService());
+
+		verify(serviceResolver).getService(eq(ResultSetService.class), (W3CEndpointReference) anyObject());
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/deploy.info
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/deploy.info	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/deploy.info	(revision 51874)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/cnr-service-common/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "cnr-service-common"}
\ No newline at end of file
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/applicationContext-tools.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/applicationContext-tools.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/applicationContext-tools.xml	(revision 51874)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+
+	<bean id="splittedQueryExecutor" class="eu.dnetlib.enabling.tools.SplittedQueryExecutor"
+		p:serviceLocator-ref="uniqueServiceLocator" />
+		
+</beans>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibilityTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibilityTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibilityTest.java	(revision 51874)
@@ -0,0 +1,32 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
+
+public class InterfaceServiceNameResolverCompatibilityTest {
+
+	private transient InterfaceServiceNameResolverCompatibility resolver;
+
+	private interface IndexService {}
+
+	private interface ISomethingService {}
+
+	@Before
+	public void setUp() throws Exception {
+		resolver = new InterfaceServiceNameResolverCompatibility();
+	}
+
+	@Test
+	public void testGetNameClassOfQ() {
+		assertEquals("IndexService", resolver.getName(IndexService.class));
+		assertEquals("SomethingService", resolver.getName(ISomethingService.class));
+		assertEquals("ISRegistryService", resolver.getName(ISRegistryService.class));
+		assertEquals("ResultSetService", resolver.getName(ResultSetService.class));
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/BulkResourceImporter.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/BulkResourceImporter.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/BulkResourceImporter.java	(revision 51874)
@@ -0,0 +1,115 @@
+package eu.dnetlib.enabling.is.store;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.schema.OpaqueResourceValidator;
+import eu.dnetlib.enabling.is.registry.schema.ValidationException;
+import eu.dnetlib.enabling.is.store.rmi.ISStoreException;
+import eu.dnetlib.enabling.is.store.rmi.ISStoreService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.enabling.tools.XQueryUtils;
+
+/**
+ * This class implements a bulk resource import, i.e. importing stuff straight into the store, bypassing checks and policies imposed by the
+ * registry service.
+ * 
+ * TODO: move from registry based to store based.
+ * 
+ * @author marko
+ * 
+ */
+public class BulkResourceImporter {
+
+	/**
+	 * xquery utils, needed to map resources with the xmldb collection names.
+	 */
+	private XQueryUtils xqueryUtils;
+
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * resource validator.
+	 */
+	private OpaqueResourceValidator resourceValidator;
+
+	/**
+	 * set to false to skip validation.
+	 */
+	private boolean validating = true;
+
+	/**
+	 * bulk loading enabled.
+	 */
+	private boolean enabled = true;
+
+	/**
+	 * register a resource bypassing the checks.
+	 * 
+	 * @param resource
+	 *            a resource
+	 * @throws ISRegistryException
+	 *             could happen
+	 */
+	public void importResource(final OpaqueResource resource) throws ISRegistryException {
+		try {
+			if (validating) {
+				resourceValidator.validate(resource);
+			}
+			serviceLocator.getService(ISStoreService.class, true).insertXML(xqueryUtils.getFileName(resource), xqueryUtils.getCollectionAbsPath(resource),
+					resource.asString());
+		} catch (final ISStoreException e) {
+			throw new ISRegistryException(e);
+		} catch (final ValidationException e) {
+			throw new ISRegistryException(e);
+		}
+	}
+
+	public XQueryUtils getXqueryUtils() {
+		return xqueryUtils;
+	}
+
+	@Required
+	public void setXqueryUtils(final XQueryUtils xqueryUtils) {
+		this.xqueryUtils = xqueryUtils;
+	}
+
+	@Required
+	public void setResourceValidator(final OpaqueResourceValidator resourceValidator) {
+		this.resourceValidator = resourceValidator;
+	}
+
+	public OpaqueResourceValidator getResourceValidator() {
+		return resourceValidator;
+	}
+
+	public void setValidating(final boolean validating) {
+		this.validating = validating;
+	}
+
+	public boolean isValidating() {
+		return validating;
+	}
+
+	public boolean isEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(final boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/.springBeans
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/.springBeans	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/.springBeans	(revision 51874)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/AbstractContentInitializer.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/AbstractContentInitializer.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/store/AbstractContentInitializer.java	(revision 51874)
@@ -0,0 +1,135 @@
+package eu.dnetlib.enabling.is.store;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URL;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+import org.xml.sax.SAXException;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.StreamOpaqueResource;
+
+/**
+ * Abstract resource loading code.
+ * 
+ * @author marko, michele
+ * 
+ */
+public class AbstractContentInitializer {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(AbstractContentInitializer.class); // NOPMD by marko on 11/24/08 5:02 PM
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+	/**
+	 * helper class used to bypass the registry and import resources as-is from a backup dump.
+	 */
+	private BulkResourceImporter bulkImporter;
+
+	private int timeToSleep;
+
+	/**
+	 * register a schema from a local resource.
+	 * 
+	 * @param url
+	 *            url
+	 * @throws IOException
+	 *             happens
+	 * @throws ISRegistryException
+	 *             could happen
+	 */
+	protected void registerSchema(final URL url) throws IOException, ISRegistryException {
+		final String resourceType = FilenameUtils.getBaseName(url.getPath());
+		log.debug("registering schema: " + resourceType);
+
+		final StringWriter writer = new StringWriter();
+		IOUtils.copy(url.openStream(), writer);
+		ISRegistryService service = null;
+		while (service == null) {
+			try {
+				service = serviceLocator.getService(ISRegistryService.class, true);
+				service.addResourceType(resourceType, writer.getBuffer().toString());
+				log.info("The is registry service is ready ");
+			} catch (Exception e) {
+				log.fatal("The is registry service is not ready ", e);
+				try {
+					Thread.sleep(timeToSleep);
+				} catch (InterruptedException e1) {
+					log.error(e1);
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * register a profile from a local resource.
+	 * 
+	 * @param url
+	 *            url
+	 * @throws IOException
+	 *             could happen
+	 * @throws ISRegistryException
+	 *             could happen
+	 * @throws ParserConfigurationException
+	 *             could happen
+	 * @throws SAXException
+	 *             could happen
+	 * @throws XPathExpressionException
+	 *             could happen
+	 */
+	protected void registerProfile(final URL url) throws IOException, ISRegistryException, XPathExpressionException, SAXException, ParserConfigurationException {
+		log.debug("registering profile: " + url);
+
+		bulkImporter.importResource(new StreamOpaqueResource(url.openStream()));
+	}
+
+	@Required
+	public void setBulkImporter(final BulkResourceImporter bulkImporter) {
+		this.bulkImporter = bulkImporter;
+	}
+
+	public BulkResourceImporter getBulkImporter() {
+		return bulkImporter;
+	}
+
+	/**
+	 * @return the timeToSleep
+	 */
+	public int getTimeToSleep() {
+		return timeToSleep;
+	}
+
+	/**
+	 * @param timeToSleep
+	 *            the timeToSleep to set
+	 */
+	@Required
+	public void setTimeToSleep(final int timeToSleep) {
+		this.timeToSleep = timeToSleep;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocatorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocatorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/DefaultUniqueServiceLocatorTest.java	(revision 51874)
@@ -0,0 +1,154 @@
+package eu.dnetlib.enabling.locators;
+
+import java.util.Map;
+import java.util.Set;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.comparators.PreferLocalRunningInstanceComparator;
+import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
+import eu.dnetlib.enabling.tools.registration.ServiceRegistrationManager;
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.context.ApplicationContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DefaultUniqueServiceLocatorTest {
+
+	/**
+	 * Class under test.
+	 */
+	private DefaultUniqueServiceLocator locator;
+
+	@Mock
+	private ISLookUpService lookupService;
+	@Mock
+	private ResultSetService resultsetService;
+	@Mock
+	private ApplicationContext appContext;
+	@Mock
+	private ServiceNameResolver serviceNameResolver;
+	@Mock
+	private ServiceRegistrationManager resultSetRegistrator;
+	@Mock
+	private OpaqueResource opaqueResource;
+
+	private static final String SERVICE_NAME = "ResultsetService";
+
+	private static final String XQUERY = "for $x in collection('/db/DRIVER/ServiceResources/" + SERVICE_NAME + "ResourceType') return $x";
+
+	@Before
+	public void setUp() throws Exception {
+		locator = new DefaultUniqueServiceLocator();
+		locator.setApplicationContext(appContext);
+		locator.setDefaultComparator(new PreferLocalRunningInstanceComparator());
+		locator.setServiceNameResolver(serviceNameResolver);
+		locator.setIsLookupService(lookupService);
+
+		final Map<String, ServiceRegistrationManager> registratorBeans = Maps.newHashMap();
+		registratorBeans.put("resultSetRegistrator", resultSetRegistrator);
+		final Map<String, ResultSetService> serviceBeans = Maps.newHashMap();
+		serviceBeans.put("resultSetService", resultsetService);
+
+		final StringTemplate st1 = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("serviceProfile.xml.st")));
+		st1.setAttribute("name", SERVICE_NAME);
+		st1.setAttribute("id", "1111");
+		final StringTemplate st2 = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("serviceProfile.xml.st")));
+		st2.setAttribute("name", SERVICE_NAME);
+		st2.setAttribute("id", "2222");
+		final StringTemplate st3 = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream("serviceProfile.xml.st")));
+		st3.setAttribute("name", SERVICE_NAME);
+		st3.setAttribute("id", "3333");
+
+		when(serviceNameResolver.getName(ResultSetService.class)).thenReturn(SERVICE_NAME);
+		when(lookupService.quickSearchProfile(XQUERY)).thenReturn(Lists.newArrayList(st1.toString(), st2.toString(), st3.toString()));
+		when(lookupService.getResourceProfileByQuery(anyString())).thenReturn(st2.toString());
+		//when(appContext.getBeansOfType(ServiceRegistrationManager.class)).thenReturn(registratorBeans);
+		//when(appContext.getBeansOfType(ResultSetService.class)).thenReturn(serviceBeans);
+
+		//when(resultSetRegistrator.getServiceProfile()).thenReturn(opaqueResource);
+		//when(resultSetRegistrator.getService()).thenReturn(resultsetService);
+		//when(opaqueResource.getResourceId()).thenReturn("2222");
+
+	}
+
+	@Test
+	public void testGetServiceClassOfT_1() {
+		assertEquals(lookupService, locator.getService(ISLookUpService.class));
+	}
+
+	@Test
+	@Ignore
+	public void testGetServiceClassOfT_2() throws ISLookUpException {
+		assertEquals(resultsetService, locator.getService(ResultSetService.class, false));
+		verify(lookupService, times(1)).quickSearchProfile(XQUERY);
+	}
+
+	@Test
+	@Ignore
+	public void testGetServiceClassOfTComparatorOfServiceRunningInstance() throws ISLookUpException {
+		assertEquals(resultsetService, locator.getService(ResultSetService.class, new PreferLocalRunningInstanceComparator()));
+		verify(lookupService, times(1)).quickSearchProfile(XQUERY);
+	}
+
+	@Test
+	@Ignore
+	public void testGetServiceClassOfTString() {
+		assertEquals(resultsetService, locator.getService(ResultSetService.class, "rs-1234"));
+	}
+
+	@Test
+	@Ignore
+	public void testGetServiceClassOfTBoolean() throws ISLookUpException {
+		assertEquals(resultsetService, locator.getService(ResultSetService.class, true));
+		verify(lookupService, never()).quickSearchProfile(XQUERY);
+	}
+
+	@Test
+	public void testGetServiceIdClassOfT() {
+		assertEquals("1111", locator.getServiceId(ResultSetService.class));
+	}
+
+	@Test
+	public void testGetServiceIdClassOfTComparatorOfServiceRunningInstance() {
+		assertEquals("1111", locator.getServiceId(ResultSetService.class, new PreferLocalRunningInstanceComparator()));
+	}
+
+	@Test
+	public void testGetServiceIdClassOfTString() {
+		assertEquals("2222", locator.getServiceId(ResultSetService.class, "rs-1234"));
+	}
+
+	@Test
+	@Ignore
+	public void testGetAllServices() {
+		final Set<ResultSetService> list = locator.getAllServices(ResultSetService.class);
+		assertEquals(3, list.size());
+		assertTrue(list.contains(resultsetService));
+	}
+
+	@Test
+	public void testGetAllServiceIds() {
+		final Set<String> list = locator.getAllServiceIds(ResultSetService.class);
+		assertEquals(3, list.size());
+		assertTrue(list.contains("1111"));
+		assertTrue(list.contains("2222"));
+		assertTrue(list.contains("3333"));
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/ValidationException.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/ValidationException.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/ValidationException.java	(revision 51874)
@@ -0,0 +1,35 @@
+package eu.dnetlib.enabling.is.registry.schema;
+
+
+/**
+ * encapsulates a schema validation exception.
+ * 
+ * @author marko
+ *
+ */
+public class ValidationException extends Exception {
+
+	/**
+	 * version.
+	 */
+	private static final long serialVersionUID = -6886927707534508655L;
+
+	/**
+	 * construct a validation exception based upon an encapsulated cause.
+	 * @param cause cause
+	 */
+	public ValidationException(final Throwable cause) {
+		super(cause);
+	}
+
+	/**
+	 * construct a validation exception with a message.
+	 * 
+	 * @param message message
+	 */
+	public ValidationException(final String message) {
+		super(message);
+	}
+
+	
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/OpaqueResourceValidator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/OpaqueResourceValidator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/is/registry/schema/OpaqueResourceValidator.java	(revision 51874)
@@ -0,0 +1,19 @@
+package eu.dnetlib.enabling.is.registry.schema;
+
+import eu.dnetlib.enabling.tools.OpaqueResource;
+
+/**
+ * validates the conformity of a resource to a give resource type.
+ * 
+ * @author marko
+ * 
+ */
+public interface OpaqueResourceValidator {
+	/**
+	 * check if the given resource is valid according to it's schema.
+	 * 
+	 * @param resource opaque resource
+	 * @throws ValidationException thrown if the validation fails, along with a description of the cause.
+	 */
+	void validate(OpaqueResource resource) throws ValidationException;
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceEnumeratorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceEnumeratorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/tools/DynamicServiceEnumeratorTest.java	(revision 51874)
@@ -0,0 +1,112 @@
+package eu.dnetlib.enabling.tools;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.tools.registration.ServiceNameResolver;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+/**
+ * Test the dynamic service enumerator.
+ *
+ * @author marko
+ *
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class DynamicServiceEnumeratorTest {
+
+	/**
+	 * Dummy service interface.
+	 *
+	 * @author marko
+	 *
+	 */
+	interface TestService {
+	}
+
+	/**
+	 * instance under test.
+	 */
+	private transient DynamicServiceEnumerator<TestService> enumerator;
+
+	/**
+	 * lookup service locator mock
+	 */
+	@Mock
+	private transient ISLookUpService lookUpService;
+
+	/**
+	 * lookup mock locator.
+	 */
+	private transient ServiceLocator<ISLookUpService> lookUpLocator;
+
+	/**
+	 * service name resolver mock.
+	 */
+	@Mock
+	private transient ServiceNameResolver nameResolver;
+
+	/**
+	 * epr builder.
+	 */
+	StandaloneCxfEndpointReferenceBuilder eprBuilder;
+
+	/**
+	 * common preparation.
+	 */
+	@Before
+	public void setUp()  {
+		lookUpLocator = new StaticServiceLocator<ISLookUpService>(lookUpService);
+		eprBuilder = new StandaloneCxfEndpointReferenceBuilder();
+
+		enumerator = new DynamicServiceEnumerator<TestService>(TestService.class);
+		enumerator.setLookUpLocator(lookUpLocator);
+		enumerator.setServiceNameResolver(nameResolver);
+		enumerator.setEprBuilder(eprBuilder);
+
+		when(nameResolver.getName(TestService.class)).thenReturn("TestService");
+	}
+
+	/**
+	 * test get services.
+	 *
+	 * @throws ISLookUpException mock exception
+	 */
+	@Test
+	public void testGetServices() throws ISLookUpException {
+		List<String> services = new ArrayList<String>();
+		services.add("<service><id>123</id><url>http://test.com</url></service>");
+
+		when(lookUpService.quickSearchProfile(anyString())).thenReturn(services);
+
+		List<ServiceRunningInstance<TestService>> instances = enumerator.getServices();
+
+		assertEquals("query size", 1, instances.size());
+		assertEquals("service id", "123", instances.get(0).getServiceId());
+		assertEquals("service url", "http://test.com", instances.get(0).getUrl());
+		assertNotNull("service epr", instances.get(0).getEpr());
+	}
+
+	@Test
+	public void testEmptyGetServices() throws ISLookUpException {
+		List<String> services = new ArrayList<String>();
+		when(lookUpService.quickSearchProfile(anyString())).thenReturn(services);
+
+		List<ServiceRunningInstance<TestService>> instances = enumerator.getServices();
+		assertTrue("empty", instances.isEmpty());
+	}
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/locators/serviceProfile.xml.st
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/locators/serviceProfile.xml.st	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/locators/serviceProfile.xml.st	(revision 51874)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<RESOURCE_PROFILE>
+    <HEADER>
+        <RESOURCE_IDENTIFIER value="$id$"/>
+        <RESOURCE_TYPE value="$name$ResourceType"/>
+        <RESOURCE_KIND value="ServiceResources"/>
+        <RESOURCE_URI value="http://localhost:8280/is/services/$name$?wsdl"/>
+        <PARENT_ID value="" type="HNM"/>
+        <DATE_OF_CREATION value="2014-11-04T19:34:56+01:00"/>
+        <PROTOCOLS>
+            <PROTOCOL name="SOAP" address="http://localhost:8280/is/services/$name$"/>
+        </PROTOCOLS>
+    </HEADER>
+    <BODY>
+        <CONFIGURATION>
+            <TYPOLOGY/>
+            <MAX_SIZE_OF_DATASTRUCTURE>0</MAX_SIZE_OF_DATASTRUCTURE>
+            <AVAILABLE_DISKSPACE>0</AVAILABLE_DISKSPACE>
+            <MAX_NUMBER_OF_DATASTRUCTURE>0</MAX_NUMBER_OF_DATASTRUCTURE>
+            <SERVICE_PROPERTIES/>
+        </CONFIGURATION>
+        <STATUS>
+            <HANDLED_DATASTRUCTURE>0</HANDLED_DATASTRUCTURE>
+            <USED_DISKSPACE>0</USED_DISKSPACE>
+            <LAST_UPDATE value="2000-01-01T00:00:00+00:00"/>
+        </STATUS>
+        <QOS>
+            <AVAILABILITY/>
+            <CAPACITY/>
+            <RESPONSE_TIME>0</RESPONSE_TIME>
+            <THROUGHPUT>0</THROUGHPUT>
+        </QOS>
+        <SECURITY_PARAMETERS/>
+        <BLACKBOARD>
+            <LAST_REQUEST />
+            <LAST_RESPONSE />
+        </BLACKBOARD>
+    </BODY>
+</RESOURCE_PROFILE>
\ No newline at end of file
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrator.java	(revision 51874)
@@ -0,0 +1,331 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.HNMLocator;
+import eu.dnetlib.enabling.tools.NullHNMLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+/**
+ * This class takes care of registering a service.
+ * 
+ * TODO: merge the implementation
+ * 
+ * @author marko
+ * 
+ */
+public class ServiceRegistrator {
+
+	/**
+	 * second.
+	 */
+	private static final int SECOND = 0;
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(ServiceRegistrator.class); // NOPMD
+	// by
+	// marko
+	// on
+	// 11/24/08
+	// 5:02
+	// PM
+
+	/**
+	 * locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * epr builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	/**
+	 * component which finds an hnm profile.
+	 */
+	private HNMLocator hnmLocator = new NullHNMLocator();
+
+	/**
+	 * Key-value pairs with service specific parameters which will appear in service profile.
+	 */
+	private Map<String, String> serviceProperties = new HashMap<String, String>();
+
+	/**
+	 * Key-value pairs [name - endpoint] of extra protocols available in service profiles.
+	 */
+	private Map<String, String> extraProtocols = new HashMap<String, String>();
+
+	/**
+	 * this bean helps us resolve service names from service instances.
+	 */
+	private ServiceNameResolver serviceNameResolver = new InterfaceServiceNameResolver(); // NOPMD
+
+	/**
+	 * Register a service schema for a given service.
+	 * 
+	 * @param service
+	 *            service
+	 */
+	public void registerServiceSchema(final Object service) {
+		registerServiceSchema(serviceNameResolver.getName(service));
+	}
+
+	/**
+	 * Register a service schema for a particular service.
+	 * 
+	 * @param serviceName
+	 *            service name
+	 */
+	public void registerServiceSchema(final String serviceName) {
+		try {
+			final InputStream schemaStream = getClass().getResourceAsStream("ServiceProfileSchemaTemplate.st");
+			if (schemaStream == null) { throw new IllegalStateException("cannot find service profile schema template"); }
+
+			final StringWriter schemaBuffer = new StringWriter();
+			IOUtils.copy(schemaStream, schemaBuffer);
+			final StringTemplate schema = new StringTemplate(schemaBuffer.toString());
+
+			final String resourceType = serviceName + "ResourceType";
+			schema.setAttribute("resourceType", resourceType);
+
+			if (serviceLocator == null) {
+				log.error("************* SERVICE LOCATOR IS NULL:" + serviceName);
+				return;
+			}
+			final ISRegistryService registry = serviceLocator.getService(ISRegistryService.class, true);
+			if (registry == null) {
+				log.error("************* REGISTRY SERVICE IS NULL");
+				return;
+			}
+
+			registry.addResourceType(resourceType, schema.toString());
+		} catch (final ISRegistryException e) {
+			throw new IllegalStateException("cannot register service profile schema", e);
+		} catch (final IOException e) {
+			throw new IllegalStateException("cannot read service profile schema template", e);
+		}
+	}
+
+	/**
+	 * register a given service.
+	 * 
+	 * @param service
+	 *            infers the service name from the class or annotations
+	 * @param endpoint
+	 *            jaxws endpoint
+	 * @return service profile id
+	 */
+	public String registerService(final Object service, final Endpoint endpoint) {
+		return registerService(serviceNameResolver.getName(service), endpoint);
+	}
+
+	/**
+	 * register a service with a given service name. Return null if the service cannot be registered, for example because it's blocked if
+	 * the HNM is missing.
+	 * 
+	 * @param serviceName
+	 *            service name
+	 * @param endpoint
+	 *            jaxws endpoint
+	 * @return service profile id, or null if the service cannot be registered because blocked
+	 */
+	public String registerService(final String serviceName, final Endpoint endpoint) {
+		return registerService(serviceName, eprBuilder.getEndpointReference(endpoint));
+	}
+
+	/**
+	 * register a service with a given service name.
+	 * 
+	 * @param serviceName
+	 *            service name
+	 * @param epr
+	 *            w3c endpoint reference
+	 * @return service profile id
+	 */
+	public String registerService(final String serviceName, final W3CEndpointReference epr) {
+
+		ensureSchemaExists(serviceName);
+
+		final DOMResult result = new DOMResult();
+		epr.writeTo(result);
+
+		try {
+			final InputStream templateStream = getClass().getResourceAsStream("ServiceProfileTemplate.st");
+			if (templateStream == null) { throw new IllegalStateException("cannot find service profile template"); }
+
+			final StringWriter buffer = new StringWriter();
+			IOUtils.copy(templateStream, buffer);
+
+			final StringTemplate templ = new StringTemplate(buffer.toString());
+
+			final String resourceType = serviceName + "ResourceType";
+
+			final String address = result.getNode().getChildNodes().item(0).getChildNodes().item(0).getTextContent();
+			final String hnmId = hnmLocator.getHNMForUrl(address);
+
+			// skip registration if there is no HNM yet.
+			if (hnmId == null) {
+				log.warn(String.format("skipping %s service registration, can't find NHM service'", serviceName));
+				return null;
+			}
+
+			templ.setAttribute("resourceType", resourceType);
+			templ.setAttribute("serviceName", serviceName);
+			templ.setAttribute("address", address);
+			templ.setAttribute("protocols", getExtraProtocols());
+			templ.setAttribute("parentId", hnmId);
+			templ.setAttribute("properties", serviceProperties);
+
+			log.debug("template: " + templ.toString());
+
+			final String res = serviceLocator.getService(ISRegistryService.class, true).insertProfileForValidation(resourceType, templ.toString());
+			Thread.sleep(SECOND);
+			return res;
+		} catch (final IOException e) {
+			throw new IllegalStateException("cannot load service profile template", e);
+
+		} catch (final ISRegistryException e) {
+			throw new IllegalStateException("cannot register service profile", e);
+		} catch (final InterruptedException e) {
+			throw new IllegalStateException("cannot wait for register service profile", e);
+		}
+	}
+
+	/**
+	 * Check that the service schema for this service already exists, and create it if it doesn't.
+	 * 
+	 * @param serviceName
+	 *            service name
+	 */
+	protected void ensureSchemaExists(final String serviceName) {
+		try {
+			serviceLocator.getService(ISLookUpService.class).getResourceTypeSchema(serviceName);
+			//serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
+			//		"//*[local-name() = 'complexType' and @name = 'RESOURCE_TYPEType']//*[local-name() = 'enumeration' and @value = '" + serviceName
+			//				+ "ResourceType']");
+			log.warn("schema for " + serviceName + " appears to exist");
+		} catch (final ISLookUpDocumentNotFoundException e) {
+			log.warn("registering schema for " + serviceName);
+			registerServiceSchema(serviceName);
+		} catch (final ISLookUpException e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	/**
+	 * validate the registered profile.
+	 * 
+	 * TODO: XXX: huge hack. used right now to automatically register the blackboard. It won't work anymore once the services are validated
+	 * from the GUI
+	 * 
+	 * @param profId
+	 *            profile id
+	 * @param endpoint
+	 *            service endpoint (hook for possible IS_SN automated registrations)
+	 * @return new id.
+	 */
+	public String validateProfile(final String profId, final Endpoint endpoint) {
+		try {
+			Thread.sleep(SECOND);
+		} catch (final InterruptedException e) {
+			throw new IllegalStateException("interrupted", e);
+		}
+
+		try {
+			return serviceLocator.getService(ISRegistryService.class, true).validateProfile(profId);
+		} catch (final ISRegistryException e) {
+			throw new IllegalStateException("cannot validate service profile", e);
+		}
+	}
+
+	/**
+	 * validate the registered profile.
+	 * 
+	 * @param profId
+	 *            old profile identifier
+	 * @return new profile identifier
+	 */
+	public String validateProfile(final String profId) {
+		return validateProfile(profId, null);
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(final EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public HNMLocator getHnmLocator() {
+		return hnmLocator;
+	}
+
+	public void setHnmLocator(final HNMLocator hnmLocator) {
+		this.hnmLocator = hnmLocator;
+	}
+
+	public ServiceNameResolver getServiceNameGen() {
+		return serviceNameResolver;
+	}
+
+	public void setServiceNameGen(final ServiceNameResolver serviceNameGen) {
+		this.serviceNameResolver = serviceNameGen;
+	}
+
+	public ServiceNameResolver getServiceNameResolver() {
+		return serviceNameResolver;
+	}
+
+	public void setServiceNameResolver(final ServiceNameResolver serviceNameRes) {
+		this.serviceNameResolver = serviceNameRes;
+	}
+
+	public Map<String, String> getServiceProperties() {
+		return serviceProperties;
+	}
+
+	public void setServiceProperties(final Map<String, String> serviceProperties) {
+		this.serviceProperties = serviceProperties;
+	}
+
+	public Map<String, String> getExtraProtocols() {
+		return extraProtocols;
+	}
+
+	public void setExtraProtocols(final Map<String, String> extraProtocols) {
+		this.extraProtocols = extraProtocols;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/BlackboardServiceRegistrator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/BlackboardServiceRegistrator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/BlackboardServiceRegistrator.java	(revision 51874)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import javax.xml.ws.Endpoint;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.enabling.tools.StringOpaqueResource;
+
+/**
+ * This service registrator also subscribes the service to it's own blackboard.
+ * 
+ * XXX: this class is a hack. It only works with the ValidatingServiceRegistrationManager
+ * 
+ * @author marko
+ * 
+ */
+public class BlackboardServiceRegistrator extends ServiceRegistrator {
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceRegistrator#validateProfile(java.lang.String)
+	 */
+	@Override
+	public String validateProfile(final String profId, final Endpoint endpoint) {
+		final String profileId = super.validateProfile(profId, endpoint);
+
+		try {
+			final OpaqueResource serviceProfile = new StringOpaqueResource(getServiceLocator().getService(ISLookUpService.class).getResourceProfile(profileId));
+
+			getServiceLocator().getService(ISSNService.class, true).subscribe(getEprBuilder().getEndpointReference(endpoint),
+					"UPDATE/" + serviceProfile.getResourceType() + "/" + profileId + "/RESOURCE_PROFILE/BODY/BLACKBOARD/LAST_REQUEST", 0);
+		} catch (Exception e) {
+			throw new IllegalStateException("cannot validate service profile", e);
+		}
+		return profileId;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManagerImpl.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManagerImpl.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManagerImpl.java	(revision 51874)
@@ -0,0 +1,366 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.PENDING;
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.REGISTERED;
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.UNKNOWN;
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.UNREGISTERED;
+
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.ws.Endpoint;
+import javax.xml.xpath.XPathExpressionException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+import org.xml.sax.SAXException;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.OpaqueResource;
+import eu.dnetlib.enabling.tools.StringOpaqueResource;
+
+/**
+ * Simple service registration manager implementation.
+ * 
+ * <p>
+ * The simplest way to use of the service registration manager is to declare the following in your bean definition file:
+ * </p>
+ * 
+ * <pre>
+ * 	&lt;template:instance name=&quot;serviceRegistrationManager&quot;
+ *  t:name=&quot;myServiceRegistrationManager&quot; t:service=&quot;myService&quot; t:endpoint=&quot;myServiceEndpoint&quot;
+ *  t:jobScheduler=&quot;jobScheduler&quot;/&gt;
+ * </pre>
+ * 
+ * <p>
+ * The ServiceRegistrationManager requires periodic ticks from a quartz job scheduler (the 'jobScheduler' bean in the above example)
+ * </p>
+ * 
+ * <p>
+ * See the ValidatingServiceRegistrationManagerImpl class for a special implementation which performs automatic service profile validation.
+ * </p>
+ * 
+ * @see ValidatingServiceRegistrationManagerImpl
+ * @author marko
+ * 
+ */
+public class ServiceRegistrationManagerImpl implements ServiceRegistrationManager {
+
+	/**
+	 * error message: the profile is not found. This actually happens a lot, because of the way the old ISLookUpService API was concieved.
+	 */
+	private static final String PROFILE_NOT_FOUND = "profile not found";
+
+	/**
+	 * error message: some error during searches for service profile state.
+	 */
+	private static final String ERROR_CHECK = "error checking profile";
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(ServiceRegistrationManagerImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * registration manager states.
+	 * 
+	 * @author marko
+	 * 
+	 */
+	public enum State {
+		/**
+		 * service profile is either registered or registered and we have to check out if the profile already exists.
+		 */
+		UNKNOWN,
+		/**
+		 * service profile is not yet registered or the registration disappeared.
+		 */
+		UNREGISTERED, /**
+		 * the service profile is registered for validation. A validation operation is awaited.
+		 */
+		PENDING, /**
+		 * the service profile is fully registered.
+		 */
+		REGISTERED
+	}
+
+	/**
+	 * service profile identifier.
+	 */
+	private String profileId;
+
+	/**
+	 * service to be registered.
+	 */
+	private Object service;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * service registrator.
+	 */
+	private ServiceRegistrator registrator;
+
+	/**
+	 * service profile resource local cache.
+	 */
+	private OpaqueResource serviceProfile;
+
+	/**
+	 * if true the service profile schema will be always updated at boot.
+	 */
+	private boolean schemaUpdate = true;
+
+	/**
+	 * disable the service registration.
+	 */
+	private boolean disabled = false;
+
+	/**
+	 * registration state of the service profile.
+	 */
+	private State state = State.UNKNOWN;
+
+	/**
+	 * check if we have already a registered service profile for this service.
+	 */
+	void checkExisting() {
+		final String uri = registrator.getEprBuilder().getAddress(endpoint) + "?wsdl";
+		final String query = "for $x in //RESOURCE_PROFILE[.//RESOURCE_URI/@value='" + uri + "']"
+				+ " where contains($x//RESOURCE_TYPE/@value/string(), 'Service') return $x";
+
+		try {
+			final OpaqueResource resource = new StringOpaqueResource(serviceLocator.getService(ISLookUpService.class, true).getResourceProfileByQuery(query));
+
+			if ("PendingServiceResources".equals(resource.getResourceKind())) {
+				state = State.PENDING;
+			} else {
+				setProfileId(resource.getResourceId());
+				setServiceProfile(resource);
+				state = State.REGISTERED;
+			}
+		} catch (final ISLookUpDocumentNotFoundException e) {
+			log.debug("there is no service registered for uri: " + uri);
+			state = State.UNREGISTERED;
+		} catch (final ISLookUpException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final XPathExpressionException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final SAXException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final IOException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final ParserConfigurationException e) {
+			log.warn(ERROR_CHECK, e);
+		}
+	}
+
+	/**
+	 * check that a pending service profile has been validated.
+	 * 
+	 * if it has been validated change the state to REGISTERED.
+	 */
+	void checkPending() {
+		log.debug("checking pending status: " + getService());
+
+		final String uri = serviceProfile.getResourceUri();
+		final String query = "collection('')//RESOURCE_PROFILE[.//RESOURCE_URI/@value='" + uri + "']";
+		try {
+			final OpaqueResource resource = new StringOpaqueResource(serviceLocator.getService(ISLookUpService.class, true).getResourceProfileByQuery(query));
+
+			if (!"PendingServiceResources".equals(resource.getResourceKind())) {
+				setProfileId(resource.getResourceId());
+				setServiceProfile(resource);
+				state = State.REGISTERED;
+			}
+		} catch (final ISLookUpDocumentNotFoundException e) {
+			log.debug(PROFILE_NOT_FOUND, e);
+		} catch (final ISLookUpException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final XPathExpressionException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final SAXException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final IOException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final ParserConfigurationException e) {
+			log.warn(ERROR_CHECK, e);
+		}
+	}
+
+	/**
+	 * ensure the service is registered.
+	 */
+	public void registerService() {
+		log.debug("registering service profile: " + getService());
+
+		setProfileId(getRegistrator().registerService(getService(), getEndpoint()));
+
+		if (getProfileId() == null) {
+			log.debug("cannot register profile, no hnm");
+			return;
+		}
+
+		log.debug("Service profile registered: " + getProfileId());
+
+		retrieveServiceProfile();
+		state = State.PENDING;
+		if (getProfileId() == null) throw new IllegalStateException("cannot be true, I'm dreaming");
+	}
+
+	/**
+	 * register service schema.
+	 */
+	public void registerSchema() {
+		getRegistrator().registerServiceSchema(getService());
+	}
+
+	/**
+	 * maintain the cached service profile.
+	 */
+	private void retrieveServiceProfile() {
+		log.debug("Retrieving service profile: " + getProfileId());
+
+		try {
+			setServiceProfile(new StringOpaqueResource(serviceLocator.getService(ISLookUpService.class, true).getResourceProfile(getProfileId())));
+		} catch (final ISLookUpDocumentNotFoundException e) {
+			log.debug(PROFILE_NOT_FOUND, e);
+		} catch (final ISLookUpException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final XPathExpressionException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final SAXException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final IOException e) {
+			log.warn(ERROR_CHECK, e);
+		} catch (final ParserConfigurationException e) {
+			log.warn(ERROR_CHECK, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceRegistrationManager#getServiceProfile()
+	 */
+	@Override
+	public OpaqueResource getServiceProfile() {
+		retrieveServiceProfile();
+		return serviceProfile;
+	}
+
+	/**
+	 * called periodically to advance the state machine.
+	 */
+	public void tick() {
+		if (disabled) return;
+
+		synchronized (registrator) {
+			if (state != REGISTERED) {
+				log.debug("checking service profile registration: " + getService() + " (" + state + ")");
+			}
+
+			if (state == UNKNOWN) {
+				if (schemaUpdate) {
+					registerSchema();
+				}
+				checkExisting();
+			} else if (state == UNREGISTERED) {
+				registerService();
+			} else if (state == PENDING) {
+				checkPending();
+			}
+
+			if (state != REGISTERED) {
+				log.debug("tick finished");
+			}
+		}
+	}
+
+	public void setProfileId(final String profileId) {
+		this.profileId = profileId;
+	}
+
+	public String getProfileId() {
+		return profileId;
+	}
+
+	@Override
+	public Object getService() {
+		return service;
+	}
+
+	@Override
+	public void setService(final Object service) {
+		this.service = service;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Override
+	public void setEndpoint(final Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public ServiceRegistrator getRegistrator() {
+		return registrator;
+	}
+
+	@Required
+	public void setRegistrator(final ServiceRegistrator registrator) {
+		this.registrator = registrator;
+	}
+
+	public void setServiceProfile(final OpaqueResource serviceProfile) {
+		this.serviceProfile = serviceProfile;
+	}
+
+	public State getState() {
+		return state;
+	}
+
+	public void setState(final State state) {
+		this.state = state;
+	}
+
+	public boolean isSchemaUpdate() {
+		return schemaUpdate;
+	}
+
+	public void setSchemaUpdate(final boolean schemaUpdate) {
+		this.schemaUpdate = schemaUpdate;
+	}
+
+	public boolean isDisabled() {
+		return disabled;
+	}
+
+	@Override
+	public void setDisabled(final boolean disabled) {
+		this.disabled = disabled;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/StaticServiceNameResolver.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/StaticServiceNameResolver.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/StaticServiceNameResolver.java	(revision 51874)
@@ -0,0 +1,43 @@
+package eu.dnetlib.enabling.tools.registration;
+
+/**
+ * Useful if you want to register a service external to this framework.
+ *
+ * @author marko
+ *
+ */
+@Deprecated
+public class StaticServiceNameResolver implements ServiceNameResolver {
+
+	/**
+	 * service name.
+	 */
+	private String name;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Object)
+	 */
+	@Override
+	public String getName(final Object service) {
+		return name;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Class)
+	 */
+	@Override
+	public String getName(final Class<?> serviceInterface) {
+		return name;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(final String name) {
+		this.name = name;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/SimpleServiceNameResolver.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/SimpleServiceNameResolver.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/SimpleServiceNameResolver.java	(revision 51874)
@@ -0,0 +1,32 @@
+package eu.dnetlib.enabling.tools.registration;
+
+/**
+ * Dummy service name generator implementation. Simply returns the class name. This will never work in practice because
+ * people have freedom calling their implementations of the service interface as they want.
+ * 
+ * @author marko
+ * 
+ */
+@Deprecated
+public class SimpleServiceNameResolver implements ServiceNameResolver {
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Object)
+	 */
+	@Override
+	public String getName(final Object service) {
+		return getName(service.getClass());
+	}
+	
+	/** 
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Class)
+	 */
+	@Override
+	public String getName(final Class<?> iface) {
+		return iface.getSimpleName();
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManager.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManager.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceRegistrationManager.java	(revision 51874)
@@ -0,0 +1,55 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import javax.xml.ws.Endpoint;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.tools.OpaqueResource;
+
+/**
+ * A service registration manager manages the registration of the service profile for a given service.
+ * 
+ * @author marko
+ *
+ */
+public interface ServiceRegistrationManager {
+	/**
+	 * service to register.
+	 * 
+	 * @param service service instance
+	 */
+	@Required
+	void setService(Object service);
+	
+	/**
+	 * service endpoint.
+	 * 
+	 * @param endpoint service endpoint
+	 */
+	@Required
+	void setEndpoint(Endpoint endpoint);
+	
+	/**
+	 * set to true if we want to disable service registration.
+	 * 
+	 * @param disabled
+	 */
+	@Required
+	void setDisabled(boolean disabled);
+	
+	/**
+	 * returns the service profile associated with the service.
+	 * 
+	 * @return service profile
+	 */
+	OpaqueResource getServiceProfile();
+
+	/**
+	 * returns the registered service
+	 *
+	 * @return the service
+	 */
+	Object getService();
+
+	
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolver.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolver.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolver.java	(revision 51874)
@@ -0,0 +1,74 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import java.lang.annotation.Annotation;
+
+import javax.jws.WebService;
+
+/**
+ * This service name resolver tries to find the real service name through various heuristics based on the existence of the WebService
+ * annotation on some interface the service implements.
+ * 
+ * <p>
+ * NOTE: The search for the interface is depth first on interfaces and then on subclasses.
+ * </p>
+ * 
+ * @author marko
+ * 
+ */
+public class InterfaceServiceNameResolver implements ServiceNameResolver {
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Object)
+	 */
+	@Override
+	public String getName(final Object service) {
+
+		Class<?> res = findInterface(WebService.class, service.getClass());
+		if (res == null) {
+			res = service.getClass();
+		}
+
+		return getName(res);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceNameResolver#getName(java.lang.Class)
+	 */
+	@Override
+	public String getName(final Class<?> iface) {
+		return iface.getSimpleName();
+	}
+
+	/**
+	 * recursively searches a given annotation and returns the class/interface which contains it.
+	 * 
+	 * @param <T>
+	 *            annotation type
+	 * @param annotation
+	 *            annotation to search
+	 * @param clazz
+	 *            root of the class hierarchy.
+	 * @return class which contains annotation 'annotation'
+	 */
+	private <T extends Annotation> Class<?> findInterface(final Class<T> annotation, final Class<?> clazz) {
+		if (clazz == null) return null;
+
+		final T ann = clazz.getAnnotation(annotation);
+		if ((ann != null) && clazz.isInterface()) return clazz;
+
+		for (Class<?> iface : clazz.getInterfaces()) {
+			final Class<?> ires = findInterface(annotation, iface);
+			if (ires != null) return ires;
+		}
+
+		final Class<?> sres = findInterface(annotation, clazz.getSuperclass());
+		if (sres != null) return sres;
+
+		return null;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibility.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibility.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/InterfaceServiceNameResolverCompatibility.java	(revision 51874)
@@ -0,0 +1,45 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Allow manual (external) override of service types, through an appropriate mapping (e.g. injected with spring).
+ *
+ * @author marko
+ *
+ */
+public class InterfaceServiceNameResolverCompatibility extends InterfaceServiceNameResolver {
+
+	/**
+	 * Service names resolved with InterfaceServiceNameResolver will be used as keys in this map. If there is a match,
+	 * the mapping is used instead of the inferred name.
+	 */
+	private Map<String, String> mapping = new HashMap<String, String>();
+
+	public Map<String, String> getMapping() {
+		return mapping;
+	}
+
+	public void setMapping(final Map<String, String> mapping) {
+		this.mapping = mapping;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.tools.registration.InterfaceServiceNameResolver#getName(java.lang.Object)
+	 */
+	@Override
+	public String getName(final Class<?> iface) {
+		final String name = super.getName(iface);
+
+		final String override = getMapping().get(name);
+		if (override != null)
+			return override;
+
+		if(name.charAt(0) == 'I' && Character.isUpperCase(name.charAt(1)) && !Character.isUpperCase(name.charAt(2)))
+			return name.substring(1);
+
+		return name;
+	}
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ValidatingServiceRegistrationManagerImpl.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ValidatingServiceRegistrationManagerImpl.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ValidatingServiceRegistrationManagerImpl.java	(revision 51874)
@@ -0,0 +1,62 @@
+package eu.dnetlib.enabling.tools.registration;
+
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.PENDING;
+import static eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl.State.REGISTERED;
+
+/**
+ * This service registration manager implementation performs automatic service profile validation.
+ * <p>
+ * This is useful during automated testing. You can use it simply by overriding the default class in the service
+ * registration manager bean template:
+ * </p>
+ *
+ * <pre>
+ * 	&lt;template:instance name=&quot;serviceRegistrationManager&quot;
+ *  t:serviceRegistrationManagerClass=&quot;eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl&quot;
+ *  t:name=&quot;myServiceRegistrationManager&quot; t:service=&quot;myService&quot; t:endpoint=&quot;myServiceEndpoint&quot;
+ *  t:jobScheduler=&quot;jobScheduler&quot;/&gt;
+ * </pre>
+ *
+ * <p>
+ * If your service needs to receive blackboard messages, the notification can be automatically subscribed to your
+ * service profile simply by using a different service registrator component (blackboardServiceRegistrator):
+ * </p>
+ *
+ * <pre>
+ * 	&lt;template:instance name=&quot;serviceRegistrationManager&quot;
+ *  t:serviceRegistrationManagerClass=&quot;eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl&quot;
+ *  t:name=&quot;myServiceRegistrationManager&quot; t:service=&quot;myService&quot; t:endpoint=&quot;myServiceEndpoint&quot;
+ *  t:jobScheduler=&quot;jobScheduler&quot; t:serviceRegistrator=&quot;blackboardServiceRegistrator&quot;/&gt;
+ * </pre>
+ *
+ * <p>
+ * This option is very useful for example to the MDStoreService or the IndexService.
+ * </p>
+ *
+ * @author marko
+ *
+ */
+public class ValidatingServiceRegistrationManagerImpl extends ServiceRegistrationManagerImpl {
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl#tick()
+	 */
+	@Override
+	public void tick() {
+		synchronized (getRegistrator()) {
+			if (getState() == PENDING) {
+				if(getProfileId() == null) {
+					throw new IllegalStateException("State is PENDING but profile id isn't initialized");
+				}
+				final String newId = getRegistrator().validateProfile(getProfileId(), getEndpoint());
+				setProfileId(newId);
+				setState(REGISTERED);
+				return;
+			}
+		}
+
+		super.tick();
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceNameResolver.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceNameResolver.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/registration/ServiceNameResolver.java	(revision 51874)
@@ -0,0 +1,26 @@
+package eu.dnetlib.enabling.tools.registration;
+
+/**
+ * Infers the actual name of the service from a service instance.
+ * 
+ * @author marko
+ *
+ */
+public interface ServiceNameResolver {
+	/**
+	 * returns the service name for a given service.
+	 * 
+	 * @param service service instance
+	 * @return service name
+	 */
+	String getName(Object service);
+	
+	
+	/**
+	 * Get the service name for a given service interface.
+	 * 
+	 * @param serviceInterface service interface
+	 * @return service name.
+	 */
+	String getName(Class<?> serviceInterface);
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocator.java	(revision 51874)
@@ -0,0 +1,47 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * A service locator provides a reference to a, possibly remote, service.
+ * 
+ * @author marko
+ * 
+ * @param <T>
+ *            the type of the service to return
+ * @deprecated As of release 2.0.0, use instead {@link eu.dnetlib.enabling.locators.DefaultUniqueServiceLocator}
+ */
+@Deprecated
+public interface ServiceLocator<T> {
+
+	/**
+	 * locate and return a service of this type.
+	 * 
+	 * @return a service client instance
+	 */
+	T getService();
+
+	/**
+	 * Locate using a profileID (service or datastructure) the service of this type.
+	 * 
+	 * @param profileId
+	 * @param clazz
+	 * @return a service client instance
+	 */
+	T getService(final String profileId, final Class<T> clazz);
+
+	/**
+	 * locate and return a service ID.
+	 * 
+	 * @return a service ID
+	 */
+	String getServiceId();
+
+	/**
+	 * locate and return a service ID.
+	 * 
+	 * @param profileId
+	 *            (the id of the service or the id of one of its datastructures)
+	 * @return a service ID.
+	 */
+	String getServiceId(final String profileId);
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/NullHNMLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/NullHNMLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/NullHNMLocator.java	(revision 51874)
@@ -0,0 +1,21 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * simplest HNM locator: doesn't find any.
+ * 
+ * @author marko
+ * 
+ */
+public class NullHNMLocator implements HNMLocator {
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.HNMLocator#getHNMForUrl(java.lang.String)
+	 */
+	@Override
+	public String getHNMForUrl(final String url) {
+		return "";
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/HNMLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/HNMLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/HNMLocator.java	(revision 51874)
@@ -0,0 +1,19 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * finds an HNM profile for a giver service url.
+ * 
+ * @author marko
+ * 
+ */
+public interface HNMLocator {
+
+	/**
+	 * finds an HNM profile for a giver service url.
+	 * 
+	 * @param url
+	 *            service address
+	 * @return hnm id
+	 */
+	String getHNMForUrl(String url);
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicHNMLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicHNMLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicHNMLocator.java	(revision 51874)
@@ -0,0 +1,62 @@
+package eu.dnetlib.enabling.tools;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+
+/**
+ * Locates a registered HNM running on a given url.
+ *
+ * @author marko
+ *
+ */
+@Deprecated
+public class DynamicHNMLocator implements HNMLocator {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(DynamicHNMLocator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * service locator.
+	 */
+	UniqueServiceLocator serviceLocator;
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.enabling.tools.HNMLocator#getHNMForUrl(java.lang.String)
+	 */
+	@Override
+	public String getHNMForUrl(final String url) {
+
+		final String prefix = url.substring(0, url.indexOf('/', "http://".length()));
+		final String query = "collection('')//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'HostingNodeManagerServiceResourceType' and starts-with(.//RESOURCE_URI/@value, '"
+				+ prefix + "')]//RESOURCE_IDENTIFIER/@value/string()";
+
+		try {
+			return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query);
+		} catch (final ISLookUpDocumentNotFoundException e) {
+			log.debug("doument not found for query: " + query);
+			return null;
+		} catch (final ISLookUpException e) {
+			throw new IllegalStateException("cannot search hnm", e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorLocationScorer.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorLocationScorer.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/DynamicServiceLocatorLocationScorer.java	(revision 51874)
@@ -0,0 +1,21 @@
+package eu.dnetlib.enabling.tools;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Implementors of this interface provide custom methods to assign scores to services based solely on their location.
+ * @author marko
+ *
+ */
+@Deprecated
+public interface DynamicServiceLocatorLocationScorer {
+	/**
+	 * Compute the score assigned to a given service location (url).
+	 * 
+	 * @param url service url
+	 * @return score (the higher the better)
+	 * @throws MalformedURLException could happen
+	 */
+	int score(URL url) throws MalformedURLException;
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceEnumerator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceEnumerator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceEnumerator.java	(revision 51874)
@@ -0,0 +1,19 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.List;
+
+/**
+ * A service enumerator returns a bunch of service descriptions. The logic depends on the service enumerator.
+ *
+ * @author marko
+ *
+ */
+@Deprecated
+public interface ServiceEnumerator<T> {
+	/**
+	 * Obtain a list of services.
+	 *
+	 * @return a list of service running instance descriptions
+	 */
+	List<ServiceRunningInstance<T>> getServices();
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceLocator.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceLocator.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractServiceLocator.java	(revision 51874)
@@ -0,0 +1,119 @@
+package eu.dnetlib.enabling.tools;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import com.google.common.collect.Maps;
+
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.soap.cxf.StandaloneCxfEndpointReferenceBuilder;
+
+@Deprecated
+public abstract class AbstractServiceLocator<T> implements ServiceLocator<T> {
+
+	/**
+	 * lookup locator.
+	 */
+	@Resource(name="lookupLocator")
+	private ServiceLocator<ISLookUpService> lookUpLocator;	
+	
+	/**
+	 * build epr.
+	 */
+	@Resource
+	private StandaloneCxfEndpointReferenceBuilder eprBuilder;
+	
+	/**
+	 * service resolver. used to create proxies for discovered services.
+	 */
+	@Resource(name="serviceResolver")
+	private ServiceResolver serviceResolver;
+	
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(AbstractServiceLocator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	
+	@Override
+	public T getService(final String profileId, final Class<T> clazz) {
+		final String profile = executeQuery(profileId, null);
+		
+		try {
+			final XPathFactory factory = XPathFactory.newInstance();
+			final XPath xpath = factory.newXPath();
+	
+			final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+			final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+			
+			final Document doc = docBuilder.parse(new InputSource(new StringReader(profile)));
+			final String url = xpath.evaluate("//url", doc);
+			final String serviceId = xpath.evaluate("//id", doc);
+	
+			final NodeList propElements = (NodeList) xpath.evaluate("//PROPERTY", doc, XPathConstants.NODESET);
+			final Map<String, String> props = Maps.newHashMap();
+	
+			for (int i = 0; i < propElements.getLength(); i++) {
+				Element propElement = (Element) propElements.item(i);
+				props.put(propElement.getAttribute("key"), propElement.getAttribute("value"));
+			}
+	
+			final W3CEndpointReference epr = eprBuilder.getEndpointReference(url, null, null, url + "?wsdl", null, null);
+	
+			final ServiceRunningInstance<T> instance = new ServiceRunningInstance<T>(epr, serviceId, url, props);
+			
+			return serviceResolver.getService(clazz, instance.getEpr());
+		} catch(Exception e) {
+			log.error("cannot instantiate service from id: " + profileId, e);
+			throw new IllegalStateException("cannot instantiate service from id: " + profileId, e);
+		}
+	}
+
+	@Override
+	public String getServiceId(final String profileId) {
+		return executeQuery(profileId, "/RESOURCE_PROFILE/HEADER/RESOURCE_IDENTIFIER/@value/string()");
+	}
+		
+	private String executeQuery(final String profileId, final String xpath) {
+		final StringWriter sw = new StringWriter();
+		sw.append("let $uri:=/RESOURCE_PROFILE/HEADER[./RESOURCE_IDENTIFIER/@value='");
+		sw.append(profileId);
+		sw.append("']/RESOURCE_URI/@value/string()");
+		sw.append("\n\n");
+		sw.append("for $x in collection('/db/DRIVER/ServiceResources')/RESOURCE_PROFILE/HEADER");
+		sw.append("\n");		
+		sw.append("where $x/RESOURCE_PROFILE/HEADER/RESOURCE_URI/@value = $uri");
+		sw.append("\n");		
+		sw.append("return $x");
+		if (xpath != null) {
+			sw.append(xpath);
+		}
+		final String xq = sw.toString();
+		
+		try {
+			return lookUpLocator.getService().getResourceProfileByQuery(xq);
+		} catch (ISLookUpException e) {
+			log.error("cannot locate service using query: " + xq, e);
+			throw new IllegalStateException("cannot locate service using query: " + xq, e);
+		}
+	}
+	
+
+}
\ No newline at end of file
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocatorChain.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocatorChain.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/ServiceLocatorChain.java	(revision 51874)
@@ -0,0 +1,69 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.Collection;
+
+/**
+ * This class allows chaining several service locators and return the first one matching. Usually this is usefully when
+ * we want a StaticLocator as a fallback if the DynamicLocator cannot find anything.
+ * 
+ * @author marko
+ * 
+ * @param <T>
+ *            service type
+ */
+@Deprecated
+public class ServiceLocatorChain<T> extends AbstractServiceLocator<T> {
+
+	/**
+	 * service locators, iterated in order.
+	 */
+	private Collection<ServiceLocator<T>> locators;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.enabling.tools.ServiceLocator#getService()
+	 */
+	@Override
+	public T getService() {
+		IllegalStateException lastException = null; // NOPMD
+
+		for (ServiceLocator<T> locator : locators) {
+			try {
+				return locator.getService();
+			} catch (IllegalStateException e) {
+				lastException = e;
+			}
+		}
+		if (lastException != null) {
+			throw new IllegalStateException("cannot find any matching service. Last locator in the chain reported as cause", lastException);
+		}
+		throw new IllegalStateException("cannot find any matching service: the service locator chain is empty");
+	}
+
+	@Override
+	public String getServiceId() {
+		IllegalStateException lastException = null; // NOPMD
+
+		for (ServiceLocator<T> locator : locators) {
+			try {
+				return locator.getServiceId();
+			} catch (IllegalStateException e) {
+				lastException = e;
+			}
+		}
+		if (lastException != null) {
+			throw new IllegalStateException("cannot find any matching service. Last locator in the chain reported as cause", lastException);
+		}
+		throw new IllegalStateException("cannot find any matching service: the service locator chain is empty");
+	}
+
+	public Collection<ServiceLocator<T>> getLocators() {
+		return locators;
+	}
+	
+	public void setLocators(final Collection<ServiceLocator<T>> locators) {
+		this.locators = locators;
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractBaseService.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractBaseService.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/AbstractBaseService.java	(revision 51874)
@@ -0,0 +1,85 @@
+package eu.dnetlib.enabling.tools;
+
+import javax.jws.WebService;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.Lifecycle;
+
+import eu.dnetlib.common.rmi.BaseService;
+
+/**
+ * This class contains default definition for BaseService contract and basic service lifecycle.
+ * 
+ * TODO: split BaseService contract implementation from lifecycle and other helper method
+ * 
+ * @author marko
+ * 
+ */
+@WebService(targetNamespace = "http://services.dnetlib.eu/")
+public abstract class AbstractBaseService implements BaseService, Lifecycle {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory // NOPMD by marko on 11/24/08 5:02 PM
+			.getLog(AbstractBaseService.class);
+
+	private boolean started = false;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.common.rmi.BaseService#identify()
+	 */
+	@Override
+	public String identify() {
+		return getClass().getName();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.common.rmi.BaseService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		log.debug("got notification: " + topic + ", profile: " + isId + ", body: " + message);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see eu.dnetlib.common.rmi.BaseService#start()
+	 */
+	@Override
+	public void start() {
+		log.info("Starting service " + identify());
+		if (started) {
+			log.warn("Service " + this + "already started, check bean initializations!");
+		}
+		started = true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.springframework.context.Lifecycle#isRunning()
+	 */
+	@Override
+	public boolean isRunning() {
+		log.debug("called isRunning " + this);
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.springframework.context.Lifecycle#stop()
+	 */
+	@Override
+	public void stop() {
+		log.info("Stopping service " + this);
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/XQueryUtils.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/XQueryUtils.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/XQueryUtils.java	(revision 51874)
@@ -0,0 +1,39 @@
+package eu.dnetlib.enabling.tools;
+
+/**
+ * Implementations of this interface will provide functionalities useful to create xqueries or parts of thereof, like
+ * xmldb collection names for a given profile.
+ * 
+ * @author marko
+ * 
+ */
+public interface XQueryUtils {
+	/**
+	 * obtain the name of the xmldb collection for a given resource.
+	 * @param resource resource
+	 * @return path of the collection relative to the xmldb dnet root.
+	 */
+	String getCollectionPath(OpaqueResource resource);
+	
+	/**
+	 * obtain the absolute xmldb collection path for a given resource.
+	 * @param resource resource
+	 * @return collection absolute path
+	 */
+	String getCollectionAbsPath(OpaqueResource resource);
+	
+	/**
+	 * get the absolute xmldb collection path.
+	 * 
+	 * @return root xmldb root collection path
+	 */
+	String getRootCollection();
+
+	/**
+	 * Return the xmldb filename for a given resource.
+	 * 
+	 * @param resource resource
+	 * @return xmldb filename
+	 */
+	String getFileName(OpaqueResource resource);
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/OpaqueResource.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/OpaqueResource.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/tools/OpaqueResource.java	(revision 51874)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.tools;
+
+import java.util.Date;
+
+import org.w3c.dom.Document;
+
+/**
+ * Some services, in particular the enabling layer, needs to manipulate all types of resources without knowing the exact
+ * structure of their content, but only some well defined properties defined here.
+ * 
+ * <p>
+ * Different wrappers can be provided for different kind of resources. For example resources returned from the xmldb
+ * layer can be cheaply mapped to an OpaqueResource, without going to full xml->bean conversion.
+ * </p>
+ * 
+ * @author marko
+ * 
+ */
+public interface OpaqueResource {
+	/**
+	 * Resource type.
+	 * 
+	 * @return resource type string
+	 */
+	String getResourceType();
+
+	/**
+	 * Resource kind.
+	 * 
+	 * @return resource kind string
+	 */
+	String getResourceKind();
+
+	/**
+	 * Resource identifier.
+	 * 
+	 * @return resource identifier string
+	 */
+	String getResourceId();
+	
+	/**
+	 * Resource URI.
+	 * 
+	 * @return resource uri string
+	 */
+	String getResourceUri();
+	
+	/**
+	 * get modification time stamp.
+	 * 
+	 * @return time stamp
+	 */
+	Date getModificationDate();
+
+	/**
+	 * Implementors may need to serialize the resource to a xml string representation.
+	 * 
+	 * @return xml serialization
+	 */
+	String asString();
+
+	/**
+	 * Implementors may store the DOM in the first place. Otherwise they should
+	 * return a parsed w3c DOM instance.
+	 * 
+	 * @return DOM document
+	 */
+	Document asDom();
+
+	/**
+	 * change the resource identifier.
+	 * 
+	 * @param identifier new identifier
+	 */
+	void setResourceId(String identifier);
+
+	/**
+	 * change the resource kind.
+	 * 
+	 * @param kind new kind
+	 */
+	void setResourceKind(String kind);
+	
+	/**
+	 * change the resource uri.
+	 * 
+	 * @param uri new uri
+	 */
+	void setResourceUri(String uri);
+	
+	/**
+	 * set modification timestamp.
+	 * 
+	 * @param timeStamp modification time stamp
+	 */
+	void setModificationDate(Date timeStamp);
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/Stoppable.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/Stoppable.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/java/eu/dnetlib/enabling/common/Stoppable.java	(revision 51874)
@@ -0,0 +1,7 @@
+package eu.dnetlib.enabling.common;
+
+public interface Stoppable {
+	void stop();
+	void resume();
+	StoppableDetails getStopDetails();
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileSchemaTemplate.st
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileSchemaTemplate.st	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/tools/registration/ServiceProfileSchemaTemplate.st	(revision 51874)
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+	<xs:element name="USED_DISKSPACE" type="xs:int"/>
+	<xs:element name="TYPOLOGY" type="xs:string"/>
+	<xs:element name="MASTER" type="xs:boolean"/>
+	<xs:element name="THROUGHPUT" type="xs:double"/>
+	<xs:element name="STATUS">
+		<xs:complexType mixed="true">
+			<xs:all minOccurs="0">
+				<xs:element ref="MASTER" minOccurs="0"/>
+				<xs:element ref="HANDLED_DATASTRUCTURE"/>
+				<xs:element ref="USED_DISKSPACE"/>
+				<xs:element name="LAST_UPDATE" type="LAST_UPDATEType"/>
+			</xs:all>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="ACTION_STATUS">
+		<xs:simpleType>
+			<xs:restriction base="xs:string">
+				<xs:enumeration value="DONE"/>
+				<xs:enumeration value="ONGOING"/>
+				<xs:enumeration value="FAILED"/>
+				<xs:enumeration value="WAITING"/>
+				<xs:enumeration value="ASSIGNED"/>
+			</xs:restriction>
+		</xs:simpleType>
+	</xs:element>
+	<xs:element name="SECURITY_PARAMETERS" type="xs:string"/>
+	<xs:element name="RESPONSE_TIME" type="xs:int"/>
+	<xs:element name="RESOURCE_PROFILE">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="HEADER" type="HEADERType"/>
+				<xs:element name="BODY" type="BODYType"/>
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+  <xs:complexType name="RESOURCE_TYPEType">
+                <xs:attribute name="value" use="required">
+                        <xs:simpleType>
+                                <xs:restriction base="xs:string">
+                                        <xs:enumeration value="$resourceType$"/>
+                                </xs:restriction>
+                        </xs:simpleType>
+                </xs:attribute>
+  </xs:complexType>
+	<xs:complexType name="RESOURCE_URIType">
+		<xs:attribute name="value" type="xs:string" use="required"/>
+	</xs:complexType>
+	 <xs:complexType name="RESOURCE_KINDType">
+                <xs:attribute name="value" use="required">
+                        <xs:simpleType>
+                                <xs:restriction base="xs:string">
+                                        <xs:enumeration value="ServiceResources"/>
+                                        <xs:enumeration value="PendingServiceResources"/>
+                                </xs:restriction>
+                        </xs:simpleType>
+                </xs:attribute>
+  </xs:complexType>
+	<xs:complexType name="RESOURCE_IDENTIFIERType">
+		<xs:attribute name="value" type="xs:string" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="PARENT_IDType">
+		<xs:attribute name="value" type="xs:string" use="required"/>
+		<xs:attribute name="type" type="xs:string" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="DATE_OF_CREATIONType">
+		<xs:attribute name="value" type="xs:dateTime" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="LAST_UPDATEType">
+		<xs:attribute name="value" type="xs:dateTime" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="PROTOCOLType">
+		<xs:attribute name="name" type="xs:string" use="required"/>
+		<xs:attribute name="address" type="xs:string" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="PROTOCOLSType">
+		<xs:sequence>
+			<xs:element name="PROTOCOL" type="PROTOCOLType" maxOccurs="unbounded"/>
+		</xs:sequence>
+	</xs:complexType>
+	<xs:element name="QOS">
+		<xs:complexType>
+			<xs:all>
+				<xs:element ref="AVAILABILITY"/>
+				<xs:element ref="CAPACITY"/>
+				<xs:element ref="RESPONSE_TIME"/>
+				<xs:element ref="THROUGHPUT"/>
+			</xs:all>
+		</xs:complexType>
+	</xs:element>
+	<xs:complexType name="MESSAGEType">
+		<xs:sequence>
+			<xs:element ref="ACTION"/>
+			<xs:element name="PARAMETER" type="PARAMETERType" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element ref="ACTION_STATUS"/>
+		</xs:sequence>
+		<xs:attribute name="id" type="xs:string" use="required"/>
+		<xs:attribute name="date" type="xs:dateTime" use="required"/>
+	</xs:complexType>
+	<xs:complexType name="PARAMETERType">
+		<xs:attribute name="name" type="xs:string" use="required"/>
+		<xs:attribute name="value" type="xs:string" use="required"/>
+	</xs:complexType>
+
+
+	<xs:complexType name="SERVICEPROPERTIESType">
+		<xs:sequence>
+			<xs:element name="PROPERTY" type="PROPERTYType" minOccurs="0" maxOccurs="unbounded" />
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:complexType name="PROPERTYType">
+		<xs:attribute name="key"   type="xs:string" use="required" />
+		<xs:attribute name="value" type="xs:string" use="required" />
+	</xs:complexType>
+
+	<xs:element name="MAX_SIZE_OF_DATASTRUCTURE" type="xs:int"/>
+	<xs:element name="MAX_NUMBER_OF_DATASTRUCTURE" type="xs:int"/>
+	<xs:complexType name="HEADERType">
+		<xs:all>
+			<xs:element name="RESOURCE_IDENTIFIER" type="RESOURCE_IDENTIFIERType"/>
+			<xs:element name="RESOURCE_TYPE" type="RESOURCE_TYPEType"/>
+			<xs:element name="RESOURCE_KIND" type="RESOURCE_KINDType"/>
+			<xs:element name="RESOURCE_URI" type="RESOURCE_URIType"/>
+			<xs:element name="PARENT_ID" type="PARENT_IDType" minOccurs="0"/>
+			<xs:element name="DATE_OF_CREATION" type="DATE_OF_CREATIONType"/>
+			<xs:element name="PROTOCOLS" type="PROTOCOLSType"/>
+		</xs:all>
+	</xs:complexType>
+	<xs:element name="HANDLED_DATASTRUCTURE" type="xs:int"/>
+	<xs:element name="CONFIGURATION">
+		<xs:complexType>
+			<xs:all>
+				<xs:element ref="TYPOLOGY"/>
+				<xs:element ref="MAX_SIZE_OF_DATASTRUCTURE"/>
+				<xs:element ref="AVAILABLE_DISKSPACE"/>
+				<xs:element ref="MAX_NUMBER_OF_DATASTRUCTURE"/>
+				<xs:element name="SERVICE_PROPERTIES" type="SERVICEPROPERTIESType" minOccurs="0"/>
+			</xs:all>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="CAPACITY" type="xs:string"/>
+	<xs:complexType name="BLACKBOARD_LASTType">
+    <xs:simpleContent>
+      <xs:extension base="xs:string">
+        <xs:attribute name="date" type="xs:string"/>
+      </xs:extension>
+    </xs:simpleContent>
+	</xs:complexType>
+	<xs:complexType name="BLACKBOARDType">
+		<xs:sequence>
+			<xs:element name="LAST_REQUEST" type="BLACKBOARD_LASTType" minOccurs="1" maxOccurs="1"/>
+			<xs:element name="LAST_RESPONSE" type="BLACKBOARD_LASTType" minOccurs="1" maxOccurs="1"/>
+			<xs:element name="MESSAGE" type="MESSAGEType" minOccurs="0" maxOccurs="unbounded"/>
+		</xs:sequence>
+	</xs:complexType>
+	<xs:complexType name="BODYType">
+		<xs:all>
+			<xs:element ref="CONFIGURATION"/>
+			<xs:element ref="STATUS"/>
+			<xs:element ref="QOS"/>
+			<xs:element ref="SECURITY_PARAMETERS"/>
+			<xs:element ref="BLACKBOARD"/>
+		</xs:all>
+	</xs:complexType>
+	<xs:element name="BLACKBOARD" type="BLACKBOARDType"/>
+	<xs:element name="AVAILABLE_DISKSPACE" type="xs:int"/>
+	<xs:element name="AVAILABILITY" type="xs:string"/>
+	<xs:element name="ACTION" type="xs:string"/>
+</xs:schema>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/main/resources/eu/dnetlib/enabling/locators/applicationContext-locators.xml	(revision 51874)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
+	xmlns:util="http://www.springframework.org/schema/util"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+		http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
+		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+
+	<bean id="uniqueServiceLocator"
+		class="eu.dnetlib.enabling.locators.DefaultUniqueServiceLocator"
+		p:defaultComparator-ref="defaultServiceComparator" />
+
+	<bean id="preferLocalRunningInstanceComparator"
+		class="eu.dnetlib.enabling.locators.comparators.PreferLocalRunningInstanceComparator" />
+
+	<alias name="${default.service.comparator}" alias="defaultServiceComparator" />
+	
+
+</beans>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparatorTest.java
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparatorTest.java	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/java/eu/dnetlib/enabling/locators/comparators/DiskSpaceComparatorTest.java	(revision 51874)
@@ -0,0 +1,45 @@
+package eu.dnetlib.enabling.locators.comparators;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import static org.mockito.Mockito.*;
+
+import org.mockito.junit.MockitoJUnitRunner;
+
+import eu.dnetlib.enabling.locators.ServiceRunningInstance;
+
+@RunWith(MockitoJUnitRunner.class)
+public class DiskSpaceComparatorTest {
+
+	/**
+	 * Class Under test.
+	 */
+	private DiskSpaceComparator comparator;
+	
+	@Mock
+	private ServiceRunningInstance s1;
+	@Mock
+	private ServiceRunningInstance s2;
+	@Mock
+	private ServiceRunningInstance s3;
+	
+	@Before
+	public void setUp() throws Exception {
+		comparator = new DiskSpaceComparator();
+		when(s1.getUsedDiskSpace()).thenReturn(0);
+		when(s2.getUsedDiskSpace()).thenReturn(0);
+		when(s3.getUsedDiskSpace()).thenReturn(10);
+	}
+
+	@Test
+	public void testCompare() {
+		assertEquals(0, comparator.compare(s1, s2));
+		assertEquals(-1, comparator.compare(s1, s3));
+		assertEquals(1, comparator.compare(s3, s1));
+	}
+
+}
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest-context.xml
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest-context.xml	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7/src/test/resources/eu/dnetlib/enabling/tools/DynamicServiceLocatorTest-context.xml	(revision 51874)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xmlns:util="http://www.springframework.org/schema/util"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+	<bean id="propertyConfigurer"
+		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+		<property name="properties">
+			<props>
+				<prop key="transport.soap.baseAddress">http://localhost:8090/app/services/
+				</prop>
+				<prop key="infrastructure.name">junitTest</prop>
+				<prop key="transport.soap.force.local.address">true</prop>
+			</props>
+		</property>
+	</bean>
+
+	<import
+		resource="classpath:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml" />
+
+	<bean id="defaultServiceNameResolver"
+		class="eu.dnetlib.enabling.tools.registration.InterfaceServiceNameResolver" />
+
+	<bean id="serviceResolver" 
+		class="eu.dnetlib.test.utils.MockBeanFactory" 
+		p:clazz="eu.dnetlib.enabling.tools.ServiceResolver" />		
+
+	<bean id="lookupLocator" class="eu.dnetlib.enabling.tools.StaticServiceLocator">
+		<property name="service">
+			<bean class="eu.dnetlib.test.utils.MockBeanFactory" p:clazz="eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService" />
+		</property>
+	</bean>
+	
+	<bean id="dynamicLocator" class="eu.dnetlib.enabling.tools.DynamicServiceLocator"
+		p:clazz="eu.dnetlib.enabling.resultset.rmi.ResultSetService"
+		p:lookUpLocator-ref="lookupLocator" />
+
+	<util:list id="serviceProfiles">
+		<value><![CDATA[<service><id>1234</id><url>http://localhost:1234/app/services/resultSet</url></service>]]>
+		</value>
+		<value><![CDATA[<service><id>1234</id><url>http://localhost:8090/otherContext/services/resultSet</url></service>]]>
+		</value>
+		<value><![CDATA[<service><id>1234</id><url>http://localhost:8090/app/services/resultSet</url></service>]]>
+		</value>
+		<value><![CDATA[<service><id>1234</id><url>http://192.168.1.12:8090/app/services/resultSet</url></service>]]>
+		</value>
+	</util:list>
+</beans>
Index: modules/cnr-service-common/tags/cnr-service-common-2.1.7
===================================================================
--- modules/cnr-service-common/tags/cnr-service-common-2.1.7	(nonexistent)
+++ modules/cnr-service-common/tags/cnr-service-common-2.1.7	(revision 51874)

Property changes on: modules/cnr-service-common/tags/cnr-service-common-2.1.7
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.project
+.classpath
+.settings
+target
+*.iml
