Search in sources :

Example 16 with DomDocument

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

the class ConfigTest method parseDomainXml.

// @Test
public void parseDomainXml() {
    ConfigParser parser = new ConfigParser(habitat);
    URL url = this.getClass().getResource("/domain.xml");
    System.out.println("URL : " + url);
    try {
        DomDocument doc = parser.parse(url);
        System.out.println("[parseDomainXml] ==> Successfully parsed");
        assert (doc != null);
    } catch (Exception ex) {
        ex.printStackTrace();
        assert (false);
    }
}
Also used : ConfigParser(org.jvnet.hk2.config.ConfigParser) URL(java.net.URL) PropertyVetoException(java.beans.PropertyVetoException) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 17 with DomDocument

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

the class ConfigApiTest method getDocument.

@Override
public DomDocument getDocument(ServiceLocator habitat) {
    DomDocument doc = habitat.getService(GlassFishDocument.class);
    if (doc == null) {
        return new GlassFishDocument(habitat, Executors.newCachedThreadPool(new ThreadFactory() {

            public Thread newThread(Runnable r) {
                Thread t = Executors.defaultThreadFactory().newThread(r);
                t.setDaemon(true);
                return t;
            }
        }));
    }
    return doc;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) GlassFishDocument(org.glassfish.config.support.GlassFishDocument) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 18 with DomDocument

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

the class ConfigApiTest method getDocument.

@Override
public DomDocument getDocument(ServiceLocator habitat) {
    DomDocument doc = habitat.getService(GlassFishDocument.class);
    if (doc == null) {
        return new GlassFishDocument(habitat, Executors.newCachedThreadPool(new ThreadFactory() {

            public Thread newThread(Runnable r) {
                Thread t = Executors.defaultThreadFactory().newThread(r);
                t.setDaemon(true);
                return t;
            }
        }));
    }
    return doc;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) GlassFishDocument(org.glassfish.config.support.GlassFishDocument) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 19 with DomDocument

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

the class ConfigApiTest method getDocument.

@Override
public DomDocument getDocument(ServiceLocator habitat) {
    DomDocument doc = habitat.getService(GlassFishDocument.class);
    if (doc == null) {
        return new GlassFishDocument(habitat, Executors.newCachedThreadPool(new ThreadFactory() {

            public Thread newThread(Runnable r) {
                Thread t = Executors.defaultThreadFactory().newThread(r);
                t.setDaemon(true);
                return t;
            }
        }));
    }
    return doc;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) GlassFishDocument(org.glassfish.config.support.GlassFishDocument) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 20 with DomDocument

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

the class ConsolePluginService method getHelpTOC.

/**
 *	<p> This method returns a merged Table Of Contents for all found help
 *	    sets for the given locale.</p>
 */
public synchronized TOC getHelpTOC(String locale) {
    if (locale == null) {
        // Use this as the default...
        locale = "en";
    }
    TOC mergedTOC = helpSetMap.get(locale);
    if (mergedTOC != null) {
        // Already calculated...
        return mergedTOC;
    }
    // TOC
    Map<String, List<URL>> mapUrls = getResources(locale + "/help/toc.xml");
    // Get our parser...
    ConfigParser parser = new ConfigParser(habitat);
    // Setup a new "merged" TOC...
    mergedTOC = new TOC();
    mergedTOC.setTOCItems(new ArrayList<TOCItem>());
    mergedTOC.setVersion("2.0");
    // Loop through the urls and add them all
    // module id
    String id = null;
    // prefix (minus module id)
    String prefix = "/" + locale + "/help/";
    // URLs to TOC files w/i each plugin module
    List<URL> urls = null;
    for (Map.Entry<String, List<URL>> entry : mapUrls.entrySet()) {
        id = entry.getKey();
        urls = entry.getValue();
        for (URL url : urls) {
            DomDocument doc = parser.parse(url);
            // Merge all the TOC's...
            TOC toc = (TOC) doc.getRoot().get();
            for (TOCItem item : toc.getTOCItems()) {
                insertTOCItem(mergedTOC.getTOCItems(), item, id + prefix);
            }
        }
    }
    // FIXME: Sort?
    return mergedTOC;
}
Also used : TOCItem(org.glassfish.admingui.connector.TOCItem) TOC(org.glassfish.admingui.connector.TOC) ConfigParser(org.jvnet.hk2.config.ConfigParser) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) MultiMap(org.jvnet.hk2.component.MultiMap) URL(java.net.URL) DomDocument(org.jvnet.hk2.config.DomDocument)

Aggregations

DomDocument (org.jvnet.hk2.config.DomDocument)25 ConfigModel (org.jvnet.hk2.config.ConfigModel)12 ConfigParser (org.jvnet.hk2.config.ConfigParser)12 URL (java.net.URL)8 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)7 IOException (java.io.IOException)6 ThreadFactory (java.util.concurrent.ThreadFactory)6 GlassFishDocument (org.glassfish.config.support.GlassFishDocument)6 Domain (com.sun.enterprise.config.serverbeans.Domain)5 Dom (org.jvnet.hk2.config.Dom)5 PropertyVetoException (java.beans.PropertyVetoException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)3 GET (javax.ws.rs.GET)3 Produces (javax.ws.rs.Produces)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 ResourcesGenerator (org.glassfish.admin.rest.generator.ResourcesGenerator)3 GlassFishConfigBean (org.glassfish.config.support.GlassFishConfigBean)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)3