Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.DomDocument


    //@Override
    public void run(ConfigParser parser) throws ConfigPopulatorException {
        String tenantName = tenantManager.getCurrentTenant();
        System.out.println("Running populator for tenant " + tenantName);
        URL source = EnvironmentXml.class.getResource("/" + tenantName + ".xml");
        parser.parse(source, new DomDocument(habitat));
    }
View Full Code Here


    private void populateWithConfig(ServiceLocator serviceLocator, String tenantName) {
        System.out.println("Running populator for tenant " + tenantName);
        URL source = EnvironmentXml.class.getResource("/" + tenantName + ".xml");
        ConfigParser parser = new ConfigParser(serviceLocator);
        parser.parse(source, new DomDocument(serviceLocator));
    }
View Full Code Here

                      logger.log(Level.SEVERE, "Error initializing HK2", e);
                    }
                   
                    ConfigParser parser = new ConfigParser(serviceLocator);
                    URL domainURL = domainXMLFile.toURI().toURL();
                    DomDocument doc = parser.parse(domainURL);
                    Dom domDomain = doc.getRoot();
                    Domain domain = domDomain.createProxy(Domain.class);
                    Nodes nodes = domain.getNodes();

                    for (Node node : nodes.getNode()) {
                        //make it Unix style and remove trailing slash
View Full Code Here

    }

    /** works only for @Configured types */
    public static Class[] getTypesImplementing(final Class<?> clazz)
    {
        final DomDocument domDoc = new DomDocument(InjectedValues.getInstance().getHabitat());

        try
        {
            final List<ConfigModel> models = domDoc.getAllModelsImplementing(clazz);
            final Class[] interfaces = new Class[models == null ? 0 : models.size()];
            if (models != null)
            {
                int i = 0;
                for (final ConfigModel model : models)
View Full Code Here

                logger.finer("Domain XML file = " + domainXMLFile);
                try {
                    Habitat habitat = Globals.getStaticHabitat();
                    ConfigParser parser = new ConfigParser(habitat);
                    URL domainURL = domainXMLFile.toURI().toURL();
                    DomDocument doc = parser.parse(domainURL);
                    Dom domDomain = doc.getRoot();
                    Domain domain = domDomain.createProxy(Domain.class);
                    Nodes nodes = domain.getNodes();

                    for (Node node : nodes.getNode()) {
                        //make it Unix style and remove trailing slash
View Full Code Here

        Class configBeanClass = getClassForFullName(defaultValue.getConfigBeanClassName());
        Method m = findSuitableCollectionGetter(parentClass, configBeanClass);
        if (m != null) {
            ConfigParser configParser = new ConfigParser(serviceLocator);
            // I don't use the GlassFish document here as I don't need persistence
            final DomDocument doc = new DomDocument<GlassFishConfigBean>(serviceLocator) {
                @Override
                public Dom make(final ServiceLocator serviceLocator, XMLStreamReader xmlStreamReader, GlassFishConfigBean dom,
                                ConfigModel configModel) {
                    // by default, people get the translated view.
                    return new GlassFishConfigBean(serviceLocator, this, dom, configModel, xmlStreamReader);
                }
            };

            ConfigBeanProxy parent = getOwningObject(defaultValue.getLocation());
            ConfigurationPopulator populator = new ConfigurationPopulator(defaultValue.getXmlConfiguration(), doc, parent);
            populator.run(configParser);
            ConfigBeanProxy configBean = doc.getRoot().createProxy(configBeanClass);
            Collection col = (Collection) m.invoke(parent);
            return (T) getConfigBeanFromCollection(col, configBean, configBeanClass);

        }
        return null;
View Full Code Here

    long now = System.currentTimeMillis();
    URL url = Utils.class.getClassLoader().getResource(fileName + ".xml");
    if (url != null) {
      try {
          DomDocument testDocument = test.getDocument(sl);
        DomDocument document = configParser.parse(url,
            testDocument);
        ServiceLocatorUtilities.addOneConstant(sl, document);
        test.decorate(sl);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

        try {
            ServiceLocator habitat = Globals.getStaticHabitat();
            ConfigParser parser = new ConfigParser(habitat);
            URL domainURL = domainXMLFile.toURI().toURL();
            DomDocument doc = parser.parse(domainURL);
            Dom domDomain = doc.getRoot();
            Domain d = domDomain.createProxy(Domain.class);
            return d;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

        String retVal = "Code Generation done at : " + outputDir;

        try {
            Domain entity = habitat.getService(Domain.class);
            Dom dom = Dom.unwrap(entity);
            DomDocument document = dom.document;
            ConfigModel rootModel = dom.document.getRoot().model;

            ResourcesGenerator resourcesGenerator = new TextResourcesGenerator(outputDir, habitat);
            resourcesGenerator.generateSingle(rootModel, document);
            resourcesGenerator.endGeneration();
View Full Code Here

    }

    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;
View Full Code Here

TOP

Related Classes of org.jvnet.hk2.config.DomDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.