]> source.dussan.org Git - vaadin-framework.git/commitdiff
Rename VaadinContext -> AddonContext (#9273)
authorLeif Åstrand <leif@vaadin.com>
Mon, 13 Aug 2012 12:26:17 +0000 (15:26 +0300)
committerLeif Åstrand <leif@vaadin.com>
Mon, 13 Aug 2012 12:26:17 +0000 (15:26 +0300)
15 files changed:
src/com/vaadin/terminal/DeploymentConfiguration.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java
src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
src/com/vaadin/terminal/gwt/server/AddonContext.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/AddonContextEvent.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/AddonContextListener.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/ApplicationStartedEvent.java
src/com/vaadin/terminal/gwt/server/VaadinContext.java [deleted file]
src/com/vaadin/terminal/gwt/server/VaadinContextEvent.java [deleted file]
src/com/vaadin/terminal/gwt/server/VaadinContextListener.java [deleted file]
tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.AddonContextListener [new file with mode: 0644]
tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener [deleted file]
tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java [new file with mode: 0644]
tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java [deleted file]

index 160350ca2415d53d9428d36f4b4dda9d0d1a6fe6..ae96dcaec57b1eb510ce27b41f38fccc33dbda87 100644 (file)
@@ -11,8 +11,8 @@ import java.util.Properties;
 import javax.portlet.PortletContext;
 import javax.servlet.ServletContext;
 
-import com.vaadin.terminal.gwt.server.VaadinContext;
-import com.vaadin.terminal.gwt.server.VaadinContextListener;
+import com.vaadin.terminal.gwt.server.AddonContext;
+import com.vaadin.terminal.gwt.server.AddonContextListener;
 
 /**
  * Provide deployment specific settings that are required outside terminal
@@ -115,9 +115,9 @@ public interface DeploymentConfiguration extends Serializable {
      */
     public Properties getInitParameters();
 
-    public Iterator<VaadinContextListener> getContextListeners();
+    public Iterator<AddonContextListener> getAddonContextListeners();
 
-    public VaadinContext getVaadinContext();
+    public AddonContext getAddonContext();
 
-    public void setVaadinContext(VaadinContext vaadinContext);
+    public void setAddonContext(AddonContext vaadinContext);
 }
index e5fb6afad2b673378019f019888b185123d2e738..40958e28687530d3f71609273ebd67baf92225b5 100644 (file)
@@ -290,7 +290,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
         }
     };
 
-    private final VaadinContext vaadinContext = new VaadinContext(
+    private final AddonContext addonContext = new AddonContext(
             getDeploymentConfiguration());
 
     @Override
@@ -319,14 +319,14 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
         checkProductionMode();
         checkCrossSiteProtection();
 
-        vaadinContext.init();
+        addonContext.init();
     }
 
     @Override
     public void destroy() {
         super.destroy();
 
-        vaadinContext.destroy();
+        addonContext.destroy();
     }
 
     private void checkCrossSiteProtection() {
@@ -801,7 +801,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet
             application.start(new ApplicationStartEvent(null,
                     getDeploymentConfiguration().getInitParameters(), context,
                     isProductionMode()));
-            vaadinContext.applicationStarted(application);
+            addonContext.applicationStarted(application);
         }
     }
 
index b8aba5c4b43c8b544e3fdcfacb20d0ab430a855a..603bc74a2186421b8d58878e0faafd8f7c7d5c6b 100644 (file)
@@ -128,7 +128,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
         }
     };
 
-    private final VaadinContext vaadinContext = new VaadinContext(
+    private final AddonContext addonContext = new AddonContext(
             getDeploymentConfiguration());
 
     /**
@@ -170,14 +170,14 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
         checkCrossSiteProtection();
         checkResourceCacheTime();
 
-        vaadinContext.init();
+        addonContext.init();
     }
 
     @Override
     public void destroy() {
         super.destroy();
 
-        vaadinContext.destroy();
+        addonContext.destroy();
     }
 
     private void checkCrossSiteProtection() {
@@ -901,7 +901,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements
             application.start(new ApplicationStartEvent(applicationUrl,
                     getDeploymentConfiguration().getInitParameters(),
                     webApplicationContext, isProductionMode()));
-            vaadinContext.applicationStarted(application);
+            addonContext.applicationStarted(application);
         }
     }
 
index 47bf5ecc6063b3b977346ec29addff92b176b816..f731cbbdd09c1515ac0339e76140bbe9d0972c9d 100644 (file)
@@ -16,7 +16,7 @@ public abstract class AbstractDeploymentConfiguration implements
 
     private final Class<?> systemPropertyBaseClass;
     private final Properties applicationProperties = new Properties();
-    private VaadinContext vaadinContext;
+    private AddonContext addonContext;
 
     public AbstractDeploymentConfiguration(Class<?> systemPropertyBaseClass) {
         this.systemPropertyBaseClass = systemPropertyBaseClass;
@@ -123,21 +123,21 @@ public abstract class AbstractDeploymentConfiguration implements
     }
 
     @Override
-    public Iterator<VaadinContextListener> getContextListeners() {
+    public Iterator<AddonContextListener> getAddonContextListeners() {
         // Called once for init and once for destroy, so it's probably not worth
         // the effort caching the ServiceLoader instance
-        ServiceLoader<VaadinContextListener> contextListenerLoader = ServiceLoader
-                .load(VaadinContextListener.class, getClassLoader());
+        ServiceLoader<AddonContextListener> contextListenerLoader = ServiceLoader
+                .load(AddonContextListener.class, getClassLoader());
         return contextListenerLoader.iterator();
     }
 
     @Override
-    public void setVaadinContext(VaadinContext vaadinContext) {
-        this.vaadinContext = vaadinContext;
+    public void setAddonContext(AddonContext addonContext) {
+        this.addonContext = addonContext;
     }
 
     @Override
-    public VaadinContext getVaadinContext() {
-        return vaadinContext;
+    public AddonContext getAddonContext() {
+        return addonContext;
     }
 }
diff --git a/src/com/vaadin/terminal/gwt/server/AddonContext.java b/src/com/vaadin/terminal/gwt/server/AddonContext.java
new file mode 100644 (file)
index 0000000..0f887b0
--- /dev/null
@@ -0,0 +1,80 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.server;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.vaadin.Application;
+import com.vaadin.event.EventRouter;
+import com.vaadin.terminal.DeploymentConfiguration;
+import com.vaadin.tools.ReflectTools;
+
+public class AddonContext {
+    private static final Method APPLICATION_STARTED_METHOD = ReflectTools
+            .findMethod(ApplicationStartedListener.class, "applicationStarted",
+                    ApplicationStartedEvent.class);
+
+    private final DeploymentConfiguration deploymentConfiguration;
+
+    private final EventRouter eventRouter = new EventRouter();
+
+    private List<BootstrapListener> bootstrapListeners = new ArrayList<BootstrapListener>();
+
+    public AddonContext(DeploymentConfiguration deploymentConfiguration) {
+        this.deploymentConfiguration = deploymentConfiguration;
+        deploymentConfiguration.setAddonContext(this);
+    }
+
+    public DeploymentConfiguration getDeploymentConfiguration() {
+        return deploymentConfiguration;
+    }
+
+    public void init() {
+        AddonContextEvent event = new AddonContextEvent(this);
+        Iterator<AddonContextListener> listeners = deploymentConfiguration
+                .getAddonContextListeners();
+        while (listeners.hasNext()) {
+            AddonContextListener listener = listeners.next();
+            listener.contextCreated(event);
+        }
+    }
+
+    public void destroy() {
+        AddonContextEvent event = new AddonContextEvent(this);
+        Iterator<AddonContextListener> listeners = deploymentConfiguration
+                .getAddonContextListeners();
+        while (listeners.hasNext()) {
+            AddonContextListener listener = listeners.next();
+            listener.contextDestoryed(event);
+        }
+    }
+
+    public void addBootstrapListener(BootstrapListener listener) {
+        bootstrapListeners.add(listener);
+    }
+
+    public void applicationStarted(Application application) {
+        eventRouter.fireEvent(new ApplicationStartedEvent(this, application));
+        for (BootstrapListener l : bootstrapListeners) {
+            application.addBootstrapListener(l);
+        }
+    }
+
+    public void addApplicationStartedListener(
+            ApplicationStartedListener applicationStartListener) {
+        eventRouter.addListener(ApplicationStartedEvent.class,
+                applicationStartListener, APPLICATION_STARTED_METHOD);
+    }
+
+    public void removeApplicationStartedListener(
+            ApplicationStartedListener applicationStartListener) {
+        eventRouter.removeListener(ApplicationStartedEvent.class,
+                applicationStartListener, APPLICATION_STARTED_METHOD);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/AddonContextEvent.java b/src/com/vaadin/terminal/gwt/server/AddonContextEvent.java
new file mode 100644 (file)
index 0000000..33f6814
--- /dev/null
@@ -0,0 +1,19 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.server;
+
+import java.util.EventObject;
+
+public class AddonContextEvent extends EventObject {
+
+    public AddonContextEvent(AddonContext source) {
+        super(source);
+    }
+
+    public AddonContext getAddonContext() {
+        return (AddonContext) getSource();
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/server/AddonContextListener.java b/src/com/vaadin/terminal/gwt/server/AddonContextListener.java
new file mode 100644 (file)
index 0000000..93e7df4
--- /dev/null
@@ -0,0 +1,13 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.server;
+
+import java.util.EventListener;
+
+public interface AddonContextListener extends EventListener {
+    public void contextCreated(AddonContextEvent event);
+
+    public void contextDestoryed(AddonContextEvent event);
+}
index 33859f5605f73a4e75962c7b494147dbe1123b9d..339b88222e8e1f3ff3951af487bdc6a9f2ed1127 100644 (file)
@@ -11,14 +11,14 @@ import com.vaadin.Application;
 public class ApplicationStartedEvent extends EventObject {
     private final Application application;
 
-    public ApplicationStartedEvent(VaadinContext context,
+    public ApplicationStartedEvent(AddonContext context,
             Application application) {
         super(context);
         this.application = application;
     }
 
-    public VaadinContext getContext() {
-        return (VaadinContext) getSource();
+    public AddonContext getContext() {
+        return (AddonContext) getSource();
     }
 
     public Application getApplication() {
diff --git a/src/com/vaadin/terminal/gwt/server/VaadinContext.java b/src/com/vaadin/terminal/gwt/server/VaadinContext.java
deleted file mode 100644 (file)
index 081f25b..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* 
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.server;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import com.vaadin.Application;
-import com.vaadin.event.EventRouter;
-import com.vaadin.terminal.DeploymentConfiguration;
-import com.vaadin.tools.ReflectTools;
-
-public class VaadinContext {
-    private static final Method APPLICATION_STARTED_METHOD = ReflectTools
-            .findMethod(ApplicationStartedListener.class, "applicationStarted",
-                    ApplicationStartedEvent.class);
-
-    private final DeploymentConfiguration deploymentConfiguration;
-
-    private final EventRouter eventRouter = new EventRouter();
-
-    private List<BootstrapListener> bootstrapListeners = new ArrayList<BootstrapListener>();
-
-    public VaadinContext(DeploymentConfiguration deploymentConfiguration) {
-        this.deploymentConfiguration = deploymentConfiguration;
-        deploymentConfiguration.setVaadinContext(this);
-    }
-
-    public DeploymentConfiguration getDeploymentConfiguration() {
-        return deploymentConfiguration;
-    }
-
-    public void init() {
-        VaadinContextEvent event = new VaadinContextEvent(this);
-        Iterator<VaadinContextListener> listeners = deploymentConfiguration
-                .getContextListeners();
-        while (listeners.hasNext()) {
-            VaadinContextListener listener = listeners.next();
-            listener.contextCreated(event);
-        }
-    }
-
-    public void destroy() {
-        VaadinContextEvent event = new VaadinContextEvent(this);
-        Iterator<VaadinContextListener> listeners = deploymentConfiguration
-                .getContextListeners();
-        while (listeners.hasNext()) {
-            VaadinContextListener listener = listeners.next();
-            listener.contextDestoryed(event);
-        }
-    }
-
-    public void addBootstrapListener(BootstrapListener listener) {
-        bootstrapListeners.add(listener);
-    }
-
-    public void applicationStarted(Application application) {
-        eventRouter.fireEvent(new ApplicationStartedEvent(this, application));
-        for (BootstrapListener l : bootstrapListeners) {
-            application.addBootstrapListener(l);
-        }
-    }
-
-    public void addApplicationStartedListener(
-            ApplicationStartedListener applicationStartListener) {
-        eventRouter.addListener(ApplicationStartedEvent.class,
-                applicationStartListener, APPLICATION_STARTED_METHOD);
-    }
-
-    public void removeApplicationStartedListener(
-            ApplicationStartedListener applicationStartListener) {
-        eventRouter.removeListener(ApplicationStartedEvent.class,
-                applicationStartListener, APPLICATION_STARTED_METHOD);
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/VaadinContextEvent.java b/src/com/vaadin/terminal/gwt/server/VaadinContextEvent.java
deleted file mode 100644 (file)
index 2394904..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* 
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.server;
-
-import java.util.EventObject;
-
-public class VaadinContextEvent extends EventObject {
-
-    public VaadinContextEvent(VaadinContext source) {
-        super(source);
-    }
-
-    public VaadinContext getVaadinContext() {
-        return (VaadinContext) getSource();
-    }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/server/VaadinContextListener.java b/src/com/vaadin/terminal/gwt/server/VaadinContextListener.java
deleted file mode 100644 (file)
index 5e379d9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* 
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.server;
-
-import java.util.EventListener;
-
-public interface VaadinContextListener extends EventListener {
-    public void contextCreated(VaadinContextEvent event);
-
-    public void contextDestoryed(VaadinContextEvent event);
-}
diff --git a/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.AddonContextListener b/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.AddonContextListener
new file mode 100644 (file)
index 0000000..9b3d9eb
--- /dev/null
@@ -0,0 +1 @@
+com.vaadin.tests.vaadincontext.TestAddonContextListener
\ No newline at end of file
diff --git a/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener b/tests/testbench/META-INF/services/com.vaadin.terminal.gwt.server.VaadinContextListener
deleted file mode 100644 (file)
index fd5ebaa..0000000
+++ /dev/null
@@ -1 +0,0 @@
-com.vaadin.tests.vaadincontext.TestVaadinContextListener
\ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestAddonContextListener.java
new file mode 100644 (file)
index 0000000..08db5c7
--- /dev/null
@@ -0,0 +1,54 @@
+/* 
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.tests.vaadincontext;
+
+import org.jsoup.nodes.Element;
+import org.jsoup.parser.Tag;
+
+import com.vaadin.terminal.gwt.server.BootstrapFragmentResponse;
+import com.vaadin.terminal.gwt.server.BootstrapListener;
+import com.vaadin.terminal.gwt.server.BootstrapPageResponse;
+import com.vaadin.terminal.gwt.server.BootstrapResponse;
+import com.vaadin.terminal.gwt.server.AddonContextEvent;
+import com.vaadin.terminal.gwt.server.AddonContextListener;
+import com.vaadin.ui.Root;
+
+public class TestAddonContextListener implements AddonContextListener {
+    @Override
+    public void contextCreated(AddonContextEvent event) {
+        event.getAddonContext().addBootstrapListener(new BootstrapListener() {
+            @Override
+            public void modifyBootstrapFragment(
+                    BootstrapFragmentResponse response) {
+                if (shouldModify(response)) {
+                    Element heading = new Element(Tag.valueOf("div"), "")
+                            .text("Added by modifyBootstrapFragment");
+                    response.getFragmentNodes().add(0, heading);
+                }
+            }
+
+            private boolean shouldModify(BootstrapResponse response) {
+                Root root = response.getRoot();
+                boolean shouldModify = root != null
+                        && root.getClass() == BoostrapModifyRoot.class;
+                return shouldModify;
+            }
+
+            @Override
+            public void modifyBootstrapPage(BootstrapPageResponse response) {
+                if (shouldModify(response)) {
+                    response.getDocument().body().child(0)
+                            .before("<div>Added by modifyBootstrapPage</div>");
+                }
+            }
+        });
+    }
+
+    @Override
+    public void contextDestoryed(AddonContextEvent event) {
+        // Nothing to do
+    }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java b/tests/testbench/com/vaadin/tests/vaadincontext/TestVaadinContextListener.java
deleted file mode 100644 (file)
index 9d1fc6b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* 
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.tests.vaadincontext;
-
-import org.jsoup.nodes.Element;
-import org.jsoup.parser.Tag;
-
-import com.vaadin.terminal.gwt.server.BootstrapFragmentResponse;
-import com.vaadin.terminal.gwt.server.BootstrapListener;
-import com.vaadin.terminal.gwt.server.BootstrapPageResponse;
-import com.vaadin.terminal.gwt.server.BootstrapResponse;
-import com.vaadin.terminal.gwt.server.VaadinContextEvent;
-import com.vaadin.terminal.gwt.server.VaadinContextListener;
-import com.vaadin.ui.Root;
-
-public class TestVaadinContextListener implements VaadinContextListener {
-    @Override
-    public void contextCreated(VaadinContextEvent event) {
-        event.getVaadinContext().addBootstrapListener(new BootstrapListener() {
-            @Override
-            public void modifyBootstrapFragment(
-                    BootstrapFragmentResponse response) {
-                if (shouldModify(response)) {
-                    Element heading = new Element(Tag.valueOf("div"), "")
-                            .text("Added by modifyBootstrapFragment");
-                    response.getFragmentNodes().add(0, heading);
-                }
-            }
-
-            private boolean shouldModify(BootstrapResponse response) {
-                Root root = response.getRoot();
-                boolean shouldModify = root != null
-                        && root.getClass() == BoostrapModifyRoot.class;
-                return shouldModify;
-            }
-
-            @Override
-            public void modifyBootstrapPage(BootstrapPageResponse response) {
-                if (shouldModify(response)) {
-                    response.getDocument().body().child(0)
-                            .before("<div>Added by modifyBootstrapPage</div>");
-                }
-            }
-        });
-    }
-
-    @Override
-    public void contextDestoryed(VaadinContextEvent event) {
-        // Nothing to do
-    }
-
-}