From 4a5a691e8ff223717c098da3010e772466f25fbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petter=20Holmstr=C3=B6m?= Date: Wed, 28 Oct 2009 09:59:37 +0000 Subject: [PATCH] Added stubs for later implementation. svn changeset:9421/svn branch:portlet_2.0 --- .../server/AbstractApplicationPortlet.java | 61 +++++++++++++++++++ .../gwt/server/ApplicationPortlet2.java | 46 ++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java create mode 100644 src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java new file mode 100644 index 0000000000..ab880b0c5d --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -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 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 index 0000000000..1f28282287 --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/ApplicationPortlet2.java @@ -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 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) getClassLoader() + .loadClass(applicationClassName); + } catch (final ClassNotFoundException e) { + throw new PortletException("Failed to load application class: " + + applicationClassName); + } + } + + @Override + protected Class getApplicationClass() { + return applicationClass; + } + +} -- 2.39.5