use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ContainerExtensionTest method extensionTest.
@Test
public void extensionTest() {
Config config = habitat.<Domain>getService(Domain.class).getConfigs().getConfig().get(0);
RandomExtension extension = config.getExtensionByType(RandomExtension.class);
assertNotNull(extension);
assertEquals("foo", extension.getSomeAttribute());
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class ClientGenerator method generateClasses.
public void generateClasses() {
Domain entity = getBaseServiceLocator().getService(Domain.class);
Dom dom = Dom.unwrap(entity);
document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
alreadyGenerated.clear();
generateSingle(rootModel);
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class StatusGenerator method getHtml.
@GET
@Produces({ MediaType.TEXT_HTML })
public String getHtml() {
try {
Domain entity = serviceLocator.getService(Domain.class);
Dom dom = Dom.unwrap(entity);
DomDocument document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
ResourcesGenerator resourcesGenerator = new NOOPResourcesGenerator(serviceLocator);
resourcesGenerator.generateSingle(rootModel, document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
status.append("<h4>All Commands used in REST Admin</h4>\n<ul>\n");
for (String ss : commandsUsed) {
status.append("<li>").append(ss).append("</li>\n");
}
listOfCommands();
for (String ss : commandsUsed) {
allCommands.remove(ss);
}
status.append(HORIZONTAL_RULE).append("<h4>Missing Commands not used in REST Admin</h4>\n<ul>\n");
for (String ss : allCommands) {
if (hasTargetParam(ss)) {
status.append("<li>").append(ss).append(" has a target param.</li>\n");
} else {
status.append("<li>").append(ss).append("</li>\n");
}
}
status.append(HORIZONTAL_RULE).append("<h4>REST-REDIRECT Commands defined on ConfigBeans</h4>\n<ul>\n");
for (String ss : restRedirectCommands) {
status.append("<li>").append(ss).append("</li>\n");
}
status.append(HORIZONTAL_RULE).append("<h4>Commands to Resources Mapping Usage in REST Admin</h4>\n").append("<table border=\"1\" style=\"border-collapse: collapse\">\n").append("<tr><th>Command</th><th>Target</th><th>Resource</th></tr>\n");
for (Entry<String, String> entry : commandsToResources.entrySet()) {
status.append("<tr><td>").append(entry.getKey()).append(TABLE_CELL_DIVIDER).append(hasTargetParam(entry.getKey()) ? "target" : "").append(TABLE_CELL_DIVIDER).append(entry.getValue()).append("</td></tr>\n");
}
status.append("</table>\n<hr/>\n").append("<h4>Resources with Delete Commands in REST Admin (not counting RESTREDIRECT)</h4>\n").append("<table border=\"1\" style=\"border-collapse: collapse\">\n").append("<tr><th>Resource</th><th>Delete Command</th></tr>\n");
for (Entry<String, String> entry : resourcesToDeleteCommands.entrySet()) {
status.append("<tr><td>").append(entry.getKey()).append(TABLE_CELL_DIVIDER).append(entry.getValue()).append("</td></tr>\n");
}
status.append("</table>");
try (FileOutputStream f = new FileOutputStream(System.getProperty("user.home") + "/GlassFishI18NData.properties")) {
propsI18N.store(f, "");
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
return status.toString();
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class GlassFishDomainResource method setBaseServiceLocator.
// called when jersey is injecting the habitat...
@Context
public void setBaseServiceLocator(LocatorBridge hab) {
Dom dom1 = Dom.unwrap(hab.getRemoteLocator().<Domain>getService(Domain.class));
childModel = dom1.document.getRoot().model;
entity = dom1.document.getRoot();
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class VerifyDomainXmlCommand method executeCommand.
/**
*/
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
File domainXMLFile = getDomainXml();
logger.log(Level.FINER, "Domain XML file = {0}", domainXMLFile);
try {
// get the list of JAR files from the modules directory
ArrayList<URL> urls = new ArrayList<URL>();
File idir = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY));
File mdir = new File(idir, "modules");
for (File f : mdir.listFiles()) {
if (f.toString().endsWith(".jar")) {
urls.add(f.toURI().toURL());
}
}
final URL[] urlsA = urls.toArray(new URL[urls.size()]);
ClassLoader cl = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
@Override
public Object run() {
return new URLClassLoader(urlsA, Globals.class.getClassLoader());
}
});
ModulesRegistry registry = new StaticModulesRegistry(cl);
ServiceLocator serviceLocator = registry.createServiceLocator("default");
ConfigParser parser = new ConfigParser(serviceLocator);
URL domainURL = domainXMLFile.toURI().toURL();
DomDocument doc = parser.parse(domainURL);
Dom domDomain = doc.getRoot();
Domain domain = domDomain.createProxy(Domain.class);
DomainXmlVerifier validator = new DomainXmlVerifier(domain);
if (validator.invokeConfigValidator())
return 1;
} catch (Exception e) {
throw new CommandException(e);
}
return 0;
}
Aggregations