use of org.apache.wicket.Application in project wicket by apache.
the class WebSocketMessageBroadcastHandler method respond.
@Override
public void respond(IRequestCycle requestCycle) {
final Application application = Application.get();
final Runnable action = new Runnable() {
@Override
public void run() {
if (pageId != AbstractWebSocketProcessor.NO_PAGE_ID) {
Page page = (Page) Session.get().getPageManager().getPage(pageId);
page.send(application, Broadcast.BREADTH, payload);
} else {
ResourceReference reference = new SharedResourceReference(resourceName);
IResource resource = reference.getResource();
if (resource instanceof WebSocketResource) {
WebSocketResource wsResource = (WebSocketResource) resource;
wsResource.onPayload(payload);
} else {
throw new IllegalStateException(String.format("Shared resource with name '%s' is not a %s but %s", resourceName, WebSocketResource.class.getSimpleName(), Classes.name(resource.getClass())));
}
}
}
};
WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application);
webSocketSettings.getSendPayloadExecutor().run(action);
}
use of org.apache.wicket.Application in project wicket by apache.
the class TestWebSocketProcessor method createRequest.
/**
* Creates an HttpServletRequest that is needed by AbstractWebSocketProcessor
*
* @return a mock http request
*/
private static MockHttpServletRequest createRequest(final WicketTester wicketTester) {
Application application = wicketTester.getApplication();
HttpSession httpSession = wicketTester.getHttpSession();
MockHttpServletRequest request = new MockHttpServletRequest(application, httpSession, null);
request.addParameter(WebRequest.PARAM_AJAX_BASE_URL, ".");
return request;
}
use of org.apache.wicket.Application in project openmeetings by apache.
the class WebSocketHelper method sendClient.
private static void sendClient(IWsClient client, Consumer<IWebSocketConnection> wsc) {
Application app = (Application) getApp();
WebSocketSettings settings = WebSocketSettings.Holder.get(app);
IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
// FIXME TODO
Executor executor = settings.getWebSocketPushMessageExecutor();
final IWebSocketConnection wc = reg.getConnection(app, client.getSessionId(), new PageIdKey(client.getPageId()));
if (wc != null && wc.isOpen()) {
executor.run(() -> {
wsc.accept(wc);
});
}
}
use of org.apache.wicket.Application in project openmeetings by apache.
the class ApplicationHelper method ensureApplication.
public static IApplication ensureApplication(Long langId) {
IApplication a = ensureApplication();
if (ThreadContext.getRequestCycle() == null) {
ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application) a, new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(), a.getExceptionMapperProvider().get());
ThreadContext.setRequestCycle(new RequestCycle(rctx));
}
if (ThreadContext.getSession() == null) {
WebSession s = WebSession.get();
if (langId > 0) {
((IWebSession) s).setLanguage(langId);
}
}
return a;
}
use of org.apache.wicket.Application in project gitblit by gitblit.
the class GitBlitDiffFormatter method getLimit.
/**
* Determines a limit to use for HTML diff output.
*
* @param key
* to use to read the value from the GitBlit settings, if available.
* @param minimum
* minimum value to enforce
* @param maximum
* maximum (and default) value to enforce
* @return the limit
*/
private int getLimit(String key, int minimum, int maximum) {
if (Application.exists()) {
Application application = Application.get();
if (application instanceof GitBlitWebApp) {
GitBlitWebApp webApp = (GitBlitWebApp) application;
int configValue = webApp.settings().getInteger(key, maximum);
if (configValue < minimum) {
return minimum;
} else if (configValue < maximum) {
return configValue;
}
}
}
return maximum;
}
Aggregations