Example usage for org.apache.wicket.protocol.http WebApplication setMetaData

List of usage examples for org.apache.wicket.protocol.http WebApplication setMetaData

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebApplication 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:org.artifactory.webapp.spring.ArtifactorySpringComponentInjector.java

License:Open Source License

public ArtifactorySpringComponentInjector(WebApplication webapp) {
    Args.notNull(webapp, "webapp");

    ApplicationContext ctx = get(webapp);
    Args.notNull(ctx, "ctx");

    // store context in application's metadata ...
    webapp.setMetaData(CONTEXT_KEY, new ApplicationContextHolder(ctx));

    ///*w  ww  . j  a v  a  2s. c  o  m*/
    fieldValueFactory = new ArtifactoryContextAnnotFieldValueFactory(new NonCachingContextLocator());
    bind(webapp);
}

From source file:org.brixcms.Brix.java

License:Apache License

/**
 * Performs any {@link WebApplication} specific initialization
 *
 * @param application/*w w w .  j a v a  2s. c  o  m*/
 */
public void attachTo(WebApplication application) {
    if (application == null) {
        throw new IllegalArgumentException("Application cannot be null");
    }

    // store brix instance in applicaton's metadata so it can be retrieved
    // easily later
    application.setMetaData(APP_KEY, this);

    /*
       * XXX we are coupling to nodepage plugin here instead of using the
       * usual register mechanism - we either need to make plugins application
       * aware so they can install their own listeners or have some brix-level
       * registery
       */
    application.getComponentPreOnBeforeRenderListeners().add(new PageParametersAwareEnabler());

    // allow brix to handle any url that wicket cant
    application.getRootRequestMapperAsCompound().add(new BrixRequestMapper(this));
    // application.mount(new BrixNodePageUrlMapper());

    // register a string resource loader that allows any object that acts as
    // an extension supply its own resource bundle for the UI
    BrixExtensionStringResourceLoader loader = new BrixExtensionStringResourceLoader();
    application.getResourceSettings().getStringResourceLoaders().add(loader);
    config.getRegistry().register(loader, true);
}

From source file:org.efaps.esjp.ui.dev.DevUtils.java

License:Apache License

public Return toggleDevUtils(final Parameter _parameter) throws EFapsException {
    //Administration
    if (Role.get(UUID.fromString("1d89358d-165a-4689-8c78-fc625d37aacd")).isAssigned()) {
        final WebApplication application = WebApplication.get();
        DevUtils.LOG//from  www  . ja v a2s  .  c  om
                .info("Toggle devutils: " + !application.getDebugSettings().isDevelopmentUtilitiesEnabled());
        application.getDebugSettings().setDevelopmentUtilitiesEnabled(
                !application.getDebugSettings().isDevelopmentUtilitiesEnabled());

        // check to add them only once
        if (application.getMetaData(DevUtils.DEBUG_BAR_CONTRIBUTED) == null) {
            DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(PageSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
            application.setMetaData(DevUtils.DEBUG_BAR_CONTRIBUTED, true);
        }
    }
    return new Return();
}

From source file:org.ops4j.pax.wicket.test.spring.PaxWicketSpringBeanComponentInjector.java

License:Apache License

public PaxWicketSpringBeanComponentInjector(WebApplication webApp, ApplicationContext appContext) {
    webApp.setMetaData(CONTEXT_KEY, appContext);
    beanInjector = new PaxWicketTestBeanInjector();
    InjectorHolder.setInjector(webApp.getApplicationKey(), beanInjector);
}

From source file:org.ops4j.pax.wicket.test.spring.PaxWicketSpringBeanComponentInjector.java

License:Apache License

public PaxWicketSpringBeanComponentInjector(WebApplication webApp, ApplicationContext appContext,
        boolean simulateBlueprint) {
    webApp.setMetaData(CONTEXT_KEY, appContext);
    beanInjector = new PaxWicketTestBeanInjector();
    InjectorHolder.setInjector(webApp.getApplicationKey(), beanInjector);
    this.simulateBlueprint = simulateBlueprint;
}

From source file:org.wicketopia.Wicketopia.java

License:Apache License

public void install(WebApplication application) {
    this.application = application;
    application.setMetaData(META_KEY, this);
    addDefaultEditorProviders();/*from w w  w .jav a  2 s  .  co m*/
    adDefaultViewerProviders();
    for (WicketopiaPlugin plugin : plugins) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Initializing {} plugin...", plugin.getClass().getName());
        }
        plugin.initialize(this);
    }
}

From source file:org.wicketstuff.mergedresources.ResourceMount.java

License:Apache License

/**
 * enable annotation based adding of resources and make sure that the
 * component instantiation listener is only added once
 * //from w w w  .j  av a2s  . com
 * @param application
 * @see JsContribution
 * @see CssContribution
 */
public static void enableAnnotations(WebApplication application) {
    Boolean enabled = application.getMetaData(ANNOTATIONS_ENABLED_KEY);
    if (!Boolean.TRUE.equals(enabled)) {
        try {
            Class.forName("org.wicketstuff.config.MatchingResources");
            Class.forName("org.springframework.core.io.support.PathMatchingResourcePatternResolver");
        } catch (ClassNotFoundException e) {
            throw new WicketRuntimeException(
                    "in order to enable wicketstuff-merged-resources' annotation support, "
                            + "wicketstuff-annotations and spring-core must be on the path "
                            + "(see http://wicketstuff.org/confluence/display/STUFFWIKI/wicketstuff-annotation for details)");
        }
        application.addComponentInstantiationListener(new ContributionInjector());
        application.setMetaData(ANNOTATIONS_ENABLED_KEY, Boolean.TRUE);
    }
}

From source file:org.wicketstuff.offline.mode.OfflineCache.java

License:Apache License

/**
 * Sets the offline cache entries (can only be used if the offline cache hasn't been initialized
 * yet)//from w w w  .j av  a 2s .c o m
 *
 * @param application
 *          the application instance
 * @param offlineCacheEntries
 *          the offline cache entries to store
 */
public static void setOfflineCacheEntries(final WebApplication application,
        List<OfflineCacheEntry> offlineCacheEntries) {
    application.setMetaData(OFFLINE_CACHE_ENTRIES, offlineCacheEntries);
}

From source file:sk.drunkenpanda.leaflet.Leaflet.java

License:Apache License

/**
 * Install Leaflet with given settings to application.
 * If application already has Leaflet installed, it ignores new settings.
 *
 * @param application application, which Leaflet should be bounded to.
 * @param settings custom settings, which are used to initialized library
 * @throws IllegalArgumentException if application is {@code null}.
 *///ww w .ja  v  a2s.c o m
public static void install(WebApplication application, LeafletSettings settings) {
    // install Leaflet.js with given configuration
    Args.notNull(application, "application");

    if (application.getMetaData(LEAFLET_SETTINGS_KEY) == null) {
        LeafletSettings settingsOrDefault = settings != null ? settings : new DefaultLeafletSettings();
        application.setMetaData(LEAFLET_SETTINGS_KEY, settingsOrDefault);

        if (settingsOrDefault.autoAppendResources()) {
            application.getComponentInstantiationListeners().add(new LeafletResourceAppender());
        }

        if (settingsOrDefault.useWebJars()) {
            WicketWebjars.install(application);
        }
    }
}