You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2016/04/14 14:29:26 UTC
[46/50] [abbrv] portals-pluto git commit: Started work to add
portlet-specific async interfaces
Started work to add portlet-specific async interfaces
Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/593f7ce8
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/593f7ce8
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/593f7ce8
Branch: refs/heads/master
Commit: 593f7ce85c4780b1b9cc6b26518bbba8d6916d31
Parents: 9fa76db
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Apr 5 20:48:55 2016 +0200
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Apr 5 20:48:55 2016 +0200
----------------------------------------------------------------------
.../java/javax/portlet/PortletAsyncContext.java | 81 +++++++++
.../java/javax/portlet/PortletAsyncEvent.java | 168 +++++++++++++++++++
.../javax/portlet/PortletAsyncListener.java | 143 ++++++++++++++++
3 files changed, 392 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/593f7ce8/portlet-api/src/main/java/javax/portlet/PortletAsyncContext.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/PortletAsyncContext.java b/portlet-api/src/main/java/javax/portlet/PortletAsyncContext.java
new file mode 100644
index 0000000..d77f5c4
--- /dev/null
+++ b/portlet-api/src/main/java/javax/portlet/PortletAsyncContext.java
@@ -0,0 +1,81 @@
+/* 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 javax.portlet;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * <div class="changed_added_3_0">
+ * Class representing the execution context for an asynchronous operation that was
+ * initiated on a ResourceRequest.
+ * <p>
+ * A PortletAsyncContext is created and initialized by a call to
+ * ResourceRequest#startAsync() or ResourceRequest#startAsync(ServletRequest,
+ * ServletResponse). Repeated invocations of these methods will return the same
+ * AsyncContext instance, reinitialized as appropriate.
+ * <p>
+ * In the event that an asynchronous operation has timed out, the container must
+ * invoke, at their onTimeout method, all PortletAsyncListener instances registered
+ * with the ResourceRequest on which the asynchronous operation was initiated.
+ * If none of the listeners called complete() or any of the dispatch() methods,
+ * complete the request on behalf of the application. *
+ * </div>
+ *
+ * @see javax.servlet.AsyncContext
+ * @since 3.0
+ */
+public interface PortletAsyncContext {
+
+ public void addListener(PortletAsyncListener listener);
+
+ public void addListener(PortletAsyncListener listener, ResourceRequest request, ResourceResponse response);
+
+ public void complete();
+
+ public <T extends PortletAsyncListener> T createListener(Class<T> cls) throws PortletException;
+
+ public void dispatch();
+
+ public void dispatch(String path);
+
+ public void dispatch(ServletContext context, String path);
+
+ public ResourceRequest getRequest();
+
+ public ResourceResponse getResponse();
+
+ public long getTimeout();
+
+ public boolean hasOriginalRequestAndResponse();
+
+ public void setTimeout(long time);
+
+ /**
+ * <div class="changed_added_3_0">
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param run
+ */
+ public void start(Runnable run);
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/593f7ce8/portlet-api/src/main/java/javax/portlet/PortletAsyncEvent.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/PortletAsyncEvent.java b/portlet-api/src/main/java/javax/portlet/PortletAsyncEvent.java
new file mode 100644
index 0000000..66182dd
--- /dev/null
+++ b/portlet-api/src/main/java/javax/portlet/PortletAsyncEvent.java
@@ -0,0 +1,168 @@
+/* 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 javax.portlet;
+
+
+/**
+ * <div class="changed_added_3_0">
+ * Event that gets fired when the asynchronous operation initiated on a
+ * ResourceRequest (via a call to ResourceRequest#startAsync or
+ * ResourceRequest#startAsync(ResourceRequest, ResouceResponse)) has completed, timed
+ * out, or produced an error.
+ * </div>
+ *
+ * @since 3.0
+ */
+public class PortletAsyncEvent {
+
+ PortletAsyncContext context;
+ ResourceRequest request;
+ ResourceResponse response;
+ Throwable throwable;
+
+ /**
+ * <div class="changed_added_3_0">
+ * Constructs a PortletAsyncEvent from the given
+ * PortletAsyncContext, ResourceRequest, ResourceResponse, and Throwable.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param context
+ * @param request
+ * @param response
+ * @param throwable
+ */
+ public PortletAsyncEvent(PortletAsyncContext context, ResourceRequest request, ResourceResponse response, Throwable throwable) {
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ this.throwable = throwable;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Constructs a PortletAsyncEvent from the given
+ * PortletAsyncContext, ResourceRequest, and ResourceResponse.
+ * </div>
+ *
+ * @since 3.0
+ * @param context
+ * @param request
+ * @param response
+ */
+ public PortletAsyncEvent(PortletAsyncContext context, ResourceRequest request, ResourceResponse response) {
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ this.throwable = null;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Constructs a PortletAsyncEvent from the given
+ * PortletAsyncContext and Throwable.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param context
+ * @param throwable
+ */
+ public PortletAsyncEvent(PortletAsyncContext context, Throwable throwable) {
+ this.context = context;
+ this.request = null;
+ this.response = null;
+ this.throwable = throwable;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Constructs a PortletAsyncEvent from the given
+ * PortletAsyncContext.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param context
+ */
+ public PortletAsyncEvent(PortletAsyncContext context) {
+ this.context = context;
+ this.request = null;
+ this.response = null;
+ this.throwable = null;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Gets the portlet asynchronous context object associated with the event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @return the portlet asynchronous context
+ */
+ public PortletAsyncContext getPortletAsyncContext() {
+ return context;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Gets the resource request associated with the event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @return the resource request provided to the constructor, or <code>null</code>
+ * if no resource request was provided.
+ */
+ public ResourceRequest getSuppliedRequest() {
+ return request;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Gets the resource response associated with the event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @return the resource response provided to the constructor, or <code>null</code>
+ * if no resource response was provided.
+ */
+ public ResourceResponse getSuppliedResponse() {
+ return response;
+ }
+
+ /**
+ * <div class="changed_added_3_0">
+ * Gets the <code>Throwable</code> associated with the event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @return The <code>Throwable</code> that was used to initialize the event, or <code>null</code>
+ * if no <code>Throwable</code> was provided.
+ */
+ public Throwable getThrowable() {
+ return throwable;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/593f7ce8/portlet-api/src/main/java/javax/portlet/PortletAsyncListener.java
----------------------------------------------------------------------
diff --git a/portlet-api/src/main/java/javax/portlet/PortletAsyncListener.java b/portlet-api/src/main/java/javax/portlet/PortletAsyncListener.java
new file mode 100644
index 0000000..0865365
--- /dev/null
+++ b/portlet-api/src/main/java/javax/portlet/PortletAsyncListener.java
@@ -0,0 +1,143 @@
+/* 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 javax.portlet;
+
+import java.io.IOException;
+
+/**
+ * <div class="changed_added_3_0">
+ * Listener that will be notified in the event that an asynchronous operation
+ * initiated on a ResourceRequest to which the listener had been added has
+ * completed, timed out, or resulted in an error.
+ * </div>
+ *
+ * @since 3.0
+ */
+public interface PortletAsyncListener {
+
+ /**
+ * <div class="changed_added_3_0">
+ * Notifies this <code>PortletAsyncListener</code> that an asynchronous operation
+ * has been completed.
+ * <p>
+ * The <code>PortletAsyncContext</code> corresponding to the asynchronous
+ * operation that has been completed may be obtained by calling
+ * <code>getAsyncContext</code> on the given event.
+ * <p>
+ * In addition, if this <code>PortletAsyncListener</code> had been registered
+ * via a call to <code>PortletAsyncContext#addListener(PortletAsyncListener,
+ * ResourceRequest, ResourceResponse)</code>, the supplied
+ * <code>ResourceRequest</code> and <code>ResourceResponse</code> objects may
+ * be retrieved by calling <code>getSuppliedRequest</code> and
+ * <code>getSuppliedResponse</code>, respectively, on the given event.
+ *
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param evt the PortletAsyncEvent indicating that an asynchronous operation has been completed
+ * @throws IOException if an I/O related error has occurred during the processing
+ */
+ public void onComplete(PortletAsyncEvent evt) throws IOException;
+
+ /**
+ * <div class="changed_added_3_0">
+ * Notifies this <code>PortletAsyncListener</code> that an asynchronous
+ * operation has failed to complete.
+ * <p>
+ * The <code>PortletAsyncContext</code> corresponding to the asynchronous
+ * operation that failed to complete may be obtained by calling
+ * <code>getAsyncContext</code> on the given event.
+ * <p>
+ * In addition, if this <code>PortletAsyncListener</code> had been registered
+ * via a call to <code>PortletAsyncContext#addListener(PortletAsyncListener,
+ * ResourceRequest, ResourceResponse)</code>, the supplied
+ * <code>ResourceRequest</code> and <code>ResourceResponse</code> objects may
+ * be retrieved by calling <code>getSuppliedRequest</code> and
+ * <code>getSuppliedResponse</code>, respectively, on the given event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param evt the PortletAsyncEvent indicating that an asynchronous operation has
+ * encountered an error
+ * @throws IOException if an I/O related error has occurred during the processing
+ */
+ public void onError(PortletAsyncEvent evt) throws IOException;
+
+ /**
+ * <div class="changed_added_3_0">
+ * Notifies this <code>PortletAsyncListener</code> that a new asynchronous cycle is
+ * being initiated via a call to one of the <code>ResourceRequest</code>#startAsync
+ * methods.
+ * <p>
+ * The <code>PortletAsyncContext</code> corresponding to the asynchronous
+ * operation that is being reinitialized may be obtained by calling
+ * <code>getAsyncContext</code> on the given event.
+ * <p>
+ * In addition, if this <code>PortletAsyncListener</code> had been registered
+ * via a call to <code>PortletAsyncContext#addListener(PortletAsyncListener,
+ * ResourceRequest, ResourceResponse)</code>, the supplied
+ * <code>ResourceRequest</code> and <code>ResourceResponse</code> objects may
+ * be retrieved by calling <code>getSuppliedRequest</code> and
+ * <code>getSuppliedResponse</code>, respectively, on the given event.
+ * <p>
+ * This <code>PortletAsyncListener</code> will not receive any events related
+ * to the new asynchronous cycle unless it registers itself (via a call to
+ * <code>PortletAsyncContext</code>#addListener) with the
+ * <code>PortletAsyncContext</code> that is delivered as part of the given
+ * event.
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param evt the PortletAsyncEvent indicating that an asynchronous operation
+ * is being initiated
+ * @throws IOException if an I/O related error has occurred during the processing
+ */
+ public void onStartAsync(PortletAsyncEvent evt) throws IOException;
+
+ /**
+ * <div class="changed_added_3_0">
+ * Notifies this <code>PortletAsyncListener</code> that an asynchronous operation
+ * has timed out.
+ * <p>
+ * The <code>PortletAsyncContext</code> corresponding to the asynchronous
+ * operation that has timed out may be obtained by calling
+ * <code>getAsyncContext</code> on the given event.
+ * <p>
+ * In addition, if this <code>PortletAsyncListener</code> had been registered
+ * via a call to <code>PortletAsyncContext#addListener(PortletAsyncListener,
+ * ResourceRequest, ResourceResponse)</code>, the supplied
+ * <code>ResourceRequest</code> and <code>ResourceResponse</code> objects may
+ * be retrieved by calling <code>getSuppliedRequest</code> and
+ * <code>getSuppliedResponse</code>, respectively, on the given event.
+ *
+ * </div>
+ *
+ * @since 3.0
+ *
+ * @param evt the PortletAsyncEvent indicating that an asynchronous operation has
+ * timed out
+ * @throws IOException if an I/O related error has occurred during the processing
+ */
+ public void onTimeout(PortletAsyncEvent evt) throws IOException;
+
+}