if (!handleVariables(request, response, callback, application, uI)) {
// var inconsistency; the client is probably out-of-sync
- SystemMessages ci = response.getDeploymentConfiguration()
+ SystemMessages ci = response.getVaadinService()
.getSystemMessages();
String msg = ci.getOutOfSyncMessage();
String cap = ci.getOutOfSyncCaption();
}
}
- SystemMessages ci = request.getDeploymentConfiguration()
- .getSystemMessages();
+ SystemMessages ci = request.getVaadinService().getSystemMessages();
// meta instruction for client to enable auto-forward to
// sessionExpiredURL after timer expires.
.substring(ApplicationConstants.CONNECTOR_RESOURCE_PREFIX
.length() + 2);
- final String mimetype = response.getDeploymentConfiguration()
- .getMimeType(resourceName);
+ final String mimetype = response.getVaadinService().getMimeType(
+ resourceName);
// Security check: avoid accidentally serving from the UI of the
// classpath instead of relative to the context class
+++ /dev/null
-/*
- * 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.server;
-
-import java.lang.reflect.Constructor;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-public abstract class AbstractDeploymentConfiguration implements
- DeploymentConfiguration {
-
- private AddonContext addonContext;
- private final ApplicationConfiguration applicationConfiguration;
-
- public AbstractDeploymentConfiguration(
- ApplicationConfiguration applicationConfiguration) {
- this.applicationConfiguration = applicationConfiguration;
- }
-
- @Override
- public ApplicationConfiguration getApplicationConfiguration() {
- return applicationConfiguration;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- final String classLoaderName = getApplicationConfiguration()
- .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;
- }
-
- @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;
- }
-}
--- /dev/null
+/*
+ * 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.server;
+
+import java.lang.reflect.Constructor;
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+public abstract class AbstractVaadinService implements VaadinService {
+
+ private AddonContext addonContext;
+ private final ApplicationConfiguration applicationConfiguration;
+
+ public AbstractVaadinService(
+ ApplicationConfiguration applicationConfiguration) {
+ this.applicationConfiguration = applicationConfiguration;
+ }
+
+ @Override
+ public ApplicationConfiguration getApplicationConfiguration() {
+ return applicationConfiguration;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ final String classLoaderName = getApplicationConfiguration()
+ .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;
+ }
+
+ @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;
+ }
+}
* META-INF/services/com.vaadin.server.AddonContextListener will be checked for
* lines containing fully qualified names of classes to use. This behavior can
* however be overridden for custom deployment situations (e.g. to use CDI or
- * OSGi) by overriding
- * {@link DeploymentConfiguration#getAddonContextListeners()}.
+ * OSGi) by overriding {@link VaadinService#getAddonContextListeners()}.
*
* @author Vaadin Ltd
* @since 7.0.0
.findMethod(ApplicationStartedListener.class, "applicationStarted",
ApplicationStartedEvent.class);
- private final DeploymentConfiguration deploymentConfiguration;
+ private final VaadinService vaadinService;
private final EventRouter eventRouter = new EventRouter();
* Creates a new context using a given deployment configuration. Only the
* framework itself should typically create AddonContext methods.
*
- * @param deploymentConfiguration
- * the deployment configuration for the associated servlet or
- * portlet.
+ * @param vaadinService
+ * the vaadin service for the associated servlet or portlet.
*/
- public AddonContext(DeploymentConfiguration deploymentConfiguration) {
- this.deploymentConfiguration = deploymentConfiguration;
- deploymentConfiguration.setAddonContext(this);
+ public AddonContext(VaadinService vaadinService) {
+ this.vaadinService = vaadinService;
+ vaadinService.setAddonContext(this);
}
/**
*
* @return the deployment configuration
*/
- public DeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ public VaadinService getVaadinService() {
+ return vaadinService;
}
/**
* Initializes this context, causing all found listeners to be notified.
* Listeners are by default found using {@link ServiceLoader}, but the
- * {@link DeploymentConfiguration} can provide an alternative
- * implementation.
+ * {@link VaadinService} can provide an alternative implementation.
* <p>
* This method is not intended to be used by add-ons, but instead by the
* part of the framework that created this context object.
*/
public void init() {
AddonContextEvent event = new AddonContextEvent(this);
- Iterator<AddonContextListener> listeners = deploymentConfiguration
+ Iterator<AddonContextListener> listeners = vaadinService
.getAddonContextListeners();
while (listeners.hasNext()) {
AddonContextListener listener = listeners.next();
private String getBootstrapHtml(BootstrapContext context) {
WrappedRequest request = context.getRequest();
WrappedResponse response = context.getResponse();
- DeploymentConfiguration deploymentConfiguration = request
- .getDeploymentConfiguration();
+ VaadinService vaadinService = request.getVaadinService();
BootstrapFragmentResponse fragmentResponse = context
.getBootstrapResponse();
- if (deploymentConfiguration.isStandalone(request)) {
+ if (vaadinService.isStandalone(request)) {
Map<String, Object> headers = new LinkedHashMap<String, Object>();
Document document = Document.createShell("");
BootstrapPageResponse pageResponse = new BootstrapPageResponse(
.getUiProvider(context.getRequest(), context.getUIClass())
.getWidgetsetForUI(context.getRequest(), context.getUIClass());
if (widgetset == null) {
- widgetset = request.getDeploymentConfiguration()
- .getConfiguredWidgetset(request);
+ widgetset = request.getVaadinService().getConfiguredWidgetset(
+ request);
}
widgetset = VaadinServlet.stripSpecialChars(widgetset);
WrappedRequest request = context.getRequest();
- DeploymentConfiguration deploymentConfiguration = request
- .getDeploymentConfiguration();
- String staticFileLocation = deploymentConfiguration
+ VaadinService vaadinService = request.getVaadinService();
+ String staticFileLocation = vaadinService
.getStaticFileLocation(request);
fragmentNodes
WrappedRequest request = context.getRequest();
VaadinSession application = context.getApplication();
- DeploymentConfiguration deploymentConfiguration = request
- .getDeploymentConfiguration();
+ VaadinService vaadinService = request.getVaadinService();
// Get system messages
- SystemMessages systemMessages = deploymentConfiguration
- .getSystemMessages();
+ SystemMessages systemMessages = vaadinService.getSystemMessages();
if (systemMessages != null) {
// Write the CommunicationError -message to client
JSONObject comErrMsg = new JSONObject();
defaults.put("authErrMsg", authErrMsg);
}
- String staticFileLocation = deploymentConfiguration
+ String staticFileLocation = vaadinService
.getStaticFileLocation(request);
String widgetsetBase = staticFileLocation + "/"
+ VaadinServlet.WIDGETSET_DIRECTORY_PATH;
defaults.put("debug", true);
}
- if (deploymentConfiguration.isStandalone(request)) {
+ if (vaadinService.isStandalone(request)) {
defaults.put("standalone", true);
}
- defaults.put("heartbeatInterval", deploymentConfiguration
+ defaults.put("heartbeatInterval", vaadinService
.getApplicationConfiguration().getHeartbeatInterval());
defaults.put("appUri", getAppUri(context));
*/
public String getThemeUri(BootstrapContext context, String themeName) {
WrappedRequest request = context.getRequest();
- final String staticFilePath = request.getDeploymentConfiguration()
+ final String staticFilePath = request.getVaadinService()
.getStaticFileLocation(request);
return staticFilePath + "/" + VaadinServlet.THEME_DIRECTORY_PATH
+ themeName;
String themeName = getThemeName(context);
if (themeName == null) {
WrappedRequest request = context.getRequest();
- themeName = request.getDeploymentConfiguration()
- .getConfiguredTheme(request);
+ themeName = request.getVaadinService().getConfiguredTheme(request);
}
// XSS preventation, theme names shouldn't contain special chars anyway.
}
@Override
- public DeploymentConfiguration getDeploymentConfiguration() {
- return secondRequest.getDeploymentConfiguration();
+ public VaadinService getVaadinService() {
+ return secondRequest.getVaadinService();
}
}
if (uiClassNameObj instanceof String) {
String uiClassName = uiClassNameObj.toString();
- ClassLoader classLoader = request.getDeploymentConfiguration()
+ ClassLoader classLoader = request.getVaadinService()
.getClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
+++ /dev/null
-/*
- * 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.server;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Iterator;
-
-import javax.portlet.PortletContext;
-import javax.servlet.ServletContext;
-
-/**
- * Provide deployment specific settings that are required outside terminal
- * specific code.
- *
- * @author Vaadin Ltd.
- *
- * @since 7.0
- */
-public interface DeploymentConfiguration extends Serializable {
- /**
- * Return the URL from where static files, e.g. the widgetset and the theme,
- * are served. In a standard configuration the VAADIN folder inside the
- * returned folder is what is used for widgetsets and themes.
- *
- * The returned folder is usually the same as the context path and
- * independent of the application.
- *
- * @param request
- * the request for which the location should be determined
- *
- * @return The location of static resources (should contain the VAADIN
- * directory). Never ends with a slash (/).
- */
- public String getStaticFileLocation(WrappedRequest request);
-
- /**
- * Gets the widgetset that is configured for this deployment, e.g. from a
- * parameter in web.xml.
- *
- * @param request
- * the request for which a widgetset is required
- * @return the name of the widgetset
- */
- public String getConfiguredWidgetset(WrappedRequest request);
-
- /**
- * Gets the theme that is configured for this deployment, e.g. from a portal
- * parameter or just some sensible default value.
- *
- * @param request
- * the request for which a theme is required
- * @return the name of the theme
- */
- public String getConfiguredTheme(WrappedRequest request);
-
- /**
- * Checks whether the Vaadin application will be rendered on its own in the
- * browser or whether it will be included into some other context. A
- * standalone application may do things that might interfere with other
- * parts of a page, e.g. changing the page title and requesting focus upon
- * loading.
- *
- * @param request
- * the request for which the application is loaded
- * @return a boolean indicating whether the application should be standalone
- */
- public boolean isStandalone(WrappedRequest request);
-
- /**
- * Get the class loader to use for loading classes loaded by name, e.g.
- * custom UI classes. <code>null</code> indicates that the default class
- * loader should be used.
- *
- * @return the class loader to use, or <code>null</code>
- */
- public ClassLoader getClassLoader();
-
- /**
- * Returns the MIME type of the specified file, or null if the MIME type is
- * not known. The MIME type is determined by the configuration of the
- * container, and may be specified in a deployment descriptor. Common MIME
- * types are "text/html" and "image/gif".
- *
- * @param resourceName
- * a String specifying the name of a file
- * @return a String specifying the file's MIME type
- *
- * @see ServletContext#getMimeType(String)
- * @see PortletContext#getMimeType(String)
- */
- public String getMimeType(String resourceName);
-
- /**
- * Gets the application configuration.
- *
- * @return the application configuration
- */
- public ApplicationConfiguration getApplicationConfiguration();
-
- public Iterator<AddonContextListener> getAddonContextListeners();
-
- public AddonContext getAddonContext();
-
- public void setAddonContext(AddonContext vaadinContext);
-
- /**
- * Gets the system messages object
- *
- * @return the system messages object
- */
- public SystemMessages getSystemMessages();
-
- /**
- * Returns application context base directory.
- *
- * Typically an application is deployed in a such way that is has an
- * application directory. For web applications this directory is the root
- * directory of the web applications. In some cases applications might not
- * have an application directory (for example web applications running
- * inside a war).
- *
- * @return The application base directory or null if the application has no
- * base directory.
- */
- public File getBaseDirectory();
-}
HttpServletResponse unwrappedResponse) throws ServletException,
IOException {
WrappedHttpServletRequest request = new WrappedHttpServletRequest(
- unwrappedRequest, getDeploymentConfiguration());
+ unwrappedRequest, getVaadinService());
WrappedHttpServletResponse response = new WrappedHttpServletResponse(
- unwrappedResponse, getDeploymentConfiguration());
+ unwrappedResponse, getVaadinService());
if (isCleanupRequest(request)) {
cleanDatastore();
throws ClassNotFoundException {
try {
return ServletPortletHelper
- .getLegacyApplicationClass(getDeploymentConfiguration());
+ .getLegacyApplicationClass(getVaadinService());
} catch (ApplicationClassException e) {
throw new RuntimeException(e);
}
throws ClassNotFoundException {
try {
return ServletPortletHelper
- .getLegacyApplicationClass(getDeploymentConfiguration());
+ .getLegacyApplicationClass(getVaadinService());
} catch (ApplicationClassException e) {
throw new RuntimeException(e);
}
@Override
protected String getMainDivStyle(BootstrapContext context) {
- DeploymentConfiguration deploymentConfiguration = context
- .getRequest().getDeploymentConfiguration();
- return deploymentConfiguration.getApplicationConfiguration()
+ VaadinService vaadinService = context.getRequest()
+ .getVaadinService();
+ return vaadinService.getApplicationConfiguration()
.getApplicationOrSystemProperty(
VaadinPortlet.PORTLET_PARAMETER_STYLE, null);
}
}
static Class<? extends Application> getLegacyApplicationClass(
- DeploymentConfiguration deploymentConfiguration)
- throws ApplicationClassException {
- Properties initParameters = deploymentConfiguration
- .getApplicationConfiguration().getInitParameters();
+ VaadinService vaadinService) throws ApplicationClassException {
+ Properties initParameters = vaadinService.getApplicationConfiguration()
+ .getInitParameters();
String applicationParameter = initParameters.getProperty("application");
- ClassLoader classLoader = deploymentConfiguration.getClassLoader();
+ ClassLoader classLoader = vaadinService.getClassLoader();
if (applicationParameter == null) {
throw new ApplicationClassException(
}
public static void initDefaultUIProvider(VaadinSession application,
- DeploymentConfiguration deploymentConfiguration)
- throws ApplicationClassException {
- String uiProperty = deploymentConfiguration
- .getApplicationConfiguration().getInitParameters()
- .getProperty(VaadinSession.UI_PARAMETER);
+ VaadinService vaadinService) throws ApplicationClassException {
+ String uiProperty = vaadinService.getApplicationConfiguration()
+ .getInitParameters().getProperty(VaadinSession.UI_PARAMETER);
if (uiProperty != null) {
- verifyUIClass(uiProperty, deploymentConfiguration.getClassLoader());
+ verifyUIClass(uiProperty, vaadinService.getClassLoader());
application.addUIProvider(new DefaultUIProvider());
}
}
public static final String RESOURCE_URL_ID = "APP";
- public static class PortletDeploymentConfiguration extends
- AbstractDeploymentConfiguration {
+ public static class PortletService extends AbstractVaadinService {
private final VaadinPortlet portlet;
- public PortletDeploymentConfiguration(VaadinPortlet portlet,
+ public PortletService(VaadinPortlet portlet,
ApplicationConfiguration applicationConfiguration) {
super(applicationConfiguration);
this.portlet = portlet;
WrappedPortletRequest {
public WrappedHttpAndPortletRequest(PortletRequest request,
- HttpServletRequest originalRequest,
- DeploymentConfiguration deploymentConfiguration) {
- super(request, deploymentConfiguration);
+ HttpServletRequest originalRequest, PortletService vaadinService) {
+ super(request, vaadinService);
this.originalRequest = originalRequest;
}
public static class WrappedGateinRequest extends
WrappedHttpAndPortletRequest {
public WrappedGateinRequest(PortletRequest request,
- DeploymentConfiguration deploymentConfiguration) {
- super(request, getOriginalRequest(request), deploymentConfiguration);
+ PortletService vaadinService) {
+ super(request, getOriginalRequest(request), vaadinService);
}
private static final HttpServletRequest getOriginalRequest(
WrappedHttpAndPortletRequest {
public WrappedLiferayRequest(PortletRequest request,
- DeploymentConfiguration deploymentConfiguration) {
- super(request, getOriginalRequest(request), deploymentConfiguration);
+ PortletService vaadinService) {
+ super(request, getOriginalRequest(request), vaadinService);
}
@Override
// TODO Can we close the application when the portlet is removed? Do we know
// when the portlet is removed?
- private PortletDeploymentConfiguration deploymentConfiguration;
+ private PortletService vaadinService;
private AddonContext addonContext;
@Override
}
ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties);
- deploymentConfiguration = createDeploymentConfiguration(applicationConfiguration);
+ vaadinService = createPortletService(applicationConfiguration);
- addonContext = new AddonContext(deploymentConfiguration);
+ addonContext = new AddonContext(vaadinService);
addonContext.init();
}
applicationProperties);
}
- protected PortletDeploymentConfiguration createDeploymentConfiguration(
+ protected PortletService createPortletService(
ApplicationConfiguration applicationConfiguration) {
- return new PortletDeploymentConfiguration(this,
- applicationConfiguration);
+ return new PortletService(this, applicationConfiguration);
}
@Override
WrappedPortletRequest wrappedRequest = createWrappedRequest(request);
WrappedPortletResponse wrappedResponse = new WrappedPortletResponse(
- response, getDeploymentConfiguration());
+ response, getVaadinService());
CurrentInstance.set(WrappedRequest.class, wrappedRequest);
CurrentInstance.set(WrappedResponse.class, wrappedResponse);
String portalInfo = request.getPortalContext().getPortalInfo()
.toLowerCase();
if (portalInfo.contains("liferay")) {
- return new WrappedLiferayRequest(request,
- getDeploymentConfiguration());
+ return new WrappedLiferayRequest(request, getVaadinService());
} else if (portalInfo.contains("gatein")) {
- return new WrappedGateinRequest(request,
- getDeploymentConfiguration());
+ return new WrappedGateinRequest(request, getVaadinService());
} else {
- return new WrappedPortletRequest(request,
- getDeploymentConfiguration());
+ return new WrappedPortletRequest(request, getVaadinService());
}
}
- protected PortletDeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ protected PortletService getVaadinService() {
+ return vaadinService;
}
private void handleUnknownRequest(PortletRequest request,
Locale locale = request.getLocale();
newApplication.setLocale(locale);
// No application URL when running inside a portlet
- newApplication.start(new ApplicationStartEvent(null,
- getDeploymentConfiguration().getApplicationConfiguration(),
+ newApplication.start(new ApplicationStartEvent(null, getVaadinService()
+ .getApplicationConfiguration(),
new PortletCommunicationManager(newApplication)));
addonContext.fireApplicationStarted(newApplication);
try {
ServletPortletHelper.initDefaultUIProvider(application,
- getDeploymentConfiguration());
+ getVaadinService());
} catch (ApplicationClassException e) {
throw new PortletException(e);
}
// if this was an UIDL request, response UIDL back to client
if (getRequestType(request) == RequestType.UIDL) {
- SystemMessages ci = getDeploymentConfiguration()
- .getSystemMessages();
+ SystemMessages ci = getVaadinService().getSystemMessages();
criticalNotification(request, response,
ci.getInternalErrorCaption(), ci.getInternalErrorMessage(),
null, ci.getInternalErrorURL());
public PortletConfig getPortletConfig() {
WrappedPortletResponse response = (WrappedPortletResponse) CurrentInstance
.get(WrappedResponse.class);
- return response.getDeploymentConfiguration().getPortlet()
- .getPortletConfig();
+ return response.getVaadinService().getPortlet().getPortletConfig();
}
public void addPortletListener(PortletListener listener) {
--- /dev/null
+/*
+ * 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.server;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Iterator;
+
+import javax.portlet.PortletContext;
+import javax.servlet.ServletContext;
+
+/**
+ * Provide deployment specific settings that are required outside terminal
+ * specific code.
+ *
+ * @author Vaadin Ltd.
+ *
+ * @since 7.0
+ */
+public interface VaadinService extends Serializable {
+ /**
+ * Return the URL from where static files, e.g. the widgetset and the theme,
+ * are served. In a standard configuration the VAADIN folder inside the
+ * returned folder is what is used for widgetsets and themes.
+ *
+ * The returned folder is usually the same as the context path and
+ * independent of the application.
+ *
+ * @param request
+ * the request for which the location should be determined
+ *
+ * @return The location of static resources (should contain the VAADIN
+ * directory). Never ends with a slash (/).
+ */
+ public String getStaticFileLocation(WrappedRequest request);
+
+ /**
+ * Gets the widgetset that is configured for this deployment, e.g. from a
+ * parameter in web.xml.
+ *
+ * @param request
+ * the request for which a widgetset is required
+ * @return the name of the widgetset
+ */
+ public String getConfiguredWidgetset(WrappedRequest request);
+
+ /**
+ * Gets the theme that is configured for this deployment, e.g. from a portal
+ * parameter or just some sensible default value.
+ *
+ * @param request
+ * the request for which a theme is required
+ * @return the name of the theme
+ */
+ public String getConfiguredTheme(WrappedRequest request);
+
+ /**
+ * Checks whether the Vaadin application will be rendered on its own in the
+ * browser or whether it will be included into some other context. A
+ * standalone application may do things that might interfere with other
+ * parts of a page, e.g. changing the page title and requesting focus upon
+ * loading.
+ *
+ * @param request
+ * the request for which the application is loaded
+ * @return a boolean indicating whether the application should be standalone
+ */
+ public boolean isStandalone(WrappedRequest request);
+
+ /**
+ * Get the class loader to use for loading classes loaded by name, e.g.
+ * custom UI classes. <code>null</code> indicates that the default class
+ * loader should be used.
+ *
+ * @return the class loader to use, or <code>null</code>
+ */
+ public ClassLoader getClassLoader();
+
+ /**
+ * Returns the MIME type of the specified file, or null if the MIME type is
+ * not known. The MIME type is determined by the configuration of the
+ * container, and may be specified in a deployment descriptor. Common MIME
+ * types are "text/html" and "image/gif".
+ *
+ * @param resourceName
+ * a String specifying the name of a file
+ * @return a String specifying the file's MIME type
+ *
+ * @see ServletContext#getMimeType(String)
+ * @see PortletContext#getMimeType(String)
+ */
+ public String getMimeType(String resourceName);
+
+ /**
+ * Gets the application configuration.
+ *
+ * @return the application configuration
+ */
+ public ApplicationConfiguration getApplicationConfiguration();
+
+ public Iterator<AddonContextListener> getAddonContextListeners();
+
+ public AddonContext getAddonContext();
+
+ public void setAddonContext(AddonContext vaadinContext);
+
+ /**
+ * Gets the system messages object
+ *
+ * @return the system messages object
+ */
+ public SystemMessages getSystemMessages();
+
+ /**
+ * Returns application context base directory.
+ *
+ * Typically an application is deployed in a such way that is has an
+ * application directory. For web applications this directory is the root
+ * directory of the web applications. In some cases applications might not
+ * have an application directory (for example web applications running
+ * inside a war).
+ *
+ * @return The application base directory or null if the application has no
+ * base directory.
+ */
+ public File getBaseDirectory();
+}
@SuppressWarnings("serial")
public class VaadinServlet extends HttpServlet implements Constants {
- public static class ServletDeploymentConfiguration extends
- AbstractDeploymentConfiguration {
+ public static class ServletService extends AbstractVaadinService {
private final VaadinServlet servlet;
- public ServletDeploymentConfiguration(VaadinServlet servlet,
+ public ServletService(VaadinServlet servlet,
ApplicationConfiguration applicationProperties) {
super(applicationProperties);
this.servlet = servlet;
private final String resourcePath = null;
- private DeploymentConfiguration deploymentConfiguration;
+ private ServletService servletService;
private AddonContext addonContext;
}
ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties);
- deploymentConfiguration = createDeploymentConfiguration(applicationConfiguration);
+ servletService = createServletService(applicationConfiguration);
- addonContext = new AddonContext(deploymentConfiguration);
+ addonContext = new AddonContext(servletService);
addonContext.init();
}
applicationProperties);
}
- protected ServletDeploymentConfiguration createDeploymentConfiguration(
+ protected ServletService createServletService(
ApplicationConfiguration applicationConfiguration) {
- return new ServletDeploymentConfiguration(this,
- applicationConfiguration);
+ return new ServletService(this, applicationConfiguration);
}
@Override
private WrappedHttpServletResponse createWrappedResponse(
HttpServletResponse response) {
WrappedHttpServletResponse wrappedResponse = new WrappedHttpServletResponse(
- response, getDeploymentConfiguration());
+ response, getVaadinService());
return wrappedResponse;
}
*/
protected WrappedHttpServletRequest createWrappedRequest(
HttpServletRequest request) {
- return new WrappedHttpServletRequest(request,
- getDeploymentConfiguration());
+ return new WrappedHttpServletRequest(request, getVaadinService());
}
/**
*
* @return the deployment configuration
*/
- protected DeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ protected ServletService getVaadinService() {
+ return servletService;
}
/**
// This can be removed if cookieless mode (#3228) is supported
if (request.getRequestedSessionId() == null) {
// User has cookies disabled
- SystemMessages systemMessages = getDeploymentConfiguration()
+ SystemMessages systemMessages = getVaadinService()
.getSystemMessages();
criticalNotification(request, response,
systemMessages.getCookiesDisabledCaption(),
Locale locale = request.getLocale();
newApplication.setLocale(locale);
newApplication.start(new ApplicationStartEvent(applicationUrl,
- getDeploymentConfiguration().getApplicationConfiguration(),
+ getVaadinService().getApplicationConfiguration(),
createCommunicationManager(newApplication)));
addonContext.fireApplicationStarted(newApplication);
try {
ServletPortletHelper.initDefaultUIProvider(newApplication,
- getDeploymentConfiguration());
+ getVaadinService());
} catch (ApplicationClassException e) {
throw new ServletException(e);
}
Throwable e) throws IOException, ServletException {
// if this was an UIDL request, response UIDL back to client
if (getRequestType(request) == RequestType.UIDL) {
- SystemMessages ci = getDeploymentConfiguration()
- .getSystemMessages();
+ SystemMessages ci = getVaadinService().getSystemMessages();
criticalNotification(request, response,
ci.getInternalErrorCaption(), ci.getInternalErrorMessage(),
null, ci.getInternalErrorURL());
}
try {
- SystemMessages ci = getDeploymentConfiguration()
- .getSystemMessages();
+ SystemMessages ci = getVaadinService().getSystemMessages();
if (getRequestType(request) != RequestType.UIDL) {
// 'plain' http req - e.g. browser reload;
// just go ahead redirect the browser
}
try {
- SystemMessages ci = getDeploymentConfiguration()
- .getSystemMessages();
+ SystemMessages ci = getVaadinService().getSystemMessages();
if (getRequestType(request) != RequestType.UIDL) {
// 'plain' http req - e.g. browser reload;
// just go ahead redirect the browser
// strip leading "/" otherwise stream from JAR wont work
filename = filename.substring(1);
- resourceUrl = getDeploymentConfiguration().getClassLoader()
- .getResource(filename);
+ resourceUrl = getVaadinService().getClassLoader().getResource(
+ filename);
if (resourceUrl == null) {
// cannot serve requested file
* cache timeout can be configured by setting the resourceCacheTime
* parameter in web.xml
*/
- int resourceCacheTime = getDeploymentConfiguration()
+ int resourceCacheTime = getVaadinService()
.getApplicationConfiguration().getResourceCacheTime();
response.setHeader("Cache-Control",
"max-age= " + String.valueOf(resourceCacheTime));
* <p>
* The default implementation in {@link VaadinSession} uses the
* {@value #UI_PARAMETER} parameter from web.xml for finding the name of the
- * UI class. If {@link DeploymentConfiguration#getClassLoader()} does not
- * return <code>null</code>, the returned {@link ClassLoader} is used for
- * loading the UI class. Otherwise the {@link ClassLoader} used to load this
- * class is used.
+ * UI class. If {@link VaadinService#getClassLoader()} does not return
+ * <code>null</code>, the returned {@link ClassLoader} is used for loading
+ * the UI class. Otherwise the {@link ClassLoader} used to load this class
+ * is used.
*
* </p>
*
*
* @see #getUidlRequestTimeout()
* @see #closeInactiveUIs()
- * @see DeploymentConfiguration#getHeartbeatInterval()
+ * @see ApplicationConfiguration#getHeartbeatInterval()
*
* @since 7.0.0
*
* otherwise heartbeat requests are enough to extend UI lifetime
* indefinitely.
*
- * @see DeploymentConfiguration#isIdleUICleanupEnabled()
+ * @see ApplicationConfiguration#isIdleUICleanupEnabled()
* @see #getHeartbeatTimeout()
* @see #closeInactiveUIs()
*
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
+import com.vaadin.server.VaadinServlet.ServletService;
+
/**
* Wrapper for {@link HttpServletRequest}.
*
public class WrappedHttpServletRequest extends HttpServletRequestWrapper
implements WrappedRequest {
- private final DeploymentConfiguration deploymentConfiguration;
+ private final ServletService vaadinService;
/**
* Wraps a http servlet request and associates with a deployment
*
* @param request
* the http servlet request to wrap
- * @param deploymentConfiguration
- * the associated deployment configuration
+ * @param vaadinService
+ * the associated vaadin service
*/
public WrappedHttpServletRequest(HttpServletRequest request,
- DeploymentConfiguration deploymentConfiguration) {
+ ServletService vaadinService) {
super(request);
- this.deploymentConfiguration = deploymentConfiguration;
+ this.vaadinService = vaadinService;
}
@Override
}
@Override
- public DeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ public ServletService getVaadinService() {
+ return vaadinService;
}
@Override
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
+import com.vaadin.server.VaadinServlet.ServletService;
+
/**
* Wrapper for {@link HttpServletResponse}.
*
public class WrappedHttpServletResponse extends HttpServletResponseWrapper
implements WrappedResponse {
- private DeploymentConfiguration deploymentConfiguration;
+ private ServletService vaadinService;
/**
* Wraps a http servlet response and an associated deployment configuration
*
* @param response
* the http servlet response to wrap
- * @param deploymentConfiguration
- * the associated deployment configuration
+ * @param vaadinService
+ * the associated vaadin service
*/
public WrappedHttpServletResponse(HttpServletResponse response,
- DeploymentConfiguration deploymentConfiguration) {
+ ServletService vaadinService) {
super(response);
- this.deploymentConfiguration = deploymentConfiguration;
+ this.vaadinService = vaadinService;
}
/**
}
@Override
- public DeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ public ServletService getVaadinService() {
+ return vaadinService;
}
}
\ No newline at end of file
import javax.portlet.PortletRequest;
import javax.portlet.ResourceRequest;
+import com.vaadin.server.VaadinPortlet.PortletService;
import com.vaadin.shared.ApplicationConstants;
/**
public class WrappedPortletRequest implements WrappedRequest {
private final PortletRequest request;
- private final DeploymentConfiguration deploymentConfiguration;
+ private final PortletService vaadinService;
/**
* Wraps a portlet request and an associated deployment configuration
*
* @param request
* the portlet request to wrap
- * @param deploymentConfiguration
- * the associated deployment configuration
+ * @param vaadinService
+ * the associated vaadin service
*/
public WrappedPortletRequest(PortletRequest request,
- DeploymentConfiguration deploymentConfiguration) {
+ PortletService vaadinService) {
this.request = request;
- this.deploymentConfiguration = deploymentConfiguration;
+ this.vaadinService = vaadinService;
}
@Override
}
@Override
- public DeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ public PortletService getVaadinService() {
+ return vaadinService;
}
/**
import javax.portlet.PortletResponse;
import javax.portlet.ResourceResponse;
-import com.vaadin.server.VaadinPortlet.PortletDeploymentConfiguration;
+import com.vaadin.server.VaadinPortlet.PortletService;
/**
* Wrapper for {@link PortletResponse} and its subclasses.
}
private final PortletResponse response;
- private PortletDeploymentConfiguration deploymentConfiguration;
+ private PortletService vaadinService;
/**
* Wraps a portlet response and an associated deployment configuration
*
* @param response
* the portlet response to wrap
- * @param deploymentConfiguration
- * the associated deployment configuration
+ * @param vaadinService
+ * the associated vaadin service
*/
public WrappedPortletResponse(PortletResponse response,
- PortletDeploymentConfiguration deploymentConfiguration) {
+ PortletService vaadinService) {
this.response = response;
- this.deploymentConfiguration = deploymentConfiguration;
+ this.vaadinService = vaadinService;
}
@Override
}
@Override
- public PortletDeploymentConfiguration getDeploymentConfiguration() {
- return deploymentConfiguration;
+ public PortletService getVaadinService() {
+ return vaadinService;
}
}
\ No newline at end of file
public String getHeader(String headerName);
/**
- * Gets the deployment configuration for the context of this request.
+ * Gets the vaadin service for the context of this request.
*
- * @return the deployment configuration
+ * @return the vaadin service
*
- * @see DeploymentConfiguration
+ * @see VaadinService
*/
- public DeploymentConfiguration getDeploymentConfiguration();
+ public VaadinService getVaadinService();
}
public void sendError(int errorCode, String message) throws IOException;
/**
- * Gets the deployment configuration for the context of this response.
+ * Gets the vaadin service for the context of this response.
*
- * @return the deployment configuration
+ * @return the vaadin service
*
- * @see DeploymentConfiguration
+ * @see VaadinService
*/
- public DeploymentConfiguration getDeploymentConfiguration();
+ public VaadinService getVaadinService();
}
package com.vaadin.data.util;
-
/**
* Automated test for {@link AbstractBeanContainer}.
*
import junit.framework.TestCase;
import com.vaadin.DefaultApplicationConfiguration;
-import com.vaadin.server.VaadinServlet.ServletDeploymentConfiguration;
+import com.vaadin.server.VaadinServlet.ServletService;
public class TestAbstractApplicationServletStaticFilesLocation extends TestCase {
Field f = VaadinServlet.class
.getDeclaredField("deploymentConfiguration");
f.setAccessible(true);
- f.set(servlet, new ServletDeploymentConfiguration(servlet,
+ f.set(servlet, new ServletService(servlet,
new DefaultApplicationConfiguration(servlet.getClass(),
new Properties())));
// Set request into replay mode
replay(request);
- String location = servlet.getDeploymentConfiguration()
- .getStaticFileLocation(servlet.createWrappedRequest(request));
+ String location = servlet.getVaadinService().getStaticFileLocation(
+ servlet.createWrappedRequest(request));
return location;
}
// Set request into replay mode
replay(request);
- String location = servlet.getDeploymentConfiguration()
- .getStaticFileLocation(servlet.createWrappedRequest(request));
+ String location = servlet.getVaadinService().getStaticFileLocation(
+ servlet.createWrappedRequest(request));
return location;
}
import com.vaadin.DefaultApplicationConfiguration;
import com.vaadin.server.ApplicationConfiguration;
import com.vaadin.server.DefaultUIProvider;
-import com.vaadin.server.DeploymentConfiguration;
+import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.server.VaadinSession.ApplicationStartEvent;
import com.vaadin.server.WrappedRequest;
private static WrappedRequest createRequestMock(ClassLoader classloader) {
// Mock a DeploymentConfiguration to give the passed classloader
- DeploymentConfiguration configurationMock = EasyMock
- .createMock(DeploymentConfiguration.class);
+ VaadinService configurationMock = EasyMock
+ .createMock(VaadinService.class);
EasyMock.expect(configurationMock.getClassLoader()).andReturn(
classloader);
// Mock a WrappedRequest to give the mocked deployment configuration
WrappedRequest requestMock = EasyMock.createMock(WrappedRequest.class);
- EasyMock.expect(requestMock.getDeploymentConfiguration()).andReturn(
+ EasyMock.expect(requestMock.getVaadinService()).andReturn(
configurationMock);
EasyMock.replay(configurationMock, requestMock);
package com.vaadin.shared.ui.link;
-
public class LinkConstants {
public static String HREF_RESOURCE = "href";
}
Collections.addAll(defaultPackages, initParameter.split(","));
}
String str = TestBase.class.getName().replace('.', '/') + ".class";
- URL url = getDeploymentConfiguration().getClassLoader()
- .getResource(str);
+ URL url = getVaadinService().getClassLoader().getResource(str);
if ("file".equals(url.getProtocol())) {
File comVaadinTests = new File(url.getPath()).getParentFile()
.getParentFile();
}
@Override
- protected ServletDeploymentConfiguration createDeploymentConfiguration(
+ protected ServletService createServletService(
ApplicationConfiguration applicationConfiguration) {
- return new ServletDeploymentConfiguration(this,
- applicationConfiguration) {
+ return new ServletService(this, applicationConfiguration) {
@Override
public String getStaticFileLocation(WrappedRequest request) {
URIS uris = getApplicationRunnerURIs(WrappedHttpServletRequest
@Override
protected WrappedHttpServletRequest createWrappedRequest(
HttpServletRequest request) {
- return new WrappedHttpServletRequest(request,
- getDeploymentConfiguration()) {
+ return new WrappedHttpServletRequest(request, getVaadinService()) {
@Override
public String getRequestPathInfo() {
return ApplicationRunnerServlet.this.getRequestPathInfo(this);
@Override
public void buttonClick(ClickEvent event) {
FileResource res = new FileResource(new File(CurrentInstance
- .get(WrappedRequest.class).getDeploymentConfiguration()
+ .get(WrappedRequest.class).getVaadinService()
.getBaseDirectory()
+ "/" + filename));
getMainWindow().open(res);
}));
File baseDir = CurrentInstance.get(WrappedRequest.class)
- .getDeploymentConfiguration().getBaseDirectory()
- .getAbsoluteFile();
+ .getVaadinService().getBaseDirectory().getAbsoluteFile();
File f = new File(baseDir + "/VAADIN/themes/" + getTheme()
+ "/layouts/Ticket1975.html");
+ "possible security constraint with Application "
+ "Server or Servlet Container.<br />";
File file = CurrentInstance.get(WrappedRequest.class)
- .getDeploymentConfiguration().getBaseDirectory();
+ .getVaadinService().getBaseDirectory();
if ((file == null) || (!file.canRead())
|| (file.getAbsolutePath() == null)) {
// cannot access example directory, possible security issue with