Example usage for org.apache.wicket Application setMetaData

List of usage examples for org.apache.wicket Application setMetaData

Introduction

In this page you can find the example usage for org.apache.wicket Application setMetaData.

Prototype

public final synchronized <T> Application setMetaData(final MetaDataKey<T> key, final Object object) 

Source Link

Document

Sets the metadata for this application using the given key.

Usage

From source file:net.ftlines.wicket.validation.bean.ValidationContext.java

License:Apache License

void bind(Application application) {
    application.setMetaData(METAKEY, this);
}

From source file:org.odlabs.wiquery.core.commons.WiQueryInitializer.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  ww.  j a  v  a2 s  .  c  om*/
 * 
 * @see org.apache.wicket.IInitializer#init(org.apache.wicket.Application)
 */
public void init(Application application) {
    application.addPostComponentOnBeforeRenderListener(new WiQueryRenderingListener());

    // check for IWiQuerySettings on the application
    WiQuerySettings settings = application instanceof IWiQuerySettings
            ? ((IWiQuerySettings) application).getWiQuerySettings()
            : null;
    application.setMetaData(WIQUERY_INSTANCE_KEY, settings == null ? new WiQuerySettings() : settings);

    // IWiQueryInitializer treatments
    retrieveAndCallInitializers(application, settings);
}

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 {/*  w  w w  .  java2s.co 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[]>();
    }/*  w  w  w  .ja  va 2 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 .ja  v a2 s .  c om*/
    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 ww w .  java 2  s .com
 * 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;
}

From source file:org.wicketstuff.chat.channel.TimerChannelBehavior.java

License:Apache License

private static void touch(final Application application, String id) {
    id = getPageId(application, id);//from  ww w.  j a v a2 s . c  om
    ConcurrentMap<String, Time> eventsTimeById;
    synchronized (application) {
        eventsTimeById = application.getMetaData(EVENTS_KEY);
        if (eventsTimeById == null) {
            eventsTimeById = new ConcurrentHashMap<String, Time>();
            application.setMetaData(EVENTS_KEY, eventsTimeById);
        }
    }
    eventsTimeById.put(id, Time.now());
}

From source file:org.wicketstuff.chat.channel.TimerChannelBehavior.java

License:Apache License

private static void setRedirectId(final Application application, final String id, final String redirectedId) {
    ConcurrentMap<String, String> pageIdsById;
    synchronized (application) {
        pageIdsById = application.getMetaData(PAGE_ID_KEY);
        if (pageIdsById == null) {
            pageIdsById = new ConcurrentHashMap<String, String>();
            application.setMetaData(PAGE_ID_KEY, pageIdsById);
        }/*  ww  w  .  j  a v  a  2s . c  o m*/
    }
    final String oldRedirectedId = pageIdsById.put(id, redirectedId);
    if (!redirectedId.equals(oldRedirectedId)) {
        /*
         * The id was not already redirected to the redirectedId, we need to
         * merge the information before redirection with information after
         * redirection
         */
        final String idToRedirect = oldRedirectedId == null ? id : oldRedirectedId;
        redirect(application, idToRedirect, redirectedId);
    }
}

From source file:org.wicketstuff.dashboard.DashboardContextInitializer.java

License:Apache License

@Override
public void init(Application application) {
    // create dashboard context
    DashboardContext dashboardContext = new DashboardContext();

    // store dashboard context in application
    application.setMetaData(DASHBOARD_CONTEXT_KEY, dashboardContext);

    // add dashboard context injector
    DashboardContextInjector dashboardContextInjector = new DashboardContextInjector(dashboardContext);
    application.getComponentInstantiationListeners().add(dashboardContextInjector);
}

From source file:org.wicketstuff.dashboard.web.DashboardSettings.java

License:Apache License

/**
 * Retrieves the instance of settings object.
 *
 * @return settings instance// ww w.  j  av  a 2 s.  c  o  m
 */
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);
}