Search in sources :

Example 11 with Dom

use of org.jvnet.hk2.config.Dom in project Payara by payara.

the class GeneratorResource method get.

@GET
@Produces({ "text/plain" })
public String get(@QueryParam("outputDir") String outputDir) {
    if (outputDir == null) {
        outputDir = DEFAULT_OUTPUT_DIR;
    }
    String retVal = "Code Generation done at : " + outputDir;
    try {
        LocatorBridge locatorBridge = habitat.getService(LocatorBridge.class);
        Dom dom = Dom.unwrap(locatorBridge.getRemoteLocator().<Domain>getService(Domain.class));
        DomDocument document = dom.document;
        ConfigModel rootModel = dom.document.getRoot().model;
        ResourcesGenerator resourcesGenerator = new TextResourcesGenerator(outputDir, habitat);
        resourcesGenerator.generateSingle(rootModel, document);
        resourcesGenerator.endGeneration();
    } catch (Exception ex) {
        RestLogging.restLogger.log(Level.SEVERE, null, ex);
        retVal = "Exception encountered during generation process: " + ex.toString() + "\nPlease look at server.log for more information.";
    }
    return retVal;
}
Also used : Dom(org.jvnet.hk2.config.Dom) ConfigModel(org.jvnet.hk2.config.ConfigModel) ResourcesGenerator(org.glassfish.admin.rest.generator.ResourcesGenerator) TextResourcesGenerator(org.glassfish.admin.rest.generator.TextResourcesGenerator) TextResourcesGenerator(org.glassfish.admin.rest.generator.TextResourcesGenerator) LocatorBridge(org.glassfish.admin.rest.adapter.LocatorBridge) Domain(com.sun.enterprise.config.serverbeans.Domain) DomDocument(org.jvnet.hk2.config.DomDocument) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 12 with Dom

use of org.jvnet.hk2.config.Dom in project Payara by payara.

the class PropertiesBagResource method get.

@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Object get() {
    List<Dom> entities = getEntity();
    if (entities == null) {
        // empty dom list
        return new GetResultList(new ArrayList(), "", new String[][] {}, new OptionsResult(Util.getResourceName(uriInfo)));
    }
    RestActionReporter ar = new RestActionReporter();
    ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ar.setActionDescription("property");
    List properties = new ArrayList();
    for (Dom child : entities) {
        Map<String, String> entry = new HashMap<String, String>();
        entry.put("name", child.attribute("name"));
        entry.put("value", child.attribute("value"));
        String description = child.attribute("description");
        if (description != null) {
            entry.put("description", description);
        }
        properties.add(entry);
    }
    Properties extraProperties = new Properties();
    extraProperties.put("properties", properties);
    ar.setExtraProperties(extraProperties);
    return new ActionReportResult("properties", ar, new OptionsResult(Util.getResourceName(uriInfo)));
}
Also used : Dom(org.jvnet.hk2.config.Dom) ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) GetResultList(org.glassfish.admin.rest.results.GetResultList) GetResultList(org.glassfish.admin.rest.results.GetResultList) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with Dom

use of org.jvnet.hk2.config.Dom in project Payara by payara.

the class StatusGenerator method getPlain.

@GET
@Produces({ "text/plain" })
public String getPlain() {
    // status.append("Status of Command usage\n");
    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);
    // retVal = "Exception encountered during generation process: " + ex.toString() + "\nPlease look at server.log for more information.";
    }
    status.append("\n------------------------");
    status.append("All Commands used in REST Admin:\n");
    for (String ss : commandsUsed) {
        status.append(ss + "\n");
    }
    listOfCommands();
    for (String ss : commandsUsed) {
        allCommands.remove(ss);
    }
    status.append("\n------------------------");
    status.append("Missing Commands not used in REST Admin:\n");
    for (String ss : allCommands) {
        if (hasTargetParam(ss)) {
            status.append(ss + "          has a target param " + "\n");
        } else {
            status.append(ss + "\n");
        }
    }
    status.append("\n------------------------");
    status.append("REST-REDIRECT Commands defined on ConfigBeans:\n");
    for (String ss : restRedirectCommands) {
        status.append(ss + "\n");
    }
    status.append("\n------------------------");
    status.append("Commands to Resources Mapping Usage in REST Admin:\n");
    for (String ss : commandsToResources.keySet()) {
        if (hasTargetParam(ss)) {
            status.append(ss + "   :::target:::   " + commandsToResources.get(ss) + "\n");
        } else {
            status.append(ss + "      :::      " + commandsToResources.get(ss) + "\n");
        }
    }
    status.append("\n------------------------");
    status.append("Resources with Delete Commands in REST Admin (not counting RESTREDIRECT:\n");
    for (String ss : resourcesToDeleteCommands.keySet()) {
        status.append(ss + "      :::      " + resourcesToDeleteCommands.get(ss) + "\n");
    }
    FileOutputStream f = null;
    try {
        f = new FileOutputStream(System.getProperty("user.home") + "/GlassFishI18NData.properties");
        propsI18N.store(f, "");
    } catch (Exception ex) {
        RestLogging.restLogger.log(Level.SEVERE, null, ex);
    } finally {
        if (f != null) {
            try {
                f.close();
            } catch (IOException 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) IOException(java.io.IOException) Domain(com.sun.enterprise.config.serverbeans.Domain) IOException(java.io.IOException) MultiException(org.glassfish.hk2.api.MultiException) DomDocument(org.jvnet.hk2.config.DomDocument) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 14 with Dom

use of org.jvnet.hk2.config.Dom in project Payara by payara.

the class TemplateListOfResource method getElementTypeByName.

public static Class<? extends ConfigBeanProxy> getElementTypeByName(Dom parentDom, String elementName) throws ClassNotFoundException {
    DomDocument document = parentDom.document;
    ConfigModel.Property a = parentDom.model.getElement(elementName);
    if (a != null) {
        if (a.isLeaf()) {
            // : I am not too sure, but that should be a String @Element
            return null;
        } else {
            ConfigModel childModel = ((ConfigModel.Node) a).getModel();
            return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName);
        }
    }
    // global lookup
    ConfigModel model = document.getModelByElementName(elementName);
    if (model != null) {
        return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName);
    }
    return null;
}
Also used : ConfigModel(org.jvnet.hk2.config.ConfigModel) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 15 with Dom

use of org.jvnet.hk2.config.Dom in project Payara by payara.

the class DomainXmlVerifier method checkUnique.

private void checkUnique(Dom d) {
    try {
        Set<String> eltnames = d.getElementNames();
        Set<String> leafeltnames = d.model.getLeafElementNames();
        for (String elt : eltnames) {
            if (leafeltnames.contains(elt))
                continue;
            List<Dom> eltlist;
            synchronized (d) {
                eltlist = d.nodeElements(elt);
            }
            checkDuplicate(eltlist);
            for (Dom subelt : eltlist) {
                checkUnique(subelt);
            }
        }
    } catch (Exception e) {
        error = true;
        e.printStackTrace();
    }
}
Also used : Dom(org.jvnet.hk2.config.Dom)

Aggregations

Dom (org.jvnet.hk2.config.Dom)37 ConfigModel (org.jvnet.hk2.config.ConfigModel)14 Domain (com.sun.enterprise.config.serverbeans.Domain)12 DomDocument (org.jvnet.hk2.config.DomDocument)9 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)9 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)8 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)8 PropertyVetoException (java.beans.PropertyVetoException)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 GET (javax.ws.rs.GET)5 Produces (javax.ws.rs.Produces)5 MultiException (org.glassfish.hk2.api.MultiException)5 Config (com.sun.enterprise.config.serverbeans.Config)4 TreeMap (java.util.TreeMap)4 ConfigParser (org.jvnet.hk2.config.ConfigParser)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ResourcesGenerator (org.glassfish.admin.rest.generator.ResourcesGenerator)3 ExampleServiceConfiguration (fish.payara.service.example.config.ExampleServiceConfiguration)2