Examples of GbeanType


Examples of org.apache.geronimo.system.plugin.model.GbeanType

                    "            <attribute name=\"expression\">${host}</attribute>\n" +
                    "        </gbean>";

    public void testExpressionXml() throws Exception {
        Reader in = new StringReader(EXPRESSION_XML);
        GbeanType gbeanElement = AttributesXmlUtil.loadGbean(in);
        GBeanOverride gbean = new GBeanOverride(gbeanElement, expressionParser);
        assertCopyIdentical(gbean);
        GBeanData data = new GBeanData(MockGBean.GBEAN_INFO);
        gbean.setAttribute(portInfo, "${port}", classLoader);
        gbean.applyOverrides(data, null, null, getClass().getClassLoader());
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

     * child element.
     *
     * @return newly created element for this override
     */
    public GbeanType writeXml() {
        GbeanType gbean = new GbeanType();
        String gbeanName;
        if (name instanceof String) {
            gbeanName = (String) name;
        } else {
            gbeanName = name.toString();
        }
        gbean.setName(gbeanName);
        if (gbeanInfo != null) {
            gbean.setGbeanInfo(gbeanInfo);
        }
        if (!load) {
            gbean.setLoad(false);
        }
        if (comment != null) {
            gbean.setComment(comment);
        }

        // attributes
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            String name = entry.getKey();
            String value = entry.getValue();
            if (value == null) {
                nullAttributes.add(name);
                clearAttributes.remove(name);
            } else {               
                nullAttributes.remove(name);
                clearAttributes.remove(name);
/**
* if there was a value such as jdbc url with &amp; then when that value was oulled
* from the config.xml the &amp; would have been replaced/converted to '&', we need to check
* and change it back because an & would create a parse exception.
*/
                value = "<attribute xmlns='" + ATTRIBUTE_NAMESPACE + "'>" + value.replaceAll("&(?!amp;)", "&amp;") + "</attribute>";
                Reader reader = new StringReader(value);
                try {
                    AttributeType attribute = AttributesXmlUtil.loadAttribute(reader);
                    attribute.setName(name);
                    String editorClass = propertyEditors.get(name);
                    if (null != editorClass) {
                        attribute.setPropertyEditor(editorClass);
                    }
                    gbean.getAttributeOrReference().add(attribute);
                } catch (Exception e) {
                    log.error("Could not serialize attribute " + name + " in gbean " + gbeanName + ", value: " + value, e);
                }
            }
        }

        // cleared attributes
        for (String name : clearAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            gbean.getAttributeOrReference().add(attribute);
        }

        // Null attributes
        for (String name : nullAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            attribute.setNull(true);
            gbean.getAttributeOrReference().add(attribute);
        }

        // references
        for (Map.Entry<String, ReferencePatterns> entry : references.entrySet()) {
            String name = entry.getKey();
            ReferencePatterns patterns = entry.getValue();
            ReferenceType reference = new ReferenceType();
            reference.setName(name);

            Set<AbstractNameQuery> patternSet;
            if (patterns.isResolved()) {
                patternSet = Collections.singleton(new AbstractNameQuery(patterns.getAbstractName()));
            } else {
                patternSet = patterns.getPatterns();
            }

            for (AbstractNameQuery pattern : patternSet) {
                ReferenceType.Pattern patternType = new ReferenceType.Pattern();
                Artifact artifact = pattern.getArtifact();

                if (artifact != null) {
                    if (artifact.getGroupId() != null) {
                        patternType.setGroupId(artifact.getGroupId());
                    }
                    if (artifact.getArtifactId() != null) {
                        patternType.setArtifactId(artifact.getArtifactId());
                    }
                    if (artifact.getVersion() != null) {
                        patternType.setVersion(artifact.getVersion().toString());
                    }
                    if (artifact.getType() != null) {
                        patternType.setType(artifact.getType());
                    }
                }

                Map nameMap = pattern.getName();
                if (nameMap.get("module") != null) {
                    patternType.setModule((String) nameMap.get("module"));
                }

                if (nameMap.get("name") != null) {
                    patternType.setName((String) nameMap.get("name"));
                }
                reference.getPattern().add(patternType);
            }
            gbean.getAttributeOrReference().add(reference);
        }

        // cleared references
        for (String name : clearReferences) {
            ReferenceType reference = new ReferenceType();
            reference.setName(name);
            gbean.getAttributeOrReference().add(reference);
        }

        return gbean;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

                    "            </reference>\n" +
                    "        </gbean>";

    public void testReferenceXml() throws Exception {
        Reader in = new StringReader(REFERENCE_XML);
        GbeanType gbeanElement = AttributesXmlUtil.loadGbean(in);
        GBeanOverride gbean = new GBeanOverride(gbeanElement, expressionParser);
        assertCopyIdentical(gbean);
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

                    "            <attribute name=\"expression\">${host}</attribute>\n" +
                    "        </gbean>";

    public void testExpressionXml() throws Exception {
        Reader in = new StringReader(EXPRESSION_XML);
        GbeanType gbeanElement = AttributesXmlUtil.loadGbean(in);
        GBeanOverride gbean = new GBeanOverride(gbeanElement, expressionParser);
        assertCopyIdentical(gbean);
        GBeanData data = new GBeanData(MockGBean.GBEAN_INFO);
        gbean.setAttribute(portInfo, "${port}", bundle);
        gbean.applyOverrides(data, null, null, bundle);
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

    }
    public static GbeanType loadGbean(Reader in) throws ParserConfigurationException, IOException, SAXException, JAXBException, XMLStreamException {
        Unmarshaller unmarshaller = GBEAN_CONTEXT.createUnmarshaller();
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<GbeanType> element = unmarshaller.unmarshal(xmlStream, GbeanType.class);
        GbeanType pluginList = element.getValue();
        return pluginList;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

    }
    public static GbeanType loadGbean(Reader in) throws ParserConfigurationException, IOException, SAXException, JAXBException, XMLStreamException {
        Unmarshaller unmarshaller = GBEAN_CONTEXT.createUnmarshaller();
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<GbeanType> element = unmarshaller.unmarshal(xmlStream, GbeanType.class);
        GbeanType pluginList = element.getValue();
        return pluginList;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

            module.setComment(comment.trim());
        }

        // GBeans
        for (GBeanOverride gbeanOverride : gbeans.values()) {
            GbeanType gbean = gbeanOverride.writeXml();
            module.getGbean().add(gbean);
        }
        return module;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

     * child element.
     *
     * @return newly created element for this override
     */
    public GbeanType writeXml() {
        GbeanType gbean = new GbeanType();
        String gbeanName;
        if (name instanceof String) {
            gbeanName = (String) name;
        } else {
            gbeanName = name.toString();
        }
        gbean.setName(gbeanName);
        if (gbeanInfo != null) {
            gbean.setGbeanInfo(gbeanInfo);
        }
        if (!load) {
            gbean.setLoad(false);
        }
        if (comment != null) {
            gbean.setComment(comment);
        }

        // attributes
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            String name = entry.getKey();
            String value = entry.getValue();
            if (value == null) {
                nullAttributes.add(name);
                clearAttributes.remove(name);
            } else {               
                nullAttributes.remove(name);
                clearAttributes.remove(name);
             
                if (encryptedAttributes.contains(name)) {
                    value = EncryptionManager.encrypt(value);
                }

/**
* if there was a value such as jdbc url with &amp; then when that value was oulled
* from the config.xml the &amp; would have been replaced/converted to '&', we need to check
* and change it back because an & would create a parse exception.
*/
                value = "<attribute xmlns='" + ATTRIBUTE_NAMESPACE + "'>" + value.replaceAll("&(?!amp;)", "&amp;") + "</attribute>";
                Reader reader = new StringReader(value);
                try {
                    AttributeType attribute = AttributesXmlUtil.loadAttribute(reader);
                    attribute.setName(name);
                    String editorClass = propertyEditors.get(name);
                    if (null != editorClass) {
                        attribute.setPropertyEditor(editorClass);
                    }
                    gbean.getAttributeOrReference().add(attribute);
                } catch (Exception e) {
                    log.error("Could not serialize attribute " + name + " in gbean " + gbeanName + ", value: " + value, e);
                }
            }
        }

        // cleared attributes
        for (String name : clearAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            gbean.getAttributeOrReference().add(attribute);
        }

        // Null attributes
        for (String name : nullAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            attribute.setNull(true);
            gbean.getAttributeOrReference().add(attribute);
        }

        // references
        for (Map.Entry<String, ReferencePatterns> entry : references.entrySet()) {
            String name = entry.getKey();
            ReferencePatterns patterns = entry.getValue();
            ReferenceType reference = new ReferenceType();
            reference.setName(name);

            Set<AbstractNameQuery> patternSet;
            if (patterns.isResolved()) {
                patternSet = Collections.singleton(new AbstractNameQuery(patterns.getAbstractName()));
            } else {
                patternSet = patterns.getPatterns();
            }

            for (AbstractNameQuery pattern : patternSet) {
                ReferenceType.Pattern patternType = new ReferenceType.Pattern();
                Artifact artifact = pattern.getArtifact();

                if (artifact != null) {
                    if (artifact.getGroupId() != null) {
                        patternType.setGroupId(artifact.getGroupId());
                    }
                    if (artifact.getArtifactId() != null) {
                        patternType.setArtifactId(artifact.getArtifactId());
                    }
                    if (artifact.getVersion() != null) {
                        patternType.setVersion(artifact.getVersion().toString());
                    }
                    if (artifact.getType() != null) {
                        patternType.setType(artifact.getType());
                    }
                }

                Map nameMap = pattern.getName();
                if (nameMap.get("module") != null) {
                    patternType.setModule((String) nameMap.get("module"));
                }

                if (nameMap.get("name") != null) {
                    patternType.setName((String) nameMap.get("name"));
                }
                reference.getPattern().add(patternType);
            }
            gbean.getAttributeOrReference().add(reference);
        }

        // cleared references
        for (String name : clearReferences) {
            ReferenceType reference = new ReferenceType();
            reference.setName(name);
            gbean.getAttributeOrReference().add(reference);
        }

        return gbean;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

    }
    public static GbeanType loadGbean(Reader in) throws ParserConfigurationException, IOException, SAXException, JAXBException, XMLStreamException {
        Unmarshaller unmarshaller = GBEAN_CONTEXT.createUnmarshaller();
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<GbeanType> element = unmarshaller.unmarshal(xmlStream, GbeanType.class);
        GbeanType pluginList = element.getValue();
        return pluginList;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.GbeanType

     * child element.
     *
     * @return newly created element for this override
     */
    public GbeanType writeXml() {
        GbeanType gbean = new GbeanType();
        String gbeanName;
        if (name instanceof String) {
            gbeanName = (String) name;
        } else {
            gbeanName = name.toString();
        }
        gbean.setName(gbeanName);
        if (gbeanInfo != null) {
            gbean.setGbeanInfo(gbeanInfo);
        }
        if (!load) {
            gbean.setLoad(false);
        }
        if (comment != null) {
            gbean.setComment(comment);
        }

        // attributes
        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            String name = entry.getKey();
            String value = entry.getValue();
            if (value == null) {
                nullAttributes.add(name);
                clearAttributes.remove(name);
            } else {               
                nullAttributes.remove(name);
                clearAttributes.remove(name);
/**
* if there was a value such as jdbc url with &amp; then when that value was oulled
* from the config.xml the &amp; would have been replaced/converted to '&', we need to check
* and change it back because an & would create a parse exception.
*/
                value = "<attribute xmlns='" + ATTRIBUTE_NAMESPACE + "'>" + value.replaceAll("&(?!amp;)", "&amp;") + "</attribute>";
                Reader reader = new StringReader(value);
                try {
                    AttributeType attribute = AttributesXmlUtil.loadAttribute(reader);
                    attribute.setName(name);
                    String editorClass = propertyEditors.get(name);
                    if (null != editorClass) {
                        attribute.setPropertyEditor(editorClass);
                    }
                    gbean.getAttributeOrReference().add(attribute);
                } catch (Exception e) {
                    log.error("Could not serialize attribute " + name + " in gbean " + gbeanName + ", value: " + value, e);
                }
            }
        }

        // cleared attributes
        for (String name : clearAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            gbean.getAttributeOrReference().add(attribute);
        }

        // Null attributes
        for (String name : nullAttributes) {
            AttributeType attribute = new AttributeType();
            attribute.setName(name);
            attribute.setNull(true);
            gbean.getAttributeOrReference().add(attribute);
        }

        // references
        for (Map.Entry<String, ReferencePatterns> entry : references.entrySet()) {
            String name = entry.getKey();
            ReferencePatterns patterns = entry.getValue();
            ReferenceType reference = new ReferenceType();
            reference.setName(name);

            Set<AbstractNameQuery> patternSet;
            if (patterns.isResolved()) {
                patternSet = Collections.singleton(new AbstractNameQuery(patterns.getAbstractName()));
            } else {
                patternSet = patterns.getPatterns();
            }

            for (AbstractNameQuery pattern : patternSet) {
                ReferenceType.Pattern patternType = new ReferenceType.Pattern();
                Artifact artifact = pattern.getArtifact();

                if (artifact != null) {
                    if (artifact.getGroupId() != null) {
                        patternType.setGroupId(artifact.getGroupId());
                    }
                    if (artifact.getArtifactId() != null) {
                        patternType.setArtifactId(artifact.getArtifactId());
                    }
                    if (artifact.getVersion() != null) {
                        patternType.setVersion(artifact.getVersion().toString());
                    }
                    if (artifact.getType() != null) {
                        patternType.setType(artifact.getType());
                    }
                }

                Map nameMap = pattern.getName();
                if (nameMap.get("module") != null) {
                    patternType.setModule((String) nameMap.get("module"));
                }

                if (nameMap.get("name") != null) {
                    patternType.setName((String) nameMap.get("name"));
                }
                reference.getPattern().add(patternType);
            }
            gbean.getAttributeOrReference().add(reference);
        }

        // cleared references
        for (String name : clearReferences) {
            ReferenceType reference = new ReferenceType();
            reference.setName(name);
            gbean.getAttributeOrReference().add(reference);
        }

        return gbean;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.