com.atlassian.jira.plugin.util
Class InvolvedPluginsTracker

java.lang.Object
  extended by com.atlassian.jira.plugin.util.InvolvedPluginsTracker

public class InvolvedPluginsTracker
extends Object

This is a glorified list of plugin keys that code can use to track what plugins are involved in its caches

On plugin events it can then ask if the event related to one of the tracked plugins

This uses a CopyOnWriteArraySet under the covers to ensure that the list is as safe as possible. The assumption is that the reads and writes will be of low volume and the total number of plugins tracked will be smallish. In other words its anticipated that it will just work!

Since:
v4.4

Nested Class Summary
static class InvolvedPluginsTracker.PluginInfo
          A simple class that contains plugin key and pluginVersion.
 
Constructor Summary
InvolvedPluginsTracker()
           
 
Method Summary
 void clear()
          Clear the underlying set of tracked plugins
 Set<InvolvedPluginsTracker.PluginInfo> getInvolvedPluginKeys()
           
 int hashCode()
          The hashcode of this object will be stable so long it is tracking the same versions of the same plugins
 boolean isPluginInvolved(com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
          Returns true if the plugin that this ModuleDescriptor belongs to is being tracked
 boolean isPluginInvolved(com.atlassian.plugin.Plugin plugin)
          Returns true if the plugin is being tracked
 boolean isPluginWithModuleDescriptor(com.atlassian.plugin.ModuleDescriptor moduleDescriptor, Class<? extends com.atlassian.plugin.ModuleDescriptor> targetModuleClass)
          Returns true if the plugin pointed to by the moduleDescriptor contains in it a 1 or modules with the target module descriptor class.
 boolean isPluginWithModuleDescriptor(com.atlassian.plugin.Plugin plugin, Class<? extends com.atlassian.plugin.ModuleDescriptor> targetModuleClass)
          Returns true if the plugin pointed to by the moduleDescriptor contains in it a 1 or module descriptors with the target module descriptor class.
 boolean isPluginWithResourceType(com.atlassian.plugin.ModuleDescriptor moduleDescriptor, String pluginResourceType)
          Returns true if the underlying plugin contains resources of the specified type, for example "i18n" resource types
 boolean isPluginWithResourceType(com.atlassian.plugin.Plugin plugin, String pluginResourceType)
          Returns true if the plugin contains resources of the specified type, for example "i18n" resource types
 String toString()
           
 void trackInvolvedPlugin(com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
          Tracks a plugin as being involved via its ModuleDescriptor
 void trackInvolvedPlugin(com.atlassian.plugin.Plugin plugin)
          Tracks a plugin as being involved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvolvedPluginsTracker

public InvolvedPluginsTracker()
Method Detail

trackInvolvedPlugin

public void trackInvolvedPlugin(com.atlassian.plugin.Plugin plugin)
Tracks a plugin as being involved

Parameters:
plugin - the plugin in play

trackInvolvedPlugin

public void trackInvolvedPlugin(com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
Tracks a plugin as being involved via its ModuleDescriptor

Parameters:
moduleDescriptor - the ModuleDescriptor of the plugin in play

isPluginInvolved

public boolean isPluginInvolved(com.atlassian.plugin.Plugin plugin)
Returns true if the plugin is being tracked

Parameters:
plugin - the plugin in play
Returns:
true if the underlying plugin is being tracked

isPluginInvolved

public boolean isPluginInvolved(com.atlassian.plugin.ModuleDescriptor moduleDescriptor)
Returns true if the plugin that this ModuleDescriptor belongs to is being tracked

Parameters:
moduleDescriptor - the ModuleDescriptor of the plugin in play
Returns:
true if the underlying plugin is being tracked

isPluginWithModuleDescriptor

public boolean isPluginWithModuleDescriptor(com.atlassian.plugin.ModuleDescriptor moduleDescriptor,
                                            Class<? extends com.atlassian.plugin.ModuleDescriptor> targetModuleClass)
Returns true if the plugin pointed to by the moduleDescriptor contains in it a 1 or modules with the target module descriptor class.

Parameters:
moduleDescriptor - the module descriptor in play (typically from a plugin event)
targetModuleClass - the target capabilities you want to test
Returns:
true if the underlying plugin has the designed module descriptor class

isPluginWithModuleDescriptor

public boolean isPluginWithModuleDescriptor(com.atlassian.plugin.Plugin plugin,
                                            Class<? extends com.atlassian.plugin.ModuleDescriptor> targetModuleClass)
Returns true if the plugin pointed to by the moduleDescriptor contains in it a 1 or module descriptors with the target module descriptor class.

Parameters:
plugin - the plugin play (typically from a plugin event)
targetModuleClass - the target capabilities you want to test
Returns:
true if the underlying plugin has the designed module descriptor class

isPluginWithResourceType

public boolean isPluginWithResourceType(com.atlassian.plugin.Plugin plugin,
                                        String pluginResourceType)
Returns true if the plugin contains resources of the specified type, for example "i18n" resource types

Parameters:
plugin - the plugin play (typically from a plugin event)
pluginResourceType - the descriptive name of the resource type (for example "i18n")
Returns:
true if the plugin cvontains resources of the specified type

isPluginWithResourceType

public boolean isPluginWithResourceType(com.atlassian.plugin.ModuleDescriptor moduleDescriptor,
                                        String pluginResourceType)
Returns true if the underlying plugin contains resources of the specified type, for example "i18n" resource types

Parameters:
moduleDescriptor - the module descriptor of the plugin play (typically from a plugin event)
pluginResourceType - the descriptive name of the resource type (for example "i18n")
Returns:
true if the plugin cvontains resources of the specified type

getInvolvedPluginKeys

public Set<InvolvedPluginsTracker.PluginInfo> getInvolvedPluginKeys()
Returns:
a copy of the underlying tracked plugin keys

clear

public void clear()
Clear the underlying set of tracked plugins


hashCode

public int hashCode()
The hashcode of this object will be stable so long it is tracking the same versions of the same plugins

Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2013 Atlassian. All Rights Reserved.