Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/pom.xml
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/pom.xml	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/pom.xml	(revision 47720)
@@ -0,0 +1,67 @@
+<?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>dnet-runtime</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-runtime/tags/dnet-runtime-1.0.1</developerConnection>
+	</scm>
+	
+	<dependencies>
+		<!-- Do not remove these dependencies, even if they look like they are 
+			unused other modules expect them to be here -->
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-core</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-bindings-soap</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-transports-http</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxws</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>${commons.lang.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-web</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+		
+		<!-- For tomcat7 -->
+		<dependency>
+			<groupId>org.apache.tomcat</groupId>
+			<artifactId>tomcat-catalina</artifactId>
+			<version>7.0.47</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/deploy.info
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/deploy.info	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/deploy.info	(revision 47720)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-runtime/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": "dnet-runtime"}
\ No newline at end of file
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextPropertyLocationFactory.java
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextPropertyLocationFactory.java	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextPropertyLocationFactory.java	(revision 47720)
@@ -0,0 +1,66 @@
+package eu.dnetlib.conf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * This class wraps a list of property file paths and expands the @{webapp} placeholder with the name of the webapp taken from servlet-api
+ * 2.5.
+ * 
+ * @author marko
+ * 
+ */
+public class WebappContextPropertyLocationFactory extends AbstractWebappContextProperty implements FactoryBean<List<String>> {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(WebappContextPropertyLocationFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private List<String> locations;
+
+	@Override
+	public List<String> getObject() throws Exception {
+		List<String> expanded = new ArrayList<String>();
+
+		for (String loc : locations) {
+			expanded.add(expand(loc).trim());
+		}
+
+		if (log.isInfoEnabled()) {
+			for (String location : expanded) {
+				log.info("Searching property file: " + location);
+			}
+		}
+
+		return expanded;
+	}
+
+	private String expand(final String loc) {
+		if (getContext() == null) return loc;
+		return loc.replace("@{webapp}", getContext());
+	}
+
+	@Override
+	public Class<?> getObjectType() {
+		return locations.getClass();
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return true;
+	}
+
+	public List<String> getLocations() {
+		return locations;
+	}
+
+	public void setLocations(final List<String> locations) {
+		this.locations = locations;
+	}
+
+}
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextProperyFactory.java
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextProperyFactory.java	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/WebappContextProperyFactory.java	(revision 47720)
@@ -0,0 +1,146 @@
+package eu.dnetlib.conf;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardEngine;
+import org.apache.commons.lang.reflect.FieldUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.annotation.Required;
+
+/**
+ * This factory generates default properties based on the amount of information available from the servlet container.
+ * 
+ * @author marko
+ * 
+ */
+public class WebappContextProperyFactory extends AbstractWebappContextProperty implements FactoryBean<Properties> {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(WebappContextProperyFactory.class); // NOPMD by marko on
+																							// 11/24/08 5:02 PM
+
+	/**
+	 * If false, the ip address will be returned, otherwise a best effort attemp will be made to retrieve a meaningful host name. There is a
+	 * risk that the hostname is obtained without domain and thus completely useless.
+	 */
+	private boolean resolveHostname = false;
+
+	private PropertyFetcher propertyFetcher;
+
+	@Override
+	public Properties getObject() throws Exception {
+		Properties props = new Properties();
+
+		if (getContext() == null) return props;
+
+		props.setProperty("container.context", getContext());
+
+		log.debug("trying to autodetect port and hostame");
+
+		// if the user didn't customize, then autodetect, otherwise honour the
+		// user!
+		if (propertyFetcher.isUnchangedPort()) {
+			log.debug("PORT IS NOT OVERRIDDEN, autodetecting");
+			int port = getPort(getServletContext());
+			if (port > 0) {
+				props.setProperty("container.port", Integer.toString(port));
+			}
+		} else {
+			log.debug("PORT IS OVERRIDDEN, NOT autodetecting");
+		}
+
+		if (propertyFetcher.isUnchangedHostname()) {
+			log.debug("HOST IS NOT OVERRIDDEN, autodetecting");
+			String hostname = getHost(getServletContext());
+			if (hostname != null) {
+				props.setProperty("container.hostname", hostname);
+			}
+		} else {
+			log.debug("HOST IS OVERRIDDEN, NOT autodetecting");
+		}
+
+		return props;
+	}
+
+	@Override
+	public Class<?> getObjectType() {
+		return Properties.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return true;
+	}
+
+	private int getPort(final ServletContext servletContext) {
+		try {
+			return getContainerPort(servletContext);
+		} catch (Throwable e) {
+			log.warn("cannot obtain port from container...strange: I thought it would work both on jetty and tomcat7...)", e);
+			return 0;
+		}
+	}
+
+	private int getContainerPort(final ServletContext servletContext) {
+		try {
+			Object o = FieldUtils.readField(servletContext, "context", true);
+			StandardContext sCtx = (StandardContext) FieldUtils.readField(o, "context", true);
+			Container container = sCtx;
+
+			Container c = container.getParent();
+			while ((c != null) && !(c instanceof StandardEngine)) {
+				c = c.getParent();
+			}
+
+			if (c != null) {
+				StandardEngine engine = (StandardEngine) c;
+				for (Connector connector : engine.getService().findConnectors()) {
+					if (connector.getPort() > 0) return connector.getPort();
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return 0;
+	}
+
+	private String getHost(final ServletContext servletContext) {
+		try {
+			if (resolveHostname) return InetAddress.getLocalHost().getCanonicalHostName();
+			else return InetAddress.getLocalHost().toString().split("/")[1];
+		} catch (UnknownHostException e) {
+			log.warn("cannot obtain hostname from JVM", e);
+		}
+
+		return null;
+	}
+
+	public boolean isResolveHostname() {
+		return resolveHostname;
+	}
+
+	public void setResolveHostname(final boolean resolveHostname) {
+		this.resolveHostname = resolveHostname;
+	}
+
+	public PropertyFetcher getPropertyFetcher() {
+		return propertyFetcher;
+	}
+
+	@Required
+	public void setPropertyFetcher(final PropertyFetcher propertyFetcher) {
+		this.propertyFetcher = propertyFetcher;
+	}
+
+}
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/PropertyFetcher.java
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/PropertyFetcher.java	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/PropertyFetcher.java	(revision 47720)
@@ -0,0 +1,87 @@
+package eu.dnetlib.conf;
+
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyResourceConfigurer;
+
+/**
+ * PropertyFletcher
+ * 
+ * @author marko
+ * 
+ */
+public class PropertyFetcher extends PropertyResourceConfigurer implements InitializingBean {
+
+	private static final Log log = LogFactory.getLog(PropertyFetcher.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	boolean unchangedHostname = false;
+	boolean unchangedPort = true;
+
+	private Properties props;
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		this.props = mergeProperties();
+
+		// Convert the merged properties, if necessary.
+		convertProperties(props);
+
+		log.debug("FOUND A container.hostname property " + props.getProperty("container.hostname"));
+
+		if ("localhost".equals(props.getProperty("container.hostname"))) {
+			unchangedHostname = true;
+		}
+		if (props.getProperty("container.port") != null) {
+			log.debug("FOUND A container.port property " + props.getProperty("container.port"));
+			unchangedPort = false;
+		}
+
+		if (log.isDebugEnabled()) {
+			log.debug("HOST unchanged? " + unchangedHostname);
+			log.debug("PORT unchanged? " + unchangedPort);
+			for (Entry<?, ?> e : props.entrySet()) {
+				log.debug("system property: " + e.getKey() + " --> " + e.getValue());
+			}
+		}
+	}
+
+	@Override
+	protected void processProperties(final ConfigurableListableBeanFactory arg0, final Properties props) throws BeansException {
+
+	}
+
+	public boolean isUnchangedHostname() {
+		return unchangedHostname;
+	}
+
+	public void setUnchangedHostname(final boolean unchangedHostname) {
+		this.unchangedHostname = unchangedHostname;
+	}
+
+	public boolean isUnchangedPort() {
+		return unchangedPort;
+	}
+
+	public void setUnchangedPort(final boolean unchangedPort) {
+		this.unchangedPort = unchangedPort;
+	}
+
+	public String getProperty(final String key) {
+		return props.getProperty(key);
+	}
+
+	public Properties getProps() {
+		return props;
+	}
+
+	public void setProps(final Properties props) {
+		this.props = props;
+	}
+
+}
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/AbstractWebappContextProperty.java
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/AbstractWebappContextProperty.java	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/java/eu/dnetlib/conf/AbstractWebappContextProperty.java	(revision 47720)
@@ -0,0 +1,60 @@
+package eu.dnetlib.conf;
+
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.context.ServletContextAware;
+
+/**
+ * This spring bean detects the webapp context path, from the ServletContext. It requires servlet-api 2.5 (tomcat6 and
+ * jetty 6.x).
+ *
+ * <p>
+ * Concrete subclasses will know what to do with this information
+ * </p>
+ *
+ * @author marko
+ *
+ */
+public abstract class AbstractWebappContextProperty implements ServletContextAware {
+
+	/**
+	 * logger.
+	 */
+	private static final Log log = LogFactory.getLog(AbstractWebappContextProperty.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * web application context.
+	 */
+	protected String context;
+
+	/**
+	 * saved servlet context.
+	 */
+	protected ServletContext servletContext;
+
+	@Override
+	public void setServletContext(final ServletContext servletContext) {
+		this.servletContext = servletContext;
+
+		try {
+			context = servletContext.getContextPath().substring(1);
+		} catch (final NoSuchMethodError e) {
+			log.warn("cannot detect servlet context path. servlet-api 2.5 is required, falling back to property based configuration", e);
+		}
+	}
+
+	public String getContext() {
+		return context;
+	}
+
+	public void setContext(final String context) {
+		this.context = context;
+	}
+
+	public ServletContext getServletContext() {
+		return servletContext;
+	}
+
+}
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/META-INF/jax-ws-catalog.xml
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/META-INF/jax-ws-catalog.xml	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/META-INF/jax-ws-catalog.xml	(revision 47720)
@@ -0,0 +1,3 @@
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
+    <rewriteSystem systemIdStartString="http://www.w3.org/2006/03/addressing" rewritePrefix="classpath:/schemas/wsdl"/>
+</catalog>
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/eu/dnetlib/applicationContext-defaultProperties.properties
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/eu/dnetlib/applicationContext-defaultProperties.properties	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1/src/main/resources/eu/dnetlib/applicationContext-defaultProperties.properties	(revision 47720)
@@ -0,0 +1 @@
+transport.soap.baseAddress = http://${container.hostname}:${container.port}/${container.context}/services
Index: modules/dnet-runtime/tags/dnet-runtime-1.0.1
===================================================================
--- modules/dnet-runtime/tags/dnet-runtime-1.0.1	(nonexistent)
+++ modules/dnet-runtime/tags/dnet-runtime-1.0.1	(revision 47720)

Property changes on: modules/dnet-runtime/tags/dnet-runtime-1.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,4 ##
+.classpath
+.project
+.settings
+target
