diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-24 12:05:54 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-24 12:05:54 +0300 |
commit | 6c67fdd35747b3d6c0e38bf62e4fd773bc5c0bde (patch) | |
tree | 824b581dbf70366d2801a16dc32759108ec7f19f | |
parent | a4ba2868153ca06d827324655dbb10e5213c9b2d (diff) | |
download | vaadin-framework-6c67fdd35747b3d6c0e38bf62e4fd773bc5c0bde.tar.gz vaadin-framework-6c67fdd35747b3d6c0e38bf62e4fd773bc5c0bde.zip |
Remove ApplicationStartedListener (#9719)
4 files changed, 12 insertions, 163 deletions
diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index edddf1fe1f..6c7cb9bf98 100644 --- a/server/src/com/vaadin/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -17,15 +17,11 @@ package com.vaadin.server; import java.io.Serializable; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ServiceLoader; -import com.vaadin.event.EventRouter; -import com.vaadin.util.ReflectTools; - /** * 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 @@ -43,14 +39,8 @@ import com.vaadin.util.ReflectTools; * @since 7.0.0 */ public class AddonContext implements Serializable { - private static final Method APPLICATION_STARTED_METHOD = ReflectTools - .findMethod(ApplicationStartedListener.class, "applicationStarted", - ApplicationStartedEvent.class); - private final VaadinService vaadinService; - private final EventRouter eventRouter = new EventRouter(); - private List<BootstrapListener> bootstrapListeners = new ArrayList<BootstrapListener>(); private List<AddonContextListener> initedListeners = new ArrayList<AddonContextListener>(); @@ -64,6 +54,17 @@ public class AddonContext implements Serializable { */ public AddonContext(VaadinService vaadinService) { this.vaadinService = vaadinService; + vaadinService + .addVaadinSessionInitializationListener(new VaadinSessionInitializationListener() { + @Override + public void vaadinSessionInitialized( + VaadinSessionInitializeEvent event) + throws ServiceException { + for (BootstrapListener l : bootstrapListeners) { + event.getVaadinSession().addBootstrapListener(l); + } + } + }); vaadinService.setAddonContext(this); } @@ -110,9 +111,8 @@ public class AddonContext implements Serializable { /** * Shorthand for adding a bootstrap listener that will be added to every new - * application. + * Vaadin session. * - * @see #addApplicationStartedListener(ApplicationStartedListener) * @see VaadinSession#addBootstrapListener(BootstrapListener) * * @param listener @@ -122,50 +122,4 @@ public class AddonContext implements Serializable { public void addBootstrapListener(BootstrapListener listener) { bootstrapListeners.add(listener); } - - /** - * Fires an {@link ApplicationStartedEvent} to all registered listeners. - * This method is not intended to be used by add-ons, but instead by the - * part of the framework that creates new Application instances. - * - * @see #addApplicationStartedListener(ApplicationStartedListener) - * - * @param application - * the newly started application - */ - public void fireApplicationStarted(VaadinSession application) { - eventRouter.fireEvent(new ApplicationStartedEvent(this, application)); - for (BootstrapListener l : bootstrapListeners) { - application.addBootstrapListener(l); - } - } - - /** - * Adds a listener that will be notified any time a new - * {@link VaadinSession} instance is started or more precisely directly - * after {@link VaadinSession#init()} has been invoked. - * - * @param applicationStartListener - * the application start listener that should be added - */ - public void addApplicationStartedListener( - ApplicationStartedListener applicationStartListener) { - eventRouter.addListener(ApplicationStartedEvent.class, - applicationStartListener, APPLICATION_STARTED_METHOD); - } - - /** - * Removes an application start listener. - * - * @see #addApplicationStartedListener(ApplicationStartedListener) - * - * @param applicationStartListener - * the application start listener to remove - */ - public void removeApplicationStartedListener( - ApplicationStartedListener applicationStartListener) { - eventRouter.removeListener(ApplicationStartedEvent.class, - applicationStartListener, APPLICATION_STARTED_METHOD); - } - } diff --git a/server/src/com/vaadin/server/ApplicationStartedEvent.java b/server/src/com/vaadin/server/ApplicationStartedEvent.java deleted file mode 100644 index f1c79cc81c..0000000000 --- a/server/src/com/vaadin/server/ApplicationStartedEvent.java +++ /dev/null @@ -1,64 +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 by - * {@link ApplicationStartedListener#applicationStarted(ApplicationStartedEvent)} - * . - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public class ApplicationStartedEvent extends EventObject { - private final VaadinSession application; - - /** - * Creates a new event. - * - * @param context - * the add-on context that will fire the event - * @param application - * the application that has been started - */ - public ApplicationStartedEvent(AddonContext context, - VaadinSession application) { - super(context); - this.application = application; - } - - /** - * Gets the add-on context from which this event originated. - * - * @return the add-on context that fired the - */ - public AddonContext getContext() { - return (AddonContext) getSource(); - } - - /** - * Gets the newly started Application. - * - * @return the newly created application - */ - public VaadinSession getApplication() { - return application; - } - -} diff --git a/server/src/com/vaadin/server/ApplicationStartedListener.java b/server/src/com/vaadin/server/ApplicationStartedListener.java deleted file mode 100644 index c59035b3db..0000000000 --- a/server/src/com/vaadin/server/ApplicationStartedListener.java +++ /dev/null @@ -1,40 +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.EventListener; - -/** - * Listener that gets notified when a new {@link VaadinSession} has been - * started. Add-ons can use this listener to automatically integrate with API - * tied to the Application API. - * - * @see AddonContext#addApplicationStartedListener(ApplicationStartedListener) - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public interface ApplicationStartedListener extends EventListener { - /** - * Tells the listener that an application has been started (meaning that - * {@link VaadinSession#init()} has been invoked. - * - * @param event - * details about the event - */ - public void applicationStarted(ApplicationStartedEvent event); -} diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index e7bf14e258..b3f9cd3ecf 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -508,7 +508,6 @@ public abstract class VaadinService implements Serializable { private void onVaadinSessionStarted(VaadinRequest request, VaadinSession session) throws ServiceException { - addonContext.fireApplicationStarted(session); eventRouter.fireEvent(new VaadinSessionInitializeEvent(this, session, request)); |