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/06/26 09:31:40 UTC

olingo-odata4 git commit: [OLINGO-708] Improvements

Repository: olingo-odata4
Updated Branches:
  refs/heads/OLINGO-708_AsyncSupportTec 3a736368e -> 06d508d39


[OLINGO-708] Improvements


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

Branch: refs/heads/OLINGO-708_AsyncSupportTec
Commit: 06d508d395d3f82010cc797bd416afd18a33be4c
Parents: 3a73636
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 26 09:12:52 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 26 09:31:33 2015 +0200

----------------------------------------------------------------------
 .../olingo/fit/AbstractBaseTestITCase.java      |   8 +-
 .../fit/tecsvc/client/AsyncSupportITCase.java   |  97 ++++++++++
 .../server/tecsvc/async/AsyncProcessor.java     | 176 +++++++++++++++++
 .../tecsvc/async/TechnicalAsyncService.java     | 189 +------------------
 .../async/TechnicalStatusMonitorServlet.java    |  67 +++++++
 .../processor/TechnicalEntityProcessor.java     |   9 +-
 .../src/main/webapp/WEB-INF/web.xml             |  11 ++
 7 files changed, 367 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index f7d49a1..6123bb6 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -39,6 +39,7 @@ import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.fit.server.TomcatTestServer;
 import org.apache.olingo.server.tecsvc.TechnicalServlet;
+import org.apache.olingo.server.tecsvc.async.TechnicalStatusMonitorServlet;
 import org.junit.BeforeClass;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,9 +57,10 @@ public abstract class AbstractBaseTestITCase {
   public static void init()
       throws LifecycleException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
     TomcatTestServer.init(9080)
-    .addServlet(TechnicalServlet.class, "/odata-server-tecsvc/odata.svc/*")
-    .addServlet(StaticContent.create("org-odata-core-v1.xml"),
-        "/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml")
+      .addServlet(TechnicalServlet.class, "/odata-server-tecsvc/odata.svc/*")
+      .addServlet(TechnicalStatusMonitorServlet.class, "/odata-server-tecsvc/status/*")
+      .addServlet(StaticContent.create("org-odata-core-v1.xml"),
+                  "/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml")
         .addWebApp(false)
         .start();
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
new file mode 100644
index 0000000..c40ff85
--- /dev/null
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/AsyncSupportITCase.java
@@ -0,0 +1,97 @@
+/*
+ * 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.fit.tecsvc.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.communication.request.ODataRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
+import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
+import org.apache.olingo.client.api.communication.response.ODataResponse;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.domain.ClientEntity;
+import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.client.core.communication.request.AsyncRequestWrapperImpl;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.fit.AbstractBaseTestITCase;
+import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.apache.olingo.server.tecsvc.async.TechnicalAsyncService;
+import org.junit.Test;
+
+public final class AsyncSupportITCase extends AbstractBaseTestITCase {
+  private static final String ES_ALL_PRIM = "ESAllPrim";
+  private static final String SERVICE_URI = TecSvcConst.BASE_URI;
+
+  @Test
+  public void testSimple() throws Exception {
+    ODataClient client = getClient();
+    URI uri = client.newURIBuilder(SERVICE_URI)
+        .appendEntitySetSegment(ES_ALL_PRIM)
+        .appendKeySegment(32767).build();
+
+    //
+    final ODataRetrieveResponse<ClientEntity> response = getClient().getRetrieveRequestFactory()
+        .getEntityRequest(uri).execute();
+    assertEquals(32767, response.getBody().getProperty("PropertyInt16").getPrimitiveValue().toValue());
+    assertEquals(200, response.getStatusCode());
+
+    // first async request
+    ODataRequest re1 = getClient().getRetrieveRequestFactory()
+            .getEntityRequest(uri)
+            .addCustomHeader("Prefer", "respond-async, " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
+    AsyncResponseWrapper<ODataResponse> first = client.getAsyncRequestFactory().getAsyncRequestWrapper(re1).execute();
+
+    assertTrue(first.isPreferenceApplied());
+
+    // second async request
+    ODataRequest re2 = getClient().getRetrieveRequestFactory()
+            .getEntityRequest(uri)
+            .addCustomHeader("Prefer", "respond-async, " + TechnicalAsyncService.TEC_ASYNC_SLEEP + "=1");
+    AsyncResponseWrapper<ODataResponse> second = client.getAsyncRequestFactory().getAsyncRequestWrapper(re2).execute();
+    assertTrue(second.isPreferenceApplied());
+
+    // get result of first async request
+    assertFalse(first.isDone());
+
+//    TimeUnit.SECONDS.sleep(2);
+//    assertTrue(first.isDone());
+
+//    assertNotNull(first.getODataResponse());
+//    final ODataRetrieveResponse<ClientEntity> firstAsyncResult = getClient().getRetrieveRequestFactory()
+//        .getEntityRequest(respLocationFirstUri).execute();
+//    assertEquals(32767, firstAsyncResult.getBody().getProperty("PropertyInt16").getPrimitiveValue().toValue());
+//    assertEquals(200, firstAsyncResult.getStatusCode());
+  }
+
+  @Override
+  protected ODataClient getClient() {
+    ODataClient odata = ODataClientFactory.getClient();
+    odata.getConfiguration().setDefaultPubFormat(ContentType.JSON);
+    return odata;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/AsyncProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/AsyncProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/AsyncProcessor.java
new file mode 100644
index 0000000..5386a20
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/AsyncProcessor.java
@@ -0,0 +1,176 @@
+/*
+ * 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.server.tecsvc.async;
+
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataLibraryException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.processor.Processor;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class AsyncProcessor<T extends Processor> {
+    private final MyInvocationHandler handler;
+    private final TechnicalAsyncService service;
+    private final T proxyProcessor;
+    private String location;
+    private String preferHeader;
+
+  private static class MyInvocationHandler implements InvocationHandler {
+    private final Object wrappedInstance;
+    private Method invokeMethod;
+    private Object[] invokeParameters;
+
+    public MyInvocationHandler(Object wrappedInstance) {
+      this.wrappedInstance = wrappedInstance;
+    }
+
+    @Override
+    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
+      if(Processor.class.isAssignableFrom(method.getDeclaringClass())) {
+        invokeMethod = method;
+        invokeParameters = objects;
+      }
+
+      return null;
+    }
+
+    ODataResponse processResponse;
+
+    public Object process() throws InvocationTargetException, IllegalAccessException {
+      processResponse = new ODataResponse();
+      replaceInvokeParameter(processResponse);
+      return invokeMethod.invoke(wrappedInstance, invokeParameters);
+    }
+
+    public Object[] getInvokeParameters() {
+      return invokeParameters;
+    }
+
+    public <P> void replaceInvokeParameter(P replacement) {
+      if(replacement == null) {
+        return;
+      }
+
+      List<Object> copy = new ArrayList<Object>();
+      for (Object parameter : invokeParameters) {
+        if (replacement.getClass() == parameter.getClass()) {
+          copy.add(replacement);
+        } else {
+          copy.add(parameter);
+        }
+      }
+      invokeParameters = copy.toArray();
+    }
+
+
+    public ODataResponse getProcessResponse() {
+      return processResponse;
+    }
+  }
+
+
+  public AsyncProcessor(T processor, Class<T> processorInterface, TechnicalAsyncService service) {
+      Class<? extends Processor> aClass = processor.getClass();
+      Class[] interfaces = aClass.getInterfaces();
+      handler = new MyInvocationHandler(processor);
+      Object proxyInstance = Proxy.newProxyInstance(aClass.getClassLoader(), interfaces, handler);
+      proxyProcessor = processorInterface.cast(proxyInstance);
+      this.service = service;
+    }
+
+    public T prepareFor() {
+      return proxyProcessor;
+    }
+
+    public ODataRequest getRequest() {
+      return getParameter(ODataRequest.class);
+    }
+
+    public ODataResponse getResponse() {
+      return getParameter(ODataResponse.class);
+    }
+
+    public ODataResponse getProcessResponse() {
+      return handler.getProcessResponse();
+    }
+
+    private <P> P getParameter(Class<P> parameterClass) {
+      for (Object parameter : handler.getInvokeParameters()) {
+        if (parameter != null && parameterClass == parameter.getClass()) {
+          return parameterClass.cast(parameter);
+        }
+      }
+      return null;
+    }
+
+    public String processAsync() throws ODataApplicationException, ODataLibraryException {
+      preferHeader = getRequest().getHeader(HttpHeader.PREFER);
+      ODataRequest request = copyRequest(getRequest());
+      handler.replaceInvokeParameter(request);
+      handler.replaceInvokeParameter(new ODataResponse());
+      return service.processAsynchronous(this);
+    }
+
+    Object process() throws InvocationTargetException, IllegalAccessException {
+      return handler.process();
+    }
+
+    private ODataRequest copyRequest(ODataRequest request) {
+      ODataRequest req = new ODataRequest();
+      req.setBody(request.getBody());
+      req.setMethod(request.getMethod());
+      req.setRawBaseUri(request.getRawBaseUri());
+      req.setRawODataPath(request.getRawODataPath());
+      req.setRawQueryPath(request.getRawQueryPath());
+      req.setRawRequestUri(request.getRawRequestUri());
+      req.setRawServiceResolutionUri(request.getRawServiceResolutionUri());
+
+      for (Map.Entry<String, List<String>> header : request.getAllHeaders().entrySet()) {
+        if(HttpHeader.PREFER.toLowerCase().equals(
+                header.getKey().toLowerCase())) {
+          preferHeader = header.getValue().get(0);
+        } else {
+          req.addHeader(header.getKey(), header.getValue());
+        }
+      }
+
+      return req;
+    }
+
+    public String getPreferHeader() {
+      return preferHeader;
+    }
+
+    public String getLocation() {
+      return location;
+    }
+
+    void setLocation(String loc) {
+      this.location = loc;
+    }
+  }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
index 5f3fb10..26d426b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalAsyncService.java
@@ -22,15 +22,8 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -59,157 +52,9 @@ public class TechnicalAsyncService {
       Collections.synchronizedMap(new HashMap<String, AsyncRunner>());
   private static final ExecutorService ASYNC_REQUEST_EXECUTOR = Executors.newFixedThreadPool(10);
   private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
-  public static final String STATUS_MONITOR_TOKEN = "async";
+  public static final String STATUS_MONITOR_TOKEN = "status";
 
-  private static class MyInvocationHandler implements InvocationHandler {
-    private final Object wrappedInstance;
-    private Method invokeMethod;
-    private Object[] invokeParameters;
 
-    public MyInvocationHandler(Object wrappedInstance) {
-      this.wrappedInstance = wrappedInstance;
-    }
-
-    @Override
-    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
-      if(Processor.class.isAssignableFrom(method.getDeclaringClass())) {
-        invokeMethod = method;
-        invokeParameters = objects;
-      }
-
-      return null;
-    }
-
-    ODataResponse processResponse;
-
-    public Object process() throws InvocationTargetException, IllegalAccessException {
-      processResponse = new ODataResponse();
-      replaceInvokeParameter(processResponse);
-      return invokeMethod.invoke(wrappedInstance, invokeParameters);
-    }
-
-    public Object[] getInvokeParameters() {
-      return invokeParameters;
-    }
-
-    public <P> void replaceInvokeParameter(P replacement) {
-      if(replacement == null) {
-        return;
-      }
-
-      List<Object> copy = new ArrayList<Object>();
-      for (Object parameter : invokeParameters) {
-        if (replacement.getClass() == parameter.getClass()) {
-          copy.add(replacement);
-        } else {
-          copy.add(parameter);
-        }
-      }
-      invokeParameters = copy.toArray();
-    }
-
-    private <P> P getParameter(Class<P> parameterClass) {
-      for (Object parameter : invokeParameters) {
-        if (parameter != null && parameterClass == parameter.getClass()) {
-          return parameterClass.cast(parameter);
-        }
-      }
-      return null;
-    }
-
-    public ODataResponse getProcessResponse() {
-      return processResponse;
-    }
-  }
-
-  public class AsyncProcessor<T extends Processor> {
-    private final MyInvocationHandler handler;
-    private final TechnicalAsyncService service;
-    private final Object proxyInstance;
-    private final T proxyProcessor;
-    private String location;
-    private String preferHeader;
-
-    public AsyncProcessor(T processor, Class<T> processorInterface, TechnicalAsyncService service) {
-      Class<? extends Processor> aClass = processor.getClass();
-      Class[] interfaces = aClass.getInterfaces();
-      handler = new MyInvocationHandler(processor);
-      proxyInstance = Proxy.newProxyInstance(aClass.getClassLoader(), interfaces, handler);
-      proxyProcessor = processorInterface.cast(proxyInstance);
-      this.service = service;
-    }
-
-    public T prepareFor() {
-      return proxyProcessor;
-    }
-
-    public ODataRequest getRequest() {
-      return getParameter(ODataRequest.class);
-    }
-
-    public ODataResponse getResponse() {
-      return getParameter(ODataResponse.class);
-    }
-
-    public ODataResponse getProcessResponse() {
-      return handler.getProcessResponse();
-    }
-
-    private <P> P getParameter(Class<P> parameterClass) {
-      for (Object parameter : handler.getInvokeParameters()) {
-        if (parameter != null && parameterClass == parameter.getClass()) {
-          return parameterClass.cast(parameter);
-        }
-      }
-      return null;
-    }
-
-    public String processAsync() throws ODataApplicationException, ODataLibraryException {
-      preferHeader = getRequest().getHeader(HttpHeader.PREFER);
-      ODataRequest request = copyRequest(getRequest());
-      handler.replaceInvokeParameter(request);
-      handler.replaceInvokeParameter(new ODataResponse());
-      return service.processAsynchronous(this);
-    }
-
-    private Object process() throws InvocationTargetException, IllegalAccessException {
-      return handler.process();
-    }
-
-    private ODataRequest copyRequest(ODataRequest request) {
-      ODataRequest req = new ODataRequest();
-      req.setBody(request.getBody());
-      req.setMethod(request.getMethod());
-      req.setRawBaseUri(request.getRawBaseUri());
-      req.setRawODataPath(request.getRawODataPath());
-      req.setRawQueryPath(request.getRawQueryPath());
-      req.setRawRequestUri(request.getRawRequestUri());
-      req.setRawServiceResolutionUri(request.getRawServiceResolutionUri());
-
-      for (Map.Entry<String, List<String>> header : request.getAllHeaders().entrySet()) {
-        if(HttpHeader.PREFER.toLowerCase().equals(
-                header.getKey().toLowerCase())) {
-          preferHeader = header.getValue().get(0);
-        } else {
-          req.addHeader(header.getKey(), header.getValue());
-        }
-      }
-
-      return req;
-    }
-
-    public String getPreferHeader() {
-      return preferHeader;
-    }
-
-    public String getLocation() {
-      return location;
-    }
-
-    private void setLocation(String loc) {
-      this.location = loc;
-    }
-  }
 
 
   public <T extends Processor> AsyncProcessor<T> register(T processor, Class<T> processorInterface) {
@@ -230,10 +75,10 @@ public class TechnicalAsyncService {
   }
 
   public boolean isStatusMonitorResource(HttpServletRequest request) {
-    return request.getRequestURI() != null && request.getRequestURI().contains(STATUS_MONITOR_TOKEN);
+    return request.getRequestURL() != null && request.getRequestURL().toString().contains(STATUS_MONITOR_TOKEN);
   }
 
-  private String processAsynchronous(AsyncProcessor dispatchedProcessor)
+  String processAsynchronous(AsyncProcessor dispatchedProcessor)
       throws ODataApplicationException, ODataLibraryException {
     // use executor thread pool
     String location = createNewAsyncLocation(dispatchedProcessor.getRequest());
@@ -245,16 +90,6 @@ public class TechnicalAsyncService {
     return location;
   }
 
-  public void status(ODataRequest request, ODataResponse response)
-          throws ODataApplicationException, ODataLibraryException {
-
-  }
-
-  public void cancel(ODataRequest request, ODataResponse response)
-          throws ODataApplicationException, ODataLibraryException {
-
-  }
-
   public void handle(HttpServletRequest request, HttpServletResponse response) {
     String location = getAsyncLocation(request);
     AsyncRunner runner = LOCATION_2_ASYNC_RUNNER.get(location);
@@ -325,23 +160,12 @@ public class TechnicalAsyncService {
 
 
   private String createNewAsyncLocation(ODataRequest request) {
-    return request.getRawBaseUri() + "/" + STATUS_MONITOR_TOKEN + request.getRawODataPath() +
-            "?" + STATUS_MONITOR_TOKEN + "=" + ID_GENERATOR.incrementAndGet();
+    int pos = request.getRawBaseUri().lastIndexOf("/") + 1;
+    return request.getRawBaseUri().substring(0, pos) + STATUS_MONITOR_TOKEN + "/" + ID_GENERATOR.incrementAndGet();
   }
 
   private String getAsyncLocation(HttpServletRequest request) {
-    return "http://localhost:8080" + request.getRequestURI() + "?" + request.getQueryString();
-  }
-
-  private String getAsyncQueryPart(ODataRequest request) {
-    String rawQueryPath = request.getRawQueryPath();
-    if(rawQueryPath != null) {
-      Matcher m = Pattern.compile("(" + STATUS_MONITOR_TOKEN + "=\\d*)").matcher(rawQueryPath);
-      if(m.find()) {
-        return m.group();
-      }
-    }
-    return "";
+    return request.getRequestURL().toString();
   }
 
   private static class AsyncRunner implements Runnable {
@@ -374,7 +198,6 @@ public class TechnicalAsyncService {
     }
 
     private int getSleepTime(AsyncProcessor wrap) {
-//      String preferHeader = wrap.getRequest().getHeader(HttpHeader.PREFER);
       String preferHeader = wrap.getPreferHeader();
       Matcher matcher = Pattern.compile("(" + TEC_ASYNC_SLEEP +
               "=)(\\d*)").matcher(preferHeader);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalStatusMonitorServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalStatusMonitorServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalStatusMonitorServlet.java
new file mode 100644
index 0000000..262ad65
--- /dev/null
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/async/TechnicalStatusMonitorServlet.java
@@ -0,0 +1,67 @@
+/*
+ * 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.server.tecsvc.async;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+import org.apache.olingo.server.tecsvc.ETagSupport;
+import org.apache.olingo.server.tecsvc.MetadataETagSupport;
+import org.apache.olingo.server.tecsvc.data.DataProvider;
+import org.apache.olingo.server.tecsvc.processor.TechnicalActionProcessor;
+import org.apache.olingo.server.tecsvc.processor.TechnicalBatchProcessor;
+import org.apache.olingo.server.tecsvc.processor.TechnicalEntityProcessor;
+import org.apache.olingo.server.tecsvc.processor.TechnicalPrimitiveComplexProcessor;
+import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TechnicalStatusMonitorServlet extends HttpServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final Logger LOG = LoggerFactory.getLogger(TechnicalStatusMonitorServlet.class);
+
+  @Override
+  protected void service(final HttpServletRequest request, final HttpServletResponse response)
+      throws ServletException, IOException {
+    try {
+      if(TechnicalAsyncService.getInstance().isStatusMonitorResource(request)) {
+        TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
+        asyncService.handle(request, response);
+      }
+    } catch (final RuntimeException e) {
+      LOG.error("Server Error", e);
+      throw new ServletException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
index de332c1..60d7538 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalEntityProcessor.java
@@ -60,6 +60,7 @@ import org.apache.olingo.server.api.uri.queryoption.CountOption;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.IdOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
+import org.apache.olingo.server.tecsvc.async.AsyncProcessor;
 import org.apache.olingo.server.tecsvc.async.TechnicalAsyncService;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
 import org.apache.olingo.server.tecsvc.data.RequestValidator;
@@ -150,13 +151,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
       TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
       processor.init(odata, serviceMetadata);
-      TechnicalAsyncService.AsyncProcessor<EntityProcessor> asyncProcessor =
-              asyncService.register(processor, EntityProcessor.class);
+      AsyncProcessor<EntityProcessor> asyncProcessor = asyncService.register(processor, EntityProcessor.class);
       asyncProcessor.prepareFor().createEntity(request, response, uriInfo, requestFormat, responseFormat);
       String location = asyncProcessor.processAsync();
       //
       response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
       response.setHeader(HttpHeader.LOCATION, location);
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED, "respond-async");
       //
       return;
     }
@@ -402,13 +403,13 @@ public class TechnicalEntityProcessor extends TechnicalProcessor
       TechnicalAsyncService asyncService = TechnicalAsyncService.getInstance();
       TechnicalEntityProcessor processor = new TechnicalEntityProcessor(dataProvider, serviceMetadata);
       processor.init(odata, serviceMetadata);
-      TechnicalAsyncService.AsyncProcessor<EntityProcessor> asyncProcessor =
-              asyncService.register(processor, EntityProcessor.class);
+      AsyncProcessor<EntityProcessor> asyncProcessor = asyncService.register(processor, EntityProcessor.class);
       asyncProcessor.prepareFor().readEntity(request, response, uriInfo, requestedFormat);
       String location = asyncProcessor.processAsync();
       //
       response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
       response.setHeader(HttpHeader.LOCATION, location);
+      response.setHeader(HttpHeader.PREFERENCE_APPLIED, "respond-async");
       //
       return;
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/06d508d3/lib/server-tecsvc/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/webapp/WEB-INF/web.xml b/lib/server-tecsvc/src/main/webapp/WEB-INF/web.xml
index 216d4fd..d20194f 100644
--- a/lib/server-tecsvc/src/main/webapp/WEB-INF/web.xml
+++ b/lib/server-tecsvc/src/main/webapp/WEB-INF/web.xml
@@ -39,6 +39,17 @@
 		<url-pattern>/odata.svc/*</url-pattern>
 	</servlet-mapping>
 
+	<servlet>
+		<servlet-name>StatusMonitorServlet</servlet-name>
+		<servlet-class>org.apache.olingo.server.tecsvc.async.TechnicalStatusMonitorServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+	<servlet-mapping>
+		<servlet-name>StatusMonitorServlet</servlet-name>
+		<url-pattern>/status/*</url-pattern>
+	</servlet-mapping>
+
 	<listener>
 		<listener-class>org.apache.olingo.server.tecsvc.TechnicalServletContextListener</listener-class>
 	</listener>