displayName = declaringModule.getName(); symbolicName = declaringModule.getSymbolicName(); copyright = declaringModule.getCopyright(); loggerName = declaringModule.getSymbolicName();
public void actionPerformed(CommandEvent event) { if (scriptManager == null) { scriptManager = new ScriptManager(module.getClassLoader(), new PrintWriter(new OutputStreamWriter(System.out), true) ); URL resource = module.getResource(src); if (resource == null) { resource = new File(src).toURI().toURL();
private static String getProductReaderModule(final Product product) { final ProductReader productReader = product.getProductReader(); if (productReader != null) { Logger logger = BeamLogManager.getSystemLogger(); ModuleReader moduleReader = new ModuleReader(logger); URL moduleLocation = productReader.getClass().getProtectionDomain().getCodeSource().getLocation(); try { Module module = moduleReader.readFromLocation(moduleLocation); return module.getSymbolicName() + " v " + module.getVersion().toString(); } catch (Exception e) { logger.warning("Could not read " + moduleLocation.toString()); return "unknown"; } } return NO_PRODUCT_READER_MESSAGE; }
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);
declaringModule.getName()); moduleContext.getLogger().severe(message); return; URL helpSetUrl = declaringModule.getClassLoader().getResource(helpSetPath); if (helpSetUrl == null) { String message = String.format("Help set resource path [%s] of module [%s] not found.", helpSetPath, declaringModule.getName()); moduleContext.getLogger().severe(message); return; DefaultHelpSetFactory factory = new VerifyingHelpSetFactory(helpSetPath, declaringModule.getName(), moduleContext.getLogger()); HelpSet helpSet = HelpSet.parse(helpSetUrl, declaringModule.getClassLoader(), factory); helpSetPath, declaringModule.getName(), ""); moduleContext.getLogger().log(Level.SEVERE, message, ""); declaringModule.getSymbolicName()); moduleContext.getLogger().warning(message); helpSetId, helpSetPath, declaringModule.getName()); moduleContext.getLogger().severe(message);
private static Module getModule(String symbolicName) { final Module[] modules = VisatActivator.getInstance().getModuleContext().getModules(); for (Module module : modules) { if (module.getSymbolicName().equals(symbolicName)) { return module; } } return null; } }
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; }
@Override public void start(ModuleContext moduleContext) throws CoreException { BeamCoreActivator.moduleContext = moduleContext; SystemUtils.init3rdPartyLibs(moduleContext.getModule().getClassLoader()); registerRGBProfiles(moduleContext); registerGeotoolsServices(); }
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); } }
private URI getLocalDataSourcesUri() throws URISyntaxException { URL url = null; Module helpModule = getModule("beam-help"); if (helpModule != null) { url = helpModule.getResource("doc/help/general/BeamDataSources.html"); } if (url != null) { return url.toURI(); } else { return null; } }
private static void registerRGBProfiles(ModuleContext moduleContext) throws CoreException { ExtensionPoint rgbExtensionPoint = moduleContext.getModule().getExtensionPoint("rgbProfiles"); Extension[] rgbExtensions = rgbExtensionPoint.getExtensions(); RGBImageProfileManager profileManager = RGBImageProfileManager.getInstance(); for (Extension extension : rgbExtensions) { ConfigurationElement confElem = extension.getConfigurationElement(); ConfigurationElement[] rgbElements = confElem.getChildren("rgbProfile"); for (ConfigurationElement rgbElement : rgbElements) { RGBImageProfile rgbImageProfile = new RGBImageProfile(); rgbImageProfile.configure(rgbElement); profileManager.addProfile(rgbImageProfile); } } }
@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); } }
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); }
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);
@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); }
logger.warning("Could not read module information"); } else { ProductData nameValue = ProductData.createInstance(module.getSymbolicName()); targetNodeME.addAttribute(new MetadataAttribute("moduleName", nameValue, false)); ProductData versionValue = ProductData.createInstance(module.getVersion().toString()); targetNodeME.addAttribute(new MetadataAttribute("moduleVersion", versionValue, false));
super.configure(config); moduleName = config.getDeclaringExtension().getDeclaringModule().getName();