List of usage examples for org.apache.wicket Application getMetaData
public final synchronized <T> T getMetaData(final MetaDataKey<T> key)
From source file:at.molindo.wicketutils.openid.OpenIdSession.java
License:Apache License
private ConsumerManager getConsumerManager() { Application app = Session.get().getApplication(); ConsumerManager consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY); if (consumerManager == null) { // double checked locking synchronized (CONSUMER_MANAGER_KEY) { consumerManager = app.getMetaData(CONSUMER_MANAGER_KEY); if (consumerManager == null) { consumerManager = new ConsumerManager(); consumerManager.setAssociations(new InMemoryConsumerAssociationStore()); consumerManager.setNonceVerifier(new InMemoryNonceVerifier(10000)); app.setMetaData(CONSUMER_MANAGER_KEY, consumerManager); }/*from w w w.jav a 2 s . c o m*/ } } return consumerManager; }
From source file:com.aplombee.RepeaterUtil.java
License:Apache License
public static RepeaterUtil get() { Application app = Application.get(); RepeaterUtil util = app.getMetaData(REPEATER_UTIL_KEY); if (util != null) { return util; }// w w w. java2 s .co m util = new RepeaterUtil(app); //this registers too return util; }
From source file:com.mylab.wicket.jpa.ui.pages.select2.ApplicationSettings.java
License:Apache License
/** * Retrieves the instance of settings object. * /*from w ww . ja v a2s. c o m*/ * @return settings instance */ public static ApplicationSettings get() { // FIXME Application should provide setMetadataIfAbsent() Application application = Application.get(); ApplicationSettings settings = application.getMetaData(KEY); if (settings == null) { synchronized (application) { settings = application.getMetaData(KEY); if (settings == null) { settings = new ApplicationSettings(); application.setMetaData(KEY, settings); } } } return application.getMetaData(KEY); }
From source file:de.alpharogroup.wicket.base.application.plugins.ApplicationDebugSettingsPlugin.java
License:Apache License
/** * Returns the {@link ApplicationDebugSettingsPlugin} instance that has been installed in the * current Wicket application. This is a convenience method that only works within a Wicket * thread, and it assumes that {@link #install install()} has already been called. * * @return the {@link ApplicationDebugSettingsPlugin} instance that has been installed in the * current Wicket application./*from w ww . j a v a 2 s .com*/ * @throws IllegalStateException * is thrown if no Wicket application bound to the current thread, or if a * {@code DebugSettingsPlugin} has not been installed. */ public static ApplicationDebugSettingsPlugin get() { final Application app = Application.get(); if (null == app) { throw new IllegalStateException("No wicket application is bound to the current thread."); } final ApplicationDebugSettingsPlugin plugin = app.getMetaData(DEBUG_SETTINGS_PLUGIN_KEY); if (null == plugin) { final String pluginClassName = ApplicationDebugSettingsPlugin.class.getSimpleName(); throw new IllegalStateException("A " + pluginClassName + " has not been installed in this Wicket " + "application. You have to call " + pluginClassName + ".install() in " + "your application init()."); } return plugin; }
From source file:de.alpharogroup.wicket.base.application.plugins.SecuritySettingsPlugin.java
License:Apache License
/** * Returns the {@link SecuritySettingsPlugin} instance that has been installed in the current * Wicket application. This is a convenience method that only works within a Wicket thread, and * it assumes that {@link #install install()} has already been called. * * @return the {@link SecuritySettingsPlugin} instance that has been installed in the current * Wicket application./*w w w .ja v a2 s .co m*/ * @throws IllegalStateException * is thrown if no Wicket application bound to the current thread, or if a * {@code DebugSettingsPlugin} has not been installed. */ public static SecuritySettingsPlugin get() { final Application app = Application.get(); if (null == app) { throw new IllegalStateException("No wicket application is bound to the current thread."); } final SecuritySettingsPlugin plugin = app.getMetaData(SECURITY_SETTINGS_PLUGIN_KEY); if (null == plugin) { final String pluginClassName = SecuritySettingsPlugin.class.getSimpleName(); throw new IllegalStateException( "A " + pluginClassName + " has not been installed in this Wicket application. You have to call " + pluginClassName + ".install() in " + "your application init()."); } return plugin; }
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Authorizes the given roles to create component instances of type * componentClass. This authorization is added to any previously authorized * roles.//from w w w.j a va 2s. c om * * @param <T> * * @param componentClass The component type that is subject for the * authorization * @param roles The roles that are authorized to create component instances * of type componentClass */ private static <T extends Component> void authorize(final Class<T> componentClass, final Role... roles) { final Application application = Application.get(); InstantiationPermissions permissions = application.getMetaData(INSTANTIATION_PERMISSIONS); if (permissions == null) { permissions = new InstantiationPermissions(); application.setMetaData(INSTANTIATION_PERMISSIONS, permissions); } permissions.authorize(componentClass, roles); }
From source file:eu.uqasar.auth.strategies.metadata.MetaDataAuthorizationStrategy.java
License:Apache License
/** * Grants permission to all roles to create instances of the given component * class.//w ww. j av a 2 s .c o m * * @param <T> * * @param componentClass The component class */ private static <T extends Component> void authorizeAll(final Class<T> componentClass) { Application application = Application.get(); InstantiationPermissions authorizedLevels = application.getMetaData(INSTANTIATION_PERMISSIONS); if (authorizedLevels != null) { authorizedLevels.authorizeAll(componentClass); } }
From source file:fiftyfive.wicket.js.JavaScriptDependencySettings.java
License:Apache License
/** * Returns the JavaScriptDependencySettings associated with the current * Wicket Application, creating a new default settings object if one does * not yet exist. This method can only be called within a Wicket thread. *///from w ww.j a v a 2s. c o m public static JavaScriptDependencySettings get() { Application app = Application.get(); if (null == app) { throw new IllegalStateException("No thread-local Wicket Application object was found. " + "JavaScriptDependencySettings.get() can only be called " + "within a Wicket request."); } JavaScriptDependencySettings settings = app.getMetaData(SETTINGS_KEY); if (null == settings) { settings = new JavaScriptDependencySettings(app); app.setMetaData(SETTINGS_KEY, settings); } return settings; }
From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java
License:Apache License
/** * Returns the {@code ShiroWicketPlugin} instance that has been installed * in the current Wicket application. This is a convenience method that * only works within a Wicket thread, and it assumes that * {@link #install install()} has already been called. * /*from w w w .j a v a2 s . c o m*/ * @throws IllegalStateException if there is no Wicket application bound * to the current thread, or if a * {@code ShiroWicketPlugin} has not been * installed. */ public static ShiroWicketPlugin get() { Application app = Application.get(); if (null == app) { throw new IllegalStateException("No wicket application is bound to the current thread."); } ShiroWicketPlugin plugin = app.getMetaData(PLUGIN_KEY); if (null == plugin) { throw new IllegalStateException("A ShiroWicketPlugin has not been installed in this Wicket " + "application. You must call ShiroWicketPlugin.install() in " + "your application init()."); } return plugin; }
From source file:name.martingeisse.wicket.component.sprite.ApplicationSpriteSupport.java
License:Open Source License
/** * Returns the sprite support object for the specified application, or null if none * is associated with the application./*w w w. j a v a 2 s . c o m*/ * * @param application the Wicket application * @return the sprite support object */ public static ApplicationSpriteSupport get(Application application) { return application.getMetaData(KEY); }