use of org.glassfish.api.admingui.ConsoleProvider in project Payara by payara.
the class ConsolePluginService method init.
/**
* <p> Initialize the available {@link IntegrationPoint}s.</p>
*/
protected synchronized void init() {
if (initialized) {
return;
}
initialized = true;
// First find the parser
if ((providers != null) && (providers.iterator().hasNext())) {
// Get our parser...
ConfigParser parser = new ConfigParser(habitat);
URL url = null;
String id = null;
// Loop through the configs and add them all
for (ConsoleProvider provider : providers) {
// Read the contents from the URL
url = provider.getConfiguration();
if (url == null) {
url = provider.getClass().getClassLoader().getResource(ConsoleProvider.DEFAULT_CONFIG_FILENAME);
}
if (url == null) {
if (logger.isLoggable(Level.INFO)) {
logger.info("Unable to find " + ConsoleProvider.DEFAULT_CONFIG_FILENAME + " file for provider '" + provider.getClass().getName() + "'");
}
continue;
}
// System.out.println("Provider *"+provider+"* : url=*"+url+"*");
DomDocument doc = parser.parse(url);
// Get the New IntegrationPoints
ConsoleConfig config = (ConsoleConfig) doc.getRoot().get();
// Save the ClassLoader for later
// System.out.println("Storing: " + config.getId() + " : " + provider.getClass().getClassLoader());
id = config.getId();
moduleClassLoaderMap.put(id, provider.getClass().getClassLoader());
classLoaderModuleMap.put(provider.getClass().getClassLoader(), id);
// Add the new IntegrationPoints
addIntegrationPoints(config.getIntegrationPoints(), id);
}
}
// Log some trace messages
if (logger.isLoggable(Level.FINE)) {
logger.fine("Console Plugin Service has been Initialized!");
if (logger.isLoggable(Level.FINEST)) {
logger.finest(pointsByType.toString());
}
}
}
use of org.glassfish.api.admingui.ConsoleProvider in project Payara by payara.
the class ConsolePluginService method getResources.
/**
* <p> This method searches the classpath of all plugins for the requested
* resource and returns all instances of it (if any). This method
* will NOT return <code>null</code>, but may return an empty
* <code>List</code>.</p>
*/
public Map<String, List<URL>> getResources(String name) {
Map<String, List<URL>> result = new HashMap<String, List<URL>>();
if ((providers != null) && (providers.iterator().hasNext())) {
// Get our parser...
Enumeration<URL> urls = null;
URL url = null;
// Loop through the configs and add them all
for (ConsoleProvider provider : providers) {
// Read the contents from the URL
ClassLoader loader = provider.getClass().getClassLoader();
try {
urls = loader.getResources(name);
} catch (IOException ex) {
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, "Error getting resource '" + name + "' from provider: '" + provider.getClass().getName() + "'. Skipping...", ex);
}
continue;
}
List<URL> providerURLs = new ArrayList<URL>();
while (urls.hasMoreElements()) {
// Found one... add it.
url = urls.nextElement();
try {
providerURLs.add(new URL(url, ""));
} catch (Exception ex) {
// Ignore b/c this should not ever happen, we're not
// changing the URL
System.out.println("ConsolePluginService: URL Copy Failed!");
}
}
// Put the URLs into the Map by module id...
if (providerURLs.size() > 0) {
result.put(classLoaderModuleMap.get(loader), providerURLs);
}
}
}
return result;
}
Aggregations