From 54aef8866493a4b6cfeca07ca1fd1f85681f25fb Mon Sep 17 00:00:00 2001 From: Stephan Klevenz Date: Fri, 9 May 2014 14:22:51 +0200 Subject: [PATCH] [OLINGO-266] initial reference scenario servlet --- lib/ref/pom.xml | 10 ++++- .../apache/olingo/ref/ReferenceServlet.java | 42 +++++++++++++++++++ .../main/resources/simplelogger.properties | 20 +++++++++ lib/ref/src/main/webapp/WEB-INF/web.xml | 42 +++++++++++++++++++ lib/ref/src/main/webapp/index.html | 32 ++++++++++++++ lib/server-api/pom.xml | 40 ++++++++++-------- .../apache/olingo/server/api/ODataServer.java | 5 +++ lib/server-core/pom.xml | 36 ++++++++-------- .../olingo/server/core/ODataServerImpl.java | 16 +++++++ 9 files changed, 206 insertions(+), 37 deletions(-) create mode 100644 lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java create mode 100644 lib/ref/src/main/resources/simplelogger.properties create mode 100644 lib/ref/src/main/webapp/WEB-INF/web.xml create mode 100644 lib/ref/src/main/webapp/index.html diff --git a/lib/ref/pom.xml b/lib/ref/pom.xml index fe1da602c..76ea18874 100644 --- a/lib/ref/pom.xml +++ b/lib/ref/pom.xml @@ -24,7 +24,7 @@ 4.0.0 olingo-ref - jar + war ${project.artifactId} @@ -35,6 +35,13 @@ + + javax.servlet + servlet-api + 2.5 + provided + + org.apache.olingo olingo-server-api @@ -55,7 +62,6 @@ org.mockito mockito-all - diff --git a/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java b/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java new file mode 100644 index 000000000..a3d30ee66 --- /dev/null +++ b/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java @@ -0,0 +1,42 @@ +/* + * 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.ref; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.olingo.server.api.ODataServer; + +public class ReferenceServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + ODataServer server = ODataServer.newInstance(); + server.handle(req, resp); + + } + +} diff --git a/lib/ref/src/main/resources/simplelogger.properties b/lib/ref/src/main/resources/simplelogger.properties new file mode 100644 index 000000000..2a3350c78 --- /dev/null +++ b/lib/ref/src/main/resources/simplelogger.properties @@ -0,0 +1,20 @@ +# +# 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. +# +org.slf4j.simpleLogger.defaultLogLevel=debug +org.slf4j.simpleLogger.logFile=System.out \ No newline at end of file diff --git a/lib/ref/src/main/webapp/WEB-INF/web.xml b/lib/ref/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 000000000..cc7de77e3 --- /dev/null +++ b/lib/ref/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + Apache Olingo OData 4.0 Reference Scenario Service + + + index.html + + + + ODataServlet + org.apache.olingo.ref.ReferenceServlet + 1 + + + + ODataServlet + /odata.svc/* + + + diff --git a/lib/ref/src/main/webapp/index.html b/lib/ref/src/main/webapp/index.html new file mode 100644 index 000000000..e25f4fb6e --- /dev/null +++ b/lib/ref/src/main/webapp/index.html @@ -0,0 +1,32 @@ + + + + +

Olingo OData 4.0 Reference Scenario Service

+
+

Reference Scenario Service

+ +
  • Service Document
  • +
  • Metadata
  • +
    + + + + \ No newline at end of file diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml index b0bdda339..3d8fa8788 100644 --- a/lib/server-api/pom.xml +++ b/lib/server-api/pom.xml @@ -1,26 +1,26 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 olingo-server-api @@ -33,13 +33,19 @@ 0.1.0-SNAPSHOT .. - + org.apache.olingo olingo-commons-api ${project.version} + + javax.servlet + servlet-api + 2.5 + provided + - + diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java index a657392dc..739018912 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java @@ -18,6 +18,9 @@ */ package org.apache.olingo.server.api; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.server.api.serializer.ODataFormat; import org.apache.olingo.server.api.serializer.ODataSerializer; @@ -45,4 +48,6 @@ public abstract class ODataServer { public abstract ODataSerializer getSerializer(ODataFormat format); + public abstract void handle(HttpServletRequest req, HttpServletResponse resp); + } diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml index 28693fc66..bc7ae718f 100644 --- a/lib/server-core/pom.xml +++ b/lib/server-core/pom.xml @@ -1,26 +1,26 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 olingo-server-core @@ -45,7 +45,7 @@ olingo-commons-core ${project.version} - + javax.servlet javax.servlet-api ${servlet.version} @@ -97,8 +97,8 @@ true true - + src/main/antlr4/org/apache/olingo/server/core/uri/antlr diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java index 7beb90dad..933422d81 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java @@ -18,6 +18,11 @@ */ package org.apache.olingo.server.core; +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.server.api.ODataServer; import org.apache.olingo.server.api.serializer.ODataFormat; @@ -44,4 +49,15 @@ public class ODataServerImpl extends ODataServer { return serializer; } + @Override + public void handle(HttpServletRequest req, HttpServletResponse resp) { + + try { + resp.getWriter().print("Hello World!"); + } catch (IOException e) { + throw new ODataRuntimeException(e); + } + + } + }