Search in sources :

Example 1 with LocatorBridge

use of org.glassfish.admin.rest.adapter.LocatorBridge 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)

Aggregations

Domain (com.sun.enterprise.config.serverbeans.Domain)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 LocatorBridge (org.glassfish.admin.rest.adapter.LocatorBridge)1 ResourcesGenerator (org.glassfish.admin.rest.generator.ResourcesGenerator)1 TextResourcesGenerator (org.glassfish.admin.rest.generator.TextResourcesGenerator)1 ConfigModel (org.jvnet.hk2.config.ConfigModel)1 Dom (org.jvnet.hk2.config.Dom)1 DomDocument (org.jvnet.hk2.config.DomDocument)1