List of usage examples for org.apache.wicket Application getMetaData
public final synchronized <T> T getMetaData(final MetaDataKey<T> key)
From source file:net.ftlines.wicket.validation.bean.ValidationContext.java
License:Apache License
/** * Gets the {@link ValidationContext} associated with the specified {@code application} * /*from www.j a v a2 s . com*/ * @param application * @return */ public static ValidationContext get(Application application) { ValidationContext validation = application.getMetaData(METAKEY); if (validation == null) { throw new IllegalStateException("No ValidationConfiguration instance bound to Application"); } return validation; }
From source file:org.apache.isis.viewer.wicket.viewer.services.GuiceBeanProviderWicket.java
License:Apache License
@Programmatic @Override//www.j a va 2 s.c o m public <T> T lookup(final Class<T> beanType) { final Application application = Application.get(); final GuiceInjectorHolder injectorHolder = application.getMetaData(GuiceInjectorHolder.INJECTOR_KEY); final Injector injector = injectorHolder.getInjector(); return injector.getInstance(beanType); }
From source file:org.apache.isis.viewer.wicket.viewer.services.GuiceBeanProviderWicket.java
License:Apache License
@Programmatic @Override/*from ww w . j a v a2 s .c o m*/ public <T> T lookup(final Class<T> beanType, final Annotation qualifier) { final Application application = Application.get(); final GuiceInjectorHolder injectorHolder = application.getMetaData(GuiceInjectorHolder.INJECTOR_KEY); final Injector injector = injectorHolder.getInjector(); return injector.getInstance(Key.get(beanType, qualifier)); }
From source file:org.brixcms.Brix.java
License:Apache License
public static Brix get(Application application) { if (application == null) { throw new IllegalArgumentException("application cannot be null"); }//w w w . j a v a 2 s . c om Brix brix = application.getMetaData(APP_KEY); if (brix == null) { throw new IllegalStateException("Could not find instance of Brix associated with application: " + application.getApplicationKey() + ". Make sure Brix.attachTo(this) was called in application's init() method"); } return brix; }
From source file:org.efaps.ui.wicket.ConnectionRegistry.java
License:Apache License
/** * @param _login login of the user to be removed for the registry * @param _sessionID id to be removed * @param _application Application that contains the mapping *//*from www . j a va 2 s .co m*/ protected void removeUser(final String _login, final String _sessionID, final Application _application) { if (_login != null) { ConnectionRegistry.LOG.debug("remove user: '{}', session: '{}'", _login, _sessionID); ConcurrentMap<String, ConcurrentHashSet<String>> user2session = _application .getMetaData(ConnectionRegistry.USER2SESSION); synchronized (ConnectionRegistry.USER2SESSION) { user2session = _application.getMetaData(ConnectionRegistry.USER2SESSION); if (user2session != null) { final ConcurrentHashSet<String> sessions = user2session.get(_login); sessions.remove(_sessionID); if (sessions.isEmpty()) { user2session.remove(_login); } } } synchronized (ConnectionRegistry.KEEPALIVE) { final ConcurrentMap<String, Long> keepalive = _application .getMetaData(ConnectionRegistry.KEEPALIVE); if (keepalive != null) { keepalive.remove(_sessionID); } } ConnectionRegistry.LOG.debug("Removed User '{}' for Session: {}", _login, _sessionID); registerLogout4History(_login, _sessionID); } }
From source file:org.efaps.ui.wicket.ConnectionRegistry.java
License:Apache License
/** * Send the KeepAlive.//from ww w .j ava 2 s .c om * @param _application Application the KeepAlive will be send for */ public void sendKeepAlive(final Application _application) { final long reference = new Date().getTime(); final ConcurrentMap<String, IKey> sessionId2key = _application.getMetaData(ConnectionRegistry.SESSION2KEY); final ConcurrentMap<String, Long> keepalive = _application.getMetaData(ConnectionRegistry.KEEPALIVE); if (keepalive != null) { for (final Entry<String, Long> entry : keepalive.entrySet()) { if (reference - entry.getValue() > Configuration.getAttributeAsInteger(ConfigAttribute.WEBSOCKET_KATH) * 1000) { final IKey key = sessionId2key.get(entry.getKey()); if (key != null) { final IWebSocketConnectionRegistry registry = WebSocketSettings.Holder.get(_application) .getConnectionRegistry(); final IWebSocketConnection conn = registry.getConnection(_application, entry.getKey(), key); if (conn != null) { try { conn.sendMessage(KeepAliveBehavior.MSG); ConnectionRegistry.LOG.debug("Send KeepAlive for Session: {}", entry.getKey()); } catch (final IOException e) { ConnectionRegistry.LOG.error("Catched error", e); } } } } } } }
From source file:org.odlabs.wiquery.core.WiQueryInitializer.java
License:Open Source License
public void init(Application application) { Application.get().getComponentInstantiationListeners().add(new WiQueryPluginInstantiationListener()); // check for WiQuerySettings on the application WiQuerySettings settings = application.getMetaData(WIQUERY_INSTANCE_KEY); // create new one when application has none if (settings == null) { settings = new WiQuerySettings(); // apply IWiQuerySettings to the applications metadata application.setMetaData(WIQUERY_INSTANCE_KEY, settings); // IWiQueryInitializer treatments retrieveAndCallInitializers(application, settings); } else {/*from w ww . j a v a2 s . c o m*/ LOGGER.info("application already hasWiQuerySettings"); } }
From source file:org.qi4j.sample.dcicargo.sample_a.infrastructure.wicket.tabs.TabsPanel.java
License:Apache License
public static <T extends Page> void registerTab(Application app, Class<T> clazz, String ref, String label) { Map<Class, String[]> tabsInfo = app.getMetaData(TABS_PANEL_KEY); if (tabsInfo == null || tabsInfo.isEmpty()) { tabsInfo = new LinkedHashMap<Class, String[]>(); }//from w w w.j av a2 s.c o m tabsInfo.put(clazz, new String[] { ref, label }); app.setMetaData(TABS_PANEL_KEY, tabsInfo); }
From source file:org.qi4j.sample.dcicargo.sample_b.infrastructure.wicket.tabs.TabsPanel.java
License:Apache License
public static <T extends Page> void registerTab(Application app, Class<T> clazz, String ref, String label, String cssClass) {/*from w ww. j a v a 2s .c o m*/ Map<Class, String[]> tabsInfo = app.getMetaData(TABS_PANEL_KEY); if (tabsInfo == null || tabsInfo.isEmpty()) { tabsInfo = new LinkedHashMap<Class, String[]>(); } tabsInfo.put(clazz, new String[] { ref, label }); app.setMetaData(TABS_PANEL_KEY, tabsInfo); }
From source file:org.wicketstuff.chat.channel.TimerChannelBehavior.java
License:Apache License
/** * Methods used to access the triggers queued for the behavior * /*from w w w .jav a 2 s.c om*/ * The implementation uses a Map stored in the application, where the * behavior id is the key, because these triggers cannot be stored in * component instance or the behavior itself, since they may be serialized * and deserialized. * * @param application * the application in which the triggers are stored * @param id * the id of the behavior * * @return a List of triggers queued for the component */ private static List<DelayedMethodCallList> getTriggers(final Application application, String id) { id = getPageId(application, id); ConcurrentMap<String, List<DelayedMethodCallList>> triggersById; synchronized (application) { triggersById = application.getMetaData(TRIGGERS_KEY); if (triggersById == null) { triggersById = new ConcurrentHashMap<String, List<DelayedMethodCallList>>(); application.setMetaData(TRIGGERS_KEY, triggersById); } } List<DelayedMethodCallList> triggers = triggersById.get(id); if (triggers == null) { triggersById.putIfAbsent(id, new ArrayList<DelayedMethodCallList>()); triggers = triggersById.get(id); } return triggers; }