use of org.jvnet.hk2.config.Dom in project Payara by payara.
the class MonitoredAttributeBagResource method getMonitoredAttributes.
/**
* Gets all of the monitored attributes in the entity.
*
* @return a list of the monitored attributes
*/
public List<Map<String, String>> getMonitoredAttributes() {
List<Map<String, String>> attributes = new ArrayList<>();
for (Dom child : entity) {
Map<String, String> entry = new HashMap<>();
entry.put("attributeName", child.attribute("attribute-name"));
entry.put("objectName", child.attribute("object-name"));
String description = child.attribute("description");
if (description != null) {
entry.put("description", description);
}
attributes.add(entry);
}
return attributes;
}
use of org.jvnet.hk2.config.Dom in project Payara by payara.
the class RestManagementResourceProvider method generateASM.
private void generateASM(ServiceLocator habitat) {
try {
Domain entity = habitat.getService(Domain.class);
Dom dom = Dom.unwrap(entity);
ResourcesGenerator resourcesGenerator = new ASMResourcesGenerator(habitat);
resourcesGenerator.generateSingle(dom.document.getRoot().model, dom.document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
}
use of org.jvnet.hk2.config.Dom in project Payara by payara.
the class SystemPropertiesCliResource method getConfig.
protected Dom getConfig(Dom domain, String configName) {
Dom rootConfig;
List<Dom> configs;
synchronized (domain) {
rootConfig = domain.nodeElements("configs").get(0);
}
synchronized (rootConfig) {
configs = rootConfig.nodeElements("config");
}
for (Dom config : configs) {
if (config.attribute("name").equals(configName)) {
return config;
}
}
return null;
}
use of org.jvnet.hk2.config.Dom in project Payara by payara.
the class ResourceUtil method getResourceLinks.
public static Map<String, String> getResourceLinks(List<Dom> proxyList, UriInfo uriInfo) {
Map<String, String> links = new TreeMap<String, String>();
Collections.sort(proxyList, new DomConfigurator());
for (Dom proxy : proxyList) {
// for each element
try {
links.put(getKey(proxy), getElementLink(uriInfo, getKey(proxy)));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return links;
}
use of org.jvnet.hk2.config.Dom in project Payara by payara.
the class ResourceUtil method getMethodMetaData2.
public static MethodMetaData getMethodMetaData2(Dom parent, ConfigModel childModel, int parameterType) {
MethodMetaData methodMetaData = new MethodMetaData();
List<Class<?>> interfaces = new ArrayList<Class<?>>();
Map<String, ParameterMetaData> params = new HashMap<String, ParameterMetaData>();
try {
Class<? extends ConfigBeanProxy> configBeanProxy = (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName);
getInterfaces(configBeanProxy, interfaces);
Set<String> attributeNames = childModel.getAttributeNames();
for (String attributeName : attributeNames) {
String methodName = ResourceUtil.getAttributeMethodName(attributeName);
// camelCase the attributeName before passing out
attributeName = Util.eleminateHypen(attributeName);
ParameterMetaData parameterMetaData = params.get(attributeName);
if (parameterMetaData == null) {
parameterMetaData = new ParameterMetaData();
params.put(attributeName, parameterMetaData);
}
// Check parent interfaces
for (int i = interfaces.size() - 1; i >= 0; i--) {
Class<?> intf = interfaces.get(i);
try {
Method method = intf.getMethod(methodName);
Attribute attribute = method.getAnnotation(Attribute.class);
if (attribute != null) {
ParameterMetaData localParam = ResourceUtil.getParameterMetaData(attribute);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.DEFAULT_VALUE);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.KEY);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.TYPE);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.OPTIONAL);
}
} catch (NoSuchMethodException e) {
}
}
// Check ConfigBean
try {
Method method = configBeanProxy.getMethod(methodName);
Attribute attribute = method.getAnnotation(Attribute.class);
if (attribute != null) {
ParameterMetaData localParam = ResourceUtil.getParameterMetaData(attribute);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.DEFAULT_VALUE);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.KEY);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.TYPE);
copyParameterMetaDataAttribute(localParam, parameterMetaData, Constants.OPTIONAL);
}
} catch (NoSuchMethodException e) {
}
methodMetaData.putParameterMetaData(attributeName, parameterMetaData);
}
} catch (MultiException cnfe) {
throw new RuntimeException(cnfe);
}
return methodMetaData;
}
Aggregations