Search in sources :

Example 56 with Domain

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());
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) Domain(com.sun.enterprise.config.serverbeans.Domain) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 57 with Domain

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);
}
Also used : Dom(org.jvnet.hk2.config.Dom) ConfigModel(org.jvnet.hk2.config.ConfigModel) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 58 with Domain

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();
}
Also used : Dom(org.jvnet.hk2.config.Dom) ConfigModel(org.jvnet.hk2.config.ConfigModel) FileOutputStream(java.io.FileOutputStream) ResourcesGenerator(org.glassfish.admin.rest.generator.ResourcesGenerator) Domain(com.sun.enterprise.config.serverbeans.Domain) MultiException(org.glassfish.hk2.api.MultiException) DomDocument(org.jvnet.hk2.config.DomDocument) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 59 with Domain

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();
}
Also used : Dom(org.jvnet.hk2.config.Dom) Domain(com.sun.enterprise.config.serverbeans.Domain) Context(javax.ws.rs.core.Context)

Example 60 with Domain

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;
}
Also used : Dom(org.jvnet.hk2.config.Dom) ArrayList(java.util.ArrayList) ConfigParser(org.jvnet.hk2.config.ConfigParser) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) URL(java.net.URL) DomDocument(org.jvnet.hk2.config.DomDocument) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) PrivilegedAction(java.security.PrivilegedAction) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) Domain(com.sun.enterprise.config.serverbeans.Domain) File(java.io.File)

Aggregations

Domain (com.sun.enterprise.config.serverbeans.Domain)70 Test (org.junit.Test)21 Server (com.sun.enterprise.config.serverbeans.Server)15 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)12 Dom (org.jvnet.hk2.config.Dom)11 PropertyVetoException (java.beans.PropertyVetoException)10 Cluster (com.sun.enterprise.config.serverbeans.Cluster)7 Resources (com.sun.enterprise.config.serverbeans.Resources)7 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)7 ServerContext (org.glassfish.internal.api.ServerContext)7 Config (com.sun.enterprise.config.serverbeans.Config)6 Resource (com.sun.enterprise.config.serverbeans.Resource)6 ParameterMap (org.glassfish.api.admin.ParameterMap)6 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)6 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Before (org.junit.Before)5 ConfigModel (org.jvnet.hk2.config.ConfigModel)5 PropsFileActionReporter (com.sun.enterprise.admin.report.PropsFileActionReporter)4