Search in sources :

Example 16 with Dom

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;
}
Also used : Dom(org.jvnet.hk2.config.Dom)

Example 17 with Dom

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);
    }
}
Also used : Dom(org.jvnet.hk2.config.Dom) ASMResourcesGenerator(org.glassfish.admin.rest.generator.ASMResourcesGenerator) ResourcesGenerator(org.glassfish.admin.rest.generator.ResourcesGenerator) Domain(com.sun.enterprise.config.serverbeans.Domain) ASMResourcesGenerator(org.glassfish.admin.rest.generator.ASMResourcesGenerator) EndpointRegistrationException(org.glassfish.api.container.EndpointRegistrationException)

Example 18 with Dom

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;
}
Also used : Dom(org.jvnet.hk2.config.Dom)

Example 19 with Dom

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;
}
Also used : Dom(org.jvnet.hk2.config.Dom) TreeMap(java.util.TreeMap) LoginException(javax.security.auth.login.LoginException) URISyntaxException(java.net.URISyntaxException) MultiException(org.glassfish.hk2.api.MultiException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Example 20 with Dom

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;
}
Also used : HashMap(java.util.HashMap) Attribute(org.jvnet.hk2.config.Attribute) ArrayList(java.util.ArrayList) MethodMetaData(org.glassfish.admin.rest.provider.MethodMetaData) Method(java.lang.reflect.Method) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) MultiException(org.glassfish.hk2.api.MultiException) ParameterMetaData(org.glassfish.admin.rest.provider.ParameterMetaData)

Aggregations

Dom (org.jvnet.hk2.config.Dom)37 ConfigModel (org.jvnet.hk2.config.ConfigModel)14 Domain (com.sun.enterprise.config.serverbeans.Domain)12 DomDocument (org.jvnet.hk2.config.DomDocument)9 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)9 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)8 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)8 PropertyVetoException (java.beans.PropertyVetoException)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 GET (javax.ws.rs.GET)5 Produces (javax.ws.rs.Produces)5 MultiException (org.glassfish.hk2.api.MultiException)5 Config (com.sun.enterprise.config.serverbeans.Config)4 TreeMap (java.util.TreeMap)4 ConfigParser (org.jvnet.hk2.config.ConfigParser)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ResourcesGenerator (org.glassfish.admin.rest.generator.ResourcesGenerator)3 ExampleServiceConfiguration (fish.payara.service.example.config.ExampleServiceConfiguration)2