]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove ApplicationClassException (#9690)
authorLeif Åstrand <leif@vaadin.com>
Thu, 20 Sep 2012 11:25:46 +0000 (14:25 +0300)
committerLeif Åstrand <leif@vaadin.com>
Thu, 20 Sep 2012 11:26:05 +0000 (14:26 +0300)
server/src/com/vaadin/server/LegacyVaadinPortlet.java
server/src/com/vaadin/server/LegacyVaadinServlet.java
server/src/com/vaadin/server/ServiceException.java
server/src/com/vaadin/server/ServletPortletHelper.java
server/src/com/vaadin/server/VaadinService.java

index ef59615a29b7c67c71da0f8f52c0fd0bc566e3ab..6aa8fb7165971deea4dd4900fb86b2bdbbe09009 100644 (file)
@@ -20,7 +20,6 @@ import javax.portlet.PortletException;
 import javax.portlet.PortletRequest;
 
 import com.vaadin.LegacyApplication;
-import com.vaadin.server.ServletPortletHelper.ApplicationClassException;
 
 public class LegacyVaadinPortlet extends VaadinPortlet {
 
@@ -71,7 +70,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet {
         try {
             return ServletPortletHelper
                     .getLegacyApplicationClass(getVaadinService());
-        } catch (ApplicationClassException e) {
+        } catch (ServiceException e) {
             throw new RuntimeException(e);
         }
     }
index d9c84309fb117e8532039b4211ed0d37db3f5218..ace29e9e1f6e555b57810447f20994f48e28d95f 100644 (file)
@@ -21,7 +21,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 
 import com.vaadin.LegacyApplication;
-import com.vaadin.server.ServletPortletHelper.ApplicationClassException;
 
 public class LegacyVaadinServlet extends VaadinServlet {
 
@@ -71,7 +70,7 @@ public class LegacyVaadinServlet extends VaadinServlet {
         try {
             return ServletPortletHelper
                     .getLegacyApplicationClass(getVaadinService());
-        } catch (ApplicationClassException e) {
+        } catch (ServiceException e) {
             throw new RuntimeException(e);
         }
     }
index 538e8b30eaf1eefca08dc9c4de30c13941e31030..ac693e5747b8390d7b79b3d5a0fae4457136aefd 100644 (file)
@@ -18,12 +18,16 @@ package com.vaadin.server;
 
 public class ServiceException extends Exception {
 
-    public ServiceException(Exception e) {
-        super(e);
+    public ServiceException(Throwable t) {
+        super(t);
     }
 
     public ServiceException(String message) {
         super(message);
     }
 
+    public ServiceException(String message, Throwable t) {
+        super(message, t);
+    }
+
 }
index 7f4a05deef1d1224394e8e52be77923ab4cf6a80..3f2674392c448cc52fa3574da72b8954d4f1df96 100644 (file)
@@ -30,26 +30,15 @@ class ServletPortletHelper implements Serializable {
      */
     static final SystemMessages DEFAULT_SYSTEM_MESSAGES = new SystemMessages();
 
-    public static class ApplicationClassException extends Exception {
-
-        public ApplicationClassException(String message, Throwable cause) {
-            super(message, cause);
-        }
-
-        public ApplicationClassException(String message) {
-            super(message);
-        }
-    }
-
     static Class<? extends LegacyApplication> getLegacyApplicationClass(
-            VaadinService vaadinService) throws ApplicationClassException {
+            VaadinService vaadinService) throws ServiceException {
         Properties initParameters = vaadinService.getDeploymentConfiguration()
                 .getInitParameters();
         String applicationParameter = initParameters.getProperty("application");
         ClassLoader classLoader = vaadinService.getClassLoader();
 
         if (applicationParameter == null) {
-            throw new ApplicationClassException(
+            throw new ServiceException(
                     "No \"application\" init parameter found");
         }
 
@@ -57,16 +46,15 @@ class ServletPortletHelper implements Serializable {
             return classLoader.loadClass(applicationParameter).asSubclass(
                     LegacyApplication.class);
         } catch (final ClassNotFoundException e) {
-            throw new ApplicationClassException(
-                    "Failed to load application class: " + applicationParameter,
-                    e);
+            throw new ServiceException("Failed to load application class: "
+                    + applicationParameter, e);
         }
     }
 
     private static void verifyUIClass(String className, ClassLoader classLoader)
-            throws ApplicationClassException {
+            throws ServiceException {
         if (className == null) {
-            throw new ApplicationClassException(VaadinSession.UI_PARAMETER
+            throw new ServiceException(VaadinSession.UI_PARAMETER
                     + " init parameter not defined");
         }
 
@@ -74,19 +62,17 @@ class ServletPortletHelper implements Serializable {
         try {
             Class<?> uiClass = classLoader.loadClass(className);
             if (!UI.class.isAssignableFrom(uiClass)) {
-                throw new ApplicationClassException(className
-                        + " does not implement UI");
+                throw new ServiceException(className + " does not implement UI");
             }
             // Try finding a default constructor, else throw exception
             uiClass.getConstructor();
         } catch (ClassNotFoundException e) {
-            throw new ApplicationClassException(className
-                    + " could not be loaded", e);
+            throw new ServiceException(className + " could not be loaded", e);
         } catch (SecurityException e) {
-            throw new ApplicationClassException("Could not access " + className
+            throw new ServiceException("Could not access " + className
                     + " class", e);
         } catch (NoSuchMethodException e) {
-            throw new ApplicationClassException(className
+            throw new ServiceException(className
                     + " doesn't have a public no-args constructor");
         }
     }
@@ -132,7 +118,7 @@ class ServletPortletHelper implements Serializable {
     }
 
     public static void initDefaultUIProvider(VaadinSession application,
-            VaadinService vaadinService) throws ApplicationClassException {
+            VaadinService vaadinService) throws ServiceException {
         String uiProperty = vaadinService.getDeploymentConfiguration()
                 .getInitParameters().getProperty(VaadinSession.UI_PARAMETER);
         if (uiProperty != null) {
@@ -142,9 +128,9 @@ class ServletPortletHelper implements Serializable {
     }
 
     public static void checkUiProviders(VaadinSession newApplication)
-            throws ApplicationClassException {
+            throws ServiceException {
         if (newApplication.getUIProviders().isEmpty()) {
-            throw new ApplicationClassException(
+            throw new ServiceException(
                     "No UIProvider has been added to the application and there is no \""
                             + VaadinSession.UI_PARAMETER + "\" init parameter.");
         }
index 9977fa0da7dc0a6c4961472b4579e170acb40d2c..eb5d838b725926f60c514dc95fb36035e4a9c1f2 100644 (file)
@@ -33,7 +33,6 @@ import javax.servlet.ServletException;
 
 import com.vaadin.LegacyApplication;
 import com.vaadin.event.EventRouter;
-import com.vaadin.server.ServletPortletHelper.ApplicationClassException;
 import com.vaadin.server.VaadinSession.SessionStartEvent;
 import com.vaadin.ui.UI;
 import com.vaadin.util.CurrentInstance;
@@ -362,11 +361,7 @@ public abstract class VaadinService implements Serializable {
             throws ServiceException {
         VaadinSession session = createVaadinSession(request);
 
-        try {
-            ServletPortletHelper.initDefaultUIProvider(session, this);
-        } catch (ApplicationClassException e) {
-            throw new ServiceException(e);
-        }
+        ServletPortletHelper.initDefaultUIProvider(session, this);
 
         session.setVaadinService(this);
         session.storeInSession(request.getWrappedSession());
@@ -436,11 +431,7 @@ public abstract class VaadinService implements Serializable {
         eventRouter.fireEvent(new VaadinSessionInitializeEvent(this, session,
                 request));
 
-        try {
-            ServletPortletHelper.checkUiProviders(session);
-        } catch (ApplicationClassException e) {
-            throw new ServiceException(e);
-        }
+        ServletPortletHelper.checkUiProviders(session);
     }
 
     private void closeApplication(VaadinSession application,