]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added stubs for later implementation.
authorPetter Holmström <petter.holmstrom@itmill.com>
Wed, 28 Oct 2009 09:59:37 +0000 (09:59 +0000)
committerPetter Holmström <petter.holmstrom@itmill.com>
Wed, 28 Oct 2009 09:59:37 +0000 (09:59 +0000)
svn changeset:9421/svn branch:portlet_2.0

src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java [new file with mode: 0644]

diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java
new file mode 100644 (file)
index 0000000..ab880b0
--- /dev/null
@@ -0,0 +1,61 @@
+package com.vaadin.terminal.gwt.server;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.Portlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import com.vaadin.Application;
+
+public abstract class AbstractApplicationPortlet implements Portlet {
+
+       public void destroy() {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void init(PortletConfig config) throws PortletException {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void processAction(ActionRequest request, ActionResponse response)
+                       throws PortletException, IOException {
+               // TODO Auto-generated method stub
+
+       }
+
+       public void render(RenderRequest request, RenderResponse response)
+                       throws PortletException, IOException {
+               // TODO Auto-generated method stub
+
+       }
+
+       protected abstract Class<? extends Application> getApplicationClass()
+                       throws ClassNotFoundException;
+
+       protected Application getNewApplication(PortletRequest request)
+                       throws PortletException {
+               try {
+                       final Application application = getApplicationClass().newInstance();
+                       return application;
+               } catch (final IllegalAccessException e) {
+                       throw new PortletException("getNewApplication failed", e);
+               } catch (final InstantiationException e) {
+                       throw new PortletException("getNewApplication failed", e);
+               } catch (final ClassNotFoundException e) {
+                       throw new PortletException("getNewApplication failed", e);
+               }
+       }
+
+       protected ClassLoader getClassLoader() throws PortletException {
+               // TODO Add support for custom class loader
+               return getClass().getClassLoader();
+       }
+}
diff --git a/src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java b/src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java
new file mode 100644 (file)
index 0000000..1f28282
--- /dev/null
@@ -0,0 +1,46 @@
+/* 
+@ITMillApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.server;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+
+import com.vaadin.Application;
+
+/**
+ * TODO Write documentation, fix JavaDoc tags.
+ * 
+ * @author peholmst
+ */
+public class ApplicationPortlet2 extends AbstractApplicationPortlet {
+
+       private Class<? extends Application> applicationClass;
+
+       @SuppressWarnings("unchecked")
+       @Override
+       public void init(PortletConfig config) throws PortletException {
+               super.init(config);
+               final String applicationClassName = config
+                               .getInitParameter("application");
+               if (applicationClassName == null) {
+                       throw new PortletException(
+                                       "Application not specified in portlet parameters");
+               }
+
+               try {
+                       applicationClass = (Class<? extends Application>) getClassLoader()
+                                       .loadClass(applicationClassName);
+               } catch (final ClassNotFoundException e) {
+                       throw new PortletException("Failed to load application class: "
+                                       + applicationClassName);
+               }
+       }
+
+       @Override
+       protected Class<? extends Application> getApplicationClass() {
+               return applicationClass;
+       }
+
+}