diff --git a/deegree-spring/pom.xml b/deegree-spring/pom.xml
new file mode 100644
index 0000000000..1e6c7e1031
--- /dev/null
+++ b/deegree-spring/pom.xml
@@ -0,0 +1,66 @@
+
+ 4.0.0
+
+ org.deegree
+ deegree
+ 3.4-pre3-SNAPSHOT
+
+ deegree-spring
+ deegree Spring framework integration module
+
+
+
+
+ org.jvnet.jaxb2.maven2
+ maven-jaxb2-plugin
+
+
+
+
+
+ ok
+ 3.2.3.RELEASE
+
+
+
+
+ junit
+ junit
+
+
+ org.mockito
+ mockito-core
+
+
+ org.springframework
+ spring-context
+ ${spring.version}
+
+
+ org.springframework
+ spring-jdbc
+ ${spring.version}
+
+
+ org.deegree
+ deegree-core-workspace
+ ${project.version}
+
+
+ org.deegree
+ deegree-core-commons
+ ${project.version}
+
+
+ org.deegree
+ deegree-core-db
+ ${project.version}
+
+
+ org.deegree
+ deegree-services-commons
+ ${project.version}
+
+
+
\ No newline at end of file
diff --git a/deegree-spring/src/main/java/org/deegree/spring/AbstractSpringResourceBuilder.java b/deegree-spring/src/main/java/org/deegree/spring/AbstractSpringResourceBuilder.java
new file mode 100644
index 0000000000..5ced590348
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/AbstractSpringResourceBuilder.java
@@ -0,0 +1,171 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import java.util.Map;
+
+import org.deegree.workspace.Resource;
+import org.deegree.workspace.ResourceBuilder;
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.Workspace;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.context.ApplicationContext;
+
+/**
+ * The AbstractSpringResourceBuilder can be extended in order to create a
+ * {@link org.deegree.workspace.ResourceBuilder} that fetches beans from
+ * the {@link org.springframework.context.ApplicationContext} contained in
+ * the specified {@link org.deegree.spring.ApplicationContextHolder}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public abstract class AbstractSpringResourceBuilder implements ResourceBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractSpringResourceBuilder.class );
+
+ private final Workspace workspace;
+
+ private final String applicationContextHolderId;
+
+ /**
+ * Creates an AbstractSpringResourceBuilder for a given workspace and application context holder.
+ *
+ * @param workspace A reference to the current workspace.
+ * @param applicationContextHolderId The resource identifier of the application context holder.
+ */
+ public AbstractSpringResourceBuilder( final Workspace workspace, final String applicationContextHolderId ) {
+ this.workspace = workspace;
+ this.applicationContextHolderId = applicationContextHolderId;
+ }
+
+ /**
+ * Get a bean for a given type.
+ *
+ * @param clazz The type of bean to fetch.
+ * @throws org.deegree.workspace.ResourceInitException if there is not
+ * exactly one single bean of given type.
+ * @return A bean.
+ */
+ protected B getBean( final Class clazz ) {
+ return getBean( clazz, null );
+ }
+
+ /**
+ * Get a bean for a given name and type.
+ *
+ * @param clazz The type of bean to fetch.
+ * @param beanName The name of the bean. Allowed to be null.
+ * @throws org.deegree.workspace.ResourceInitException if the requested
+ * bean does not exist.
+ * @return A bean.
+ */
+ protected B getBean( final Class clazz, final String beanName ) {
+ return getBean( clazz, beanName, null );
+ }
+
+ /**
+ * Get a bean for a given name and type.
+ *
+ * @param clazz The type of bean to fetch.
+ * @param beanName The name of the bean. Allowed to be null.
+ * @param conventionalBeanName The conventional Spring name of this type of bean.
+ * Allowed to be null. Only used in case beanName is null.
+ * @throws org.deegree.workspace.ResourceInitException if the requested
+ * bean does not exist.
+ * @return A bean.
+ */
+ protected B getBean( final Class clazz, final String beanName, final String conventionalBeanName ) {
+ final String className = clazz.getCanonicalName();
+
+ final ApplicationContextHolder applicationContextHolder = workspace.getResource( ApplicationContextHolderProvider.class,
+ applicationContextHolderId );
+ final ApplicationContext applicationContext = applicationContextHolder.getApplicationContext();
+
+ final B bean;
+ if ( beanName != null ) {
+ try {
+ bean = applicationContext.getBean( beanName, clazz );
+
+ LOG.info( "Bean with name '{}' fetched from ApplicationContext.", beanName );
+ } catch ( Exception e ) {
+ throw new ResourceInitException( "Couldn't fetch bean with type '" + className + "' and name '"
+ + beanName + "' from ApplicationContext.", e );
+ }
+ } else {
+ final Map beans = applicationContext.getBeansOfType( clazz );
+ switch ( beans.size() ) {
+ case 0:
+ throw new ResourceInitException( "No beans of type " + className
+ + " found in ApplicationContext." );
+ case 1:
+ bean = beans.values().iterator().next();
+
+ LOG.info( "Single {} bean fetched from ApplicationContext.", className );
+ break;
+ default:
+ if ( conventionalBeanName != null ) {
+ if ( beans.containsKey( conventionalBeanName ) ) {
+ bean = beans.get( conventionalBeanName );
+
+ LOG.info( "Multiple {} beans found in ApplicationContext, bean named '{}' selected by convention.",
+ className, conventionalBeanName );
+ } else {
+ throw new ResourceInitException( "Multiple beans of type " + className
+ + " are found in ApplicationContext, none of them bares the conventional name '"
+ + conventionalBeanName
+ + "'. Suggestion: add bean name to configuration." );
+ }
+ } else {
+ throw new ResourceInitException( "Multiple beans of type " + className
+ + " are found in ApplicationContext." );
+ }
+ }
+ }
+
+ return bean;
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolder.java b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolder.java
new file mode 100644
index 0000000000..bc92f9dc4f
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolder.java
@@ -0,0 +1,88 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import org.deegree.workspace.Resource;
+import org.deegree.workspace.ResourceMetadata;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * The ApplicationContextHolder is a deegree {@link org.deegree.workspace.Resource}
+ * that contains a Spring {@link org.springframework.context.ApplicationContext}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class ApplicationContextHolder implements Resource {
+
+ private final ResourceMetadata metadata;
+
+ private final ConfigurableApplicationContext applicationContext;
+
+ public ApplicationContextHolder( final ResourceMetadata metadata,
+ final ConfigurableApplicationContext applicationContext ) {
+ this.metadata = metadata;
+ this.applicationContext = applicationContext;
+ }
+
+ @Override
+ public ResourceMetadata getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public void init() {
+
+ }
+
+ @Override
+ public void destroy() {
+ applicationContext.close();
+ }
+
+ public ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderManager.java b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderManager.java
new file mode 100644
index 0000000000..b48d0e78dd
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderManager.java
@@ -0,0 +1,63 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import org.deegree.workspace.standard.DefaultResourceManager;
+import org.deegree.workspace.standard.DefaultResourceManagerMetadata;
+
+/**
+ * The ApplicationContextHolderManager manages the
+ * {@link org.deegree.spring.ApplicationContextHolder} resources within
+ * a deegree workspace.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class ApplicationContextHolderManager extends DefaultResourceManager {
+
+ public ApplicationContextHolderManager() {
+ super( new DefaultResourceManagerMetadata( ApplicationContextHolderProvider.class,
+ "spring application context holders",
+ "spring" ) );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderProvider.java b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderProvider.java
new file mode 100644
index 0000000000..0427a0a766
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/ApplicationContextHolderProvider.java
@@ -0,0 +1,57 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import org.deegree.workspace.standard.AbstractResourceProvider;
+
+/**
+ * An ApplicationContextHolderProvider is responsible for constructing
+ * an {@link ApplicationContextHolder} containing an
+ * {@link org.springframework.context.ApplicationContext}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public abstract class ApplicationContextHolderProvider extends AbstractResourceProvider {
+
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceBuilder.java b/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceBuilder.java
new file mode 100644
index 0000000000..feb959cc11
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceBuilder.java
@@ -0,0 +1,122 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import java.lang.reflect.Field;
+
+import org.deegree.spring.annotation.InjectMetadata;
+import org.deegree.spring.jaxb.SingleBeanRef;
+
+import org.deegree.workspace.Resource;
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.Workspace;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A GenericSpringResourceBuilder can be used to provide a single bean as deegree workspace resource.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class GenericSpringResourceBuilder extends AbstractSpringResourceBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger( GenericSpringResourceBuilder.class );
+
+ private final Class clazz;
+
+ private final String beanName;
+
+ private final GenericSpringResourceMetadata metadata;
+
+ /**
+ * Creates a GenericSpringResourceBuilder for a given workspace bean reference.
+ *
+ * @param workspace
+ * A reference to the current workspace.
+ * @param singleBeanRef
+ * A configuration snippet containing the reference to the bean.
+ * @param clazz
+ * The type of the bean.
+ * @param metadata
+ * The metadata to be associated with the bean.
+ */
+ public GenericSpringResourceBuilder( final Workspace workspace, final SingleBeanRef singleBeanRef,
+ final Class clazz, final GenericSpringResourceMetadata metadata ) {
+ super( workspace, singleBeanRef.getApplicationContextHolder() );
+
+ this.clazz = clazz;
+ this.beanName = singleBeanRef.getBeanName();
+ this.metadata = metadata;
+ }
+
+ private void wireMetadata( Class> clazz, Object o )
+ throws IllegalArgumentException, IllegalAccessException {
+
+ for ( Field f : clazz.getDeclaredFields() ) {
+ if ( f.getAnnotation( InjectMetadata.class ) != null ) {
+ f.setAccessible( true );
+ f.set( o, metadata );
+ }
+ }
+
+ if ( !clazz.equals( Object.class ) ) {
+ wireMetadata( clazz.getSuperclass(), o );
+ }
+ }
+
+ @Override
+ public T build() {
+ final T t = getBean( clazz, beanName );
+
+ try {
+ wireMetadata( t.getClass(), t );
+ } catch ( Exception e ) {
+ LOG.debug( "Couldn't inject metadata.", e );
+ throw new ResourceInitException( "Couldn't inject metadata.", e );
+ }
+
+ return t;
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceMetadata.java b/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceMetadata.java
new file mode 100644
index 0000000000..46f5a26a9b
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/GenericSpringResourceMetadata.java
@@ -0,0 +1,107 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import javax.xml.bind.JAXBElement;
+
+import org.deegree.commons.xml.jaxb.JAXBUtils;
+import org.deegree.spring.jaxb.SingleBeanRef;
+
+import org.deegree.workspace.Resource;
+import org.deegree.workspace.ResourceBuilder;
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.Workspace;
+import org.deegree.workspace.standard.AbstractResourceMetadata;
+import org.deegree.workspace.standard.AbstractResourceProvider;
+import org.deegree.workspace.standard.DefaultResourceIdentifier;
+
+/**
+ * A GenericSpringResourceMetadata is to be used as the
+ * {@link org.deegree.workspace.ResourceMetadata} for resources
+ * provided by {@link org.deegree.spring.GenericSpringResourceBuilder}.
+ * It registers the configured
+ * {@link org.deegree.spring.ApplicationContextHolder} as dependency.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class GenericSpringResourceMetadata extends AbstractResourceMetadata {
+
+ private final String configJaxbPackage;
+
+ private final Class clazz;
+
+ public GenericSpringResourceMetadata( final Workspace workspace, final ResourceLocation location,
+ final AbstractResourceProvider provider, final String configJaxbPackage,
+ final Class clazz ) {
+ super( workspace, location, provider );
+
+ this.configJaxbPackage = configJaxbPackage;
+ this.clazz = clazz;
+ }
+
+ @Override
+ public ResourceBuilder prepare() {
+ final SingleBeanRef config;
+
+ try {
+ final JAXBElement> element = (JAXBElement>) JAXBUtils.unmarshall( configJaxbPackage, provider.getSchema(),
+ location.getAsStream(), workspace );
+ if ( element.getDeclaredType().equals( SingleBeanRef.class ) ) {
+ config = (SingleBeanRef) element.getValue();
+
+ final String applicationContextHolder = config.getApplicationContextHolder();
+ dependencies.add( new DefaultResourceIdentifier(
+ ApplicationContextHolderProvider.class,
+ applicationContextHolder ) );
+ } else {
+ throw new ResourceInitException( "Wrong configuration object passed to GenericSpringResourceMetadata." );
+ }
+ } catch ( Exception e ) {
+ throw new ResourceInitException( "Couldn't construct GenericSpringResourceBuilder.", e );
+ }
+
+ return new GenericSpringResourceBuilder( workspace, config, clazz, this );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/annotation/InjectMetadata.java b/deegree-spring/src/main/java/org/deegree/spring/annotation/InjectMetadata.java
new file mode 100644
index 0000000000..0689adb165
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/annotation/InjectMetadata.java
@@ -0,0 +1,63 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * Identifies the field where {@link org.deegree.spring.GenericSpringResourceBuilder} should
+ * inject the reference to {@link org.deegree.spring.GenericSpringResourceMetadata}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+@Documented
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface InjectMetadata {
+
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderBuilder.java b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderBuilder.java
new file mode 100644
index 0000000000..cba27bb9d9
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderBuilder.java
@@ -0,0 +1,125 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.bootstrap;
+
+import org.deegree.spring.ApplicationContextHolder;
+import org.deegree.spring.bootstrap.jaxb.BootstrapApplicationContextHolderConfig;
+import org.deegree.workspace.ResourceBuilder;
+import org.deegree.workspace.ResourceInitException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.support.GenericXmlApplicationContext;
+
+/**
+ * The BootstrapApplicationContextHolderBuilder bootstraps a
+ * Spring {@link org.springframework.context.ApplicationContext} and
+ * wraps it in an {@link org.deegree.spring.ApplicationContextHolder}
+ *
+ * This builder is the deegree workspace equivalent of Spring classes like
+ * {@link org.springframework.web.servlet.FrameworkServlet},
+ * {@link org.springframework.web.context.ContextLoaderListener} or
+ * other Spring classes that construct a root
+ * {@link org.springframework.context.ApplicationContext}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class BootstrapApplicationContextHolderBuilder implements ResourceBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger( BootstrapApplicationContextHolderBuilder.class );
+
+ private final BootstrapApplicationContextHolderMetadata metadata;
+
+ private final BootstrapApplicationContextHolderConfig config;
+
+ private final ClassLoader classLoader;
+
+ public BootstrapApplicationContextHolderBuilder( ClassLoader classLoader,
+ BootstrapApplicationContextHolderMetadata metadata,
+ BootstrapApplicationContextHolderConfig config ) {
+ this.classLoader = classLoader;
+ this.metadata = metadata;
+ this.config = config;
+ }
+
+ @Override
+ public ApplicationContextHolder build() {
+ LOG.debug( "Building BootstrapApplicationContextHolder." );
+
+ try {
+ final String contextClass = config.getContextClass();
+
+ if ( contextClass != null ) {
+ LOG.debug( "Using ContextClass {}", contextClass );
+
+ final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+ context.setClassLoader( classLoader );
+ context.register( classLoader.loadClass( contextClass ) );
+ context.refresh();
+
+ return new ApplicationContextHolder( metadata, context );
+ } else {
+ final String contextConfigLocation = config.getContextConfigLocation();
+ if ( contextConfigLocation == null ) {
+ throw new ResourceInitException(
+ "Both ContextClass and ContextConfigLocation are missing from BootstrapApplicationContextHolderConfig" );
+ }
+
+ LOG.debug( "Using ContextConfigLocation {}", contextConfigLocation );
+ final GenericXmlApplicationContext context = new GenericXmlApplicationContext();
+ context.setClassLoader( classLoader );
+ context.load( contextConfigLocation );
+ context.refresh();
+
+ return new ApplicationContextHolder( metadata, context );
+ }
+ } catch ( Exception e ) {
+ LOG.debug( "Couldn't build BootstrapApplicationContextHolder", e );
+ throw new ResourceInitException( "Couldn't build BootstrapApplicationContextHolder", e );
+ }
+ }
+
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderMetadata.java b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderMetadata.java
new file mode 100644
index 0000000000..235aa0f6b7
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderMetadata.java
@@ -0,0 +1,95 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.bootstrap;
+
+import static org.deegree.spring.bootstrap.BootstrapApplicationContextHolderProvider.CONFIG_SCHEMA;
+
+import org.deegree.commons.xml.jaxb.JAXBUtils;
+import org.deegree.spring.ApplicationContextHolder;
+import org.deegree.spring.bootstrap.jaxb.BootstrapApplicationContextHolderConfig;
+import org.deegree.workspace.ResourceBuilder;
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.Workspace;
+import org.deegree.workspace.standard.AbstractResourceMetadata;
+import org.deegree.workspace.standard.AbstractResourceProvider;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BootstrapApplicationContextHolderMetadata is used as
+ * {@link org.deegree.workspace.ResourceMetadata} by
+ * {@link org.deegree.spring.bootstrap.BootstrapApplicationContextHolderProvider}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class BootstrapApplicationContextHolderMetadata extends AbstractResourceMetadata {
+
+ private static final Logger LOG = LoggerFactory.getLogger( BootstrapApplicationContextHolderMetadata.class );
+
+ private static final String CONFIG_JAXB_PACKAGE = "org.deegree.spring.bootstrap.jaxb";
+
+ public BootstrapApplicationContextHolderMetadata( Workspace workspace,
+ ResourceLocation location,
+ AbstractResourceProvider provider ) {
+ super( workspace, location, provider );
+ }
+
+ @Override
+ public ResourceBuilder prepare() {
+ BootstrapApplicationContextHolderConfig config;
+
+ try {
+ config = (BootstrapApplicationContextHolderConfig) JAXBUtils.unmarshall( CONFIG_JAXB_PACKAGE,
+ CONFIG_SCHEMA,
+ location.getAsStream(), workspace );
+ } catch ( Exception e ) {
+ LOG.trace( "Stack trace:", e );
+ throw new ResourceInitException( e.getLocalizedMessage(), e );
+ }
+
+ return new BootstrapApplicationContextHolderBuilder( workspace.getModuleClassLoader(), this, config );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderProvider.java b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderProvider.java
new file mode 100644
index 0000000000..6d62d546fc
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/bootstrap/BootstrapApplicationContextHolderProvider.java
@@ -0,0 +1,85 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.bootstrap;
+
+import java.net.URL;
+
+import org.deegree.spring.ApplicationContextHolder;
+import org.deegree.spring.ApplicationContextHolderProvider;
+
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.ResourceMetadata;
+import org.deegree.workspace.Workspace;
+
+/**
+ * BootstrapApplicationContextHolderProvider provides a
+ * {@link org.deegree.spring.bootstrap.BootstrapApplicationContextHolderMetadata} object
+ * which is subsequently used to construct a
+ * {@link org.deegree.spring.bootstrap.BootstrapApplicationContextHolderBuilder}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class BootstrapApplicationContextHolderProvider extends ApplicationContextHolderProvider {
+
+ private static final String CONFIG_NS = "http://www.deegree.org/spring/bootstrap";
+
+ static final URL CONFIG_SCHEMA = BootstrapApplicationContextHolderProvider.class.getResource( "/META-INF/schemas/spring/3.4.0/bootstrap.xsd" );
+
+ @Override
+ public String getNamespace() {
+ return CONFIG_NS;
+ }
+
+ @Override
+ public ResourceMetadata createFromLocation( Workspace workspace,
+ ResourceLocation location ) {
+ return new BootstrapApplicationContextHolderMetadata( workspace, location, this );
+ }
+
+ @Override
+ public URL getSchema() {
+ return CONFIG_SCHEMA;
+ }
+
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProvider.java b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProvider.java
new file mode 100644
index 0000000000..15fb993194
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProvider.java
@@ -0,0 +1,110 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.db;
+
+import java.sql.Connection;
+
+import javax.sql.DataSource;
+
+import org.deegree.db.ConnectionProvider;
+import org.deegree.sqldialect.SQLDialect;
+
+import org.springframework.jdbc.datasource.DataSourceUtils;
+
+/**
+ * A SpringConnectionProvider provides a {@link java.sql.Connection} from a
+ * {@link javax.sql.DataSource} available as bean within the configured
+ * application context using
+ * {@link org.springframework.jdbc.datasource.DataSourceUtils}.
+ *
+ * The {@link org.deegree.sqldialect.SQLDialect} is also
+ * expected to be available as bean.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class SpringConnectionProvider implements ConnectionProvider {
+
+ private final SpringConnectionProviderMetadata metadata;
+
+ private final DataSource dataSource;
+
+ private final SQLDialect dialect;
+
+ public SpringConnectionProvider( final SpringConnectionProviderMetadata metadata, final DataSource dataSource,
+ final SQLDialect dialect ) {
+ this.metadata = metadata;
+ this.dataSource = dataSource;
+ this.dialect = dialect;
+ }
+
+ @Override
+ public SpringConnectionProviderMetadata getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public void init() {
+
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+
+ @Override
+ public Connection getConnection() {
+ return DataSourceUtils.getConnection( dataSource );
+ }
+
+ @Override
+ public SQLDialect getDialect() {
+ return dialect;
+ }
+
+ @Override
+ public void invalidate( Connection conn ) {
+ DataSourceUtils.releaseConnection( conn, dataSource );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderBuilder.java b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderBuilder.java
new file mode 100644
index 0000000000..7acfa03624
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderBuilder.java
@@ -0,0 +1,87 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.db;
+
+import javax.sql.DataSource;
+
+import org.deegree.db.ConnectionProvider;
+import org.deegree.spring.AbstractSpringResourceBuilder;
+import org.deegree.spring.db.jaxb.SpringConnectionProviderConfig;
+import org.deegree.sqldialect.SQLDialect;
+import org.deegree.workspace.Workspace;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SpringConnectionProviderBuilder is used to build a
+ * @{link org.deegree.spring.db.SpringConnectionProvider}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class SpringConnectionProviderBuilder extends AbstractSpringResourceBuilder {
+
+ private static final Logger LOG = LoggerFactory.getLogger( SpringConnectionProviderBuilder.class );
+
+ private final SpringConnectionProviderConfig config;
+
+ private final SpringConnectionProviderMetadata metadata;
+
+ public SpringConnectionProviderBuilder( final Workspace workspace, final SpringConnectionProviderMetadata metadata,
+ final SpringConnectionProviderConfig config ) {
+ super( workspace, config.getApplicationContextHolder() );
+
+ this.metadata = metadata;
+ this.config = config;
+ }
+
+ @Override
+ public ConnectionProvider build() {
+ LOG.debug( "Building SpringConnectionProvider" );
+
+ final DataSource dataSource = getBean( DataSource.class, config.getDataSourceName(), "dataSource" );
+ final SQLDialect dialect = getBean( SQLDialect.class, config.getSQLDialectName() );
+ return new SpringConnectionProvider( metadata, dataSource, dialect );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderMetadata.java b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderMetadata.java
new file mode 100644
index 0000000000..362dddca21
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderMetadata.java
@@ -0,0 +1,102 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.db;
+
+import static org.deegree.spring.db.SpringConnectionProviderProvider.CONFIG_SCHEMA;
+
+import org.deegree.commons.xml.jaxb.JAXBUtils;
+import org.deegree.db.ConnectionProvider;
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.Workspace;
+import org.deegree.workspace.standard.AbstractResourceMetadata;
+import org.deegree.workspace.standard.AbstractResourceProvider;
+import org.deegree.workspace.standard.DefaultResourceIdentifier;
+
+import org.deegree.spring.ApplicationContextHolder;
+import org.deegree.spring.ApplicationContextHolderProvider;
+import org.deegree.spring.db.jaxb.SpringConnectionProviderConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SpringConnectionProviderMetadata is used as the
+ * {@link org.deegree.workspace.ResourceMetadata} by the
+ * {@link org.deegree.spring.db.SpringConnectionProviderProvider}
+ * It registers the configured
+ * {@link org.deegree.spring.ApplicationContextHolder} as dependency.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class SpringConnectionProviderMetadata extends AbstractResourceMetadata {
+
+ private static final Logger LOG = LoggerFactory.getLogger( SpringConnectionProviderMetadata.class );
+
+ private static final String CONFIG_JAXB_PACKAGE = "org.deegree.spring.db.jaxb";
+
+ public SpringConnectionProviderMetadata( Workspace workspace, ResourceLocation location,
+ AbstractResourceProvider provider ) {
+ super( workspace, location, provider );
+ }
+
+ @Override
+ public SpringConnectionProviderBuilder prepare() {
+
+ final SpringConnectionProviderConfig config;
+ try {
+ config = (SpringConnectionProviderConfig) JAXBUtils.unmarshall( CONFIG_JAXB_PACKAGE, CONFIG_SCHEMA,
+ location.getAsStream(), workspace );
+
+ final String applicationContextHolder = config.getApplicationContextHolder();
+ dependencies.add( new DefaultResourceIdentifier(
+ ApplicationContextHolderProvider.class,
+ applicationContextHolder ) );
+ } catch ( Exception e ) {
+ LOG.trace( "Stack trace:", e );
+ throw new ResourceInitException( e.getLocalizedMessage(), e );
+ }
+
+ return new SpringConnectionProviderBuilder( workspace, this, config );
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderProvider.java b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderProvider.java
new file mode 100644
index 0000000000..c9e6b2a443
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/db/SpringConnectionProviderProvider.java
@@ -0,0 +1,82 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.db;
+
+import java.net.URL;
+
+import org.deegree.db.ConnectionProvider;
+import org.deegree.db.ConnectionProviderProvider;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.Workspace;
+
+/**
+ * SpringConnectionProviderProvider provides a
+ * {@link org.deegree.spring.db.SpringConnectionProviderMetadata} object
+ * which is subsequently used to construct a
+ * {@link org.deegree.spring.db.SpringConnectionProviderBuilder}.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class SpringConnectionProviderProvider extends ConnectionProviderProvider {
+
+ private static final String CONFIG_NS = "http://www.deegree.org/spring/db";
+
+ static final URL CONFIG_SCHEMA = SpringConnectionProviderProvider.class.getResource( "/META-INF/schemas/spring/3.4.0/db.xsd" );
+
+ @Override
+ public String getNamespace() {
+ return CONFIG_NS;
+ }
+
+ @Override
+ public SpringConnectionProviderMetadata createFromLocation( Workspace workspace,
+ ResourceLocation location ) {
+ return new SpringConnectionProviderMetadata( workspace, location, this );
+ }
+
+ @Override
+ public URL getSchema() {
+ return CONFIG_SCHEMA;
+ }
+}
diff --git a/deegree-spring/src/main/java/org/deegree/spring/services/SpringOWSMetadataProviderProvider.java b/deegree-spring/src/main/java/org/deegree/spring/services/SpringOWSMetadataProviderProvider.java
new file mode 100644
index 0000000000..b52dfb8481
--- /dev/null
+++ b/deegree-spring/src/main/java/org/deegree/spring/services/SpringOWSMetadataProviderProvider.java
@@ -0,0 +1,86 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+----------------------------------------------------------------------------*/
+package org.deegree.spring.services;
+
+import java.net.URL;
+
+import org.deegree.services.metadata.OWSMetadataProvider;
+import org.deegree.services.metadata.provider.OWSMetadataProviderProvider;
+import org.deegree.spring.GenericSpringResourceMetadata;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.ResourceMetadata;
+import org.deegree.workspace.Workspace;
+
+/**
+ * SpringOWSMetadataProviderProvider enables a bean implementing
+ * {@link org.deegree.services.metadata.OWSMetadataProvider}
+ * to be used within a deegree workspace.
+ *
+ * @author Reijer Copier
+ * @author last edited by: $Author$
+ *
+ * @version $Revision$, $Date$
+ */
+public class SpringOWSMetadataProviderProvider extends OWSMetadataProviderProvider {
+
+ private static final String CONFIG_NS = "http://www.deegree.org/spring/metadata";
+
+ private static final URL CONFIG_SCHEMA = SpringOWSMetadataProviderProvider.class.getResource( "/META-INF/schemas/spring/3.4.0/metadata.xsd" );
+
+ private static final String CONFIG_JAXB_PACKAGE = "org.deegree.spring.metadata.jaxb";
+
+ @Override
+ public String getNamespace() {
+ return CONFIG_NS;
+ }
+
+ @Override
+ public ResourceMetadata createFromLocation( Workspace workspace,
+ ResourceLocation location ) {
+
+ return new GenericSpringResourceMetadata( workspace, location, this, CONFIG_JAXB_PACKAGE, OWSMetadataProvider.class );
+ }
+
+ @Override
+ public URL getSchema() {
+ return CONFIG_SCHEMA;
+ }
+}
diff --git a/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/bootstrap.xsd b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/bootstrap.xsd
new file mode 100644
index 0000000000..8152c98329
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/bootstrap.xsd
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/db.xsd b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/db.xsd
new file mode 100644
index 0000000000..412032db50
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/db.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/generic.xsd b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/generic.xsd
new file mode 100644
index 0000000000..84d25070c1
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/generic.xsd
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/metadata.xsd b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/metadata.xsd
new file mode 100644
index 0000000000..8cf8bea0d9
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/schemas/spring/3.4.0/metadata.xsd
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/services/org.deegree.db.ConnectionProviderProvider b/deegree-spring/src/main/resources/META-INF/services/org.deegree.db.ConnectionProviderProvider
new file mode 100644
index 0000000000..749646606f
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/services/org.deegree.db.ConnectionProviderProvider
@@ -0,0 +1 @@
+org.deegree.spring.db.SpringConnectionProviderProvider
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/services/org.deegree.services.metadata.provider.OWSMetadataProviderProvider b/deegree-spring/src/main/resources/META-INF/services/org.deegree.services.metadata.provider.OWSMetadataProviderProvider
new file mode 100644
index 0000000000..2c0798eb9f
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/services/org.deegree.services.metadata.provider.OWSMetadataProviderProvider
@@ -0,0 +1 @@
+org.deegree.spring.services.SpringOWSMetadataProviderProvider
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/services/org.deegree.spring.ApplicationContextHolderProvider b/deegree-spring/src/main/resources/META-INF/services/org.deegree.spring.ApplicationContextHolderProvider
new file mode 100644
index 0000000000..8ba0c909df
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/services/org.deegree.spring.ApplicationContextHolderProvider
@@ -0,0 +1 @@
+org.deegree.spring.bootstrap.BootstrapApplicationContextHolderProvider
\ No newline at end of file
diff --git a/deegree-spring/src/main/resources/META-INF/services/org.deegree.workspace.ResourceManager b/deegree-spring/src/main/resources/META-INF/services/org.deegree.workspace.ResourceManager
new file mode 100644
index 0000000000..c2fdff9591
--- /dev/null
+++ b/deegree-spring/src/main/resources/META-INF/services/org.deegree.workspace.ResourceManager
@@ -0,0 +1 @@
+org.deegree.spring.ApplicationContextHolderManager
\ No newline at end of file
diff --git a/deegree-spring/src/test/java/org/deegree/spring/AbstractSpringResourceBuilderTest.java b/deegree-spring/src/test/java/org/deegree/spring/AbstractSpringResourceBuilderTest.java
new file mode 100644
index 0000000000..834d644b6a
--- /dev/null
+++ b/deegree-spring/src/test/java/org/deegree/spring/AbstractSpringResourceBuilderTest.java
@@ -0,0 +1,183 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import org.deegree.spring.TestContext.ContentBean;
+import org.deegree.spring.TestContext.NoBean;
+import org.deegree.spring.TestContext.SingleBean;
+
+import org.deegree.workspace.ResourceInitException;
+import org.deegree.workspace.Workspace;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AbstractSpringResourceBuilderTest {
+
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( TestContext.class );
+
+ ApplicationContextHolder contextHolder = new ApplicationContextHolder( null, context );
+
+ Workspace workspace;
+
+ @Before
+ public void setUp() {
+ workspace = mock( Workspace.class );
+ when( workspace.getResource( ApplicationContextHolderProvider.class, "test" ) ).thenReturn( contextHolder );
+ }
+
+ @Test(expected = ResourceInitException.class)
+ public void testGetNonExistingBeanType() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public NoBean build() {
+ return getBean( NoBean.class );
+ }
+ };
+
+ builder.build();
+ }
+
+ @Test(expected = ResourceInitException.class)
+ public void testGetNonExistingBeanName() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public SingleBean build() {
+ return getBean( SingleBean.class, "wrongName" );
+ }
+ };
+
+ builder.build();
+ }
+
+ @Test
+ public void testGetSingleBean() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public SingleBean build() {
+ return getBean( SingleBean.class );
+ }
+ };
+
+ assertEquals( context.getBean( SingleBean.class ), builder.build() );
+ }
+
+ @Test(expected = ResourceInitException.class)
+ public void testGetBeanNameMissing() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public ContentBean build() {
+ return getBean( ContentBean.class );
+ }
+ };
+
+ builder.build();
+ }
+
+ @Test
+ public void testGetNamedBean() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public ContentBean build() {
+ return getBean( ContentBean.class, "contentBean0" );
+ }
+ };
+
+ final ContentBean bean = builder.build();
+ assertNotNull( bean );
+ assertEquals( "contentBean0", bean.getContent() );
+ }
+
+ @Test
+ public void testGetConventionallyNamedBean() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public ContentBean build() {
+ return getBean( ContentBean.class, null, "contentBean" );
+ }
+ };
+
+ final ContentBean bean = builder.build();
+ assertNotNull( bean );
+ assertEquals( "contentBean", bean.getContent() );
+ }
+
+ @Test(expected = ResourceInitException.class)
+ public void testGetNonConventionallyNamedBean() {
+ final AbstractSpringResourceBuilder builder = new AbstractSpringResourceBuilder(
+ workspace,
+ "test" ) {
+
+ @Override
+ public ContentBean build() {
+ return getBean( ContentBean.class, null, "defaultContentBean" );
+ }
+ };
+
+ builder.build();
+ }
+}
diff --git a/deegree-spring/src/test/java/org/deegree/spring/GenericSpringResourceBuilderTest.java b/deegree-spring/src/test/java/org/deegree/spring/GenericSpringResourceBuilderTest.java
new file mode 100644
index 0000000000..59b2dfaf94
--- /dev/null
+++ b/deegree-spring/src/test/java/org/deegree/spring/GenericSpringResourceBuilderTest.java
@@ -0,0 +1,127 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.deegree.spring.TestContext.SingleBean;
+import org.deegree.workspace.ResourceBuilder;
+import org.deegree.workspace.ResourceLocation;
+import org.deegree.workspace.ResourceMetadata;
+import org.deegree.workspace.Workspace;
+import org.deegree.workspace.standard.AbstractResourceProvider;
+import org.deegree.workspace.standard.DefaultResourceIdentifier;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+public class GenericSpringResourceBuilderTest {
+
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( TestContext.class );
+
+ ApplicationContextHolder contextHolder = new ApplicationContextHolder( null, context );
+
+ Workspace workspace;
+
+ static class TestProvider extends AbstractResourceProvider {
+
+ @Override
+ public String getNamespace() {
+ return "http://www.deegree.org/spring/test";
+ }
+
+ @Override
+ public ResourceMetadata createFromLocation( Workspace workspace,
+ ResourceLocation location ) {
+ return new GenericSpringResourceMetadata( workspace, location, this,
+ "org.deegree.spring.test.jaxb", SingleBean.class );
+ }
+
+ @Override
+ public URL getSchema() {
+ return null;
+ }
+ }
+
+ @Before
+ public void setUp() {
+ workspace = mock( Workspace.class );
+ when( workspace.getResource( ApplicationContextHolderProvider.class, "test" ) ).thenReturn( contextHolder );
+ when( workspace.getModuleClassLoader() ).thenReturn( GenericSpringResourceBuilderTest.class.getClassLoader() );
+ }
+
+ @Test
+ public void testInjectMetadata() {
+
+ final TestProvider provider = new TestProvider();
+
+ final InputStream testConfig = GenericSpringResourceBuilderTest.class.getClassLoader().getResourceAsStream( "org/deegree/spring/test.xml" );
+ assertNotNull( testConfig );
+
+ @SuppressWarnings("unchecked")
+ final ResourceLocation location = mock( ResourceLocation.class );
+ when( location.getAsStream() ).thenReturn( testConfig );
+ when( location.getIdentifier() ).thenReturn( new DefaultResourceIdentifier( TestProvider.class,
+ "test" ) );
+
+ final ResourceMetadata metadata = provider.createFromLocation( workspace, location );
+ assertNotNull( metadata );
+
+ final ResourceBuilder builder = metadata.prepare();
+ assertNotNull( builder );
+
+ final SingleBean beanFromComtext = context.getBean( SingleBean.class );
+ assertNull( beanFromComtext.getMetadata() );
+
+ final SingleBean beanFromBuilder = builder.build();
+ assertNotNull( beanFromBuilder );
+ assertEquals( beanFromComtext, beanFromBuilder );
+
+ assertEquals( metadata, beanFromBuilder.getMetadata() );
+ }
+}
diff --git a/deegree-spring/src/test/java/org/deegree/spring/TestContext.java b/deegree-spring/src/test/java/org/deegree/spring/TestContext.java
new file mode 100644
index 0000000000..71dc8393fc
--- /dev/null
+++ b/deegree-spring/src/test/java/org/deegree/spring/TestContext.java
@@ -0,0 +1,121 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring;
+
+import org.deegree.spring.annotation.InjectMetadata;
+import org.deegree.workspace.Resource;
+import org.deegree.workspace.ResourceMetadata;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class TestContext {
+
+ public static class TestResource implements Resource {
+
+ @InjectMetadata
+ private ResourceMetadata extends Resource> metadata;
+
+ @Override
+ public void destroy() {
+
+ }
+
+ @Override
+ public ResourceMetadata extends Resource> getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public void init() {
+
+ }
+ }
+
+ public static class NoBean extends TestResource {
+ }
+
+ public static class SingleBean extends TestResource {
+
+ private String property;
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty( String property ) {
+ this.property = property;
+ }
+ }
+
+ public static class ContentBean extends TestResource {
+
+ final String content;
+
+ ContentBean( final String content ) {
+ this.content = content;
+ }
+
+ public String getContent() {
+ return content;
+ }
+ }
+
+ @Bean
+ public SingleBean singleBean() {
+ return new SingleBean();
+ }
+
+ @Bean
+ public ContentBean contentBean0() {
+ return new ContentBean( "contentBean0" );
+ }
+
+ @Bean
+ public ContentBean contentBean1() {
+ return new ContentBean( "contentBean1" );
+ }
+
+ @Bean
+ public ContentBean contentBean() {
+ return new ContentBean( "contentBean" );
+ }
+}
diff --git a/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/ObjectFactory.java b/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/ObjectFactory.java
new file mode 100644
index 0000000000..480682e04a
--- /dev/null
+++ b/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/ObjectFactory.java
@@ -0,0 +1,58 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring.test.jaxb;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+import org.deegree.spring.jaxb.SingleBeanRef;
+
+@XmlRegistry
+public class ObjectFactory {
+
+ @XmlElementDecl(namespace = "http://www.deegree.org/spring/test", name = "SpringServicesTest")
+ public JAXBElement createSpringOWSMetadataProviderConfig( SingleBeanRef value ) {
+ return new JAXBElement( new QName( "http://www.deegree.org/spring/test", "SpringServicesTest" ),
+ SingleBeanRef.class, value );
+ }
+}
\ No newline at end of file
diff --git a/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/TestConfig.java b/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/TestConfig.java
new file mode 100644
index 0000000000..5539b88e45
--- /dev/null
+++ b/deegree-spring/src/test/java/org/deegree/spring/test/jaxb/TestConfig.java
@@ -0,0 +1,59 @@
+//$HeadURL$
+/*----------------------------------------------------------------------------
+ This file is part of deegree, http://deegree.org/
+ Copyright (C) 2013 by:
+
+ IDgis bv
+
+ This library is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at your option)
+ any later version.
+ This library is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Contact information:
+
+ IDgis bv
+ Boomkamp 16
+ 7461 AX Rijssen
+ The Netherlands
+ http://idgis.nl/
+
+ lat/lon GmbH
+ Aennchenstr. 19, 53177 Bonn
+ Germany
+ http://lat-lon.de/
+
+ Department of Geography, University of Bonn
+ Prof. Dr. Klaus Greve
+ Postfach 1147, 53001 Bonn
+ Germany
+ http://www.geographie.uni-bonn.de/deegree/
+
+ e-mail: info@deegree.org
+ ----------------------------------------------------------------------------*/
+package org.deegree.spring.test.jaxb;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.deegree.spring.jaxb.SingleBeanRef;
+
+public class TestConfig extends JAXBElement {
+
+ private static final long serialVersionUID = -4402750689025345875L;
+
+ public TestConfig() {
+ this( null );
+ }
+
+ public TestConfig( SingleBeanRef value ) {
+ super( new QName( "http://www.deegree.org/spring/test", "SpringServicesTest" ), SingleBeanRef.class, value );
+ }
+}
diff --git a/deegree-spring/src/test/resources/org/deegree/spring/test.xml b/deegree-spring/src/test/resources/org/deegree/spring/test.xml
new file mode 100644
index 0000000000..52ac943622
--- /dev/null
+++ b/deegree-spring/src/test/resources/org/deegree/spring/test.xml
@@ -0,0 +1,3 @@
+
+ test
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f079663a4d..ff920514dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1013,6 +1013,7 @@
deegree-themes
deegree-tools
deegree-workspaces
+ deegree-spring