Package play.plugins

Class PluginCollection


  • public class PluginCollection
    extends java.lang.Object
    Class handling all plugins used by Play. Loading/reloading/enabling/disabling is handled here. This class also exposes many PlayPlugin-methods which when called, the method is executed on all enabled plugins. Since all the enabled-plugins-iteration is done here, the code elsewhere is cleaner.
    • Field Detail

      • play_plugins_resourceName

        protected java.lang.String play_plugins_resourceName
        Property holding the name of the play.plugins-resource-name. Can be modified in unittest to supply modifies plugin-list
      • allPlugins

        protected java.util.List<PlayPlugin> allPlugins
        List that holds all loaded plugins, enabled or disabled
      • allPlugins_readOnlyCopy

        protected java.util.List<PlayPlugin> allPlugins_readOnlyCopy
        Readonly copy of allPlugins - updated each time allPlugins is updated. Using this cached copy so we don't have to create it all the time..
      • enabledPlugins

        protected java.util.List<PlayPlugin> enabledPlugins
        List of all enabled plugins
      • enabledPlugins_readOnlyCopy

        protected java.util.List<PlayPlugin> enabledPlugins_readOnlyCopy
        Readonly copy of enabledPlugins - updated each time enabledPlugins is updated. Using this cached copy so we don't have to create it all the time
      • enabledPluginsWithFilters

        protected java.util.List<PlayPlugin> enabledPluginsWithFilters
        List of all enabled plugins with filters
      • enabledPluginsWithFilters_readOnlyCopy

        protected java.util.List<PlayPlugin> enabledPluginsWithFilters_readOnlyCopy
        Readonly copy of enabledPluginsWithFilters - updated each time enabledPluginsWithFilters is updated. Using this cached copy so we don't have to create it all the time
    • Constructor Detail

      • PluginCollection

        public PluginCollection()
    • Method Detail

      • createReadonlyCopy

        protected java.util.List<PlayPlugin> createReadonlyCopy​(java.util.List<PlayPlugin> list)
        Using readonly list to crash if someone tries to modify the copy.
        Parameters:
        list - The list of plugins
        Returns:
        Read only list of plugins
      • loadPlugins

        public void loadPlugins()
      • reloadApplicationPlugins

        public void reloadApplicationPlugins()
                                      throws java.lang.Exception
        Reloads all loaded plugins that is application-supplied.
        Throws:
        java.lang.Exception - If problem occurred during reload
      • isLoadedByApplicationClassloader

        protected boolean isLoadedByApplicationClassloader​(PlayPlugin plugin)
      • initializePlugin

        protected void initializePlugin​(PlayPlugin plugin)
        Calls plugin.onLoad but detects if plugin removes other plugins from Play.plugins-list to detect if plugins disables a plugin the old hacked way..
        Parameters:
        plugin - The given plugin
      • addPlugin

        protected boolean addPlugin​(PlayPlugin plugin)
        Adds one plugin and enables it
        Parameters:
        plugin - The given plugin
        Returns:
        true if plugin was new and was added
      • enablePlugin

        public boolean enablePlugin​(PlayPlugin plugin)
        Enable plugin.
        Parameters:
        plugin - The given plugin
        Returns:
        true if plugin exists and was enabled now
      • enablePlugin

        public boolean enablePlugin​(java.lang.Class<? extends PlayPlugin> pluginClazz)
        enable plugin of specified type
        Parameters:
        pluginClazz - The plugin class
        Returns:
        true if plugin was enabled
      • getPluginInstance

        public <T extends PlayPlugin> T getPluginInstance​(java.lang.Class<T> pluginClazz)
        Returns the first instance of a loaded plugin of specified type
        Parameters:
        pluginClazz - The plugin class
        Returns:
        PlayPlugin
      • disablePlugin

        public boolean disablePlugin​(PlayPlugin plugin)
        disable plugin
        Parameters:
        plugin - The given plugin
        Returns:
        true if plugin was enabled and now is disabled
      • disablePlugin

        public boolean disablePlugin​(java.lang.Class<? extends PlayPlugin> pluginClazz)
        Disable plugin of specified type
        Parameters:
        pluginClazz - The plugin class
        Returns:
        true if plugin was enabled and now is disabled
      • updatePlayPluginsList

        public void updatePlayPluginsList()
        Must update Play.plugins-list to be backward compatible
      • getEnabledPlugins

        public java.util.List<PlayPlugin> getEnabledPlugins()
        Returns new readonly list of all enabled plugins
        Returns:
        List of plugins
      • getEnabledPluginsWithFilters

        public java.util.List<PlayPlugin> getEnabledPluginsWithFilters()
        Returns new readonly list of all enabled plugins that define filters.
        Returns:
        List of plugins
      • getReversedEnabledPlugins

        public java.util.Collection<PlayPlugin> getReversedEnabledPlugins()
        Returns readonly view of all enabled plugins in reversed order
        Returns:
        Collection of plugins
      • getAllPlugins

        public java.util.List<PlayPlugin> getAllPlugins()
        Returns new readonly list of all plugins
        Returns:
        List of plugins
      • isEnabled

        public boolean isEnabled​(PlayPlugin plugin)
        Indicate if a plugin is enabled
        Parameters:
        plugin - The given plugin
        Returns:
        true if plugin is enabled
      • compileSources

        public boolean compileSources()
      • detectClassesChange

        public boolean detectClassesChange()
      • invocationFinally

        public void invocationFinally()
      • beforeInvocation

        public void beforeInvocation()
      • afterInvocation

        public void afterInvocation()
      • onInvocationSuccess

        public void onInvocationSuccess()
      • onInvocationException

        public void onInvocationException​(java.lang.Throwable e)
      • beforeDetectingChanges

        public void beforeDetectingChanges()
      • detectChange

        public void detectChange()
      • onApplicationReady

        public void onApplicationReady()
      • onConfigurationRead

        public void onConfigurationRead()
      • onApplicationStart

        public void onApplicationStart()
      • afterApplicationStart

        public void afterApplicationStart()
      • onApplicationStop

        public void onApplicationStop()
      • onEvent

        public void onEvent​(java.lang.String message,
                            java.lang.Object context)
      • bind

        public java.lang.Object bind​(RootParamNode rootParamNode,
                                     java.lang.String name,
                                     java.lang.Class<?> clazz,
                                     java.lang.reflect.Type type,
                                     java.lang.annotation.Annotation[] annotations)
      • bindBean

        public java.lang.Object bindBean​(RootParamNode rootParamNode,
                                         java.lang.String name,
                                         java.lang.Object bean)
      • unBind

        public java.util.Map<java.lang.String,​java.lang.Object> unBind​(java.lang.Object src,
                                                                             java.lang.String name)
      • willBeValidated

        public java.lang.Object willBeValidated​(java.lang.Object value)
      • modelFactory

        public Model.Factory modelFactory​(java.lang.Class<? extends Model> modelClass)
      • getMessage

        public java.lang.String getMessage​(java.lang.String locale,
                                           java.lang.Object key,
                                           java.lang.Object... args)
      • beforeActionInvocation

        public void beforeActionInvocation​(java.lang.reflect.Method actionMethod)
      • onActionInvocationResult

        public void onActionInvocationResult​(Result result)
      • afterActionInvocation

        public void afterActionInvocation()
      • onActionInvocationFinally

        public void onActionInvocationFinally()
      • routeRequest

        public void routeRequest​(Http.Request request)
      • onRequestRouting

        public void onRequestRouting​(Router.Route route)
      • onRoutesLoaded

        public void onRoutesLoaded()
      • rawInvocation

        public boolean rawInvocation​(Http.Request request,
                                     Http.Response response)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • addTemplateExtensions

        public java.util.List<java.lang.String> addTemplateExtensions()
      • overrideTemplateSource

        public java.lang.String overrideTemplateSource​(BaseTemplate template,
                                                       java.lang.String source)
      • afterFixtureLoad

        public void afterFixtureLoad()
      • getUnitTests

        public java.util.Collection<java.lang.Class> getUnitTests()
      • getFunctionalTests

        public java.util.Collection<java.lang.Class> getFunctionalTests()