summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-04 14:20:13 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-05 11:39:34 +0300
commit437e700dfc4173da66d45abd95b6f661d7216218 (patch)
treeb2653dfadd5656dfbc37c14eb6a0037a776efa66 /server/src
parentb3525638865cdea297c7f2e32c96221132af949f (diff)
downloadvaadin-framework-437e700dfc4173da66d45abd95b6f661d7216218.tar.gz
vaadin-framework-437e700dfc4173da66d45abd95b6f661d7216218.zip
Remove transaction listener support (#9402)
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/server/ApplicationContext.java139
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java32
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java31
3 files changed, 15 insertions, 187 deletions
diff --git a/server/src/com/vaadin/server/ApplicationContext.java b/server/src/com/vaadin/server/ApplicationContext.java
index 7577639a3f..2c09ed3857 100644
--- a/server/src/com/vaadin/server/ApplicationContext.java
+++ b/server/src/com/vaadin/server/ApplicationContext.java
@@ -16,15 +16,11 @@
package com.vaadin.server;
import java.io.File;
-import java.io.PrintWriter;
import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,50 +44,6 @@ import com.vaadin.Application;
public abstract class ApplicationContext implements HttpSessionBindingListener,
Serializable {
- /**
- * Interface for listening to transaction events. Implement this interface
- * to listen to all transactions between the client and the application.
- *
- */
- public static interface TransactionListener extends Serializable {
-
- /**
- * Invoked at the beginning of every transaction.
- *
- * The transaction is linked to the context, not the application so if
- * you have multiple applications running in the same context you need
- * to check that the request is associated with the application you are
- * interested in. This can be done looking at the application parameter.
- *
- * @param application
- * the Application object.
- * @param transactionData
- * the Data identifying the transaction.
- */
- public void transactionStart(Application application,
- Object transactionData);
-
- /**
- * Invoked at the end of every transaction.
- *
- * The transaction is linked to the context, not the application so if
- * you have multiple applications running in the same context you need
- * to check that the request is associated with the application you are
- * interested in. This can be done looking at the application parameter.
- *
- * @param applcation
- * the Application object.
- * @param transactionData
- * the Data identifying the transaction.
- */
- public void transactionEnd(Application application,
- Object transactionData);
-
- }
-
- protected Collection<ApplicationContext.TransactionListener> listeners = Collections
- .synchronizedList(new LinkedList<ApplicationContext.TransactionListener>());
-
protected final HashSet<Application> applications = new HashSet<Application>();
protected WebBrowser browser = new WebBrowser();
@@ -105,97 +57,6 @@ public abstract class ApplicationContext implements HttpSessionBindingListener,
private transient WrappedSession session;
/**
- * Adds a transaction listener to this context. The transaction listener is
- * called before and after each each request related to this session except
- * when serving static resources.
- *
- * The transaction listener must not be null.
- *
- * @see com.vaadin.service.ApplicationContext#addTransactionListener(com.vaadin.service.ApplicationContext.TransactionListener)
- */
- public void addTransactionListener(
- ApplicationContext.TransactionListener listener) {
- if (listener != null) {
- listeners.add(listener);
- }
- }
-
- /**
- * Removes a transaction listener from this context.
- *
- * @param listener
- * the listener to be removed.
- * @see ApplicationContext.TransactionListener
- */
- public void removeTransactionListener(
- ApplicationContext.TransactionListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Sends a notification that a transaction is starting.
- *
- * @param application
- * The application associated with the transaction.
- * @param request
- * the HTTP or portlet request that triggered the transaction.
- */
- protected void startTransaction(Application application, Object request) {
- ArrayList<ApplicationContext.TransactionListener> currentListeners;
- synchronized (listeners) {
- currentListeners = new ArrayList<ApplicationContext.TransactionListener>(
- listeners);
- }
- for (ApplicationContext.TransactionListener listener : currentListeners) {
- listener.transactionStart(application, request);
- }
- }
-
- /**
- * Sends a notification that a transaction has ended.
- *
- * @param application
- * The application associated with the transaction.
- * @param request
- * the HTTP or portlet request that triggered the transaction.
- */
- protected void endTransaction(Application application, Object request) {
- LinkedList<Exception> exceptions = null;
-
- ArrayList<ApplicationContext.TransactionListener> currentListeners;
- synchronized (listeners) {
- currentListeners = new ArrayList<ApplicationContext.TransactionListener>(
- listeners);
- }
-
- for (ApplicationContext.TransactionListener listener : currentListeners) {
- try {
- listener.transactionEnd(application, request);
- } catch (final RuntimeException t) {
- if (exceptions == null) {
- exceptions = new LinkedList<Exception>();
- }
- exceptions.add(t);
- }
- }
-
- // If any runtime exceptions occurred, throw a combined exception
- if (exceptions != null) {
- final StringBuffer msg = new StringBuffer();
- for (Exception e : exceptions) {
- if (msg.length() == 0) {
- msg.append("\n\n--------------------------\n\n");
- }
- msg.append(e.getMessage() + "\n");
- final StringWriter trace = new StringWriter();
- e.printStackTrace(new PrintWriter(trace, true));
- msg.append(trace.toString());
- }
- throw new RuntimeException(msg.toString());
- }
- }
-
- /**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
*/
@Override
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 0a99644735..3d99cf603e 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -432,7 +432,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
(ResourceResponse) response);
} else {
Application application = null;
- boolean transactionStarted = false;
boolean requestStarted = false;
boolean applicationRunning = false;
@@ -485,13 +484,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
startApplication(request, application, applicationContext);
applicationRunning = true;
- /*
- * Transaction starts. Call transaction listeners. Transaction
- * end is called in the finally block below.
- */
- applicationContext.startTransaction(application, request);
- transactionStarted = true;
-
/* Notify listeners */
// Finds the window within the application
@@ -592,25 +584,17 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// Notifies transaction end
try {
- if (transactionStarted) {
- ((PortletApplicationContext2) application.getContext())
- .endTransaction(application, request);
+ if (requestStarted) {
+ ((PortletRequestListener) application).onRequestEnd(
+ request, response);
+
}
} finally {
- try {
- if (requestStarted) {
- ((PortletRequestListener) application)
- .onRequestEnd(request, response);
+ CurrentInstance.clearAll();
- }
- } finally {
- CurrentInstance.clearAll();
-
- PortletSession session = request
- .getPortletSession(false);
- if (session != null) {
- requestTimer.stop(getApplicationContext(session));
- }
+ PortletSession session = request.getPortletSession(false);
+ if (session != null) {
+ requestTimer.stop(getApplicationContext(session));
}
}
}
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 81569030e7..29e473a16a 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -285,7 +285,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
Application application = null;
- boolean transactionStarted = false;
boolean requestStarted = false;
boolean applicationRunning = false;
@@ -350,13 +349,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
startApplication(request, application, webApplicationContext);
applicationRunning = true;
- /*
- * Transaction starts. Call transaction listeners. Transaction end
- * is called in the finally block below.
- */
- webApplicationContext.startTransaction(application, request);
- transactionStarted = true;
-
/* Handle the request */
if (requestType == RequestType.FILE_UPLOAD) {
// UI is resolved in communication manager
@@ -406,25 +398,16 @@ public class VaadinServlet extends HttpServlet implements Constants {
// Notifies transaction end
try {
- if (transactionStarted) {
- ((ServletApplicationContext) application.getContext())
- .endTransaction(application, request);
-
+ if (requestStarted) {
+ ((HttpServletRequestListener) application).onRequestEnd(
+ request, response);
}
-
} finally {
- try {
- if (requestStarted) {
- ((HttpServletRequestListener) application)
- .onRequestEnd(request, response);
- }
- } finally {
- CurrentInstance.clearAll();
+ CurrentInstance.clearAll();
- HttpSession session = request.getSession(false);
- if (session != null) {
- requestTimer.stop(getApplicationContext(session));
- }
+ HttpSession session = request.getSession(false);
+ if (session != null) {
+ requestTimer.stop(getApplicationContext(session));
}
}