You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/05/12 15:17:13 UTC
[16/40] git commit: [OLINGO-266] initial reference scenario servlet
[OLINGO-266] initial reference scenario servlet
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/54aef886
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/54aef886
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/54aef886
Branch: refs/heads/master
Commit: 54aef8866493a4b6cfeca07ca1fd1f85681f25fb
Parents: 554c795
Author: Stephan Klevenz <st...@sap.com>
Authored: Fri May 9 14:22:51 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Fri May 9 14:22:51 2014 +0200
----------------------------------------------------------------------
lib/ref/pom.xml | 10 ++++-
.../org/apache/olingo/ref/ReferenceServlet.java | 42 +++++++++++++++++++
.../src/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 | 44 +++++++++++---------
.../apache/olingo/server/api/ODataServer.java | 5 +++
lib/server-core/pom.xml | 36 ++++++++--------
.../olingo/server/core/ODataServerImpl.java | 16 +++++++
9 files changed, 208 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/pom.xml
----------------------------------------------------------------------
diff --git a/lib/ref/pom.xml b/lib/ref/pom.xml
index fe1da60..76ea188 100644
--- a/lib/ref/pom.xml
+++ b/lib/ref/pom.xml
@@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>olingo-ref</artifactId>
- <packaging>jar</packaging>
+ <packaging>war</packaging>
<name>${project.artifactId}</name>
<parent>
@@ -36,6 +36,13 @@
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-server-api</artifactId>
<version>${project.version}</version>
@@ -55,7 +62,6 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
-
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/java/org/apache/olingo/ref/ReferenceServlet.java
----------------------------------------------------------------------
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 0000000..a3d30ee
--- /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);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/resources/simplelogger.properties b/lib/ref/src/main/resources/simplelogger.properties
new file mode 100644
index 0000000..2a3350c
--- /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
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
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 0000000..cc7de77
--- /dev/null
+++ b/lib/ref/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+
+ <display-name>Apache Olingo OData 4.0 Reference Scenario Service</display-name>
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+ <servlet>
+ <servlet-name>ODataServlet</servlet-name>
+ <servlet-class>org.apache.olingo.ref.ReferenceServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ODataServlet</servlet-name>
+ <url-pattern>/odata.svc/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/ref/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/lib/ref/src/main/webapp/index.html b/lib/ref/src/main/webapp/index.html
new file mode 100644
index 0000000..e25f4fb
--- /dev/null
+++ b/lib/ref/src/main/webapp/index.html
@@ -0,0 +1,32 @@
+<html>
+<!--
+ 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.
+-->
+
+<body>
+ <h1>Olingo OData 4.0 Reference Scenario Service</h1>
+ <hr>
+ <h2>Reference Scenario Service</h2>
+ <lu>
+ <li><a href="odata.svc/">Service Document</a></li>
+ <li><a href="odata.svc/$metadata">Metadata</a></li>
+ </lu>
+
+</body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml
index b0bdda3..3d8fa87 100644
--- a/lib/server-api/pom.xml
+++ b/lib/server-api/pom.xml
@@ -1,26 +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.
+ 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">
+ 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>olingo-server-api</artifactId>
@@ -33,13 +33,19 @@
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
-
+
<dependencies>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-commons-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
+
</project>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataServer.java
----------------------------------------------------------------------
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 a657392..7390189 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);
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-core/pom.xml
----------------------------------------------------------------------
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 28693fc..bc7ae71 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -1,26 +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
+ 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
+ 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.
+ 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">
+ 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>olingo-server-core</artifactId>
@@ -45,7 +45,7 @@
<artifactId>olingo-commons-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
@@ -97,8 +97,8 @@
<!--<arguments><argument>-atn</argument></arguments> -->
<listener>true</listener>
<visitor>true</visitor>
- <!--maven antlr plugin has trouble with grammer import if the grammerfiles
- are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
+ <!--maven antlr plugin has trouble with grammer import if the grammerfiles
+ are not directly inside src/main/antlr4, hence we have to set the libDirectory -->
<libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/54aef886/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataServerImpl.java
----------------------------------------------------------------------
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 7beb90d..933422d 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);
+ }
+
+ }
+
}