Package org.jvnet.hk2.config

Examples of org.jvnet.hk2.config.Dom


    public String getPlain() {
//        status.append("\n------------------------");
//        status.append("Status of Command usage\n");
        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 NOOPResourcesGenerator((Habitat)habitat);
            resourcesGenerator.generateSingle(rootModel, document);
View Full Code Here


    @GET
    @Produces({MediaType.TEXT_HTML})
    public String getHtml() {
        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 NOOPResourcesGenerator((Habitat)habitat);
            resourcesGenerator.generateSingle(rootModel, document);
View Full Code Here

    }

    //called when jersey is injecting the habitat...
    @Context
    public void setBaseServiceLocator(Habitat hab) {
        Dom dom1 = Dom.unwrap(hab.<Domain>getService(Domain.class));
        childModel = dom1.document.getRoot().model;
        entity = dom1.document.getRoot();
    }
View Full Code Here

     * as we recurse up to the top of the Dom tree to finish building the path desired.
     * @param node
     * @return
     */
    private String buildPath (Dom node) {
        final Dom parentNode = node.parent();
        String part = node.model.getTagName();
        String name = node.attribute("name");
        if (name != null) {
            part = name;
        }
View Full Code Here

        }
        return Response.status(status).entity(results).build();
    }

    protected void deleteExistingProperties() {
        Dom parent = getEntity();
        for (Dom existingProp : parent.nodeElements(TAG_SYSTEM_PROPERTY)) {
            try {
                ConfigSupport.deleteChild((ConfigBean) parent, (ConfigBean) existingProp);
            } catch (TransactionFailure ex) {
                Logger.getLogger(SystemPropertiesCliResource.class.getName()).log(Level.SEVERE, null, ex);
            }
View Full Code Here

    }

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

                        //fail(context, "No configuration found for " + targetName);
                        fail(context, localStrings.getLocalString("admin.set.configuration.notfound", "No configuration found for {0}", propTargetName));
                        return false;
                    }
                    // need to find the right parent.
                    Dom parentNode = null;
                    for (Map.Entry<Dom, String> node : matchingNodes.entrySet()) {
                        if (node.getValue().equals(pattern)) {
                            parentNode = node.getKey();
                        }
                    }
                    if (parentNode == null) {
                        //fail(context, "No configuration found for " + targetName);
                        fail(context, localStrings.getLocalString("admin.set.configuration.notfound", "No configuration found for {0}", propTargetName));
                        return false;
                    }

                    if (value == null || value.length() == 0) {
                        // setting to the empty string means to remove the property, so don't create it
                        recordAutoSuccessAction(propTargetName, value);
                        success(context, propTargetName, value);
                        return true;
                    }
                    // create and set the property
                    recordConfigBeanCreateAndSet((ConfigBean) parentNode, attrName,
                            value, propTargetName);
                    return true;
                }
            }
           
            /*
             * We are processing a "set" applied to something other than a
             * property. 
             */
            final NonPropertyAction nonPropAction = new NonPropertyAction(value);
            setAction = nonPropAction;
           
           
            boolean delProperty = false;
            Map<String, String> attrChanges = new HashMap<String, String>();
            if (isProperty) {
                attrName = "value";
                if ((value == null) || (value.length() == 0)) {
                    delProperty = true;
                }
                attrChanges.put(attrName, value);
            }

            List<Map.Entry> mNodes = new ArrayList(matchingNodes.entrySet());
            if (applyOverrideRules) {
                mNodes = applyOverrideRules(mNodes);
            }
            for (Map.Entry<Dom, String> node : mNodes) {
                final Dom targetNode = node.getKey();

                for (String name : targetNode.model.getAttributeNames()) {
                    String finalDottedName = node.getValue() + "." + name;
                    if (matches(finalDottedName, pattern)) {
                        if (attrName.equals(name) ||
View Full Code Here

            try {
                return type.cast(config);
            } catch (ClassCastException e) {
                // ok we need to do more work to find which object is really requested.
            }
            Dom parentDom = Dom.unwrap(config);

            String elementName = GenericCrudCommand.elementName(parentDom.document, targetType, type);
            if (elementName==null) {
                return null;
            }
            ConfigModel.Property property = parentDom.model.getElement(elementName);
            if (property.isCollection()) {
                Collection<Dom> collection = parentDom.nodeElements(elementName);
                if (collection==null) {
                    return null;
                }

                for (Dom child : collection) {
View Full Code Here

    @Override
    public boolean isValid(ConfigBeanProxy config, ConstraintValidatorContext cvc) throws UnexpectedTypeException {
        if (config == null) {
            return true;
        }
        Dom dom = Dom.unwrap(config);
        if (rc.skipDuringCreation() && dom.getKey() == null) {
            return true; //During creation the coresponding DOM is not fully loaded.
        }
        Collection<RemoteKeyInfo> remoteKeys = findRemoteKeys(config);
        if (remoteKeys != null && !remoteKeys.isEmpty()) {
            ServiceLocator habitat = dom.getHabitat();
            boolean result = true;
            boolean disableGlobalMessage = true;
            for (RemoteKeyInfo remoteKeyInfo : remoteKeys) {
                if (remoteKeyInfo.method.getParameterTypes().length > 0) {
                    throw new UnexpectedTypeException(localStrings.getLocalString("referenceValidator.not.getter",
View Full Code Here

        return messages;
    }

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

TOP

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

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.