private <T> T loadObjectInstance(ConfigurationElement config, Class<? extends T> baseClass, String implClassName) throws CoreException { Class<?> derivedClass; try { derivedClass = config.getDeclaringExtension().getDeclaringModule().loadClass(implClassName); } catch (ClassNotFoundException e) { String msg = MessageFormat.format("[{0}]: Not able to load class [{1}]", config.getDeclaringExtension().getDeclaringModule().getName(), implClassName); throw new CoreException(msg, e); } else { String msg = MessageFormat.format("[{0}]: Specified class [{1}] must be derived from [{2}]", config.getDeclaringExtension().getDeclaringModule().getName(), implClassName, baseClass.getName()); } catch (Exception e) { String msg = MessageFormat.format("[{0}]: Not able to create new instance of class [{1}]", config.getDeclaringExtension().getDeclaringModule().getName(), interactorClass.getName()); throw new CoreException(msg, e);
Class<?> aClass; try { aClass = config.getDeclaringExtension().getDeclaringModule().loadClass(writerPluginClassName); } catch (ClassNotFoundException e) { String msg = MessageFormat.format("[{0}]: Not able to load class [{1}]", config.getDeclaringExtension().getDeclaringModule().getName(), writerPluginClassName); throw new CoreException(msg, e); } else { String msg = MessageFormat.format("[{0}]: Specified class [{1}] must be derived from [{2}]", config.getDeclaringExtension().getDeclaringModule().getName(), writerPluginClassName, ProductWriterPlugIn.class.getName()); } catch (Exception e) { String msg = MessageFormat.format("[{0}]: Specified class [{1}] could not be instantiated", config.getDeclaringExtension().getDeclaringModule().getName(), writerPluginClass.getName()); throw new CoreException(msg);
Module declaringModule = config.getDeclaringExtension().getDeclaringModule(); if (displayName == null) { displayName = declaringModule.getName();
@Override public void configure(ConfigurationElement config) throws CoreException { super.configure(config); module = config.getDeclaringExtension().getDeclaringModule(); ConfigurationElement script = config.getChild("script"); if (script != null) { String scriptType = script.getAttribute("type"); if (StringUtils.isNotNullAndNotEmpty(scriptType)) { type = scriptType; } String scriptSrc = script.getAttribute("src"); if (StringUtils.isNotNullAndNotEmpty(scriptSrc)) { src = scriptSrc; } String scriptCode = script.getValue(); if (StringUtils.isNotNullAndNotEmpty(scriptCode)) { code = scriptCode; } System.out.printf("ScriptAction [%s] of module [%s]:%n", getText(), module.getSymbolicName()); System.out.printf(" type = [%s]%n", this.type); System.out.printf(" src = [%s]%n", this.src); System.out.printf(" code = [%s]%n", this.code); } }
public static <T> List<T> loadExecutableExtensions(ModuleContext moduleContext, String extensionPointId, String elementName, Class<T> extensionType) { Module module = moduleContext.getModule(); ExtensionPoint extensionPoint = module.getExtensionPoint(extensionPointId); ConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements(); List<T> executableExtensions = new ArrayList<>(32); for (ConfigurationElement configurationElement : configurationElements) { ConfigurationElement[] children = configurationElement.getChildren(elementName); for (ConfigurationElement child : children) { try { ModuleState moduleState = child.getDeclaringExtension().getDeclaringModule().getState(); if (moduleState.isOneOf(ModuleState.STARTING, ModuleState.RESOLVED)) { T executableExtension = child.createExecutableExtension(extensionType); executableExtensions.add(executableExtension); } } catch (CoreException e) { moduleContext.getLogger().log(Level.SEVERE, e.getMessage(), e); } } } return executableExtensions; }
private void configureInteractor(ConfigurationElement config) throws CoreException { String interactorClassName = getConfigString(config, INTERACTOR_ELEMENT_NAME); if (interactorClassName != null) { Interactor interactor = loadObjectInstance(config, Interactor.class, interactorClassName); interactor.addListener(activationHandler); String interactorListenerClassName = getConfigString(config, INTERACTOR_LISTENER_ELEMENT_NAME); if (interactorListenerClassName != null) { InteractorListener interactorListener = loadObjectInstance(config, InteractorListener.class, interactorListenerClassName); interactor.addListener(interactorListener); } setInteractor(interactor); } else { String msg = MessageFormat.format("[{0}]: Missing element [{1}] whose value must be an instance of [{2}]", config.getDeclaringExtension().getDeclaringModule().getName(), INTERACTOR_ELEMENT_NAME, Interactor.class.getName()); throw new CoreException(msg); } }
@Override public void configure(ConfigurationElement config) throws CoreException { super.configure(config); ConfigurationElement itemsElement = config.getChild(ELEMENT_NAME_ITEMS); if (itemsElement == null) { return; } ConfigurationElement[] children = itemsElement.getChildren(); String[] groupItems = new String[children.length]; for (int i = 0; i < children.length; i++) { ConfigurationElement child = children[i]; String childName = child.getName(); switch (childName) { case ELEMENT_NAME_ACTION_ID: case ELEMENT_NAME_ACTION_GROUP_ID: groupItems[i] = child.getValue().trim(); break; case ELEMENT_NAME_SEPARATOR: groupItems[i] = null; break; default: Module declaringModule = config.getDeclaringExtension().getDeclaringModule(); throw new CoreException(String.format("Module [%s]: '%s' is an unknown 'groupItems' element", declaringModule.getName(), childName)); } } setProperty(ACTION_KEY_GROUP_ITEMS, groupItems); }
private void registerHelpSets(ModuleContext moduleContext) { this.helpSetRegistry = new TreeNode<>(""); ExtensionPoint hsExtensionPoint = moduleContext.getModule().getExtensionPoint("helpSets"); Extension[] hsExtensions = hsExtensionPoint.getExtensions(); for (Extension extension : hsExtensions) { ConfigurationElement confElem = extension.getConfigurationElement(); ConfigurationElement[] helpSetElements = confElem.getChildren("helpSet"); for (ConfigurationElement helpSetElement : helpSetElements) { final Module declaringModule = extension.getDeclaringModule(); if (declaringModule.getState().is(ModuleState.RESOLVED)) { registerHelpSet(helpSetElement, declaringModule); } } } addNodeToHelpSys(helpSetRegistry); }
super.configure(config); moduleName = config.getDeclaringExtension().getDeclaringModule().getName();