public boolean matches( Plugin plugin ) { try { Class<?> loadedClass = plugin.loadClass( DefaultOverrideManager.class.getName(), null ); Class<?> myClass = DefaultOverrideManager.class; return loadedClass == myClass; } catch ( ClassNotFoundException e ) { return false; } } } ) ) {
BlockRenderer loadBlockRenderer(String blockRendererClassName, Plugin plugin) throws ClassNotFoundException { Class blockRendererClass = plugin.loadClass(blockRendererClassName, getClass()); return (BlockRenderer) JiraUtils.loadComponent(blockRendererClass); }
@Override protected void loadClass(Plugin plugin, String clazz) throws PluginParseException { try { // this should have been done once by the plugin container so should never throw exception. this.moduleClass = plugin.loadClass(clazz, null); } catch (ClassNotFoundException e) { throw new PluginParseException("cannot load component class", e); } }
private <T> Class<? extends T> findClass(String className, Class<T> castTo) { checkNotNull(className); Class<T> clazz; try { clazz = plugin.loadClass(className, getClass()); } catch (ClassNotFoundException e) { throw new PluginParseException("Unable to find class " + className); } return clazz.asSubclass(castTo); }
@SuppressWarnings("unchecked") private <A> Class<? extends A> loadSubModuleClass(String subModuleName, String subModuleClassName, Class<A> subModuleClassParentType) { if (subModuleClassName == null) { return null; } try { final Class<?> subModuleClass = plugin.loadClass(subModuleClassName, this.getClass()); if (!subModuleClassParentType.isAssignableFrom(subModuleClass)) { throw new IllegalArgumentException("Sub module '" + subModuleName + "' class '" + subModuleClassName + "' must be of type '" + subModuleClassParentType.getName() + "'"); } return (Class<? extends A>) subModuleClass; } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Sub module '" + subModuleName + "' class '" + subModuleClassName + "' not found "); } }
private <T> Class<? extends T> findClass(String className, Class<T> castTo) { checkNotNull(className); Class<T> clazz = null; try { clazz = plugin.loadClass(className, getClass()); } catch (ClassNotFoundException e) { throw new PluginParseException("Unable to find class " + className); } return clazz.asSubclass(castTo); }
@Override public void enabled() { super.enabled(); try { this.manifestProducerClass = plugin.loadClass(manifestProducerClassName, getModuleClass()); } catch (ClassNotFoundException cnfe) { throw new IllegalStateException("Unable to load this application type's " + ManifestProducer.class.getSimpleName() + " class.", cnfe); } }
private <T> T loadClass( String className, Class<T> type ) { Class cls = null; try { cls = plugin.loadClass( className, getClass() ); return type.cast( ConfluencePluginUtils.instantiatePluginModule( plugin, cls ) ); } catch ( ClassNotFoundException e ) { throw new PluginParseException( "Unable to load the condition class: " + className ); } }
@Override public void enabled() { super.enabled(); try { this.manifestProducerClass = plugin.loadClass(manifestProducerClassName, getModuleClass()); } catch (ClassNotFoundException cnfe) { throw new IllegalStateException("Unable to load this application type's " + ManifestProducer.class.getSimpleName() + " class.", cnfe); } }
public Condition loadCondition(final String className, final Plugin plugin) throws ConditionLoadingException { try { final Class<Condition> conditionClass = plugin.loadClass(className, getClass()); return PluginInjector.newInstance(conditionClass, plugin); } catch (Exception e) { throw new ConditionLoadingException("Could not load '" + className + "' in plugin " + plugin, e); } }
@Override public void enabled() { super.enabled(); try { this.manifestProducerClass = plugin.loadClass(manifestProducerClassName, getModuleClass()); } catch (ClassNotFoundException cnfe) { throw new IllegalStateException("Unable to load this application type's " + ManifestProducer.class.getSimpleName() + " class.", cnfe); } }
@Override public void enabled() { // Note that components loaded as plugins2 will use the com.atlassian.plugin.osgi.factory.descriptor.ComponentModuleDescriptor if (interfaceClazzName != null) { // Load the interfaceClazz now that the OSGi bundle will be available. try { interfaceClazz = plugin.loadClass(interfaceClazzName, getClass()); } catch (final Exception e) { throw new PluginException("Unable to load interface class: " + interfaceClazzName, e); } } super.enabled(); }
private <T> T autowire(final String className, final Plugin plugin) { try { Class<T> conditionClass = plugin.loadClass(className, getClass()); if (plugin instanceof ContainerManagedPlugin) { return ((ContainerManagedPlugin) plugin).getContainerAccessor().createBean(conditionClass); } else { return hostContainer.create(conditionClass); } } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } }
private <T> T getObjectFromClassName(final String className, final Class<T> castClass) { if (!(plugin instanceof ContainerManagedPlugin)) { throw new IllegalStateException("Plugin object has to implement a ContainerManagedPlugin interface."); } try { final Class<Object> clazz = plugin.loadClass(className, getClass()); final Object bean = ((ContainerManagedPlugin) plugin).getContainerAccessor().createBean(clazz); return castClass.cast(bean); } catch (ClassNotFoundException e) { throw new PluginParseException("Error finding object descriptor class:" + className, e); } }
/** * Checks if the given class exists. * * @param className a class name * @return className if it exists. Null otherwise. */ private String checkClassExists(String className) { if (isBlank(className)) { return null; } try { // Here we just check whether the class exists; in the ProjectTemplateModule we'll check whether it is an instance of AddProjectHook. // We can't do it the other way around because we would be creating a class of a non-initialized project-create-hook module descriptor. getPlugin().loadClass(className, this.getClass()); return className; } catch (ClassNotFoundException e) { throw new PluginException("Class '" + className + "' not found.", e); } }
public void enabled() { if (log.isDebugEnabled()) { log.debug(String.format("Plugin '%s' is attempting to register workflow module '%s'.", getKey(), implementationClassName)); } try { implementationClass = getPlugin().loadClass(implementationClassName, getClass()); } catch (final ClassNotFoundException ex) { throw new PluginException("Cannot load condition class '" + implementationClassName + "'. " + ex.getMessage()); } // Load the implementation class now that the OSGi bundle will be available super.enabled(); registerWorkflowTypeResolver(); }
public static <T> T create(Plugin plugin, Class<?> callingClass, HostContainer hostContainer, String className) throws ClassNotFoundException { Class<T> clazz = plugin.loadClass(className, callingClass); if (plugin instanceof ContainerManagedPlugin) { return ((ContainerManagedPlugin) plugin).getContainerAccessor().createBean(clazz); } else { return hostContainer.create(clazz); } } }
public Condition loadCondition(String className, Plugin plugin) throws ConditionLoadingException { try { if (plugin instanceof ContainerManagedPlugin) { Class conditionClass = plugin.loadClass(className, getClass()); return (Condition) ((ContainerManagedPlugin) plugin).getContainerAccessor().createBean(conditionClass); } else { throw new ConditionLoadingException("Plugin " + plugin.getKey() + " is not a ContainerManagedPlugin, could not load condition."); } } catch (IllegalArgumentException e) { throw new ConditionLoadingException(e); } catch (ClassNotFoundException e) { throw new ConditionLoadingException(e); } }
<T> Class<T> getModuleClass(final String name, final ModuleDescriptor moduleDescriptor) throws ModuleClassNotFoundException { try { return moduleDescriptor.getPlugin().loadClass(name, null); } catch (ClassNotFoundException e) { throw new ModuleClassNotFoundException(name, moduleDescriptor.getPluginKey(), moduleDescriptor.getKey(), e, createErrorMsg(name)); } }
public ContextProvider loadContextProvider(String className, Plugin plugin) throws ConditionLoadingException { try { if (plugin instanceof ContainerManagedPlugin) { Class conditionClass = plugin.loadClass(className, getClass()); return (ContextProvider) ((ContainerManagedPlugin) plugin).getContainerAccessor().createBean(conditionClass); } else { throw new ConditionLoadingException("Plugin " + plugin.getKey() + " is not a ContainerManagedPlugin, could not load context."); } } catch (IllegalArgumentException e) { throw new ConditionLoadingException(e); } catch (ClassNotFoundException e) { throw new ConditionLoadingException(e); } }