diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-08-20 19:19:47 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-08-20 19:20:09 +0300 |
commit | 72d9cc9ec098952dfdb03708f808da555307e78d (patch) | |
tree | d2e97757e8a1ecdcf25cfec3b066c87a2db6c791 /server/src/com/vaadin/terminal/DefaultRootProvider.java | |
parent | 0dfdb151913a13e929a65c4dd8b5987c9edd06d5 (diff) | |
download | vaadin-framework-72d9cc9ec098952dfdb03708f808da555307e78d.tar.gz vaadin-framework-72d9cc9ec098952dfdb03708f808da555307e78d.zip |
Add RootProvider for Root selection without custom Application (#8159)
Diffstat (limited to 'server/src/com/vaadin/terminal/DefaultRootProvider.java')
-rw-r--r-- | server/src/com/vaadin/terminal/DefaultRootProvider.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/server/src/com/vaadin/terminal/DefaultRootProvider.java b/server/src/com/vaadin/terminal/DefaultRootProvider.java new file mode 100644 index 0000000000..cbf8c98828 --- /dev/null +++ b/server/src/com/vaadin/terminal/DefaultRootProvider.java @@ -0,0 +1,51 @@ +/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.terminal;
+
+import com.vaadin.Application;
+import com.vaadin.RootRequiresMoreInformationException;
+import com.vaadin.ui.Root;
+
+public class DefaultRootProvider extends AbstractRootProvider {
+
+ @Override
+ public Class<? extends Root> getRootClass(Application application,
+ WrappedRequest request) throws RootRequiresMoreInformationException {
+ Object rootClassNameObj = application
+ .getProperty(Application.ROOT_PARAMETER);
+
+ if (rootClassNameObj instanceof String) {
+ String rootClassName = rootClassNameObj.toString();
+
+ ClassLoader classLoader = request.getDeploymentConfiguration()
+ .getClassLoader();
+ if (classLoader == null) {
+ classLoader = getClass().getClassLoader();
+ }
+ try {
+ Class<? extends Root> rootClass = Class.forName(rootClassName,
+ true, classLoader).asSubclass(Root.class);
+
+ return rootClass;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not find root class", e);
+ }
+ }
+
+ return null;
+ }
+}
|