本文整理了Java中com.atlassian.plugin.Plugin.getModuleDescriptors()
方法的一些代码示例,展示了Plugin.getModuleDescriptors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.getModuleDescriptors()
方法的具体详情如下:
包路径:com.atlassian.plugin.Plugin
类名称:Plugin
方法名:getModuleDescriptors
暂无
代码示例来源:origin: com.atlassian.plugin.rest/atlassian-rest-plugin-manager-plugin
public static Collection<PluginModule> getModules(final PluginAccessor pluginAccessor, Plugin plugin)
{
final Iterable<PluginModule> moduleIterable = Iterables.transform(plugin.getModuleDescriptors(), new Function<ModuleDescriptor, PluginModule>()
{
public PluginModule apply(@Nullable ModuleDescriptor moduleDescriptor)
{
return getModule(pluginAccessor, moduleDescriptor);
}
});
return Lists.newLinkedList(moduleIterable);
}
代码示例来源:origin: com.atlassian.jira/jira-core
public static Predicate<Plugin> isPluginWithModuleDescriptor(@Nonnull final Class<? extends ModuleDescriptor> targetModuleClass)
{
return (Plugin plugin) -> plugin.getModuleDescriptors().stream().
map(ModuleDescriptor::getClass).anyMatch(targetModuleClass::isAssignableFrom);
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
private boolean hasSystemModules(Plugin plugin) {
for (ModuleDescriptor descriptor : plugin.getModuleDescriptors()) {
if (descriptor.isSystemModule()) {
return true;
}
}
return false;
}
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
private void disablePluginModules(final Plugin plugin) {
final List<ModuleDescriptor<?>> moduleDescriptors = new ArrayList<>(plugin.getModuleDescriptors());
Collections.reverse(moduleDescriptors); // disable in reverse order
for (final ModuleDescriptor<?> module : moduleDescriptors) {
// don't actually disable the module, just fire the events because
// its plugin is being disabled
// if the module was actually disabled, you'd have to reenable each
// one when enabling the plugin
disablePluginModuleNoPersist(module);
}
}
代码示例来源:origin: com.atlassian.labs/speakeasy-plugin
private Set<String> findUnresolvedCommonJsDependencies(Plugin plugin)
{
Set<String> unresolved = newHashSet();
for (ModuleDescriptor descriptor : plugin.getModuleDescriptors())
{
if (descriptor instanceof CommonJsModulesDescriptor)
{
unresolved.addAll(((CommonJsModulesDescriptor)descriptor).getUnresolvedExternalModuleDependencies());
}
}
return unresolved;
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
/**
* Get the all the module descriptors from the given collection of plugins,
* filtered by the predicate.
* <p>
* Be careful, your predicate must filter ModuleDescriptors that are not M,
* this method does not guarantee that the descriptors are of the correct
* type by itself.
*
* @param plugins a collection of {@link Plugin}s
* @return a collection of {@link ModuleDescriptor descriptors}
*/
private <M> Stream<ModuleDescriptor<M>> getModuleDescriptors(final Collection<Plugin> plugins,
final Predicate<ModuleDescriptor<M>> predicate) {
//noinspection unchecked
return plugins.stream()
.flatMap(plugin -> plugin.getModuleDescriptors().stream())
.map(descriptor -> (ModuleDescriptor<M>) descriptor)
.filter(predicate);
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
/**
* Builds an iterable of module descriptors for the given module predicate out of a collection of plugins.
*
* @param plugins A collection of plugins to search through
* @param predicate A predicate to filter the module descriptors by
* @param <M> The module class type
* @return An Iterable of module descriptors of module class M
*/
private <M> List<ModuleDescriptor<M>> getModuleDescriptors(final Collection<Plugin> plugins,
final Predicate<ModuleDescriptor<M>> predicate) {
//noinspection unchecked
return plugins.stream()
.flatMap(plugin -> plugin.getModuleDescriptors().stream())
.map(moduleDescriptor -> (ModuleDescriptor<M>) moduleDescriptor)
.filter(predicate)
.collect(Collectors.toList());
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
public static Predicate<Plugin> isPluginWithResourceType(@Nonnull final String pluginResourceType)
{
return (Plugin plugin) -> {
final Stream<ResourceDescriptor> resourceDescriptors = Stream.concat(plugin.getResourceDescriptors().stream(),
plugin.getModuleDescriptors().stream().flatMap(module -> module.getResourceDescriptors().stream()));
return resourceDescriptors.map(ResourceDescriptor::getType).anyMatch(pluginResourceType::equals);
};
}}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
/**
* Gets a list of all the module keys in a plugin that require restart. Looks for the annotation
* {@link RequiresRestart} on the plugin's module descriptors.
*
* @param plugin The plugin
* @return A unique set of module keys
* @since 2.5.0
*/
public static Set<String> getPluginModulesThatRequireRestart(final Plugin plugin) {
final Set<String> keys = new HashSet<>();
for (final ModuleDescriptor<?> descriptor : plugin.getModuleDescriptors()) {
if (descriptor.getClass().getAnnotation(RequiresRestart.class) != null) {
keys.add(descriptor.getKey());
}
}
return keys;
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
@Override
public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(final Class<D> descriptorClazz) {
notNull("Descriptor class", descriptorClazz);
return getEnabledPlugins().stream()
.flatMap(p -> p.getModuleDescriptors().stream())
.filter(descriptorClazz::isInstance)
.filter(new EnabledModulePredicate())
.map(descriptorClazz::cast)
.collect(Collectors.toList());
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
/**
* This method has been reverted to pre PLUG-40 to fix performance issues
* that were encountered during load testing. This should be reverted to the
* state it was in at 54639 when the fundamental issue leading to this
* slowdown has been corrected (that is, slowness of PluginClassLoader).
*
* @see PluginAccessor#getEnabledModuleDescriptorsByClass(Class)
*/
public <D extends ModuleDescriptor<?>> List<D> getEnabledModuleDescriptorsByClass(final Class<D> descriptorClazz) {
// TODO Avoid moving elements into a List until we call something other than iterator()
// Most of the time getEnabledModuleDescriptorsByClass is called within a foreach loop so would only call iterator()
return getEnabledPlugins().stream()
.flatMap(plugin -> plugin.getModuleDescriptors().stream())
.filter(descriptorClazz::isInstance)
.filter(new EnabledModulePredicate())
.map(descriptorClazz::cast)
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
}
代码示例来源:origin: com.atlassian.confluence.ext/newcode-macro-plugin
public List<String> listLocalization() {
Plugin plugin = pluginAccessor.getPlugin(Constants.PLUGIN_KEY);
Collection<ModuleDescriptor<?>> descriptors = plugin.getModuleDescriptors();
List<String> result = new ArrayList<>();
for (ModuleDescriptor<?> descriptor : descriptors) {
if (descriptor.getKey().startsWith(LOCALIZATION_DESCRIPTOR_PREFIX)) {
String webResourceId = descriptor.getCompleteKey();
if (StringUtils.isNotEmpty(webResourceId)) {
String languageKey = webResourceId.substring(webResourceId.length() - 2,
webResourceId.length());
result.add(languageKey.toLowerCase());
}
}
}
return result;
}
代码示例来源:origin: com.atlassian.labs/speakeasy-plugin
public boolean isFinished()
{
for (ModuleDescriptor desc : plugin.getModuleDescriptors())
{
if (!pluginAccessor.isPluginModuleEnabled(desc.getCompleteKey()) && desc instanceof UnrecognisedModuleDescriptor)
{
return false;
}
}
return true;
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
protected void notifyUninstallPlugin(final Plugin plugin) {
classLoader.notifyUninstallPlugin(plugin);
for (final ModuleDescriptor<?> descriptor : plugin.getModuleDescriptors()) {
descriptor.destroy();
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
@PluginEventListener
@SuppressWarnings("unused")
public void onPluginUninstalled(final PluginUninstalledEvent event)
{
final Iterable<UserFormatModuleDescriptor> userFormatModuleDescriptors =
Iterables.filter(event.getPlugin().getModuleDescriptors(), UserFormatModuleDescriptor.class);
if (Iterables.size(userFormatModuleDescriptors) > 0)
{
for (final UserFormatModuleDescriptor descriptor : userFormatModuleDescriptors)
{
removeUserFormatFrom(descriptor);
}
}
}
代码示例来源:origin: com.atlassian.soy/soy-template-plugin
@PluginEventListener
@SuppressWarnings("unchecked")
public void onPluginDisabled(PluginDisabledEvent event) {
removeDescriptors((Collection) Collections2.filter(event.getPlugin().getModuleDescriptors(), IS_SOY_FUNCTION));
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
@PluginEventListener
public void onPluginDisabled(final PluginDisabledEvent event) {
removeDescriptors(event.getPlugin().getModuleDescriptors());
}
代码示例来源:origin: com.atlassian.labs/speakeasy-plugin
@PluginEventListener
public void onPluginDisabled(final PluginDisabledEvent event)
{
removeDescriptors(event.getPlugin().getModuleDescriptors());
}
代码示例来源:origin: com.atlassian.rpc/atlassian-json-rpc-components
@PluginEventListener
public void onPluginDisabled(PluginDisabledEvent event) {
for (ModuleDescriptor<?> moduleDescriptor : event.getPlugin().getModuleDescriptors()) {
unregister(moduleDescriptor);
}
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
public void removeState(final Plugin plugin) {
apply(builder -> {
builder.removeState(plugin.getKey());
for (final ModuleDescriptor<?> moduleDescriptor : plugin.getModuleDescriptors()) {
builder.removeState(moduleDescriptor.getCompleteKey());
}
});
}
}
内容来源于网络,如有侵权,请联系作者删除!