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