You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/01/13 09:17:19 UTC

[01/11] olingo-odata2 git commit: Added support for Spring

Repository: olingo-odata2
Updated Branches:
  refs/heads/master e80f0199f -> b2b42b1e4


Added support for Spring

Signed-off-by: Michael Bolz <mi...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/5a93f4cc
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/5a93f4cc
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/5a93f4cc

Branch: refs/heads/master
Commit: 5a93f4cc4e7c14759b1f3e8d1022c02978573646
Parents: 0c4bac5
Author: Lior Okman <li...@sap.com>
Authored: Wed Nov 12 20:25:43 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Nov 13 06:35:57 2014 +0100

----------------------------------------------------------------------
 .../core/rest/spring/ODataRootLocator.java      | 141 +++++++++++++++++++
 odata2-lib/odata-spring/pom.xml                 |  39 +++++
 .../odata2/spring/OlingoNamespaceHandler.java   |  13 ++
 .../spring/OlingoServerDefinitionParser.java    |  73 ++++++++++
 .../src/main/resources/META-INF/spring.handlers |   1 +
 .../src/main/resources/META-INF/spring.schemas  |   1 +
 .../src/main/resources/schema/olingo.xsd        |  23 +++
 odata2-lib/pom.xml                              |   1 +
 pom.xml                                         |   2 +
 9 files changed, 294 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
new file mode 100755
index 0000000..295dc9d
--- /dev/null
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.core.rest.spring;
+
+import java.util.List;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Encoded;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.olingo.odata2.api.ODataServiceFactory;
+import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.core.rest.ODataRedirectLocator;
+import org.apache.olingo.odata2.core.rest.ODataSubLocator;
+import org.apache.olingo.odata2.core.rest.SubLocatorParameter;
+
+/**
+ * Default OData root locator responsible to handle the whole path and delegate all calls to a sub locator:<p>
+ * <code>/{odata path} e.g. http://host:port/webapp/odata.svc/$metadata</code><br>
+ * All path segments defined by a servlet mapping belong to the odata uri.
+ * </p>
+ * This behavior can be changed:<p>
+ * <code>/{custom path}{odata path} e.g. http://host:port/webapp/bmw/odata.svc/$metadata</code><br>
+ * The first segment defined by a servlet mapping belong to customer context and the following segments are OData
+ * specific.
+ * </p>
+ *
+ */
+@Path("/")
+public class ODataRootLocator {
+
+  @Context
+  private HttpHeaders httpHeaders;
+  @Context
+  private UriInfo uriInfo;
+  @Context
+  private Request request;
+  @Context
+  private ServletConfig servletConfig;
+  @Context
+  private HttpServletRequest servletRequest;
+
+  @Context
+  private Application app;
+
+  // These next two members are exposed so that they can be injected with Spring
+  private ODataServiceFactory serviceFactory;
+  private int pathSplit = 0;
+
+  /**
+   * Default root behavior which will delegate all paths to a ODataLocator.
+   * @param pathSegments URI path segments - all segments have to be OData
+   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
+   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
+   * @return a locator handling OData protocol
+   * @throws ODataException
+   * @throws ClassNotFoundException
+   * @throws IllegalAccessException
+   * @throws InstantiationException
+   */
+  @Path("/{pathSegments: .*}")
+  public Object handleRequest(
+      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
+      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
+      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
+      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+    if (xHttpMethod != null && xHttpMethodOverride != null) {
+
+      /*
+       * X-HTTP-Method-Override : implemented by CXF
+       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
+       */
+
+      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
+        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
+      }
+    }
+
+    if (servletRequest.getPathInfo() == null) {
+      return handleRedirect();
+    }
+
+    final SubLocatorParameter param = new SubLocatorParameter();
+    param.setServiceFactory(serviceFactory);
+    param.setPathSegments(pathSegments);
+    param.setHttpHeaders(httpHeaders);
+    param.setUriInfo(uriInfo);
+    param.setRequest(request);
+    param.setServletRequest(servletRequest);
+    param.setPathSplit(pathSplit);
+
+    return ODataSubLocator.create(param);
+  }
+
+  private Object handleRedirect() {
+    return new ODataRedirectLocator();
+  }
+
+  public ODataServiceFactory getServiceFactory() {
+	return serviceFactory;
+  }
+
+  public void setServiceFactory(ODataServiceFactory serviceFactory) {
+	this.serviceFactory = serviceFactory;
+  }
+
+  public int getPathSplit() {
+	return pathSplit;
+  }
+
+  public void setPathSplit(int pathSplit) {
+	this.pathSplit = pathSplit;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/pom.xml b/odata2-lib/odata-spring/pom.xml
new file mode 100755
index 0000000..8602fcc
--- /dev/null
+++ b/odata2-lib/odata-spring/pom.xml
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>odata-spring</artifactId>
+	<name>${project.artifactId}</name>
+
+	<parent>
+		<groupId>org.apache.olingo</groupId>
+		<artifactId>olingo-odata2-lib</artifactId>
+		<version>2.0.2-SNAPSHOT</version>
+	</parent>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+			<exclusions>
+				<exclusion>
+					<groupId>commons-logging</groupId>
+					<artifactId>commons-logging</artifactId>
+				</exclusion>
+			</exclusions>
+			<optional>true</optional>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.version}</version>
+			<artifactId>olingo-odata2-core</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
new file mode 100755
index 0000000..a141dde
--- /dev/null
+++ b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
@@ -0,0 +1,13 @@
+package org.apache.olingo.odata2.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+
+public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
+
+	@Override
+	public void init() {
+		registerBeanDefinitionParser("server", new OlingoServerDefinitionParser());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
new file mode 100755
index 0000000..849e7a8
--- /dev/null
+++ b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -0,0 +1,73 @@
+package org.apache.olingo.odata2.spring;
+
+import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser;
+import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
+import org.apache.olingo.odata2.core.rest.app.ODataApplication;
+import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefinitionParser {
+
+	public OlingoServerDefinitionParser() {
+		super();
+		setBeanClass(SpringJAXRSServerFactoryBean.class);
+	}
+
+	@Override
+	protected void mapAttribute(BeanDefinitionBuilder bean, Element e,  String name, String val) {
+		if ("id".equals(name) || "address".equals(name)) {
+			mapToProperty(bean, name, val);
+		}
+	}
+
+	@Override
+	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
+		super.doParse(element, parserContext, bean);
+		ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
+
+		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
+			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
+			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+		}
+
+		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
+			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
+			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+		}
+
+		if (!element.hasAttribute("factory")) {
+			if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
+				AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
+				definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+				BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
+				registerBeanDefinition(holder, parserContext.getRegistry());
+			}
+			services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
+		}
+		else {
+			BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
+			builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
+			AbstractBeanDefinition definition = builder.getBeanDefinition();
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator-"+element.getAttribute("factory"), new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+			services.add(definition);
+
+		}
+
+		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
+		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
+		bean.addPropertyValue("serviceBeans", services);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
new file mode 100755
index 0000000..6f63fc8
--- /dev/null
+++ b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.apache.org/olingo/odata2/spring/namespace=org.apache.olingo.odata2.spring.OlingoNamespaceHandler

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
new file mode 100755
index 0000000..85b9a6d
--- /dev/null
+++ b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.apache.org/olingo/odata2/spring/namespace.xsd=schema/olingo.xsd

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd b/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
new file mode 100755
index 0000000..2b160e9
--- /dev/null
+++ b/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/namespace"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:beans="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+	targetNamespace="http://www.apache.org/olingo/odata2/spring/namespace"
+	elementFormDefault="unqualified">
+
+	<xsd:import namespace="http://www.springframework.org/schema/beans"
+				schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
+
+	<xsd:element name="server">
+		<xsd:complexType>
+			<xsd:complexContent>
+				<xsd:extension base="beans:identifiedType">
+					<xsd:attribute name="address" type="xsd:string" use="required"/>
+					<xsd:attribute name="factory" type="xsd:string" use="optional"/>
+				</xsd:extension>
+			</xsd:complexContent>
+		</xsd:complexType>
+	</xsd:element>
+</xsd:schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/odata2-lib/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/pom.xml b/odata2-lib/pom.xml
index c646f3f..f510ec7 100644
--- a/odata2-lib/pom.xml
+++ b/odata2-lib/pom.xml
@@ -30,5 +30,6 @@
         <module>odata-fit</module>
         <module>odata-ref</module>
         <module>odata-web</module>
+        <module>odata-spring</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5a93f4cc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index fbe059e..67ae922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,6 +72,8 @@
 
 		<version.eclipselink>2.5.1</version.eclipselink>
 		<version.javax.persistence>2.0.5</version.javax.persistence>
+
+		<spring.version>3.2.12.RELEASE</spring.version>
 	</properties>
 
 	<modules>


[08/11] olingo-odata2 git commit: [OLINGO-193] Adapted RAT check for odata2-spring module

Posted by mi...@apache.org.
[OLINGO-193] Adapted RAT check for odata2-spring module


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/7a596e20
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/7a596e20
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/7a596e20

Branch: refs/heads/master
Commit: 7a596e207e0292419447f11b1df792f1824ca432
Parents: 986b1c4
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Dec 23 14:10:33 2014 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Dec 23 14:10:33 2014 +0100

----------------------------------------------------------------------
 pom.xml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/7a596e20/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 67ae922..9ffc517 100644
--- a/pom.xml
+++ b/pom.xml
@@ -350,6 +350,8 @@
 										<exclude>**/NOTICE</exclude>
 										<exclude>**/DEPENDENCIES</exclude>
 										<exclude>**/goal.txt</exclude>
+										<exclude>**/target/**</exclude>
+										<exclude>**/*.iml</exclude>
 									</excludes>
 								</configuration>
 							</execution>


[03/11] olingo-odata2 git commit: [OLINGO-193] Minor code and license clean up

Posted by mi...@apache.org.
[OLINGO-193] Minor code and license clean up


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/ee079873
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/ee079873
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/ee079873

Branch: refs/heads/master
Commit: ee0798736eaff71a377d704067032c3add145567
Parents: dd98b32
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Nov 14 08:46:52 2014 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Nov 14 08:46:52 2014 +0100

----------------------------------------------------------------------
 odata2-spring/pom.xml                           |   8 ++
 .../odata2/spring/OlingoNamespaceHandler.java   |  28 ++++-
 .../spring/OlingoServerDefinitionParser.java    | 118 +++++++++++--------
 .../src/main/resources/META-INF/spring.handlers |   7 ++
 .../src/main/resources/META-INF/spring.schemas  |   7 ++
 .../src/main/resources/schema/olingo.xsd        |   7 ++
 6 files changed, 121 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
index 75650d0..bf8f6a8 100755
--- a/odata2-spring/pom.xml
+++ b/odata2-spring/pom.xml
@@ -1,3 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+    the License. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
index a141dde..9014733 100755
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
@@ -1,13 +1,29 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
 package org.apache.olingo.odata2.spring;
 
 import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
 
-
 public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
 
-	@Override
-	public void init() {
-		registerBeanDefinitionParser("server", new OlingoServerDefinitionParser());
-	}
-
+  @Override
+  public void init() {
+    registerBeanDefinitionParser("server", new OlingoServerDefinitionParser());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
index 849e7a8..d4469a3 100755
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -1,3 +1,21 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
 package org.apache.olingo.odata2.spring;
 
 import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser;
@@ -14,60 +32,64 @@ import org.w3c.dom.Element;
 
 public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefinitionParser {
 
-	public OlingoServerDefinitionParser() {
-		super();
-		setBeanClass(SpringJAXRSServerFactoryBean.class);
-	}
+  public OlingoServerDefinitionParser() {
+    super();
+    setBeanClass(SpringJAXRSServerFactoryBean.class);
+  }
 
-	@Override
-	protected void mapAttribute(BeanDefinitionBuilder bean, Element e,  String name, String val) {
-		if ("id".equals(name) || "address".equals(name)) {
-			mapToProperty(bean, name, val);
-		}
-	}
+  @Override
+  protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String val) {
+    if ("id".equals(name) || "address".equals(name)) {
+      mapToProperty(bean, name, val);
+    }
+  }
 
-	@Override
-	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
-		super.doParse(element, parserContext, bean);
-		ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
+  @Override
+  protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
+    super.doParse(element, parserContext, bean);
+    ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
 
-		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
-			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
-			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-		}
+    if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
+      AbstractBeanDefinition definition =
+          BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
+      definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
+      registerBeanDefinition(holder, parserContext.getRegistry());
+    }
 
-		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
-			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
-			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-		}
+    if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
+      AbstractBeanDefinition definition =
+          BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
+      definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
+      registerBeanDefinition(holder, parserContext.getRegistry());
+    }
 
-		if (!element.hasAttribute("factory")) {
-			if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
-				AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
-				definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-				BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
-				registerBeanDefinition(holder, parserContext.getRegistry());
-			}
-			services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
-		}
-		else {
-			BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
-			builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
-			AbstractBeanDefinition definition = builder.getBeanDefinition();
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator-"+element.getAttribute("factory"), new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-			services.add(definition);
+    if (!element.hasAttribute("factory")) {
+      if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
+        AbstractBeanDefinition definition =
+            BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
+        definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+        BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
+        registerBeanDefinition(holder, parserContext.getRegistry());
+      }
+      services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
+    } else {
+      BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
+      builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+      builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
+      AbstractBeanDefinition definition = builder.getBeanDefinition();
+      BeanDefinitionHolder holder =
+          new BeanDefinitionHolder(definition, "OlingoODataRootLocator-" + element.getAttribute("factory"),
+              new String[0]);
+      registerBeanDefinition(holder, parserContext.getRegistry());
+      services.add(definition);
 
-		}
+    }
 
-		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
-		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
-		bean.addPropertyValue("serviceBeans", services);
-	}
+    services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
+    services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
+    bean.addPropertyValue("serviceBeans", services);
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.handlers b/odata2-spring/src/main/resources/META-INF/spring.handlers
index 6f63fc8..4b9c4c5 100755
--- a/odata2-spring/src/main/resources/META-INF/spring.handlers
+++ b/odata2-spring/src/main/resources/META-INF/spring.handlers
@@ -1 +1,8 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+    the License. -->
 http\://www.apache.org/olingo/odata2/spring/namespace=org.apache.olingo.odata2.spring.OlingoNamespaceHandler

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.schemas b/odata2-spring/src/main/resources/META-INF/spring.schemas
index 85b9a6d..f9ff528 100755
--- a/odata2-spring/src/main/resources/META-INF/spring.schemas
+++ b/odata2-spring/src/main/resources/META-INF/spring.schemas
@@ -1 +1,8 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+    the License. -->
 http\://www.apache.org/olingo/odata2/spring/namespace.xsd=schema/olingo.xsd

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/ee079873/odata2-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/schema/olingo.xsd b/odata2-spring/src/main/resources/schema/olingo.xsd
index 2b160e9..6818687 100755
--- a/odata2-spring/src/main/resources/schema/olingo.xsd
+++ b/odata2-spring/src/main/resources/schema/olingo.xsd
@@ -1,4 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
+    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
+    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
+    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
+    the License. -->
 <xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/namespace"
 	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 	xmlns:beans="http://www.springframework.org/schema/beans"


[09/11] olingo-odata2 git commit: [OLINGO-193] Reuse as much code as possible in the spring extension (Extend the core ODataRootLocator and override the setters)

Posted by mi...@apache.org.
[OLINGO-193] Reuse as much code as possible in the spring extension (Extend the core ODataRootLocator and override the setters)

Signed-off-by: Michael Bolz <mi...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/5b632779
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/5b632779
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/5b632779

Branch: refs/heads/master
Commit: 5b632779b992c151478d8333c19489740c8255b9
Parents: 7a596e2
Author: Lior Okman <li...@gmail.com>
Authored: Wed Dec 24 20:43:44 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jan 7 14:52:24 2015 +0100

----------------------------------------------------------------------
 .../odata2/core/rest/ODataRootLocator.java      | 21 +++++--
 .../olingo/odata2/spring/OlingoRootLocator.java | 64 ++------------------
 2 files changed, 19 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5b632779/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
index 3ff5984..e75ef5d 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
@@ -102,13 +102,9 @@ public class ODataRootLocator {
       return handleRedirect();
     }
 
-    ODataServiceFactory serviceFactory = createServiceFactoryFromContext(app, servletRequest, servletConfig);
+    ODataServiceFactory serviceFactory = getServiceFactory();
 
-    int pathSplit = 0;
-    final String pathSplitAsString = servletConfig.getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
-    if (pathSplitAsString != null) {
-      pathSplit = Integer.parseInt(pathSplitAsString);
-    }
+    int pathSplit = getPathSplit();
 
     final SubLocatorParameter param = new SubLocatorParameter();
     param.setServiceFactory(serviceFactory);
@@ -122,6 +118,19 @@ public class ODataRootLocator {
     return ODataSubLocator.create(param);
   }
 
+  public ODataServiceFactory getServiceFactory() {
+    return createServiceFactoryFromContext(app, servletRequest, servletConfig);
+  }
+
+  public int getPathSplit() {
+    int pathSplit = 0;
+    final String pathSplitAsString = servletConfig.getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
+    if (pathSplitAsString != null) {
+      pathSplit = Integer.parseInt(pathSplitAsString);
+    }
+    return pathSplit;
+  }
+
   public static ODataServiceFactory createServiceFactoryFromContext(final Application app,
       final HttpServletRequest servletRequest,
       final ServletConfig servletConfig) {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5b632779/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
index bf60cb6..4cfceea 100644
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
@@ -24,6 +24,7 @@ import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.core.rest.ODataRedirectLocator;
 import org.apache.olingo.odata2.core.rest.ODataSubLocator;
 import org.apache.olingo.odata2.core.rest.SubLocatorParameter;
+import org.apache.olingo.odata2.core.rest.ODataRootLocator;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Encoded;
@@ -51,71 +52,13 @@ import java.util.List;
  *
  */
 @Path("/")
-public class OlingoRootLocator {
-
-  @Context
-  private HttpHeaders httpHeaders;
-  @Context
-  private UriInfo uriInfo;
-  @Context
-  private Request request;
-  @Context
-  private HttpServletRequest servletRequest;
+public class OlingoRootLocator extends ODataRootLocator {
 
   // These next two members are exposed so that they can be injected with Spring
   private ODataServiceFactory serviceFactory;
   private int pathSplit = 0;
 
-  /**
-   * Default root behavior which will delegate all paths to a ODataLocator.
-   * @param pathSegments URI path segments - all segments have to be OData
-   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
-   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
-   * @return a locator handling OData protocol
-   * @throws org.apache.olingo.odata2.api.exception.ODataException
-   * @throws ClassNotFoundException
-   * @throws IllegalAccessException
-   * @throws InstantiationException
-   */
-  @Path("/{pathSegments: .*}")
-  public Object handleRequest(
-      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
-      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
-      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
-      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
-
-    if (xHttpMethod != null && xHttpMethodOverride != null) {
-
-      /*
-       * X-HTTP-Method-Override : implemented by CXF
-       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
-       */
-
-      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
-        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
-      }
-    }
-
-    if (servletRequest.getPathInfo() == null) {
-      return handleRedirect();
-    }
-
-    final SubLocatorParameter param = new SubLocatorParameter();
-    param.setServiceFactory(getServiceFactory());
-    param.setPathSegments(pathSegments);
-    param.setHttpHeaders(httpHeaders);
-    param.setUriInfo(uriInfo);
-    param.setRequest(request);
-    param.setServletRequest(servletRequest);
-    param.setPathSplit(getPathSplit());
-
-    return ODataSubLocator.create(param);
-  }
-
-  private Object handleRedirect() {
-    return new ODataRedirectLocator();
-  }
-
+  @Override
   public ODataServiceFactory getServiceFactory() {
     return serviceFactory;
   }
@@ -124,6 +67,7 @@ public class OlingoRootLocator {
     this.serviceFactory = serviceFactory;
   }
 
+  @Override
   public int getPathSplit() {
     return pathSplit;
   }


[07/11] olingo-odata2 git commit: [OLINGO-193] Moved all spring related into spring extension module

Posted by mi...@apache.org.
[OLINGO-193] Moved all spring related into spring extension module


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/986b1c4b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/986b1c4b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/986b1c4b

Branch: refs/heads/master
Commit: 986b1c4b4c45bfa0b156928108f2fe5ae6410236
Parents: 1ee1ff4
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Dec 23 13:51:06 2014 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Dec 23 13:56:35 2014 +0100

----------------------------------------------------------------------
 .../odata2/core/rest/ODataRootLocator.java      |  98 +++++++++----
 .../core/rest/spring/ODataRootLocator.java      | 138 -------------------
 odata2-spring/pom.xml                           |   1 -
 .../olingo/odata2/spring/OlingoRootLocator.java | 134 ++++++++++++++++++
 .../spring/OlingoServerDefinitionParser.java    |  39 ++++--
 .../src/main/resources/schema/olingo.xsd        |   2 +-
 .../spring/SpringNamespaceHandlerTest.java      |  20 +--
 .../resources/spring/applicationContext.xml     |   2 +-
 8 files changed, 247 insertions(+), 187 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
index 64f9d4f..3ff5984 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,13 +18,24 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.core.rest;
 
+import java.util.List;
+
 import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Encoded;
+import javax.ws.rs.HeaderParam;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.olingo.odata2.api.ODataServiceFactory;
+import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
+import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
 import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication;
 
@@ -38,40 +49,77 @@ import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication;
  * The first segment defined by a servlet mapping belong to customer context and the following segments are OData
  * specific.
  * </p>
- * 
+ *
  */
 @Path("/")
-public class ODataRootLocator extends
-    org.apache.olingo.odata2.core.rest.spring.ODataRootLocator {
+public class ODataRootLocator {
 
   @Context
+  private HttpHeaders httpHeaders;
+  @Context
+  private UriInfo uriInfo;
+  @Context
+  private Request request;
+  @Context
   private ServletConfig servletConfig;
+  @Context
+  private HttpServletRequest servletRequest;
 
-  @Override
-  public ODataServiceFactory getServiceFactory() {
-    return createServiceFactoryFromContext(app, servletRequest,
-        servletConfig);
-  }
+  @Context
+  private Application app;
 
-  @Override
-  public void setServiceFactory(ODataServiceFactory serviceFactory) {
-    // Don't do anything
-  }
+  /**
+   * Default root behavior which will delegate all paths to a ODataLocator.
+   * @param pathSegments URI path segments - all segments have to be OData
+   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
+   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
+   * @return a locator handling OData protocol
+   * @throws ODataException
+   * @throws ClassNotFoundException
+   * @throws IllegalAccessException
+   * @throws InstantiationException
+   */
+  @Path("/{pathSegments: .*}")
+  public Object handleRequest(
+      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
+      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
+      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
+      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+    if (xHttpMethod != null && xHttpMethodOverride != null) {
+
+      /*
+       * X-HTTP-Method-Override : implemented by CXF
+       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
+       */
+
+      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
+        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
+      }
+    }
+
+    if (servletRequest.getPathInfo() == null) {
+      return handleRedirect();
+    }
+
+    ODataServiceFactory serviceFactory = createServiceFactoryFromContext(app, servletRequest, servletConfig);
 
-  @Override
-  public int getPathSplit() {
     int pathSplit = 0;
-    final String pathSplitAsString = servletConfig
-        .getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
+    final String pathSplitAsString = servletConfig.getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
     if (pathSplitAsString != null) {
       pathSplit = Integer.parseInt(pathSplitAsString);
     }
-    return pathSplit;
-  }
 
-  @Override
-  public void setPathSplit(int pathSplit) {
-    // Don't do anything
+    final SubLocatorParameter param = new SubLocatorParameter();
+    param.setServiceFactory(serviceFactory);
+    param.setPathSegments(pathSegments);
+    param.setHttpHeaders(httpHeaders);
+    param.setUriInfo(uriInfo);
+    param.setRequest(request);
+    param.setServletRequest(servletRequest);
+    param.setPathSplit(pathSplit);
+
+    return ODataSubLocator.create(param);
   }
 
   public static ODataServiceFactory createServiceFactoryFromContext(final Application app,
@@ -100,4 +148,8 @@ public class ODataRootLocator extends
       throw new ODataRuntimeException("Exception during ODataServiceFactory creation occured.", e);
     }
   }
+
+  private Object handleRedirect() {
+    return new ODataRedirectLocator();
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
deleted file mode 100644
index ea143e7..0000000
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata2.core.rest.spring;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.rest.ODataRedirectLocator;
-import org.apache.olingo.odata2.core.rest.ODataSubLocator;
-import org.apache.olingo.odata2.core.rest.SubLocatorParameter;
-
-/**
- * Default OData root locator responsible to handle the whole path and delegate all calls to a sub locator:<p>
- * <code>/{odata path} e.g. http://host:port/webapp/odata.svc/$metadata</code><br>
- * All path segments defined by a servlet mapping belong to the odata uri.
- * </p>
- * This behavior can be changed:<p>
- * <code>/{custom path}{odata path} e.g. http://host:port/webapp/bmw/odata.svc/$metadata</code><br>
- * The first segment defined by a servlet mapping belong to customer context and the following segments are OData
- * specific.
- * </p>
- *
- */
-@Path("/")
-public class ODataRootLocator {
-
-  @Context
-  private HttpHeaders httpHeaders;
-  @Context
-  private UriInfo uriInfo;
-  @Context
-  private Request request;
-  @Context
-  protected HttpServletRequest servletRequest;
-
-  @Context
-  protected Application app;
-
-  // These next two members are exposed so that they can be injected with Spring
-  private ODataServiceFactory serviceFactory;
-  private int pathSplit = 0;
-
-  /**
-   * Default root behavior which will delegate all paths to a ODataLocator.
-   * @param pathSegments URI path segments - all segments have to be OData
-   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
-   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
-   * @return a locator handling OData protocol
-   * @throws ODataException
-   * @throws ClassNotFoundException
-   * @throws IllegalAccessException
-   * @throws InstantiationException
-   */
-  @Path("/{pathSegments: .*}")
-  public Object handleRequest(
-      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
-      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
-      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
-      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
-
-    if (xHttpMethod != null && xHttpMethodOverride != null) {
-
-      /*
-       * X-HTTP-Method-Override : implemented by CXF
-       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
-       */
-
-      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
-        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
-      }
-    }
-
-    if (servletRequest.getPathInfo() == null) {
-      return handleRedirect();
-    }
-
-    final SubLocatorParameter param = new SubLocatorParameter();
-    param.setServiceFactory(getServiceFactory());
-    param.setPathSegments(pathSegments);
-    param.setHttpHeaders(httpHeaders);
-    param.setUriInfo(uriInfo);
-    param.setRequest(request);
-    param.setServletRequest(servletRequest);
-    param.setPathSplit(getPathSplit());
-
-    return ODataSubLocator.create(param);
-  }
-
-  private Object handleRedirect() {
-    return new ODataRedirectLocator();
-  }
-
-  public ODataServiceFactory getServiceFactory() {
-    return serviceFactory;
-  }
-
-  public void setServiceFactory(ODataServiceFactory serviceFactory) {
-    this.serviceFactory = serviceFactory;
-  }
-
-  public int getPathSplit() {
-    return pathSplit;
-  }
-
-  public void setPathSplit(int pathSplit) {
-    this.pathSplit = pathSplit;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
index 5183719..ed1c7b3 100755
--- a/odata2-spring/pom.xml
+++ b/odata2-spring/pom.xml
@@ -75,7 +75,6 @@
 			<groupId>javax.servlet</groupId>
 			<artifactId>servlet-api</artifactId>
 			<version>2.5</version>
-			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>commons-logging</groupId>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
new file mode 100644
index 0000000..bf60cb6
--- /dev/null
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.spring;
+
+import org.apache.olingo.odata2.api.ODataServiceFactory;
+import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.core.rest.ODataRedirectLocator;
+import org.apache.olingo.odata2.core.rest.ODataSubLocator;
+import org.apache.olingo.odata2.core.rest.SubLocatorParameter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Encoded;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+import java.util.List;
+
+/**
+ * Default OData root locator responsible to handle the whole path and delegate all calls to a sub locator:<p>
+ * <code>/{odata path} e.g. http://host:port/webapp/odata.svc/$metadata</code><br>
+ * All path segments defined by a servlet mapping belong to the odata uri.
+ * </p>
+ * This behavior can be changed:<p>
+ * <code>/{custom path}{odata path} e.g. http://host:port/webapp/bmw/odata.svc/$metadata</code><br>
+ * The first segment defined by a servlet mapping belong to customer context and the following segments are OData
+ * specific.
+ * </p>
+ *
+ */
+@Path("/")
+public class OlingoRootLocator {
+
+  @Context
+  private HttpHeaders httpHeaders;
+  @Context
+  private UriInfo uriInfo;
+  @Context
+  private Request request;
+  @Context
+  private HttpServletRequest servletRequest;
+
+  // These next two members are exposed so that they can be injected with Spring
+  private ODataServiceFactory serviceFactory;
+  private int pathSplit = 0;
+
+  /**
+   * Default root behavior which will delegate all paths to a ODataLocator.
+   * @param pathSegments URI path segments - all segments have to be OData
+   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
+   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
+   * @return a locator handling OData protocol
+   * @throws org.apache.olingo.odata2.api.exception.ODataException
+   * @throws ClassNotFoundException
+   * @throws IllegalAccessException
+   * @throws InstantiationException
+   */
+  @Path("/{pathSegments: .*}")
+  public Object handleRequest(
+      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
+      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
+      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
+      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+    if (xHttpMethod != null && xHttpMethodOverride != null) {
+
+      /*
+       * X-HTTP-Method-Override : implemented by CXF
+       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
+       */
+
+      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
+        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
+      }
+    }
+
+    if (servletRequest.getPathInfo() == null) {
+      return handleRedirect();
+    }
+
+    final SubLocatorParameter param = new SubLocatorParameter();
+    param.setServiceFactory(getServiceFactory());
+    param.setPathSegments(pathSegments);
+    param.setHttpHeaders(httpHeaders);
+    param.setUriInfo(uriInfo);
+    param.setRequest(request);
+    param.setServletRequest(servletRequest);
+    param.setPathSplit(getPathSplit());
+
+    return ODataSubLocator.create(param);
+  }
+
+  private Object handleRedirect() {
+    return new ODataRedirectLocator();
+  }
+
+  public ODataServiceFactory getServiceFactory() {
+    return serviceFactory;
+  }
+
+  public void setServiceFactory(ODataServiceFactory serviceFactory) {
+    this.serviceFactory = serviceFactory;
+  }
+
+  public int getPathSplit() {
+    return pathSplit;
+  }
+
+  public void setPathSplit(int pathSplit) {
+    this.pathSplit = pathSplit;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
index a8e7f77..c517ad4 100755
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -21,7 +21,6 @@ package org.apache.olingo.odata2.spring;
 import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser;
 import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
 import org.apache.olingo.odata2.core.rest.app.ODataApplication;
-import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.BeanDefinitionHolder;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
@@ -30,8 +29,20 @@ import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.w3c.dom.Element;
 
+/**
+ *
+ */
 public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefinitionParser {
 
+  protected static final String OLINGO_ROOT_LOCATOR = "OlingoRootLocator";
+  protected static final String OLINGO_ODATA_PROVIDER = "OlingoODataProvider";
+  protected static final String OLINGO_ODATA_EXCEPTION_HANDLER = "OlingoODataExceptionHandler";
+  protected static final String SERVICE_FACTORY = "serviceFactory";
+  protected static final String SERVICE_BEANS = "serviceBeans";
+  protected static final String ID = "id";
+  protected static final String FACTORY = "factory";
+  protected static final String PATH_SPLIT = "pathSplit";
+
   public OlingoServerDefinitionParser() {
     super();
     setBeanClass(SpringJAXRSServerFactoryBean.class);
@@ -39,7 +50,7 @@ public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefiniti
 
   @Override
   protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String val) {
-    if ("id".equals(name) || "address".equals(name)) {
+    if (ID.equals(name) || "address".equals(name)) {
       mapToProperty(bean, name, val);
     }
   }
@@ -48,38 +59,38 @@ public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefiniti
   protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
     super.doParse(element, parserContext, bean);
 
-    if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
+    if (!parserContext.getRegistry().containsBeanDefinition(OLINGO_ODATA_EXCEPTION_HANDLER)) {
       AbstractBeanDefinition definition =
           BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
       definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
+      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, OLINGO_ODATA_EXCEPTION_HANDLER, new String[0]);
       registerBeanDefinition(holder, parserContext.getRegistry());
     }
 
-    if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
+    if (!parserContext.getRegistry().containsBeanDefinition(OLINGO_ODATA_PROVIDER)) {
       AbstractBeanDefinition definition =
           BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
       definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
+      BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, OLINGO_ODATA_PROVIDER, new String[0]);
       registerBeanDefinition(holder, parserContext.getRegistry());
     }
 
-    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
+    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(OlingoRootLocator.class);
     builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-    builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
-    if (element.hasAttribute("pathsplit")) {
-      builder.addPropertyValue("pathSplit", element.getAttribute("pathsplit"));
+    builder.addPropertyReference(SERVICE_FACTORY, element.getAttribute(FACTORY));
+    if (element.hasAttribute(PATH_SPLIT)) {
+      builder.addPropertyValue(PATH_SPLIT, element.getAttribute(PATH_SPLIT));
     }
     AbstractBeanDefinition definition = builder.getBeanDefinition();
     BeanDefinitionHolder holder = new BeanDefinitionHolder(definition,
-        "OlingoODataRootLocator-" + element.getAttribute("id") + "-" + element.getAttribute("factory"), new String[0]);
+        OLINGO_ROOT_LOCATOR + "-" + element.getAttribute(ID) + "-" + element.getAttribute(FACTORY));
     registerBeanDefinition(holder, parserContext.getRegistry());
 
     ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
     services.add(definition);
-    services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
-    services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
-    bean.addPropertyValue("serviceBeans", services);
+    services.add(parserContext.getRegistry().getBeanDefinition(OLINGO_ODATA_EXCEPTION_HANDLER));
+    services.add(parserContext.getRegistry().getBeanDefinition(OLINGO_ODATA_PROVIDER));
+    bean.addPropertyValue(SERVICE_BEANS, services);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/schema/olingo.xsd b/odata2-spring/src/main/resources/schema/olingo.xsd
index 39424dd..436eb74 100755
--- a/odata2-spring/src/main/resources/schema/olingo.xsd
+++ b/odata2-spring/src/main/resources/schema/olingo.xsd
@@ -24,7 +24,7 @@
 				<xsd:extension base="beans:identifiedType">
 					<xsd:attribute name="address" type="xsd:string" use="required" />
 					<xsd:attribute name="factory" type="xsd:string" use="required" />
-					<xsd:attribute name="pathsplit" type="xsd:int" use="optional" />
+					<xsd:attribute name="pathSplit" type="xsd:int" use="optional" />
 				</xsd:extension>
 			</xsd:complexContent>
 		</xsd:complexType>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
index 81a2372..089cfe3 100755
--- a/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
+++ b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
@@ -18,12 +18,9 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.spring;
 
-import static org.junit.Assert.*;
-
 import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser.SpringJAXRSServerFactoryBean;
 import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
 import org.apache.olingo.odata2.core.rest.app.ODataApplication;
-import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +29,11 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration("classpath:spring/applicationContext.xml")
 @WebAppConfiguration
@@ -44,15 +46,15 @@ public class SpringNamespaceHandlerTest {
   public void testSuccessfullyCreated() {
     assertTrue(appCtx.containsBean("testServer"));
 
-    assertTrue(appCtx.containsBean("OlingoODataExceptionHandler"));
-    assertTrue(appCtx.containsBean("OlingoODataProvider"));
+    assertTrue(appCtx.containsBean(OlingoServerDefinitionParser.OLINGO_ODATA_EXCEPTION_HANDLER));
+    assertTrue(appCtx.containsBean(OlingoServerDefinitionParser.OLINGO_ODATA_PROVIDER));
 
     assertEquals(ODataExceptionMapperImpl.class, appCtx.getType("OlingoODataExceptionHandler"));
     assertEquals(ODataApplication.MyProvider.class, appCtx.getType("OlingoODataProvider"));
 
-    String rootLocatorName = "OlingoODataRootLocator-testServer-serviceFactory";
+    String rootLocatorName = "OlingoRootLocator-testServer-serviceFactory";
     assertTrue(appCtx.containsBean(rootLocatorName));
-    assertEquals(ODataRootLocator.class, appCtx.getType(rootLocatorName));
+    assertEquals(OlingoRootLocator.class, appCtx.getType(rootLocatorName));
 
     SpringJAXRSServerFactoryBean server = appCtx.getBean("testServer", SpringJAXRSServerFactoryBean.class);
     assertEquals("/service.svc", server.getAddress());
@@ -60,8 +62,8 @@ public class SpringNamespaceHandlerTest {
 
   @Test
   public void testCorrectFactoryAndPathSplit() {
-    String rootLocatorName = "OlingoODataRootLocator-testServer-serviceFactory";
-    ODataRootLocator rootLocator = appCtx.getBean(rootLocatorName, ODataRootLocator.class);
+    String rootLocatorName = "OlingoRootLocator-testServer-serviceFactory";
+    OlingoRootLocator rootLocator = appCtx.getBean(rootLocatorName, OlingoRootLocator.class);
     assertNotNull(rootLocator.getServiceFactory());
     assertSame(appCtx.getBean("serviceFactory"), rootLocator.getServiceFactory());
     assertEquals(3, rootLocator.getPathSplit());

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/986b1c4b/odata2-spring/src/test/resources/spring/applicationContext.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/src/test/resources/spring/applicationContext.xml b/odata2-spring/src/test/resources/spring/applicationContext.xml
index 567c8da..31e9cd8 100755
--- a/odata2-spring/src/test/resources/spring/applicationContext.xml
+++ b/odata2-spring/src/test/resources/spring/applicationContext.xml
@@ -24,7 +24,7 @@
 	<bean id="serviceFactory" class="org.apache.olingo.odata2.spring.TestFactory" />
 
 	<!-- This is what is actually being tested -->
-	<odata:server id="testServer" address="/service.svc" factory="serviceFactory" pathsplit="3"/>
+	<odata:server id="testServer" address="/service.svc" factory="serviceFactory" pathSplit="3"/>
 
 	<!-- In order to be useful in a real environment, Apache CXF needs to be configured correctly as well.
 	     This context file doesn't handle this, since the unit test only tests that the namespace handler


[11/11] olingo-odata2 git commit: [OLINGO-193] Merge branch 'OLINGO-193_SpringSupport'

Posted by mi...@apache.org.
[OLINGO-193] Merge branch 'OLINGO-193_SpringSupport'


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/b2b42b1e
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/b2b42b1e
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/b2b42b1e

Branch: refs/heads/master
Commit: b2b42b1e4387c2b3c6e89521062c7ed4d6bf4feb
Parents: e80f019 9253114
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Jan 13 09:02:25 2015 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Jan 13 09:02:25 2015 +0100

----------------------------------------------------------------------
 .../odata2/core/rest/ODataRootLocator.java      | 30 +++---
 .../olingo/odata2/core/rest/RestUtil.java       |  8 +-
 odata2-spring/.springBeans                      | 26 ++++++
 odata2-spring/pom.xml                           | 86 ++++++++++++++++++
 .../odata2/spring/OlingoNamespaceHandler.java   | 29 ++++++
 .../olingo/odata2/spring/OlingoRootLocator.java | 62 +++++++++++++
 .../spring/OlingoServerDefinitionParser.java    | 96 ++++++++++++++++++++
 .../src/main/resources/META-INF/spring.handlers |  8 ++
 .../src/main/resources/META-INF/spring.schemas  |  8 ++
 .../src/main/resources/schema/olingo.xsd        | 32 +++++++
 .../spring/SpringNamespaceHandlerTest.java      | 71 +++++++++++++++
 .../olingo/odata2/spring/TestFactory.java       | 39 ++++++++
 .../resources/spring/applicationContext.xml     | 33 +++++++
 pom.xml                                         |  4 +
 14 files changed, 518 insertions(+), 14 deletions(-)
----------------------------------------------------------------------



[06/11] olingo-odata2 git commit: Minor fix in combination with Spring/CXFServlet

Posted by mi...@apache.org.
Minor fix in combination with Spring/CXFServlet


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/1ee1ff43
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/1ee1ff43
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/1ee1ff43

Branch: refs/heads/master
Commit: 1ee1ff4334f5f3d993aa1e772c0e9b4e55c7dc82
Parents: a339d29
Author: Michael Bolz <mi...@sap.com>
Authored: Tue Dec 23 11:09:46 2014 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Tue Dec 23 11:09:46 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/olingo/odata2/core/rest/RestUtil.java    | 8 +++++---
 pom.xml                                                      | 1 -
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/1ee1ff43/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
index 8cb200d..b726f9b 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/RestUtil.java
@@ -37,6 +37,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.olingo.odata2.api.commons.HttpHeaders;
 import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
@@ -180,7 +181,8 @@ public class RestUtil {
   public static PathInfoImpl buildODataPathInfo(final SubLocatorParameter param) throws ODataException {
     PathInfoImpl pathInfo = splitPath(param);
 
-    pathInfo.setServiceRoot(buildBaseUri(param.getServletRequest(), pathInfo.getPrecedingSegments()));
+    pathInfo.setServiceRoot(buildBaseUri(param.getUriInfo(),
+        param.getServletRequest(), pathInfo.getPrecedingSegments()));
     pathInfo.setRequestUri(buildRequestUri(param.getServletRequest()));
 
     return pathInfo;
@@ -224,10 +226,10 @@ public class RestUtil {
     return pathInfo;
   }
 
-  private static URI buildBaseUri(final HttpServletRequest request,
+  private static URI buildBaseUri(final UriInfo uriInfo, final HttpServletRequest request,
       final List<PathSegment> precedingPathSegments) throws ODataException {
     try {
-      String path = request.getContextPath() + request.getServletPath();
+      String path = uriInfo.getBaseUri().getPath();
       UriBuilder uriBuilder = UriBuilder.fromUri(path);
       for (final PathSegment ps : precedingPathSegments) {
         uriBuilder = uriBuilder.path(ps.getPath());

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/1ee1ff43/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1c8875b..67ae922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,7 +82,6 @@
 		<module>odata2-annotation-processor</module>
 		<module>odata2-dist</module>
 		<module>odata2-sample</module>
-        	<module>odata2-spring</module>
 	</modules>
 
 	<build>


[10/11] olingo-odata2 git commit: [OLINGO-193] Renamed artifact and minor code clean up

Posted by mi...@apache.org.
[OLINGO-193] Renamed artifact and minor code clean up


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/92531140
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/92531140
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/92531140

Branch: refs/heads/master
Commit: 92531140bb369a98a12c6a85f3f8aac08fb803bc
Parents: 5b63277
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Jan 7 14:54:42 2015 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Jan 7 14:54:42 2015 +0100

----------------------------------------------------------------------
 .../olingo/odata2/core/rest/ODataRootLocator.java   |  3 +--
 odata2-spring/pom.xml                               |  2 +-
 .../olingo/odata2/spring/OlingoRootLocator.java     | 16 ----------------
 3 files changed, 2 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/92531140/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
index e75ef5d..57a8bc8 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
@@ -151,8 +151,7 @@ public class ODataRootLocator {
           factoryClass = Class.forName(factoryClassName, true, cl);
         }
       }
-      ODataServiceFactory serviceFactory = (ODataServiceFactory) factoryClass.newInstance();
-      return serviceFactory;
+      return (ODataServiceFactory) factoryClass.newInstance();
     } catch (Exception e) {
       throw new ODataRuntimeException("Exception during ODataServiceFactory creation occured.", e);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/92531140/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
index ed1c7b3..1a10bb9 100755
--- a/odata2-spring/pom.xml
+++ b/odata2-spring/pom.xml
@@ -12,7 +12,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
-	<artifactId>odata2-spring</artifactId>
+	<artifactId>olingo-odata2-spring</artifactId>
 	<name>${project.artifactId}</name>
 
 	<parent>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/92531140/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
index 4cfceea..82442d6 100644
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoRootLocator.java
@@ -19,25 +19,9 @@
 package org.apache.olingo.odata2.spring;
 
 import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.core.rest.ODataRedirectLocator;
-import org.apache.olingo.odata2.core.rest.ODataSubLocator;
-import org.apache.olingo.odata2.core.rest.SubLocatorParameter;
 import org.apache.olingo.odata2.core.rest.ODataRootLocator;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.HeaderParam;
 import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
-import java.util.List;
 
 /**
  * Default OData root locator responsible to handle the whole path and delegate all calls to a sub locator:<p>


[02/11] olingo-odata2 git commit: [OLINGO-193] Moved the Spring integration to the level above lib

Posted by mi...@apache.org.
[OLINGO-193] Moved the Spring integration to the level above lib

Signed-off-by: Michael Bolz <mi...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/dd98b32d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/dd98b32d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/dd98b32d

Branch: refs/heads/master
Commit: dd98b32d395f51da7ab0c1eac194cd2e25f9ad6a
Parents: 5a93f4c
Author: Lior Okman <li...@sap.com>
Authored: Thu Nov 13 09:22:08 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Nov 14 08:38:55 2014 +0100

----------------------------------------------------------------------
 odata2-lib/odata-spring/pom.xml                 | 39 -----------
 .../odata2/spring/OlingoNamespaceHandler.java   | 13 ----
 .../spring/OlingoServerDefinitionParser.java    | 73 --------------------
 .../src/main/resources/META-INF/spring.handlers |  1 -
 .../src/main/resources/META-INF/spring.schemas  |  1 -
 .../src/main/resources/schema/olingo.xsd        | 23 ------
 odata2-lib/pom.xml                              |  1 -
 odata2-spring/pom.xml                           | 39 +++++++++++
 .../odata2/spring/OlingoNamespaceHandler.java   | 13 ++++
 .../spring/OlingoServerDefinitionParser.java    | 73 ++++++++++++++++++++
 .../src/main/resources/META-INF/spring.handlers |  1 +
 .../src/main/resources/META-INF/spring.schemas  |  1 +
 .../src/main/resources/schema/olingo.xsd        | 23 ++++++
 pom.xml                                         |  1 +
 14 files changed, 151 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/pom.xml b/odata2-lib/odata-spring/pom.xml
deleted file mode 100755
index 8602fcc..0000000
--- a/odata2-lib/odata-spring/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	<artifactId>odata-spring</artifactId>
-	<name>${project.artifactId}</name>
-
-	<parent>
-		<groupId>org.apache.olingo</groupId>
-		<artifactId>olingo-odata2-lib</artifactId>
-		<version>2.0.2-SNAPSHOT</version>
-	</parent>
-
-	<dependencies>
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-beans</artifactId>
-			<version>${spring.version}</version>
-			<exclusions>
-				<exclusion>
-					<groupId>commons-logging</groupId>
-					<artifactId>commons-logging</artifactId>
-				</exclusion>
-			</exclusions>
-			<optional>true</optional>
-		</dependency>
-
-		<dependency>
-			<groupId>${project.groupId}</groupId>
-			<version>${project.version}</version>
-			<artifactId>olingo-odata2-core</artifactId>
-		</dependency>
-
-		<dependency>
-			<groupId>org.apache.cxf</groupId>
-			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
-			<version>${cxf.version}</version>
-		</dependency>
-	</dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
deleted file mode 100755
index a141dde..0000000
--- a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.olingo.odata2.spring;
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
-
-public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
-
-	@Override
-	public void init() {
-		registerBeanDefinitionParser("server", new OlingoServerDefinitionParser());
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
deleted file mode 100755
index 849e7a8..0000000
--- a/odata2-lib/odata-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.apache.olingo.odata2.spring;
-
-import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser;
-import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
-import org.apache.olingo.odata2.core.rest.app.ODataApplication;
-import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.ManagedList;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.w3c.dom.Element;
-
-public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefinitionParser {
-
-	public OlingoServerDefinitionParser() {
-		super();
-		setBeanClass(SpringJAXRSServerFactoryBean.class);
-	}
-
-	@Override
-	protected void mapAttribute(BeanDefinitionBuilder bean, Element e,  String name, String val) {
-		if ("id".equals(name) || "address".equals(name)) {
-			mapToProperty(bean, name, val);
-		}
-	}
-
-	@Override
-	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
-		super.doParse(element, parserContext, bean);
-		ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
-
-		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
-			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
-			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-		}
-
-		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
-			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
-			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-		}
-
-		if (!element.hasAttribute("factory")) {
-			if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
-				AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
-				definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-				BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
-				registerBeanDefinition(holder, parserContext.getRegistry());
-			}
-			services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
-		}
-		else {
-			BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
-			builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-			builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
-			AbstractBeanDefinition definition = builder.getBeanDefinition();
-			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator-"+element.getAttribute("factory"), new String[0]);
-			registerBeanDefinition(holder, parserContext.getRegistry());
-			services.add(definition);
-
-		}
-
-		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
-		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
-		bean.addPropertyValue("serviceBeans", services);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
deleted file mode 100755
index 6f63fc8..0000000
--- a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.handlers
+++ /dev/null
@@ -1 +0,0 @@
-http\://www.apache.org/olingo/odata2/spring/namespace=org.apache.olingo.odata2.spring.OlingoNamespaceHandler

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas b/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
deleted file mode 100755
index 85b9a6d..0000000
--- a/odata2-lib/odata-spring/src/main/resources/META-INF/spring.schemas
+++ /dev/null
@@ -1 +0,0 @@
-http\://www.apache.org/olingo/odata2/spring/namespace.xsd=schema/olingo.xsd

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd b/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
deleted file mode 100755
index 2b160e9..0000000
--- a/odata2-lib/odata-spring/src/main/resources/schema/olingo.xsd
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/namespace"
-	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
-	targetNamespace="http://www.apache.org/olingo/odata2/spring/namespace"
-	elementFormDefault="unqualified">
-
-	<xsd:import namespace="http://www.springframework.org/schema/beans"
-				schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
-
-	<xsd:element name="server">
-		<xsd:complexType>
-			<xsd:complexContent>
-				<xsd:extension base="beans:identifiedType">
-					<xsd:attribute name="address" type="xsd:string" use="required"/>
-					<xsd:attribute name="factory" type="xsd:string" use="optional"/>
-				</xsd:extension>
-			</xsd:complexContent>
-		</xsd:complexType>
-	</xsd:element>
-</xsd:schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-lib/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/pom.xml b/odata2-lib/pom.xml
index f510ec7..c646f3f 100644
--- a/odata2-lib/pom.xml
+++ b/odata2-lib/pom.xml
@@ -30,6 +30,5 @@
         <module>odata-fit</module>
         <module>odata-ref</module>
         <module>odata-web</module>
-        <module>odata-spring</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
new file mode 100755
index 0000000..75650d0
--- /dev/null
+++ b/odata2-spring/pom.xml
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<artifactId>odata2-spring</artifactId>
+	<name>${project.artifactId}</name>
+
+	<parent>
+		<groupId>org.apache.olingo</groupId>
+		<artifactId>olingo-odata2-parent</artifactId>
+		<version>2.0.2-SNAPSHOT</version>
+	</parent>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-beans</artifactId>
+			<version>${spring.version}</version>
+			<exclusions>
+				<exclusion>
+					<groupId>commons-logging</groupId>
+					<artifactId>commons-logging</artifactId>
+				</exclusion>
+			</exclusions>
+			<optional>true</optional>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<version>${project.version}</version>
+			<artifactId>olingo-odata2-core</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.cxf</groupId>
+			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
+			<version>${cxf.version}</version>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
new file mode 100755
index 0000000..a141dde
--- /dev/null
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoNamespaceHandler.java
@@ -0,0 +1,13 @@
+package org.apache.olingo.odata2.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+
+public class OlingoNamespaceHandler extends NamespaceHandlerSupport {
+
+	@Override
+	public void init() {
+		registerBeanDefinitionParser("server", new OlingoServerDefinitionParser());
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
new file mode 100755
index 0000000..849e7a8
--- /dev/null
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -0,0 +1,73 @@
+package org.apache.olingo.odata2.spring;
+
+import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser;
+import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
+import org.apache.olingo.odata2.core.rest.app.ODataApplication;
+import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefinitionParser {
+
+	public OlingoServerDefinitionParser() {
+		super();
+		setBeanClass(SpringJAXRSServerFactoryBean.class);
+	}
+
+	@Override
+	protected void mapAttribute(BeanDefinitionBuilder bean, Element e,  String name, String val) {
+		if ("id".equals(name) || "address".equals(name)) {
+			mapToProperty(bean, name, val);
+		}
+	}
+
+	@Override
+	protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
+		super.doParse(element, parserContext, bean);
+		ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
+
+		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
+			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataExceptionMapperImpl.class).getBeanDefinition();
+			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataExceptionHandler", new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+		}
+
+		if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataProvider")) {
+			AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataApplication.MyProvider.class).getBeanDefinition();
+			definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataProvider", new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+		}
+
+		if (!element.hasAttribute("factory")) {
+			if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
+				AbstractBeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
+				definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+				BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
+				registerBeanDefinition(holder, parserContext.getRegistry());
+			}
+			services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
+		}
+		else {
+			BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
+			builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+			builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
+			AbstractBeanDefinition definition = builder.getBeanDefinition();
+			BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator-"+element.getAttribute("factory"), new String[0]);
+			registerBeanDefinition(holder, parserContext.getRegistry());
+			services.add(definition);
+
+		}
+
+		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
+		services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
+		bean.addPropertyValue("serviceBeans", services);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.handlers b/odata2-spring/src/main/resources/META-INF/spring.handlers
new file mode 100755
index 0000000..6f63fc8
--- /dev/null
+++ b/odata2-spring/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1 @@
+http\://www.apache.org/olingo/odata2/spring/namespace=org.apache.olingo.odata2.spring.OlingoNamespaceHandler

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.schemas b/odata2-spring/src/main/resources/META-INF/spring.schemas
new file mode 100755
index 0000000..85b9a6d
--- /dev/null
+++ b/odata2-spring/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1 @@
+http\://www.apache.org/olingo/odata2/spring/namespace.xsd=schema/olingo.xsd

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/odata2-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/schema/olingo.xsd b/odata2-spring/src/main/resources/schema/olingo.xsd
new file mode 100755
index 0000000..2b160e9
--- /dev/null
+++ b/odata2-spring/src/main/resources/schema/olingo.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/namespace"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:beans="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+	targetNamespace="http://www.apache.org/olingo/odata2/spring/namespace"
+	elementFormDefault="unqualified">
+
+	<xsd:import namespace="http://www.springframework.org/schema/beans"
+				schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
+
+	<xsd:element name="server">
+		<xsd:complexType>
+			<xsd:complexContent>
+				<xsd:extension base="beans:identifiedType">
+					<xsd:attribute name="address" type="xsd:string" use="required"/>
+					<xsd:attribute name="factory" type="xsd:string" use="optional"/>
+				</xsd:extension>
+			</xsd:complexContent>
+		</xsd:complexType>
+	</xsd:element>
+</xsd:schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd98b32d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 67ae922..1c8875b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,7 @@
 		<module>odata2-annotation-processor</module>
 		<module>odata2-dist</module>
 		<module>odata2-sample</module>
+        	<module>odata2-spring</module>
 	</modules>
 
 	<build>


[05/11] olingo-odata2 git commit: [OLINGO-193] Reuse as much code as possible between the spring and non-spring root locators.

Posted by mi...@apache.org.
[OLINGO-193] Reuse as much code as possible between the spring and non-spring root locators.


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/a339d295
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/a339d295
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/a339d295

Branch: refs/heads/master
Commit: a339d2956d7dd892acd2f67893c1a608e796ad0e
Parents: fe1be5e
Author: Michael Bolz <mi...@sap.com>
Authored: Wed Nov 26 09:08:21 2014 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Nov 26 09:19:59 2014 +0100

----------------------------------------------------------------------
 .../odata2/core/rest/ODataRootLocator.java      | 92 +++++---------------
 .../core/rest/spring/ODataRootLocator.java      | 19 ++--
 .../spring/OlingoServerDefinitionParser.java    |  5 +-
 3 files changed, 30 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a339d295/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
index d9a91cc..64f9d4f 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/ODataRootLocator.java
@@ -18,24 +18,13 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.core.rest;
 
-import java.util.List;
-
 import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.HeaderParam;
 import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.UriInfo;
 
 import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
 import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication;
 
@@ -52,74 +41,37 @@ import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication;
  * 
  */
 @Path("/")
-public class ODataRootLocator {
+public class ODataRootLocator extends
+    org.apache.olingo.odata2.core.rest.spring.ODataRootLocator {
 
   @Context
-  private HttpHeaders httpHeaders;
-  @Context
-  private UriInfo uriInfo;
-  @Context
-  private Request request;
-  @Context
   private ServletConfig servletConfig;
-  @Context
-  private HttpServletRequest servletRequest;
-
-  @Context
-  private Application app;
-
-  /**
-   * Default root behavior which will delegate all paths to a ODataLocator.
-   * @param pathSegments URI path segments - all segments have to be OData
-   * @param xHttpMethod HTTP Header X-HTTP-Method for tunneling through POST
-   * @param xHttpMethodOverride HTTP Header X-HTTP-Method-Override for tunneling through POST
-   * @return a locator handling OData protocol
-   * @throws ODataException
-   * @throws ClassNotFoundException
-   * @throws IllegalAccessException
-   * @throws InstantiationException
-   */
-  @Path("/{pathSegments: .*}")
-  public Object handleRequest(
-      @Encoded @PathParam("pathSegments") final List<PathSegment> pathSegments,
-      @HeaderParam("X-HTTP-Method") final String xHttpMethod,
-      @HeaderParam("X-HTTP-Method-Override") final String xHttpMethodOverride)
-      throws ODataException, ClassNotFoundException, InstantiationException, IllegalAccessException {
-
-    if (xHttpMethod != null && xHttpMethodOverride != null) {
-
-      /*
-       * X-HTTP-Method-Override : implemented by CXF
-       * X-HTTP-Method : implemented in ODataSubLocator:handlePost
-       */
 
-      if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
-        throw new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD);
-      }
-    }
-
-    if (servletRequest.getPathInfo() == null) {
-      return handleRedirect();
-    }
+  @Override
+  public ODataServiceFactory getServiceFactory() {
+    return createServiceFactoryFromContext(app, servletRequest,
+        servletConfig);
+  }
 
-    ODataServiceFactory serviceFactory = createServiceFactoryFromContext(app, servletRequest, servletConfig);
+  @Override
+  public void setServiceFactory(ODataServiceFactory serviceFactory) {
+    // Don't do anything
+  }
 
+  @Override
+  public int getPathSplit() {
     int pathSplit = 0;
-    final String pathSplitAsString = servletConfig.getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
+    final String pathSplitAsString = servletConfig
+        .getInitParameter(ODataServiceFactory.PATH_SPLIT_LABEL);
     if (pathSplitAsString != null) {
       pathSplit = Integer.parseInt(pathSplitAsString);
     }
+    return pathSplit;
+  }
 
-    final SubLocatorParameter param = new SubLocatorParameter();
-    param.setServiceFactory(serviceFactory);
-    param.setPathSegments(pathSegments);
-    param.setHttpHeaders(httpHeaders);
-    param.setUriInfo(uriInfo);
-    param.setRequest(request);
-    param.setServletRequest(servletRequest);
-    param.setPathSplit(pathSplit);
-
-    return ODataSubLocator.create(param);
+  @Override
+  public void setPathSplit(int pathSplit) {
+    // Don't do anything
   }
 
   public static ODataServiceFactory createServiceFactoryFromContext(final Application app,
@@ -148,8 +100,4 @@ public class ODataRootLocator {
       throw new ODataRuntimeException("Exception during ODataServiceFactory creation occured.", e);
     }
   }
-
-  private Object handleRedirect() {
-    return new ODataRedirectLocator();
-  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a339d295/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
old mode 100755
new mode 100644
index 295dc9d..ea143e7
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/rest/spring/ODataRootLocator.java
@@ -20,7 +20,6 @@ package org.apache.olingo.odata2.core.rest.spring;
 
 import java.util.List;
 
-import javax.servlet.ServletConfig;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Encoded;
 import javax.ws.rs.HeaderParam;
@@ -62,12 +61,10 @@ public class ODataRootLocator {
   @Context
   private Request request;
   @Context
-  private ServletConfig servletConfig;
-  @Context
-  private HttpServletRequest servletRequest;
+  protected HttpServletRequest servletRequest;
 
   @Context
-  private Application app;
+  protected Application app;
 
   // These next two members are exposed so that they can be injected with Spring
   private ODataServiceFactory serviceFactory;
@@ -108,13 +105,13 @@ public class ODataRootLocator {
     }
 
     final SubLocatorParameter param = new SubLocatorParameter();
-    param.setServiceFactory(serviceFactory);
+    param.setServiceFactory(getServiceFactory());
     param.setPathSegments(pathSegments);
     param.setHttpHeaders(httpHeaders);
     param.setUriInfo(uriInfo);
     param.setRequest(request);
     param.setServletRequest(servletRequest);
-    param.setPathSplit(pathSplit);
+    param.setPathSplit(getPathSplit());
 
     return ODataSubLocator.create(param);
   }
@@ -124,18 +121,18 @@ public class ODataRootLocator {
   }
 
   public ODataServiceFactory getServiceFactory() {
-	return serviceFactory;
+    return serviceFactory;
   }
 
   public void setServiceFactory(ODataServiceFactory serviceFactory) {
-	this.serviceFactory = serviceFactory;
+    this.serviceFactory = serviceFactory;
   }
 
   public int getPathSplit() {
-	return pathSplit;
+    return pathSplit;
   }
 
   public void setPathSplit(int pathSplit) {
-	this.pathSplit = pathSplit;
+    this.pathSplit = pathSplit;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a339d295/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
index fdb6e18..a8e7f77 100755
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -71,9 +71,8 @@ public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefiniti
       builder.addPropertyValue("pathSplit", element.getAttribute("pathsplit"));
     }
     AbstractBeanDefinition definition = builder.getBeanDefinition();
-    BeanDefinitionHolder holder =
-        new BeanDefinitionHolder(definition, "OlingoODataRootLocator-" + element.getAttribute("id") + "-" + element.getAttribute("factory"),
-            new String[0]);
+    BeanDefinitionHolder holder = new BeanDefinitionHolder(definition,
+        "OlingoODataRootLocator-" + element.getAttribute("id") + "-" + element.getAttribute("factory"), new String[0]);
     registerBeanDefinition(holder, parserContext.getRegistry());
 
     ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);


[04/11] olingo-odata2 git commit: [OLINGO-193] Added unit tests

Posted by mi...@apache.org.
[OLINGO-193] Added unit tests

Signed-off-by: Michael Bolz <mi...@sap.com>


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/fe1be5e9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/fe1be5e9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/fe1be5e9

Branch: refs/heads/master
Commit: fe1be5e92ff3575b4192ae3b827cce1116ee3b71
Parents: ee07987
Author: Lior Okman <li...@sap.com>
Authored: Sun Nov 16 12:08:50 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Wed Nov 26 08:51:19 2014 +0100

----------------------------------------------------------------------
 odata2-spring/.springBeans                      | 26 ++++++++
 odata2-spring/pom.xml                           | 54 +++++++++++++--
 .../spring/OlingoServerDefinitionParser.java    | 33 ++++------
 .../src/main/resources/META-INF/spring.handlers |  2 +-
 .../src/main/resources/META-INF/spring.schemas  |  2 +-
 .../src/main/resources/schema/olingo.xsd        | 34 +++++-----
 .../spring/SpringNamespaceHandlerTest.java      | 69 ++++++++++++++++++++
 .../olingo/odata2/spring/TestFactory.java       | 39 +++++++++++
 .../resources/spring/applicationContext.xml     | 33 ++++++++++
 9 files changed, 246 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/.springBeans
----------------------------------------------------------------------
diff --git a/odata2-spring/.springBeans b/odata2-spring/.springBeans
new file mode 100755
index 0000000..f95fac8
--- /dev/null
+++ b/odata2-spring/.springBeans
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+     	license agreements. See the NOTICE file distributed with this work for additional
+	information regarding copyright ownership. The ASF licenses this file to
+	you under the Apache License, Version 2.0 (the "License"); you may not use
+	this file except in compliance with the License. You may obtain a copy of
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+	by applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+	OF ANY KIND, either express or implied. See the License for the specific
+	language governing permissions and limitations under the License. -->
+<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/test/resources/spring/applicationContext.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
index bf8f6a8..5183719 100755
--- a/odata2-spring/pom.xml
+++ b/odata2-spring/pom.xml
@@ -1,11 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
-    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
-    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
-    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
-    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
-    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
-    the License. -->
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+	license agreements. See the NOTICE file distributed with this work for additional
+	information regarding copyright ownership. The ASF licenses this file to
+	you under the Apache License, Version 2.0 (the "License"); you may not use
+	this file except in compliance with the License. You may obtain a copy of
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+	by applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+	OF ANY KIND, either express or implied. See the License for the specific
+	language governing permissions and limitations under the License. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
@@ -43,5 +46,42 @@
 			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
 			<version>${cxf.version}</version>
 		</dependency>
+
+		<!-- Test dependencies -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-context</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-web</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<version>2.5</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<version>1.1.3</version>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
index d4469a3..fdb6e18 100755
--- a/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
+++ b/odata2-spring/src/main/java/org/apache/olingo/odata2/spring/OlingoServerDefinitionParser.java
@@ -47,7 +47,6 @@ public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefiniti
   @Override
   protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder bean) {
     super.doParse(element, parserContext, bean);
-    ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
 
     if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataExceptionHandler")) {
       AbstractBeanDefinition definition =
@@ -65,28 +64,20 @@ public class OlingoServerDefinitionParser extends JAXRSServerFactoryBeanDefiniti
       registerBeanDefinition(holder, parserContext.getRegistry());
     }
 
-    if (!element.hasAttribute("factory")) {
-      if (!parserContext.getRegistry().containsBeanDefinition("OlingoODataRootLocator")) {
-        AbstractBeanDefinition definition =
-            BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class).getBeanDefinition();
-        definition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-        BeanDefinitionHolder holder = new BeanDefinitionHolder(definition, "OlingoODataRootLocator", new String[0]);
-        registerBeanDefinition(holder, parserContext.getRegistry());
-      }
-      services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataRootLocator"));
-    } else {
-      BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
-      builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
-      builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
-      AbstractBeanDefinition definition = builder.getBeanDefinition();
-      BeanDefinitionHolder holder =
-          new BeanDefinitionHolder(definition, "OlingoODataRootLocator-" + element.getAttribute("factory"),
-              new String[0]);
-      registerBeanDefinition(holder, parserContext.getRegistry());
-      services.add(definition);
-
+    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ODataRootLocator.class);
+    builder.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+    builder.addPropertyReference("serviceFactory", element.getAttribute("factory"));
+    if (element.hasAttribute("pathsplit")) {
+      builder.addPropertyValue("pathSplit", element.getAttribute("pathsplit"));
     }
+    AbstractBeanDefinition definition = builder.getBeanDefinition();
+    BeanDefinitionHolder holder =
+        new BeanDefinitionHolder(definition, "OlingoODataRootLocator-" + element.getAttribute("id") + "-" + element.getAttribute("factory"),
+            new String[0]);
+    registerBeanDefinition(holder, parserContext.getRegistry());
 
+    ManagedList<BeanDefinition> services = new ManagedList<BeanDefinition>(3);
+    services.add(definition);
     services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataExceptionHandler"));
     services.add(parserContext.getRegistry().getBeanDefinition("OlingoODataProvider"));
     bean.addPropertyValue("serviceBeans", services);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.handlers b/odata2-spring/src/main/resources/META-INF/spring.handlers
index 4b9c4c5..dadb52f 100755
--- a/odata2-spring/src/main/resources/META-INF/spring.handlers
+++ b/odata2-spring/src/main/resources/META-INF/spring.handlers
@@ -5,4 +5,4 @@
     in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
     ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
     the License. -->
-http\://www.apache.org/olingo/odata2/spring/namespace=org.apache.olingo.odata2.spring.OlingoNamespaceHandler
+http\://www.apache.org/olingo/odata2/spring/odata=org.apache.olingo.odata2.spring.OlingoNamespaceHandler

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/main/resources/META-INF/spring.schemas
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/META-INF/spring.schemas b/odata2-spring/src/main/resources/META-INF/spring.schemas
index f9ff528..1a2a280 100755
--- a/odata2-spring/src/main/resources/META-INF/spring.schemas
+++ b/odata2-spring/src/main/resources/META-INF/spring.schemas
@@ -5,4 +5,4 @@
     in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
     ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
     the License. -->
-http\://www.apache.org/olingo/odata2/spring/namespace.xsd=schema/olingo.xsd
+http\://www.apache.org/olingo/odata2/spring/odata.xsd=schema/olingo.xsd

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/main/resources/schema/olingo.xsd
----------------------------------------------------------------------
diff --git a/odata2-spring/src/main/resources/schema/olingo.xsd b/odata2-spring/src/main/resources/schema/olingo.xsd
index 6818687..39424dd 100755
--- a/odata2-spring/src/main/resources/schema/olingo.xsd
+++ b/odata2-spring/src/main/resources/schema/olingo.xsd
@@ -1,28 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
-    distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under
-    the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
-    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to
-    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
-    ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under
-    the License. -->
-<xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/namespace"
-	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	xmlns:beans="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
-	targetNamespace="http://www.apache.org/olingo/odata2/spring/namespace"
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+	license agreements. See the NOTICE file distributed with this work for additional
+	information regarding copyright ownership. The ASF licenses this file to
+	you under the Apache License, Version 2.0 (the "License"); you may not use
+	this file except in compliance with the License. You may obtain a copy of
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+	by applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+	OF ANY KIND, either express or implied. See the License for the specific
+	language governing permissions and limitations under the License. -->
+<xsd:schema xmlns="http://www.apache.org/olingo/odata2/spring/odata"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+	targetNamespace="http://www.apache.org/olingo/odata2/spring/odata"
 	elementFormDefault="unqualified">
 
 	<xsd:import namespace="http://www.springframework.org/schema/beans"
-				schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd"/>
+		schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd" />
 
 	<xsd:element name="server">
 		<xsd:complexType>
 			<xsd:complexContent>
 				<xsd:extension base="beans:identifiedType">
-					<xsd:attribute name="address" type="xsd:string" use="required"/>
-					<xsd:attribute name="factory" type="xsd:string" use="optional"/>
+					<xsd:attribute name="address" type="xsd:string" use="required" />
+					<xsd:attribute name="factory" type="xsd:string" use="required" />
+					<xsd:attribute name="pathsplit" type="xsd:int" use="optional" />
 				</xsd:extension>
 			</xsd:complexContent>
 		</xsd:complexType>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
new file mode 100755
index 0000000..81a2372
--- /dev/null
+++ b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/SpringNamespaceHandlerTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.spring;
+
+import static org.junit.Assert.*;
+
+import org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser.SpringJAXRSServerFactoryBean;
+import org.apache.olingo.odata2.core.rest.ODataExceptionMapperImpl;
+import org.apache.olingo.odata2.core.rest.app.ODataApplication;
+import org.apache.olingo.odata2.core.rest.spring.ODataRootLocator;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath:spring/applicationContext.xml")
+@WebAppConfiguration
+public class SpringNamespaceHandlerTest {
+
+  @Autowired
+  private ApplicationContext appCtx;
+
+  @Test
+  public void testSuccessfullyCreated() {
+    assertTrue(appCtx.containsBean("testServer"));
+
+    assertTrue(appCtx.containsBean("OlingoODataExceptionHandler"));
+    assertTrue(appCtx.containsBean("OlingoODataProvider"));
+
+    assertEquals(ODataExceptionMapperImpl.class, appCtx.getType("OlingoODataExceptionHandler"));
+    assertEquals(ODataApplication.MyProvider.class, appCtx.getType("OlingoODataProvider"));
+
+    String rootLocatorName = "OlingoODataRootLocator-testServer-serviceFactory";
+    assertTrue(appCtx.containsBean(rootLocatorName));
+    assertEquals(ODataRootLocator.class, appCtx.getType(rootLocatorName));
+
+    SpringJAXRSServerFactoryBean server = appCtx.getBean("testServer", SpringJAXRSServerFactoryBean.class);
+    assertEquals("/service.svc", server.getAddress());
+  }
+
+  @Test
+  public void testCorrectFactoryAndPathSplit() {
+    String rootLocatorName = "OlingoODataRootLocator-testServer-serviceFactory";
+    ODataRootLocator rootLocator = appCtx.getBean(rootLocatorName, ODataRootLocator.class);
+    assertNotNull(rootLocator.getServiceFactory());
+    assertSame(appCtx.getBean("serviceFactory"), rootLocator.getServiceFactory());
+    assertEquals(3, rootLocator.getPathSplit());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/TestFactory.java
----------------------------------------------------------------------
diff --git a/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/TestFactory.java b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/TestFactory.java
new file mode 100755
index 0000000..746a03b
--- /dev/null
+++ b/odata2-spring/src/test/java/org/apache/olingo/odata2/spring/TestFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.spring;
+
+import org.apache.olingo.odata2.api.ODataService;
+import org.apache.olingo.odata2.api.ODataServiceFactory;
+import org.apache.olingo.odata2.api.exception.ODataException;
+import org.apache.olingo.odata2.api.processor.ODataContext;
+
+/**
+ * Empty service factory, to be used for testing that the namespace handler and server definition
+ * parser work correctly.
+ *
+ * @author Lior Okman <li...@sap.com>
+ */
+public class TestFactory extends ODataServiceFactory {
+
+  @Override
+  public ODataService createService(ODataContext ctx) throws ODataException {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fe1be5e9/odata2-spring/src/test/resources/spring/applicationContext.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/src/test/resources/spring/applicationContext.xml b/odata2-spring/src/test/resources/spring/applicationContext.xml
new file mode 100755
index 0000000..567c8da
--- /dev/null
+++ b/odata2-spring/src/test/resources/spring/applicationContext.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
+	license agreements. See the NOTICE file distributed with this work for additional
+	information regarding copyright ownership. The ASF licenses this file to
+	you under the Apache License, Version 2.0 (the "License"); you may not use
+	this file except in compliance with the License. You may obtain a copy of
+	the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+	by applicable law or agreed to in writing, software distributed under the
+	License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+	OF ANY KIND, either express or implied. See the License for the specific
+	language governing permissions and limitations under the License. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:odata="http://www.apache.org/olingo/odata2/spring/odata"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.apache.org/olingo/odata2/spring/odata http://www.apache.org/olingo/odata2/spring/odata.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+
+	<!-- Make @Autowire work -->
+	<context:annotation-config />
+
+	<!-- Register the test factory -->
+	<bean id="serviceFactory" class="org.apache.olingo.odata2.spring.TestFactory" />
+
+	<!-- This is what is actually being tested -->
+	<odata:server id="testServer" address="/service.svc" factory="serviceFactory" pathsplit="3"/>
+
+	<!-- In order to be useful in a real environment, Apache CXF needs to be configured correctly as well.
+	     This context file doesn't handle this, since the unit test only tests that the namespace handler
+	     works
+	-->
+</beans>