private static final String GET_PARAM_ANALYZE_LAYOUTS = "analyzeLayouts";
/**
- * The application this communication manager is used for
+ * The session this communication manager is used for
*/
- private final VaadinSession application;
+ private final VaadinSession session;
private List<String> locales;
/**
* TODO New constructor - document me!
*
- * @param application
+ * @param session
*/
- public AbstractCommunicationManager(VaadinSession application) {
- this.application = application;
- application.addRequestHandler(getBootstrapHandler());
- application.addRequestHandler(UNSUPPORTED_BROWSER_HANDLER);
- application.addRequestHandler(CONNECTOR_RESOURCE_HANDLER);
- requireLocale(application.getLocale().toString());
+ public AbstractCommunicationManager(VaadinSession session) {
+ this.session = session;
+ session.addRequestHandler(getBootstrapHandler());
+ session.addRequestHandler(UNSUPPORTED_BROWSER_HANDLER);
+ session.addRequestHandler(CONNECTOR_RESOURCE_HANDLER);
+ requireLocale(session.getLocale().toString());
}
- protected VaadinSession getApplication() {
- return application;
+ protected VaadinSession getVaadinSession() {
+ return session;
}
private static final int LF = "\n".getBytes()[0];
cleanStreamVariable(owner, variableName);
}
} catch (Exception e) {
- synchronized (application) {
- handleChangeVariablesError(application, (Component) owner, e,
+ synchronized (session) {
+ handleChangeVariablesError(session, (Component) owner, e,
new HashMap<String, Object>());
}
}
cleanStreamVariable(owner, variableName);
}
} catch (Exception e) {
- synchronized (application) {
- handleChangeVariablesError(application, (Component) owner, e,
+ synchronized (session) {
+ handleChangeVariablesError(session, (Component) owner, e,
new HashMap<String, Object>());
}
}
"StreamVariable for the post not found");
}
- final VaadinSession application = getApplication();
+ final VaadinSession session = getVaadinSession();
OutputStream out = null;
int totalBytes = 0;
filename, type, contentLength);
try {
boolean listenProgress;
- synchronized (application) {
+ synchronized (session) {
streamVariable.streamingStarted(startedEvent);
out = streamVariable.getOutputStream();
listenProgress = streamVariable.listenProgress();
if (listenProgress) {
// update progress if listener set and contentLength
// received
- synchronized (application) {
+ synchronized (session) {
StreamingProgressEventImpl progressEvent = new StreamingProgressEventImpl(
filename, type, contentLength, totalBytes);
streamVariable.onProgress(progressEvent);
out.close();
StreamingEndEvent event = new StreamingEndEventImpl(filename, type,
totalBytes);
- synchronized (application) {
+ synchronized (session) {
streamVariable.streamingFinished(event);
}
tryToCloseStream(out);
StreamingErrorEvent event = new StreamingErrorEventImpl(filename,
type, contentLength, totalBytes, e);
- synchronized (application) {
+ synchronized (session) {
streamVariable.streamingFailed(event);
}
// Note, we are not throwing interrupted exception forward as it is
// not a terminal level error like all other exception.
} catch (final Exception e) {
tryToCloseStream(out);
- synchronized (application) {
+ synchronized (session) {
StreamingErrorEvent event = new StreamingErrorEventImpl(
filename, type, contentLength, totalBytes, e);
- synchronized (application) {
- streamVariable.streamingFailed(event);
- }
+ streamVariable.streamingFailed(event);
// throw exception for terminal to be handled (to be passed to
// terminalErrorHandler)
throw new UploadException(e);
* to process any changes to variables by the client and then repaints
* affected components using {@link #paintAfterVariableChanges()}.
*
- * Also, some cleanup is done when a request arrives for an application that
- * has already been closed.
+ * Also, some cleanup is done when a request arrives for an session that has
+ * already been closed.
*
* The method handleUidlRequest(...) in subclasses should call this method.
*
final PrintWriter outWriter = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(out, "UTF-8")));
- // The rest of the process is synchronized with the application
+ // The rest of the process is synchronized with the session
// in order to guarantee that no parallel variable handling is
// made
- synchronized (application) {
+ synchronized (session) {
- // Finds the window within the application
- if (application.isRunning()) {
+ // Finds the UI within the session
+ if (session.isRunning()) {
// Returns if no window found
if (uI == null) {
// This should not happen, no windows exists but
- // application is still open.
- getLogger().warning("Could not get UI for application");
+ // session is still open.
+ getLogger().warning("Could not get UI for session");
return;
}
} else {
- // application has been closed
- endApplication(request, response, application);
+ // session has been closed
+ endApplication(request, response, session);
return;
}
uI.setLastUidlRequestTime(System.currentTimeMillis());
// Change all variables based on request parameters
- if (!handleVariables(request, response, callback, application, uI)) {
+ if (!handleVariables(request, response, callback, session, uI)) {
// var inconsistency; the client is probably out-of-sync
SystemMessages ci = response.getVaadinService()
/**
* Method called after the paint phase while still being synchronized on the
- * application
+ * session
*
* @param uI
*
*/
protected void postPaint(UI uI) {
- // Remove connectors that have been detached from the application during
+ // Remove connectors that have been detached from the session during
// handling of the request
uI.getConnectorTracker().cleanConnectorMap();
while (iterator.hasNext()) {
String connectorId = iterator.next();
if (uI.getConnectorTracker().getConnector(connectorId) == null) {
- // Owner is no longer attached to the application
+ // Owner is no longer attached to the session
Map<String, StreamVariable> removed = pidToNameToStreamVariable
.get(connectorId);
for (String key : removed.keySet()) {
}
sb.append("\nComponent hierarchy:\n");
- VaadinSession application2 = component.getUI().getSession();
- sb.append(application2.getClass().getName());
+ VaadinSession session2 = component.getUI().getSession();
+ sb.append(session2.getClass().getName());
sb.append(".");
- sb.append(application2.getClass().getSimpleName());
+ sb.append(session2.getClass().getSimpleName());
sb.append("(");
- sb.append(application2.getClass().getSimpleName());
+ sb.append(session2.getClass().getSimpleName());
sb.append(".java");
sb.append(":1)");
int l = 1;
final PrintWriter outWriter, UI uI, boolean analyzeLayouts)
throws PaintException, IOException, JSONException {
- // Removes application if it has stopped during variable changes
- if (!application.isRunning()) {
- endApplication(request, response, application);
+ // Removes session if it has stopped during variable changes
+ if (!session.isRunning()) {
+ endApplication(request, response, session);
return;
}
*/
private void writePerformanceData(final PrintWriter outWriter) {
outWriter.write(String.format(", \"timings\":[%d, %d]",
- application.getTotalSessionTime(),
- application.getLastRequestTime()));
+ session.getTotalSessionTime(), session.getLastRequestTime()));
}
private void legacyPaint(PaintTarget paintTarget,
* @return true if successful, false if there was an inconsistency
*/
private boolean handleVariables(WrappedRequest request,
- WrappedResponse response, Callback callback,
- VaadinSession application2, UI uI) throws IOException,
- InvalidUIDLSecurityKeyException, JSONException {
+ WrappedResponse response, Callback callback, VaadinSession session,
+ UI uI) throws IOException, InvalidUIDLSecurityKeyException,
+ JSONException {
boolean success = true;
String changes = getRequestPayload(request);
// Security: double cookie submission pattern unless disabled by
// property
- if (isXSRFEnabled(application2)) {
+ if (isXSRFEnabled(session)) {
if (bursts.length == 1 && "init".equals(bursts[0])) {
// init request; don't handle any variables, key sent in
// response.
* For {@link AbstractField} components,
* {@link AbstractField#handleError(com.vaadin.ui.AbstractComponent.ComponentErrorEvent)}
* is called. In all other cases (or if the field does not handle the
- * error), {@link ErrorListener#terminalError(ErrorEvent)} for the
- * application error handler is called.
+ * error), {@link ErrorListener#terminalError(ErrorEvent)} for the session
+ * error handler is called.
*
* @param session
* @param owner
} catch (Exception handlerException) {
/*
* If there is an error in the component error handler we pass
- * the that error to the application error handler and continue
+ * the that error to the session error handler and continue
* processing the actual error
*/
session.getErrorHandler().terminalError(
public void requireLocale(String value) {
if (locales == null) {
locales = new ArrayList<String>();
- locales.add(application.getLocale().toString());
+ locales.add(session.getLocale().toString());
pendingLocalesIndex = 0;
}
if (!locales.contains(value)) {
* The request handlers are invoked in the revere order in which they were
* added to the session until a response has been produced. This means that
* the most recently added handler is used first and the first request
- * handler that was added to the application is invoked towards the end
- * unless any previous handler has already produced a response.
+ * handler that was added to the session is invoked towards the end unless
+ * any previous handler has already produced a response.
* </p>
*
* @param request
WrappedResponse response) throws IOException {
// Use a copy to avoid ConcurrentModificationException
for (RequestHandler handler : new ArrayList<RequestHandler>(
- application.getRequestHandlers())) {
- if (handler.handleRequest(application, request, response)) {
+ session.getRequestHandlers())) {
+ if (handler.handleRequest(session, request, response)) {
return true;
}
}
}
public void handleBrowserDetailsRequest(WrappedRequest request,
- WrappedResponse response, VaadinSession application)
- throws IOException {
+ WrappedResponse response, VaadinSession session) throws IOException {
assert UI.getCurrent() == null;
response.setContentType("application/json; charset=UTF-8");
- UI uI = application.getUIForRequest(combinedRequest);
+ UI uI = session.getUIForRequest(combinedRequest);
if (uI == null) {
- uI = application.createUI(combinedRequest);
+ uI = session.createUI(combinedRequest);
}
JSONObject params = new JSONObject();
* @throws IOException
* @throws InvalidUIDLSecurityKeyException
*/
- public void handleFileUpload(VaadinSession application,
- WrappedRequest request, WrappedResponse response)
- throws IOException, InvalidUIDLSecurityKeyException {
+ public void handleFileUpload(VaadinSession session, WrappedRequest request,
+ WrappedResponse response) throws IOException,
+ InvalidUIDLSecurityKeyException {
/*
* URI pattern: APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] See
String uiId = parts[0];
String connectorId = parts[1];
String variableName = parts[2];
- UI uI = application.getUIById(Integer.parseInt(uiId));
+ UI uI = session.getUIById(Integer.parseInt(uiId));
UI.setCurrent(uI);
StreamVariable streamVariable = getStreamVariable(connectorId,
* still alive (the browser window is open, the connection is up) even when
* there are no UIDL requests for a prolonged period of time. UIs that do
* not receive either heartbeat or UIDL requests are eventually removed from
- * the application and garbage collected.
+ * the session and garbage collected.
*
* @param request
* @param response
- * @param application
+ * @param session
* @throws IOException
*/
public void handleHeartbeatRequest(WrappedRequest request,
- WrappedResponse response, VaadinSession application)
- throws IOException {
+ WrappedResponse response, VaadinSession session) throws IOException {
UI ui = null;
try {
int uiId = Integer.parseInt(request
.getParameter(UIConstants.UI_ID_PARAMETER));
- ui = application.getUIById(uiId);
+ ui = session.getUIById(uiId);
} catch (NumberFormatException nfe) {
// null-check below handles this as well
}