use of com.sun.enterprise.module.HK2Module 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 HK2Module[] 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<HK2Module> tmp = new ArrayList<HK2Module>();
for (String moduleName : getContainerModuleNames()) {
HK2Module 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 HK2Module[tmp.size()]);
return modules;
}
use of com.sun.enterprise.module.HK2Module 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"));
HK2Module 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.HK2Module 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;
HK2Module 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.HK2Module 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;
HK2Module 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.HK2Module 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() {
@Override
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.log(Level.FINE, "Found the provider xml - {0}", 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.log(Level.FINE, " The provider xml belongs to - \"{0}\"", moduleName);
if (!map.containsKey(moduleName)) {
continue;
}
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine(" Module found (containsKey)");
HK2Module 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.log(Level.FINE, "ModuleClassLoader = {0}", mcl);
LOGGER.log(Level.FINE, "XML File path = {0}", file.getAbsolutePath());
}
processProbeProviderXML(mcl, file.getAbsolutePath(), false);
}
}
}
}
Aggregations