summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-11-20 16:53:49 +0200
committerVaadin Code Review <review@vaadin.com>2012-11-21 13:41:46 +0000
commitfeac70070091a3d823632a7396ec4eef0886f5b2 (patch)
tree6f30cfdeb85bc7969d5f4c98e425e0b482d7e65c /server
parent29ea66b5bad701db2a3f6e2c67a143678d1dd52a (diff)
downloadvaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.tar.gz
vaadin-framework-feac70070091a3d823632a7396ec4eef0886f5b2.zip
Remove AddonContext (#10254)
Change-Id: I12d3075a4808b004d7b891d1c4092131fa7cb1a2
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/AddonContext.java123
-rw-r--r--server/src/com/vaadin/server/AddonContextEvent.java50
-rw-r--r--server/src/com/vaadin/server/AddonContextListener.java53
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java11
-rw-r--r--server/src/com/vaadin/server/VaadinService.java19
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java12
6 files changed, 0 insertions, 268 deletions
diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java
deleted file mode 100644
index 088366c541..0000000000
--- a/server/src/com/vaadin/server/AddonContext.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed 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 com.vaadin.server;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * Point of entry for add-ons for integrating into various aspects of the
- * framework. One add-on context is initialized for each Vaadin Servlet or
- * Portlet instance and upon initialization, every {@link AddonContextListener}
- * that can be found is notified to let it add listeners to the context.
- * <p>
- * By default, AddonContextListeners are loaded using {@link ServiceLoader},
- * which means that the file
- * META-INF/services/com.vaadin.server.AddonContextListener will be checked for
- * lines containing fully qualified names of classes to use. This behavior can
- * however be overridden for custom deployment situations (e.g. to use CDI or
- * OSGi) by overriding {@link VaadinService#getAddonContextListeners()}.
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-public class AddonContext implements Serializable {
- private final VaadinService vaadinService;
-
- private List<BootstrapListener> bootstrapListeners = new ArrayList<BootstrapListener>();
-
- private List<AddonContextListener> initedListeners = new ArrayList<AddonContextListener>();
-
- /**
- * Creates a new context using a given vaadin service. Only the framework
- * itself should typically create AddonContext instances.
- *
- * @param vaadinService
- * the vaadin service for the associated servlet or portlet.
- */
- public AddonContext(VaadinService vaadinService) {
- this.vaadinService = vaadinService;
- vaadinService.addSessionInitListener(new SessionInitListener() {
- @Override
- public void sessionInit(SessionInitEvent event)
- throws ServiceException {
- for (BootstrapListener l : bootstrapListeners) {
- event.getSession().addBootstrapListener(l);
- }
- }
- });
- vaadinService.setAddonContext(this);
- }
-
- /**
- * Gets the vaadin service for this context.
- *
- * @return the vaadin service
- */
- public VaadinService getService() {
- return vaadinService;
- }
-
- /**
- * Initializes this context, causing all found listeners to be notified.
- * Listeners are by default found using {@link ServiceLoader}, but the
- * {@link VaadinService} can provide an alternative implementation.
- * <p>
- * This method is not intended to be used by add-ons, but instead by the
- * part of the framework that created this context object.
- */
- public void init() {
- AddonContextEvent event = new AddonContextEvent(this);
- Iterator<AddonContextListener> listeners = vaadinService
- .getAddonContextListeners();
- while (listeners.hasNext()) {
- AddonContextListener listener = listeners.next();
- listener.contextCreated(event);
- initedListeners.add(listener);
- }
- }
-
- /**
- * Destroys this context, causing all initialized listeners to be invoked.
- * <p>
- * This method is not intended to be used by add-ons, but instead by the
- * part of the framework that created this context object.
- */
- public void destroy() {
- AddonContextEvent event = new AddonContextEvent(this);
- for (AddonContextListener listener : initedListeners) {
- listener.contextDestroyed(event);
- }
- }
-
- /**
- * Shorthand for adding a bootstrap listener that will be added to every new
- * service session.
- *
- * @see VaadinSession#addBootstrapListener(BootstrapListener)
- *
- * @param listener
- * the bootstrap listener that should be added to all new
- * applications.
- */
- public void addBootstrapListener(BootstrapListener listener) {
- bootstrapListeners.add(listener);
- }
-}
diff --git a/server/src/com/vaadin/server/AddonContextEvent.java b/server/src/com/vaadin/server/AddonContextEvent.java
deleted file mode 100644
index d83b1b0084..0000000000
--- a/server/src/com/vaadin/server/AddonContextEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed 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 com.vaadin.server;
-
-import java.util.EventObject;
-
-/**
- * Event used when an {@link AddonContext} is created and destroyed.
- *
- * @see AddonContextListener
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-public class AddonContextEvent extends EventObject {
-
- /**
- * Creates a new event for the given add-on context.
- *
- * @param source
- * the add-on context that created the event
- */
- public AddonContextEvent(AddonContext source) {
- super(source);
- }
-
- /**
- * Gets the add-on context that created this event.
- *
- * @return the add-on context that created this event.
- */
- public AddonContext getAddonContext() {
- return (AddonContext) getSource();
- }
-
-}
diff --git a/server/src/com/vaadin/server/AddonContextListener.java b/server/src/com/vaadin/server/AddonContextListener.java
deleted file mode 100644
index 602ba0ba66..0000000000
--- a/server/src/com/vaadin/server/AddonContextListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed 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 com.vaadin.server;
-
-import java.io.Serializable;
-import java.util.EventListener;
-
-/**
- * Listener that gets notified then the {@link AddonContext} is initialized,
- * allowing an add-on to add listeners to various parts of the framework. In a
- * default configuration, add-ons can register their listeners by including a
- * file named META-INF/services/com.vaadin.server.AddonContextListener
- * containing the fully qualified class names of classes implementing this
- * interface.
- *
- * @author Vaadin Ltd
- * @since 7.0.0
- */
-public interface AddonContextListener extends EventListener, Serializable {
- /**
- * Notifies the listener that the add-on context has been created and
- * initialized. An add-on can use this method to get access to an
- * {@link AddonContext} object to which listeners can be added.
- *
- * @param event
- * the add-on context event
- */
- public void contextCreated(AddonContextEvent event);
-
- /**
- * Notifies the listener that the add-on context has been closed. An add-on
- * can use this method to e.g. close resources that have been opened in
- * {@link #contextCreated(AddonContextEvent)}.
- *
- * @param event
- * the add-on context event
- */
- public void contextDestroyed(AddonContextEvent event);
-}
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 05b6ac360a..3f7c4472e9 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -246,7 +246,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// when the portlet is removed?
private VaadinPortletService vaadinService;
- private AddonContext addonContext;
@Override
public void init(PortletConfig config) throws PortletException {
@@ -275,9 +274,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
// Sets current service even though there are no request and response
vaadinService.setCurrentInstances(null, null);
- addonContext = new AddonContext(vaadinService);
- addonContext.init();
-
portletInitialized();
CurrentInstance.clearAll();
}
@@ -296,13 +292,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
return new VaadinPortletService(this, deploymentConfiguration);
}
- @Override
- public void destroy() {
- super.destroy();
-
- addonContext.destroy();
- }
-
/**
* @author Vaadin Ltd
*
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 41115a3503..02463242f4 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -24,9 +24,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Locale;
-import java.util.ServiceLoader;
import javax.portlet.PortletContext;
import javax.servlet.ServletContext;
@@ -70,7 +68,6 @@ public abstract class VaadinService implements Serializable {
@Deprecated
public static final String URL_PARAMETER_CLOSE_APPLICATION = "closeApplication";
- private AddonContext addonContext;
private final DeploymentConfiguration deploymentConfiguration;
private final EventRouter eventRouter = new EventRouter();
@@ -190,22 +187,6 @@ public abstract class VaadinService implements Serializable {
return deploymentConfiguration;
}
- public Iterator<AddonContextListener> getAddonContextListeners() {
- // Called once for init and then no more, so there's no point in caching
- // the instance
- ServiceLoader<AddonContextListener> contextListenerLoader = ServiceLoader
- .load(AddonContextListener.class, getClassLoader());
- return contextListenerLoader.iterator();
- }
-
- public AddonContext getAddonContext() {
- return addonContext;
- }
-
- public void setAddonContext(AddonContext addonContext) {
- this.addonContext = addonContext;
- }
-
/**
* Sets the system messages provider to use for getting system messages to
* display to users of this service.
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 3089eccc12..414e814ffd 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -74,8 +74,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
private VaadinServletService servletService;
- private AddonContext addonContext;
-
/**
* Called by the servlet container to indicate to a servlet that the servlet
* is being placed into service.
@@ -116,9 +114,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
// Sets current service even though there are no request and response
servletService.setCurrentInstances(null, null);
- addonContext = new AddonContext(servletService);
- addonContext.init();
-
servletInitialized();
CurrentInstance.clearAll();
@@ -177,13 +172,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
return new VaadinServletService(this, deploymentConfiguration);
}
- @Override
- public void destroy() {
- super.destroy();
-
- addonContext.destroy();
- }
-
/**
* Receives standard HTTP requests from the public service method and
* dispatches them.