Search in sources :

Example 21 with ConfigModel

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

the class DefaultConfigParser method parseContainerConfig.

@Override
public <T extends Container> T parseContainerConfig(ServiceLocator habitat, final URL configuration, Class<T> configType) throws IOException {
    // I don't use the GlassFish document here as I don't need persistence
    final DomDocument doc = new DomDocument<GlassFishConfigBean>(habitat) {

        @Override
        public Dom make(final ServiceLocator habitat, XMLStreamReader xmlStreamReader, GlassFishConfigBean dom, ConfigModel configModel) {
            // by default, people get the translated view.
            return new GlassFishConfigBean(habitat, this, dom, configModel, xmlStreamReader);
        }
    };
    // add the new container configuration to the server config
    final T container = doc.getRoot().createProxy(configType);
    try {
        ConfigSupport.apply(new SingleConfigCode<Config>() {

            @Override
            public Object run(Config config) throws PropertyVetoException, TransactionFailure {
                config.getContainers().add(container);
                return null;
            }
        }, config);
    } catch (TransactionFailure e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.exceptionAddContainer, e);
    }
    return container;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) XMLStreamReader(javax.xml.stream.XMLStreamReader) ConfigModel(org.jvnet.hk2.config.ConfigModel) GlassFishConfigBean(org.glassfish.config.support.GlassFishConfigBean) Config(com.sun.enterprise.config.serverbeans.Config) DomDocument(org.jvnet.hk2.config.DomDocument)

Example 22 with ConfigModel

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

the class ResourcesGeneratorBase method processNonLeafChildElement.

private void processNonLeafChildElement(String elementName, ConfigModel.Property childElement, DomDocument domDocument, ClassWriter classWriter) {
    ConfigModel.Node node = (ConfigModel.Node) childElement;
    ConfigModel childModel = node.getModel();
    String beanName = ResourceUtil.getUnqualifiedTypeName(childModel.targetTypeName);
    if (beanName.equals("Property")) {
        classWriter.createGetChildResource("property", "PropertiesBagResource");
    } else if (beanName.equals("MonitoredAttribute")) {
        classWriter.createGetChildResource("monitored-attribute", "MonitoredAttributeBagResource");
    } else {
        String childResourceClassName = getClassName(beanName);
        if (childElement.isCollection()) {
            childResourceClassName = "List" + childResourceClassName;
        }
        classWriter.createGetChildResource(/*
                     * childModel.getTagName()
                     */
        elementName, childResourceClassName);
    }
    if (childElement.isCollection()) {
        generateList(childModel, domDocument);
    } else {
        generateSingle(childModel, domDocument);
    }
}
Also used : ConfigModel(org.jvnet.hk2.config.ConfigModel)

Example 23 with ConfigModel

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

the class ClientGenerator method generateClasses.

public void generateClasses() {
    Domain entity = getBaseServiceLocator().getService(Domain.class);
    Dom dom = Dom.unwrap(entity);
    document = dom.document;
    ConfigModel rootModel = dom.document.getRoot().model;
    alreadyGenerated.clear();
    generateSingle(rootModel);
}
Also used : Dom(org.jvnet.hk2.config.Dom) ConfigModel(org.jvnet.hk2.config.ConfigModel) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 24 with ConfigModel

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

the class ClientGenerator method processNonLeafChildElement.

private void processNonLeafChildElement(ClientClassWriter writer, String elementName, ConfigModel.Property childElement) {
    ConfigModel.Node node = (ConfigModel.Node) childElement;
    ConfigModel childModel = node.getModel();
    String beanName = ResourceUtil.getUnqualifiedTypeName(childModel.targetTypeName);
    writer.createGetChildResource(childModel, Util.upperCaseFirstLetter(Util.eleminateHypen(elementName)), beanName);
    if (childElement.isCollection()) {
        generateList(writer, childModel);
    } else {
        generateSingle(childModel);
    }
}
Also used : ConfigModel(org.jvnet.hk2.config.ConfigModel)

Aggregations

ConfigModel (org.jvnet.hk2.config.ConfigModel)20 DomDocument (org.jvnet.hk2.config.DomDocument)8 MultiException (org.glassfish.hk2.api.MultiException)6 Dom (org.jvnet.hk2.config.Dom)6 Domain (com.sun.enterprise.config.serverbeans.Domain)5 Method (java.lang.reflect.Method)5 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)4 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)4 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 Attribute (org.jvnet.hk2.config.Attribute)3 PropertyVetoException (java.beans.PropertyVetoException)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 MethodMetaData (org.glassfish.admin.rest.provider.MethodMetaData)2