本文整理匯總了Java中org.apache.wicket.Application類的典型用法代碼示例。如果您正苦於以下問題:Java Application類的具體用法?Java Application怎麽用?Java Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Application類屬於org.apache.wicket包,在下文中一共展示了Application類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConnection
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public IWebSocketConnection getConnection(Application application, String sessionId, IKey key)
{
Args.notNull(application, "application");
Args.notNull(sessionId, "sessionId");
Args.notNull(key, "key");
IWebSocketConnection connection = null;
ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
if (connectionsBySession != null)
{
ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
if (connectionsByPage != null)
{
connection = connectionsByPage.get(key);
}
}
return connection;
}
示例2: getConnections
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public Collection<IWebSocketConnection> getConnections(Application application, String sessionId)
{
Args.notNull(application, "application");
Args.notNull(sessionId, "sessionId");
Collection<IWebSocketConnection> connections = Collections.emptyList();
ConcurrentMap<String, ConcurrentMap<IKey, IWebSocketConnection>> connectionsBySession = application.getMetaData(KEY);
if (connectionsBySession != null)
{
ConcurrentMap<IKey, IWebSocketConnection> connectionsByPage = connectionsBySession.get(sessionId);
if (connectionsByPage != null)
{
connections = connectionsByPage.values();
}
}
return connections;
}
示例3: getExceptionMapperProvider
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public final IProvider<IExceptionMapper> getExceptionMapperProvider() {
return new IProvider<IExceptionMapper>() {
@Override
public IExceptionMapper get() {
return new DefaultExceptionMapper() {
@Override
protected IRequestHandler mapExpectedExceptions(Exception e, Application application) {
Page errorPage = mapExceptions(e);
if (errorPage != null) {
return createPageRequestHandler(new PageProvider(errorPage));
} else {
return super.mapExpectedExceptions(e, application);
}
}
};
}
};
}
示例4: getResources
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public Iterator<URL> getResources(final String name) {
Set<URL> resultSet = new TreeSet<>(new UrlExternalFormComparator());
try {
// Try the classloader for the wicket jar/bundle
Enumeration<URL> resources = Application.class.getClassLoader().getResources(name);
loadResources(resources, resultSet);
// Try the classloader for the user's application jar/bundle
resources = Application.get().getClass().getClassLoader().getResources(name);
loadResources(resources, resultSet);
// Try the context class loader
resources = getClassLoader().getResources(name);
loadResources(resources, resultSet);
} catch (Exception e) {
throw new WicketRuntimeException(e);
}
return resultSet.iterator();
}
示例5: respond
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public void respond(IRequestCycle requestCycle) {
String script = ToastrHelper.generateJs(singularException, ToastrType.ERROR, false);
WebResponse response = (WebResponse)requestCycle.getResponse();
final String encoding = Application.get()
.getRequestCycleSettings()
.getResponseRequestEncoding();
// Set content type based on markup type for page
response.setContentType("text/xml; charset=" + encoding);
// Make sure it is not cached by a client
response.disableCaching();
response.write("<?xml version=\"1.0\" encoding=\"");
response.write(encoding);
response.write("\"?>");
response.write("<ajax-response>");
response.write("<evaluate><![CDATA[" + script + "]]></evaluate>");
response.write("</ajax-response>");
}
示例6: sendAll
import org.apache.wicket.Application; //導入依賴的package包/類
private static void sendAll(final String m, boolean publish) {
if (publish) {
publish(new WsMessageAll(m));
}
Application app = (Application)getApp();
WebSocketSettings settings = WebSocketSettings.Holder.get(app);
IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
Executor executor = settings.getWebSocketPushMessageExecutor();
for (IWebSocketConnection c : reg.getConnections(app)) {
executor.run(() -> {
try {
c.sendMessage(m);
} catch (IOException e) {
log.error("Error while sending message to ALL", e);
}
});
}
}
示例7: send
import org.apache.wicket.Application; //導入依賴的package包/類
private static void send(
final Function<Application, List<Client>> func
, BiConsumer<IWebSocketConnection, Client> consumer
, Predicate<Client> check)
{
Application app = (Application)getApp();
WebSocketSettings settings = WebSocketSettings.Holder.get(app);
IWebSocketConnectionRegistry reg = settings.getConnectionRegistry();
Executor executor = settings.getWebSocketPushMessageExecutor();
for (Client c : func.apply(app)) {
if (check == null || check.test(c)) {
final IWebSocketConnection wc = reg.getConnection(app, c.getSessionId(), new PageIdKey(c.getPageId()));
if (wc != null && wc.isOpen()) {
executor.run(() -> consumer.accept(wc, c));
}
}
}
}
示例8: getWebSocketConnection
import org.apache.wicket.Application; //導入依賴的package包/類
public static IWebSocketConnection getWebSocketConnection(WebSocketInfo wsinfo)
{
IWebSocketConnection connection = null;
if (wsinfo != null)
{
Application application = Application.get(wsinfo.getApplicationName());
WebSocketSettings settings = WebSocketSettings.Holder.get(application);
connection = settings.getConnectionRegistry().getConnection(application, wsinfo.getSessionId(), wsinfo.getKey());
if (connection == null)
{
LOG.error("WebSocket connection is lost");
}
}
else
{
LOG.error("WebSocket client is unknown");
}
return connection;
}
示例9: bind
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
public void bind(Request request, Session newSession)
{
if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != newSession)
{
// call template method
onBind(request, newSession);
for (BindListener listener : getBindListeners())
{
listener.bindingSession(request, newSession);
}
HttpSession httpSession = getHttpSession(request, false);
if (httpSession != null)
{
// register an unbinding listener for cleaning up
String applicationKey = Application.get().getName();
httpSession.setAttribute("Wicket:SessionUnbindingListener-" + applicationKey,
new SessionBindingListener(applicationKey, newSession));
}
// register the session object itself
setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, newSession);
}
}
示例10: fetchStatus
import org.apache.wicket.Application; //導入依賴的package包/類
private Status fetchStatus(MenuNode node, Class<? extends Page> currentPage, boolean enabled) {
if (!enabled) {
return DISABLED;
}
if (currentPage.equals(node.getPageClass())) {
return SELECTED;
}
Boolean opened = node.isOpened();
if (Boolean.TRUE.equals(opened)) {
return OPENED;
} else if (Boolean.FALSE.equals(opened)) {
return ENABLED;
}
SiteMap siteMap = ((SiteMapAware) Application.get()).getSiteMap();
MenuNode current = siteMap.getPageNode(currentPage);
while (current != null) {
if (current.equals(node)) {
return OPENED;
}
current = current.getParent();
}
return ENABLED;
}
示例11: onValidate
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
protected void onValidate(IValidatable<String> validatable) {
final String value = validatable.getValue();
if (value == null) return;
try {
DateFormat df = createDateFormat();
df.parse(value);
} catch (ParseException e) {
String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null,
new Model<Serializable>(new Serializable() {
@SuppressWarnings("unused")
public String getValue() {
return value;
}
}));
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
}
}
示例12: reportError
import org.apache.wicket.Application; //導入依賴的package包/類
private void reportError(String resourceKey, final String value, final String regex) {
try {
String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey, (Component)null,
new Model<Serializable>(new Serializable() {
@SuppressWarnings("unused")
public String getValue() {
return value;
}
@SuppressWarnings("unused")
public String getRegex() {
return regex;
}
}));
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
} catch (Exception e) {
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>("Regexp validation error (value='" + value+ "', regex='" + regex + "')")));
}
}
示例13: onValidate
import org.apache.wicket.Application; //導入依賴的package包/類
@Override
protected void onValidate(IValidatable<String> validatable) {
final String value = validatable.getValue();
if (value == null) return;
try {
new URILocator(value);
} catch (Exception e) {
String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(), (Component)null,
new Model<Serializable>(new Serializable() {
@SuppressWarnings("unused")
public String getValue() {
return value;
}
}));
component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
}
}
示例14: get
import org.apache.wicket.Application; //導入依賴的package包/類
/**
* Retrieves the instance of settings object.
*
* @return settings instance
*/
public static DashboardSettings get() {
Application application = Application.get();
DashboardSettings settings = application.getMetaData(KEY);
if (settings == null) {
synchronized (application) {
settings = application.getMetaData(KEY);
if (settings == null) {
settings = new DashboardSettings();
application.setMetaData(KEY, settings);
}
}
}
return application.getMetaData(KEY);
}
示例15: getObject
import org.apache.wicket.Application; //導入依賴的package包/類
/**
* Returns name
* @param component component to look associated localization
* @return name
*/
public String getObject(Component component) {
if(objectModel!=null)
{
T object = objectModel.getObject();
if(object==null) return null;
resourceKey = getResourceKey(object);
}
String defaultValue = getDefault();
if(defaultValue==null) defaultValue = Strings.lastPathComponent(resourceKey, '.');
if(defaultValue!=null) defaultValue = buitify(defaultValue);
return Application.get()
.getResourceSettings()
.getLocalizer()
.getString(resourceKey, null, defaultValue);
}