--- /dev/null
+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();
+ }
+}
--- /dev/null
+/*
+@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;
+ }
+
+}