use of com.sun.enterprise.module.Module in project Payara by payara.
the class ListContainersCommand method execute.
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
report.setActionDescription(localStrings.getLocalString("list.containers.command", "List of Containers"));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
ActionReport.MessagePart top = report.getTopMessagePart();
top.setMessage(localStrings.getLocalString("list.containers.command", "List of Containers"));
top.setChildrenType(localStrings.getLocalString("container", "Container"));
Iterable<? extends Sniffer> sniffers = habitat.getAllServices(Sniffer.class);
if (sniffers == null) {
top.setMessage(localStrings.getLocalString("list.containers.nocontainer", "No container currently configured"));
} else {
for (Sniffer sniffer : sniffers) {
ActionReport.MessagePart container = top.addChild();
container.setMessage(sniffer.getModuleType());
container.addProperty(localStrings.getLocalString("contractprovider", "ContractProvider"), sniffer.getModuleType());
EngineInfo engineInfo = containerRegistry.getContainer(sniffer.getModuleType());
if (engineInfo != null) {
container.addProperty(localStrings.getLocalString("status", "Status"), localStrings.getLocalString("started", "Started"));
Module connectorModule = modulesRegistry.find(engineInfo.getSniffer().getClass());
container.addProperty(localStrings.getLocalString("connector", "Connector"), connectorModule.getModuleDefinition().getName() + ":" + connectorModule.getModuleDefinition().getVersion());
container.addProperty(localStrings.getLocalString("implementation", "Implementation"), engineInfo.getContainer().getClass().toString());
boolean atLeastOne = false;
for (Application app : applications.getApplications()) {
for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) {
Engine engine = module.getEngine(engineInfo.getSniffer().getModuleType());
if (engine != null) {
if (!atLeastOne) {
atLeastOne = true;
container.setChildrenType(localStrings.getLocalString("list.containers.listapps", "Applications deployed"));
}
container.addChild().setMessage(app.getName());
}
}
}
if (!atLeastOne) {
container.addProperty("Status", "Not Started");
}
}
}
}
}
use of com.sun.enterprise.module.Module in project Payara by payara.
the class MonitoringBootstrap method loadXMLProviders.
private void loadXMLProviders(File xmlProvidersDir) {
// Creates a filter which will return only xml files
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".xml");
}
};
// Retrieves all the provider XML's
File[] files = xmlProvidersDir.listFiles(filter);
if (files == null)
return;
Map<String, File> providerMap = new HashMap();
for (File file : files) {
if (logger.isLoggable(Level.FINE))
logger.fine("Found the provider xml - " + file.getAbsolutePath());
int index = file.getName().indexOf("-:");
if (index != -1) {
String moduleName = file.getName().substring(0, index);
providerMap.put(moduleName, file);
if (logger.isLoggable(Level.FINE))
logger.fine(" The provider xml belongs to - \"" + moduleName + "\"");
if (!map.containsKey(moduleName)) {
continue;
}
if (logger.isLoggable(Level.FINE))
logger.fine(" Module found (containsKey)");
Module module = map.get(moduleName);
if (module == null) {
logger.log(Level.SEVERE, monitoringMissingModuleFromXmlProbeProviders, new Object[] { moduleName });
} else {
ClassLoader mcl = module.getClassLoader();
if (logger.isLoggable(Level.FINE)) {
logger.fine("ModuleClassLoader = " + mcl);
logger.fine("XML File path = " + file.getAbsolutePath());
}
processProbeProviderXML(mcl, file.getAbsolutePath(), false);
}
}
}
}
use of com.sun.enterprise.module.Module in project Payara by payara.
the class JerseyMvcTldProvider method postConstruct.
public void postConstruct() {
final Class jerseyIncludeClass = org.glassfish.jersey.server.mvc.jsp.Include.class;
URI[] uris = null;
Module m = null;
if (jerseyIncludeClass != null) {
m = registry.find(jerseyIncludeClass);
}
if (m != null) {
uris = m.getModuleDefinition().getLocations();
} else {
ClassLoader classLoader = getClass().getClassLoader();
if (classLoader instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) classLoader).getURLs();
if (urls != null && urls.length > 0) {
uris = new URI[urls.length];
for (int i = 0; i < urls.length; i++) {
try {
uris[i] = urls[i].toURI();
} catch (URISyntaxException e) {
String msg = rb.getString(LogFacade.TLD_PROVIDER_IGNORE_URL);
msg = MessageFormat.format(msg, urls[i]);
logger.log(Level.WARNING, msg, e);
}
}
}
} else {
logger.log(Level.WARNING, LogFacade.UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { JerseyMvcTldProvider.class.getSimpleName(), classLoader, JerseyMvcTldProvider.class.getName() });
}
}
if (uris != null && uris.length > 0) {
Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
for (URI uri : uris) {
List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
if (entries != null && entries.size() > 0) {
tldMap.put(uri, entries);
}
}
}
}
use of com.sun.enterprise.module.Module in project Payara by payara.
the class GlassFishTldProvider method postConstruct.
public void postConstruct() {
/*
* Check whether JSP caching has been enabled
*/
Config cfg = serverContext.getDefaultServices().getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
WebContainer webContainer = cfg.getExtensionByType(WebContainer.class);
if (webContainer == null) {
return;
}
if (!Boolean.valueOf(webContainer.getJspCachingEnabled())) {
return;
}
/*
* JSP caching has been enabled
*/
Class jspCachingImplClass = CacheTag.class;
URI[] uris = null;
Module m = null;
if (jspCachingImplClass != null) {
m = registry.find(jspCachingImplClass);
}
if (m != null) {
uris = m.getModuleDefinition().getLocations();
} else {
ClassLoader classLoader = getClass().getClassLoader();
if (classLoader instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) classLoader).getURLs();
if (urls != null && urls.length > 0) {
uris = new URI[urls.length];
for (int i = 0; i < urls.length; i++) {
try {
uris[i] = urls[i].toURI();
} catch (URISyntaxException e) {
String msg = rb.getString(LogFacade.TLD_PROVIDER_IGNORE_URL);
msg = MessageFormat.format(msg, urls[i]);
logger.log(Level.WARNING, msg, e);
}
}
}
} else {
logger.log(Level.WARNING, LogFacade.UNABLE_TO_DETERMINE_TLD_RESOURCES, new Object[] { "JSP Caching", classLoader, GlassFishTldProvider.class.getName() });
}
}
if (uris != null && uris.length > 0) {
Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
for (URI uri : uris) {
List<String> entries = JarURIPattern.getJarEntries(uri, pattern);
if (entries != null && entries.size() > 0) {
tldMap.put(uri, entries);
}
}
}
}
use of com.sun.enterprise.module.Module in project Payara by payara.
the class GenericSniffer method setup.
/**
* Sets up the container libraries so that any imported bundle from the
* connector jar file will now be known to the module subsystem
*
* This method returns a {@link ModuleDefinition} for the module containing
* the core implementation of the container. That means that this module
* will be locked as long as there is at least one module loaded in the
* associated container.
*
* @param containerHome is where the container implementation resides (Not used anymore)
* @param logger the logger to use
* @return the module definition of the core container implementation.
*
* @throws java.io.IOException exception if something goes sour
*/
@Override
public synchronized Module[] setup(String containerHome, Logger logger) throws IOException {
// TODO(Sahoo): Change signature to not accept containerHome or logger
if (modules != null) {
if (logger.isLoggable(Level.FINE)) {
logger.logp(Level.FINE, "GenericSniffer", "setup", "{0} has already setup {1} container, so just returning.", new Object[] { this, containerName });
}
return modules;
}
List<Module> tmp = new ArrayList<Module>();
for (String moduleName : getContainerModuleNames()) {
Module m = modulesRegistry.makeModuleFor(moduleName, null);
if (m != null) {
tmp.add(m);
} else {
throw new RuntimeException("Unable to set up module " + moduleName);
}
}
modules = tmp.toArray(new Module[tmp.size()]);
return modules;
}
Aggregations