summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java')
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java b/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
deleted file mode 100644
index 7b51712904..0000000000
--- a/src/com/vaadin/terminal/gwt/server/AbstractDeploymentConfiguration.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-
-package com.vaadin.terminal.gwt.server;
-
-import java.lang.reflect.Constructor;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ServiceLoader;
-
-import com.vaadin.terminal.DeploymentConfiguration;
-
-public abstract class AbstractDeploymentConfiguration implements
- DeploymentConfiguration {
-
- private final Class<?> systemPropertyBaseClass;
- private final Properties applicationProperties = new Properties();
- private AddonContext addonContext;
-
- public AbstractDeploymentConfiguration(Class<?> systemPropertyBaseClass) {
- this.systemPropertyBaseClass = systemPropertyBaseClass;
- }
-
- @Override
- public String getApplicationOrSystemProperty(String propertyName,
- String defaultValue) {
-
- String val = null;
-
- // Try application properties
- val = getApplicationProperty(propertyName);
- if (val != null) {
- return val;
- }
-
- // Try system properties
- val = getSystemProperty(propertyName);
- if (val != null) {
- return val;
- }
-
- return defaultValue;
- }
-
- /**
- * Gets an system property value.
- *
- * @param parameterName
- * the Name or the parameter.
- * @return String value or null if not found
- */
- protected String getSystemProperty(String parameterName) {
- String val = null;
-
- String pkgName;
- final Package pkg = systemPropertyBaseClass.getPackage();
- if (pkg != null) {
- pkgName = pkg.getName();
- } else {
- final String className = systemPropertyBaseClass.getName();
- pkgName = new String(className.toCharArray(), 0,
- className.lastIndexOf('.'));
- }
- val = System.getProperty(pkgName + "." + parameterName);
- if (val != null) {
- return val;
- }
-
- // Try lowercased system properties
- val = System.getProperty(pkgName + "." + parameterName.toLowerCase());
- return val;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- final String classLoaderName = getApplicationOrSystemProperty(
- "ClassLoader", null);
- ClassLoader classLoader;
- if (classLoaderName == null) {
- classLoader = getClass().getClassLoader();
- } else {
- try {
- final Class<?> classLoaderClass = getClass().getClassLoader()
- .loadClass(classLoaderName);
- final Constructor<?> c = classLoaderClass
- .getConstructor(new Class[] { ClassLoader.class });
- classLoader = (ClassLoader) c
- .newInstance(new Object[] { getClass().getClassLoader() });
- } catch (final Exception e) {
- throw new RuntimeException(
- "Could not find specified class loader: "
- + classLoaderName, e);
- }
- }
- return classLoader;
- }
-
- /**
- * Gets an application property value.
- *
- * @param parameterName
- * the Name or the parameter.
- * @return String value or null if not found
- */
- protected String getApplicationProperty(String parameterName) {
-
- String val = applicationProperties.getProperty(parameterName);
- if (val != null) {
- return val;
- }
-
- // Try lower case application properties for backward compatibility with
- // 3.0.2 and earlier
- val = applicationProperties.getProperty(parameterName.toLowerCase());
-
- return val;
- }
-
- @Override
- public Properties getInitParameters() {
- return applicationProperties;
- }
-
- @Override
- public Iterator<AddonContextListener> getAddonContextListeners() {
- // Called once for init and then no more, so there's no point in caching
- // the instance
- ServiceLoader<AddonContextListener> contextListenerLoader = ServiceLoader
- .load(AddonContextListener.class, getClassLoader());
- return contextListenerLoader.iterator();
- }
-
- @Override
- public void setAddonContext(AddonContext addonContext) {
- this.addonContext = addonContext;
- }
-
- @Override
- public AddonContext getAddonContext() {
- return addonContext;
- }
-}