@@ -571,7 +571,7 @@ public abstract class AbstractCommunicationManager implements Serializable { | |||
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(); | |||
@@ -1023,8 +1023,7 @@ public abstract class AbstractCommunicationManager implements Serializable { | |||
} | |||
} | |||
SystemMessages ci = request.getDeploymentConfiguration() | |||
.getSystemMessages(); | |||
SystemMessages ci = request.getVaadinService().getSystemMessages(); | |||
// meta instruction for client to enable auto-forward to | |||
// sessionExpiredURL after timer expires. | |||
@@ -2483,8 +2482,8 @@ public abstract class AbstractCommunicationManager implements Serializable { | |||
.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 |
@@ -20,13 +20,12 @@ import java.lang.reflect.Constructor; | |||
import java.util.Iterator; | |||
import java.util.ServiceLoader; | |||
public abstract class AbstractDeploymentConfiguration implements | |||
DeploymentConfiguration { | |||
public abstract class AbstractVaadinService implements VaadinService { | |||
private AddonContext addonContext; | |||
private final ApplicationConfiguration applicationConfiguration; | |||
public AbstractDeploymentConfiguration( | |||
public AbstractVaadinService( | |||
ApplicationConfiguration applicationConfiguration) { | |||
this.applicationConfiguration = applicationConfiguration; | |||
} |
@@ -36,8 +36,7 @@ import com.vaadin.util.ReflectTools; | |||
* 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 | |||
@@ -47,7 +46,7 @@ public class AddonContext { | |||
.findMethod(ApplicationStartedListener.class, "applicationStarted", | |||
ApplicationStartedEvent.class); | |||
private final DeploymentConfiguration deploymentConfiguration; | |||
private final VaadinService vaadinService; | |||
private final EventRouter eventRouter = new EventRouter(); | |||
@@ -59,13 +58,12 @@ public class AddonContext { | |||
* 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); | |||
} | |||
/** | |||
@@ -73,22 +71,21 @@ public class AddonContext { | |||
* | |||
* @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(); |
@@ -131,13 +131,12 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
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( | |||
@@ -274,8 +273,8 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
.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); | |||
@@ -327,9 +326,8 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
WrappedRequest request = context.getRequest(); | |||
DeploymentConfiguration deploymentConfiguration = request | |||
.getDeploymentConfiguration(); | |||
String staticFileLocation = deploymentConfiguration | |||
VaadinService vaadinService = request.getVaadinService(); | |||
String staticFileLocation = vaadinService | |||
.getStaticFileLocation(request); | |||
fragmentNodes | |||
@@ -421,12 +419,10 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
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(); | |||
@@ -448,7 +444,7 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
defaults.put("authErrMsg", authErrMsg); | |||
} | |||
String staticFileLocation = deploymentConfiguration | |||
String staticFileLocation = vaadinService | |||
.getStaticFileLocation(request); | |||
String widgetsetBase = staticFileLocation + "/" | |||
+ VaadinServlet.WIDGETSET_DIRECTORY_PATH; | |||
@@ -458,11 +454,11 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
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)); | |||
@@ -485,7 +481,7 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
*/ | |||
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; | |||
@@ -513,8 +509,7 @@ public abstract class BootstrapHandler implements RequestHandler { | |||
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. |
@@ -178,7 +178,7 @@ public class CombinedRequest implements WrappedRequest { | |||
} | |||
@Override | |||
public DeploymentConfiguration getDeploymentConfiguration() { | |||
return secondRequest.getDeploymentConfiguration(); | |||
public VaadinService getVaadinService() { | |||
return secondRequest.getVaadinService(); | |||
} | |||
} |
@@ -29,7 +29,7 @@ public class DefaultUIProvider extends AbstractUIProvider { | |||
if (uiClassNameObj instanceof String) { | |||
String uiClassName = uiClassNameObj.toString(); | |||
ClassLoader classLoader = request.getDeploymentConfiguration() | |||
ClassLoader classLoader = request.getVaadinService() | |||
.getClassLoader(); | |||
if (classLoader == null) { | |||
classLoader = getClass().getClassLoader(); |
@@ -172,9 +172,9 @@ public class GAEVaadinServlet extends VaadinServlet { | |||
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(); |
@@ -28,7 +28,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { | |||
throws ClassNotFoundException { | |||
try { | |||
return ServletPortletHelper | |||
.getLegacyApplicationClass(getDeploymentConfiguration()); | |||
.getLegacyApplicationClass(getVaadinService()); | |||
} catch (ApplicationClassException e) { | |||
throw new RuntimeException(e); | |||
} |
@@ -28,7 +28,7 @@ public class LegacyVaadinServlet extends VaadinServlet { | |||
throws ClassNotFoundException { | |||
try { | |||
return ServletPortletHelper | |||
.getLegacyApplicationClass(getDeploymentConfiguration()); | |||
.getLegacyApplicationClass(getVaadinService()); | |||
} catch (ApplicationClassException e) { | |||
throw new RuntimeException(e); | |||
} |
@@ -127,9 +127,9 @@ public class PortletCommunicationManager extends AbstractCommunicationManager { | |||
@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); | |||
} |
@@ -42,12 +42,11 @@ class ServletPortletHelper implements Serializable { | |||
} | |||
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( | |||
@@ -133,13 +132,11 @@ class ServletPortletHelper implements Serializable { | |||
} | |||
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()); | |||
} | |||
} |
@@ -74,11 +74,10 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
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; | |||
@@ -185,9 +184,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
WrappedPortletRequest { | |||
public WrappedHttpAndPortletRequest(PortletRequest request, | |||
HttpServletRequest originalRequest, | |||
DeploymentConfiguration deploymentConfiguration) { | |||
super(request, deploymentConfiguration); | |||
HttpServletRequest originalRequest, PortletService vaadinService) { | |||
super(request, vaadinService); | |||
this.originalRequest = originalRequest; | |||
} | |||
@@ -229,8 +227,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
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( | |||
@@ -252,8 +250,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
WrappedHttpAndPortletRequest { | |||
public WrappedLiferayRequest(PortletRequest request, | |||
DeploymentConfiguration deploymentConfiguration) { | |||
super(request, getOriginalRequest(request), deploymentConfiguration); | |||
PortletService vaadinService) { | |||
super(request, getOriginalRequest(request), vaadinService); | |||
} | |||
@Override | |||
@@ -320,7 +318,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
// 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 | |||
@@ -346,9 +344,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
} | |||
ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties); | |||
deploymentConfiguration = createDeploymentConfiguration(applicationConfiguration); | |||
vaadinService = createPortletService(applicationConfiguration); | |||
addonContext = new AddonContext(deploymentConfiguration); | |||
addonContext = new AddonContext(vaadinService); | |||
addonContext.init(); | |||
} | |||
@@ -358,10 +356,9 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
applicationProperties); | |||
} | |||
protected PortletDeploymentConfiguration createDeploymentConfiguration( | |||
protected PortletService createPortletService( | |||
ApplicationConfiguration applicationConfiguration) { | |||
return new PortletDeploymentConfiguration(this, | |||
applicationConfiguration); | |||
return new PortletService(this, applicationConfiguration); | |||
} | |||
@Override | |||
@@ -429,7 +426,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
WrappedPortletRequest wrappedRequest = createWrappedRequest(request); | |||
WrappedPortletResponse wrappedResponse = new WrappedPortletResponse( | |||
response, getDeploymentConfiguration()); | |||
response, getVaadinService()); | |||
CurrentInstance.set(WrappedRequest.class, wrappedRequest); | |||
CurrentInstance.set(WrappedResponse.class, wrappedResponse); | |||
@@ -611,20 +608,17 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
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, | |||
@@ -835,8 +829,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
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); | |||
@@ -849,7 +843,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
try { | |||
ServletPortletHelper.initDefaultUIProvider(application, | |||
getDeploymentConfiguration()); | |||
getVaadinService()); | |||
} catch (ApplicationClassException e) { | |||
throw new PortletException(e); | |||
} | |||
@@ -889,8 +883,7 @@ public class VaadinPortlet extends GenericPortlet implements Constants { | |||
// 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()); |
@@ -84,8 +84,7 @@ public class VaadinPortletSession extends VaadinSession { | |||
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) { |
@@ -31,7 +31,7 @@ import javax.servlet.ServletContext; | |||
* | |||
* @since 7.0 | |||
*/ | |||
public interface DeploymentConfiguration extends Serializable { | |||
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 |
@@ -55,11 +55,10 @@ import com.vaadin.util.CurrentInstance; | |||
@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; | |||
@@ -175,7 +174,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
private final String resourcePath = null; | |||
private DeploymentConfiguration deploymentConfiguration; | |||
private ServletService servletService; | |||
private AddonContext addonContext; | |||
@@ -214,9 +213,9 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
} | |||
ApplicationConfiguration applicationConfiguration = createApplicationConfiguration(applicationProperties); | |||
deploymentConfiguration = createDeploymentConfiguration(applicationConfiguration); | |||
servletService = createServletService(applicationConfiguration); | |||
addonContext = new AddonContext(deploymentConfiguration); | |||
addonContext = new AddonContext(servletService); | |||
addonContext.init(); | |||
} | |||
@@ -226,10 +225,9 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
applicationProperties); | |||
} | |||
protected ServletDeploymentConfiguration createDeploymentConfiguration( | |||
protected ServletService createServletService( | |||
ApplicationConfiguration applicationConfiguration) { | |||
return new ServletDeploymentConfiguration(this, | |||
applicationConfiguration); | |||
return new ServletService(this, applicationConfiguration); | |||
} | |||
@Override | |||
@@ -393,7 +391,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
private WrappedHttpServletResponse createWrappedResponse( | |||
HttpServletResponse response) { | |||
WrappedHttpServletResponse wrappedResponse = new WrappedHttpServletResponse( | |||
response, getDeploymentConfiguration()); | |||
response, getVaadinService()); | |||
return wrappedResponse; | |||
} | |||
@@ -407,8 +405,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
*/ | |||
protected WrappedHttpServletRequest createWrappedRequest( | |||
HttpServletRequest request) { | |||
return new WrappedHttpServletRequest(request, | |||
getDeploymentConfiguration()); | |||
return new WrappedHttpServletRequest(request, getVaadinService()); | |||
} | |||
/** | |||
@@ -416,8 +413,8 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
* | |||
* @return the deployment configuration | |||
*/ | |||
protected DeploymentConfiguration getDeploymentConfiguration() { | |||
return deploymentConfiguration; | |||
protected ServletService getVaadinService() { | |||
return servletService; | |||
} | |||
/** | |||
@@ -443,7 +440,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
// 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(), | |||
@@ -645,7 +642,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
Locale locale = request.getLocale(); | |||
newApplication.setLocale(locale); | |||
newApplication.start(new ApplicationStartEvent(applicationUrl, | |||
getDeploymentConfiguration().getApplicationConfiguration(), | |||
getVaadinService().getApplicationConfiguration(), | |||
createCommunicationManager(newApplication))); | |||
addonContext.fireApplicationStarted(newApplication); | |||
@@ -728,7 +725,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
try { | |||
ServletPortletHelper.initDefaultUIProvider(newApplication, | |||
getDeploymentConfiguration()); | |||
getVaadinService()); | |||
} catch (ApplicationClassException e) { | |||
throw new ServletException(e); | |||
} | |||
@@ -741,8 +738,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
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()); | |||
@@ -805,8 +801,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
} | |||
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 | |||
@@ -848,8 +843,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
} | |||
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 | |||
@@ -931,8 +925,8 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
// 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 | |||
@@ -1013,7 +1007,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
* 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)); |
@@ -1343,10 +1343,10 @@ public class VaadinSession implements Terminal.ErrorListener, | |||
* <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> | |||
* | |||
@@ -1885,7 +1885,7 @@ public class VaadinSession implements Terminal.ErrorListener, | |||
* | |||
* @see #getUidlRequestTimeout() | |||
* @see #closeInactiveUIs() | |||
* @see DeploymentConfiguration#getHeartbeatInterval() | |||
* @see ApplicationConfiguration#getHeartbeatInterval() | |||
* | |||
* @since 7.0.0 | |||
* | |||
@@ -1907,7 +1907,7 @@ public class VaadinSession implements Terminal.ErrorListener, | |||
* otherwise heartbeat requests are enough to extend UI lifetime | |||
* indefinitely. | |||
* | |||
* @see DeploymentConfiguration#isIdleUICleanupEnabled() | |||
* @see ApplicationConfiguration#isIdleUICleanupEnabled() | |||
* @see #getHeartbeatTimeout() | |||
* @see #closeInactiveUIs() | |||
* |
@@ -19,6 +19,8 @@ package com.vaadin.server; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletRequestWrapper; | |||
import com.vaadin.server.VaadinServlet.ServletService; | |||
/** | |||
* Wrapper for {@link HttpServletRequest}. | |||
* | |||
@@ -31,7 +33,7 @@ import javax.servlet.http.HttpServletRequestWrapper; | |||
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 | |||
@@ -39,13 +41,13 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper | |||
* | |||
* @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 | |||
@@ -68,8 +70,8 @@ public class WrappedHttpServletRequest extends HttpServletRequestWrapper | |||
} | |||
@Override | |||
public DeploymentConfiguration getDeploymentConfiguration() { | |||
return deploymentConfiguration; | |||
public ServletService getVaadinService() { | |||
return vaadinService; | |||
} | |||
@Override |
@@ -19,6 +19,8 @@ package com.vaadin.server; | |||
import javax.servlet.http.HttpServletResponse; | |||
import javax.servlet.http.HttpServletResponseWrapper; | |||
import com.vaadin.server.VaadinServlet.ServletService; | |||
/** | |||
* Wrapper for {@link HttpServletResponse}. | |||
* | |||
@@ -31,20 +33,20 @@ import javax.servlet.http.HttpServletResponseWrapper; | |||
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; | |||
} | |||
/** | |||
@@ -78,7 +80,7 @@ public class WrappedHttpServletResponse extends HttpServletResponseWrapper | |||
} | |||
@Override | |||
public DeploymentConfiguration getDeploymentConfiguration() { | |||
return deploymentConfiguration; | |||
public ServletService getVaadinService() { | |||
return vaadinService; | |||
} | |||
} |
@@ -25,6 +25,7 @@ import javax.portlet.ClientDataRequest; | |||
import javax.portlet.PortletRequest; | |||
import javax.portlet.ResourceRequest; | |||
import com.vaadin.server.VaadinPortlet.PortletService; | |||
import com.vaadin.shared.ApplicationConstants; | |||
/** | |||
@@ -39,20 +40,20 @@ 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 | |||
@@ -190,8 +191,8 @@ public class WrappedPortletRequest implements WrappedRequest { | |||
} | |||
@Override | |||
public DeploymentConfiguration getDeploymentConfiguration() { | |||
return deploymentConfiguration; | |||
public PortletService getVaadinService() { | |||
return vaadinService; | |||
} | |||
/** |
@@ -29,7 +29,7 @@ import javax.portlet.MimeResponse; | |||
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. | |||
@@ -48,20 +48,20 @@ public class WrappedPortletResponse implements WrappedResponse { | |||
} | |||
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 | |||
@@ -116,7 +116,7 @@ public class WrappedPortletResponse implements WrappedResponse { | |||
} | |||
@Override | |||
public PortletDeploymentConfiguration getDeploymentConfiguration() { | |||
return deploymentConfiguration; | |||
public PortletService getVaadinService() { | |||
return vaadinService; | |||
} | |||
} |
@@ -246,12 +246,12 @@ public interface WrappedRequest extends Serializable { | |||
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(); | |||
} |
@@ -149,11 +149,11 @@ public interface WrappedResponse extends Serializable { | |||
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(); | |||
} |
@@ -1,6 +1,5 @@ | |||
package com.vaadin.data.util; | |||
/** | |||
* Automated test for {@link AbstractBeanContainer}. | |||
* |
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest; | |||
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 { | |||
@@ -32,7 +32,7 @@ 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()))); | |||
@@ -80,8 +80,8 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase | |||
// 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; | |||
} | |||
@@ -93,8 +93,8 @@ public class TestAbstractApplicationServletStaticFilesLocation extends TestCase | |||
// 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; | |||
} | |||
@@ -11,7 +11,7 @@ import org.easymock.EasyMock; | |||
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; | |||
@@ -73,14 +73,14 @@ public class CustomUIClassLoader extends TestCase { | |||
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); |
@@ -16,7 +16,6 @@ | |||
package com.vaadin.shared.ui.link; | |||
public class LinkConstants { | |||
public static String HREF_RESOURCE = "href"; | |||
} |
@@ -61,8 +61,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { | |||
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(); | |||
@@ -270,10 +269,9 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { | |||
} | |||
@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 | |||
@@ -291,8 +289,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { | |||
@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); |
@@ -27,7 +27,7 @@ public class NonExistingFileResource extends TestBase { | |||
@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); |
@@ -48,8 +48,7 @@ public class Ticket1975 extends Application { | |||
})); | |||
File baseDir = CurrentInstance.get(WrappedRequest.class) | |||
.getDeploymentConfiguration().getBaseDirectory() | |||
.getAbsoluteFile(); | |||
.getVaadinService().getBaseDirectory().getAbsoluteFile(); | |||
File f = new File(baseDir + "/VAADIN/themes/" + getTheme() | |||
+ "/layouts/Ticket1975.html"); | |||
@@ -49,7 +49,7 @@ public class SampleDirectory { | |||
+ "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 |