Search in sources :

Example 56 with Dom

use of org.jvnet.hk2.config.Dom 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)

Aggregations

Dom (org.jvnet.hk2.config.Dom)42 ConfigModel (org.jvnet.hk2.config.ConfigModel)14 Domain (com.sun.enterprise.config.serverbeans.Domain)11 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)11 ArrayList (java.util.ArrayList)9 DomDocument (org.jvnet.hk2.config.DomDocument)9 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)8 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 PropertyVetoException (java.beans.PropertyVetoException)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 IOException (java.io.IOException)3 ResourcesGenerator (org.glassfish.admin.rest.generator.ResourcesGenerator)3 ConfigBean (org.jvnet.hk2.config.ConfigBean)3