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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations