From: Leif Åstrand Date: Tue, 25 Sep 2012 11:40:18 +0000 (+0300) Subject: Shorten addVaadinSessionInitializationListener name pattern (#9750) X-Git-Tag: 7.0.0.beta3~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=079fee4ac6b8f8633b195f0bc52c29722a232ce0;p=vaadin-framework.git Shorten addVaadinSessionInitializationListener name pattern (#9750) --- diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java index 513d56150b..0e147e4fcd 100644 --- a/server/src/com/vaadin/server/AddonContext.java +++ b/server/src/com/vaadin/server/AddonContext.java @@ -55,10 +55,10 @@ public class AddonContext implements Serializable { public AddonContext(VaadinService vaadinService) { this.vaadinService = vaadinService; vaadinService - .addVaadinSessionInitializationListener(new VaadinSessionInitializationListener() { + .addSessionInitListener(new SessionInitListener() { @Override - public void vaadinSessionInitialized( - VaadinSessionInitializeEvent event) + public void sessionInit( + SessionInitEvent event) throws ServiceException { for (BootstrapListener l : bootstrapListeners) { event.getSession().addBootstrapListener(l); diff --git a/server/src/com/vaadin/server/LegacyVaadinPortlet.java b/server/src/com/vaadin/server/LegacyVaadinPortlet.java index a91a82076e..067cd6266f 100644 --- a/server/src/com/vaadin/server/LegacyVaadinPortlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinPortlet.java @@ -48,11 +48,11 @@ public class LegacyVaadinPortlet extends VaadinPortlet { public void init(PortletConfig portletConfig) throws PortletException { super.init(portletConfig); - getService().addVaadinSessionInitializationListener( - new VaadinSessionInitializationListener() { + getService().addSessionInitListener( + new SessionInitListener() { @Override - public void vaadinSessionInitialized( - VaadinSessionInitializeEvent event) + public void sessionInit( + SessionInitEvent event) throws ServiceException { try { onVaadinSessionStarted(VaadinPortletRequest diff --git a/server/src/com/vaadin/server/LegacyVaadinServlet.java b/server/src/com/vaadin/server/LegacyVaadinServlet.java index 1209ca8419..097ab02a6a 100644 --- a/server/src/com/vaadin/server/LegacyVaadinServlet.java +++ b/server/src/com/vaadin/server/LegacyVaadinServlet.java @@ -49,11 +49,11 @@ public class LegacyVaadinServlet extends VaadinServlet { public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); - getService().addVaadinSessionInitializationListener( - new VaadinSessionInitializationListener() { + getService().addSessionInitListener( + new SessionInitListener() { @Override - public void vaadinSessionInitialized( - VaadinSessionInitializeEvent event) + public void sessionInit( + SessionInitEvent event) throws ServiceException { try { onVaadinSessionStarted(event.getRequest(), diff --git a/server/src/com/vaadin/server/SessionDestroyEvent.java b/server/src/com/vaadin/server/SessionDestroyEvent.java new file mode 100644 index 0000000000..f35dbc8154 --- /dev/null +++ b/server/src/com/vaadin/server/SessionDestroyEvent.java @@ -0,0 +1,70 @@ +/* + * 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 fired when a Vaadin session is no longer in use. + * + * @see SessionDestroyListener#sessionDestroy(VaadinSessionDestroyEvent) + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class SessionDestroyEvent extends EventObject { + + private final VaadinSession session; + + /** + * Creates a new event. + * + * @param service + * the Vaadin service from which the even originates + * @param session + * the Vaadin session that is no longer used + */ + public SessionDestroyEvent(VaadinService service, + VaadinSession session) { + super(service); + this.session = session; + } + + @Override + public VaadinService getSource() { + return (VaadinService) super.getSource(); + } + + /** + * Gets the Vaadin service from which the even originates. + * + * @return the Vaadin service + */ + public VaadinService getService() { + return getSource(); + } + + /** + * Gets the Vaadin session that is no longer used. + * + * @return the Vaadin session + */ + public VaadinSession getSession() { + return session; + } + +} diff --git a/server/src/com/vaadin/server/SessionDestroyListener.java b/server/src/com/vaadin/server/SessionDestroyListener.java new file mode 100644 index 0000000000..035b03c627 --- /dev/null +++ b/server/src/com/vaadin/server/SessionDestroyListener.java @@ -0,0 +1,35 @@ +/* + * 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; + +/** + * A listener that gets notified when a Vaadin session is no longer used. + * + * @see VaadinService#addVaadinSessionDestroyListener(VaadinSessionDestroyListener) + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public interface SessionDestroyListener { + /** + * Called when a Vaadin session is no longer used. + * + * @param event + * the event with details about the destroyed session + */ + public void sessionDestroy(SessionDestroyEvent event); +} diff --git a/server/src/com/vaadin/server/SessionInitEvent.java b/server/src/com/vaadin/server/SessionInitEvent.java new file mode 100644 index 0000000000..34272d06ad --- /dev/null +++ b/server/src/com/vaadin/server/SessionInitEvent.java @@ -0,0 +1,89 @@ +/* + * 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 gets fired when a new Vaadin session is initialized for a Vaadin + * service. + *

+ * Because of the way different service instances share the same session, the + * event is not necessarily fired immediately when the session is created but + * only when the first request for that session is handled by a specific + * service. + * + * @see SessionInitListener#sessionInit(SessionInitEvent) + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public class SessionInitEvent extends EventObject { + + private final VaadinSession session; + private final VaadinRequest request; + + /** + * Creates a new event. + * + * @param service + * the Vaadin service from which the event originates + * @param session + * the Vaadin session that has been initialized + * @param request + * the request that triggered the initialization + */ + public SessionInitEvent(VaadinService service, VaadinSession session, + VaadinRequest request) { + super(service); + this.session = session; + this.request = request; + } + + @Override + public VaadinService getSource() { + return (VaadinService) super.getSource(); + } + + /** + * Gets the Vaadin service from which this event originates + * + * @return the Vaadin service instance + */ + public VaadinService getService() { + return getSource(); + } + + /** + * Gets the Vaadin session that has been initialized. + * + * @return the Vaadin session + */ + public VaadinSession getSession() { + return session; + } + + /** + * Gets the request that triggered the initialization. + * + * @return the request + */ + public VaadinRequest getRequest() { + return request; + } + +} diff --git a/server/src/com/vaadin/server/SessionInitListener.java b/server/src/com/vaadin/server/SessionInitListener.java new file mode 100644 index 0000000000..b34cf9b095 --- /dev/null +++ b/server/src/com/vaadin/server/SessionInitListener.java @@ -0,0 +1,51 @@ +/* + * 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; + +/** + * Event listener that can be registered to a {@link VaadinService} to get an + * event when a new Vaadin session is initialized for that service. + *

+ * Because of the way different service instances share the same session, the + * listener is not necessarily notified immediately when the session is created + * but only when the first request for that session is handled by a specific + * service. + * + * @see VaadinService#addSessionInitListener(SessionInitListener) + * + * @author Vaadin Ltd + * @since 7.0.0 + */ +public interface SessionInitListener extends Serializable { + /** + * Invoked when a new Vaadin session is initialized for that service. + *

+ * Because of the way different service instances share the same session, + * the listener is not necessarily notified immediately when the session is + * created but only when the first request for that session is handled by a + * specific service. + * + * @param event + * the initialization event + * @throws ServiceException + * a problem occurs when processing the event + */ + public void sessionInit(SessionInitEvent event) + throws ServiceException; +} diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 2c0331c65e..fc55a473a0 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -117,12 +117,11 @@ public abstract class VaadinService implements Serializable { } private static final Method SESSION_INIT_METHOD = ReflectTools.findMethod( - VaadinSessionInitializationListener.class, - "vaadinSessionInitialized", VaadinSessionInitializeEvent.class); + SessionInitListener.class, "sessionInit", SessionInitEvent.class); private static final Method SESSION_DESTROY_METHOD = ReflectTools - .findMethod(VaadinSessionDestroyListener.class, - "vaadinSessionDestroyed", VaadinSessionDestroyEvent.class); + .findMethod(SessionDestroyListener.class, "sessionDestroy", + SessionDestroyEvent.class); /** * @deprecated Only supported for {@link LegacyApplication}. @@ -299,44 +298,41 @@ public abstract class VaadinService implements Serializable { * created but only when the first request for that session is handled by * this service. * - * @see #removeVaadinSessionInitializationListener(VaadinSessionInitializationListener) - * @see VaadinSessionInitializationListener + * @see #removeSessionInitListener(SessionInitListener) + * @see SessionInitListener * * @param listener * the vaadin session initialization listener */ - public void addVaadinSessionInitializationListener( - VaadinSessionInitializationListener listener) { - eventRouter.addListener(VaadinSessionInitializeEvent.class, listener, + public void addSessionInitListener(SessionInitListener listener) { + eventRouter.addListener(SessionInitEvent.class, listener, SESSION_INIT_METHOD); } /** * Removes a Vaadin session initialization listener from this service. * - * @see #addVaadinSessionInitializationListener(VaadinSessionInitializationListener) + * @see #addSessionInitListener(SessionInitListener) * * @param listener * the Vaadin session initialization listener to remove. */ - public void removeVaadinSessionInitializationListener( - VaadinSessionInitializationListener listener) { - eventRouter.removeListener(VaadinSessionInitializeEvent.class, - listener, SESSION_INIT_METHOD); + public void removeSessionInitListener(SessionInitListener listener) { + eventRouter.removeListener(SessionInitEvent.class, listener, + SESSION_INIT_METHOD); } /** * Adds a listener that gets notified when a Vaadin session that has been * initialized for this service is destroyed. * - * @see #addVaadinSessionInitializationListener(VaadinSessionInitializationListener) + * @see #addSessionInitListener(SessionInitListener) * * @param listener * the vaadin session destroy listener */ - public void addVaadinSessionDestroyListener( - VaadinSessionDestroyListener listener) { - eventRouter.addListener(VaadinSessionDestroyEvent.class, listener, + public void addVaadinSessionDestroyListener(SessionDestroyListener listener) { + eventRouter.addListener(SessionDestroyEvent.class, listener, SESSION_DESTROY_METHOD); } @@ -345,21 +341,20 @@ public abstract class VaadinService implements Serializable { vaadinSession.cleanupUI(ui); } - eventRouter - .fireEvent(new VaadinSessionDestroyEvent(this, vaadinSession)); + eventRouter.fireEvent(new SessionDestroyEvent(this, vaadinSession)); } /** * Removes a Vaadin session destroy listener from this service. * - * @see #addVaadinSessionDestroyListener(VaadinSessionDestroyListener) + * @see #addVaadinSessionDestroyListener(SessionDestroyListener) * * @param listener * the vaadin session destroy listener */ public void removeVaadinSessionDestroyListener( - VaadinSessionDestroyListener listener) { - eventRouter.removeListener(VaadinSessionDestroyEvent.class, listener, + SessionDestroyListener listener) { + eventRouter.removeListener(SessionDestroyEvent.class, listener, SESSION_DESTROY_METHOD); } @@ -508,8 +503,7 @@ public abstract class VaadinService implements Serializable { private void onVaadinSessionStarted(VaadinRequest request, VaadinSession session) throws ServiceException { - eventRouter.fireEvent(new VaadinSessionInitializeEvent(this, session, - request)); + eventRouter.fireEvent(new SessionInitEvent(this, session, request)); ServletPortletHelper.checkUiProviders(session, this); } @@ -719,6 +713,7 @@ public abstract class VaadinService implements Serializable { * typically checks the @{@link PreserveOnRefresh} annotation but UI * providers and ultimately VaadinService implementations may choose to * override the defaults. + * * @param provider * the UI provider responsible for the UI * @param event diff --git a/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java b/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java deleted file mode 100644 index 9dc877863f..0000000000 --- a/server/src/com/vaadin/server/VaadinSessionDestroyEvent.java +++ /dev/null @@ -1,70 +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 fired when a Vaadin session is no longer in use. - * - * @see VaadinSessionDestroyListener#vaadinSessionDestroyed(VaadinSessionDestroyEvent) - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public class VaadinSessionDestroyEvent extends EventObject { - - private final VaadinSession session; - - /** - * Creates a new event. - * - * @param service - * the Vaadin service from which the even originates - * @param session - * the Vaadin session that is no longer used - */ - public VaadinSessionDestroyEvent(VaadinService service, - VaadinSession session) { - super(service); - this.session = session; - } - - @Override - public VaadinService getSource() { - return (VaadinService) super.getSource(); - } - - /** - * Gets the Vaadin service from which the even originates. - * - * @return the Vaadin service - */ - public VaadinService getService() { - return getSource(); - } - - /** - * Gets the Vaadin session that is no longer used. - * - * @return the Vaadin session - */ - public VaadinSession getSession() { - return session; - } - -} diff --git a/server/src/com/vaadin/server/VaadinSessionDestroyListener.java b/server/src/com/vaadin/server/VaadinSessionDestroyListener.java deleted file mode 100644 index 3f516c1eda..0000000000 --- a/server/src/com/vaadin/server/VaadinSessionDestroyListener.java +++ /dev/null @@ -1,35 +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; - -/** - * A listener that gets notified when a Vaadin session is no longer used. - * - * @see VaadinService#addVaadinSessionDestroyListener(VaadinSessionDestroyListener) - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public interface VaadinSessionDestroyListener { - /** - * Called when a Vaadin session is no longer used. - * - * @param event - * the event with details about the destroyed session - */ - public void vaadinSessionDestroyed(VaadinSessionDestroyEvent event); -} diff --git a/server/src/com/vaadin/server/VaadinSessionInitializationListener.java b/server/src/com/vaadin/server/VaadinSessionInitializationListener.java deleted file mode 100644 index c4722b9a86..0000000000 --- a/server/src/com/vaadin/server/VaadinSessionInitializationListener.java +++ /dev/null @@ -1,51 +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; - -/** - * Event listener that can be registered to a {@link VaadinService} to get an - * event when a new Vaadin session is initialized for that service. - *

- * Because of the way different service instances share the same session, the - * listener is not necessarily notified immediately when the session is created - * but only when the first request for that session is handled by a specific - * service. - * - * @see VaadinService#addVaadinSessionInitializationListener(VaadinSessionInitializationListener) - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public interface VaadinSessionInitializationListener extends Serializable { - /** - * Invoked when a new Vaadin session is initialized for that service. - *

- * Because of the way different service instances share the same session, - * the listener is not necessarily notified immediately when the session is - * created but only when the first request for that session is handled by a - * specific service. - * - * @param event - * the initialization event - * @throws ServiceException - * a problem occurs when processing the event - */ - public void vaadinSessionInitialized(VaadinSessionInitializeEvent event) - throws ServiceException; -} diff --git a/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java b/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java deleted file mode 100644 index a05b40a7dc..0000000000 --- a/server/src/com/vaadin/server/VaadinSessionInitializeEvent.java +++ /dev/null @@ -1,89 +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 gets fired when a new Vaadin session is initialized for a Vaadin - * service. - *

- * Because of the way different service instances share the same session, the - * event is not necessarily fired immediately when the session is created but - * only when the first request for that session is handled by a specific - * service. - * - * @see VaadinSessionInitializationListener#vaadinSessionInitialized(VaadinSessionInitializeEvent) - * - * @author Vaadin Ltd - * @since 7.0.0 - */ -public class VaadinSessionInitializeEvent extends EventObject { - - private final VaadinSession session; - private final VaadinRequest request; - - /** - * Creates a new event. - * - * @param service - * the Vaadin service from which the event originates - * @param session - * the Vaadin session that has been initialized - * @param request - * the request that triggered the initialization - */ - public VaadinSessionInitializeEvent(VaadinService service, - VaadinSession session, VaadinRequest request) { - super(service); - this.session = session; - this.request = request; - } - - @Override - public VaadinService getSource() { - return (VaadinService) super.getSource(); - } - - /** - * Gets the Vaadin service from which this event originates - * - * @return the Vaadin service instance - */ - public VaadinService getService() { - return getSource(); - } - - /** - * Gets the Vaadin session that has been initialized. - * - * @return the Vaadin session - */ - public VaadinSession getSession() { - return session; - } - - /** - * Gets the request that triggered the initialization. - * - * @return the request - */ - public VaadinRequest getRequest() { - return request; - } - -} diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 269080a59c..1883910b7b 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -39,8 +39,8 @@ import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinServletRequest; import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; -import com.vaadin.server.VaadinSessionInitializationListener; -import com.vaadin.server.VaadinSessionInitializeEvent; +import com.vaadin.server.SessionInitListener; +import com.vaadin.server.SessionInitEvent; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.UI; @@ -76,11 +76,11 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { @Override protected void servletInitialized() { super.servletInitialized(); - getService().addVaadinSessionInitializationListener( - new VaadinSessionInitializationListener() { + getService().addSessionInitListener( + new SessionInitListener() { @Override - public void vaadinSessionInitialized( - VaadinSessionInitializeEvent event) + public void sessionInit( + SessionInitEvent event) throws ServiceException { onVaadinSessionStarted(event.getRequest(), event.getSession());