Package org.apache.geronimo.system.plugin.model

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


       
        attributeName = "attName";
    }
   
    public void testPropertyEditorIsCarriedByWriteXml() throws Exception {
        AttributeType attributeType = new AttributeType();
        gbeanType.getAttributeOrReference().add(attributeType);
        attributeType.setName(attributeName);
        attributeType.getContent().add("value");
        attributeType.setPropertyEditor("myPropertyEditor");
       
        GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType copiedAttributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertEquals(attributeType.getPropertyEditor(), copiedAttributeType.getPropertyEditor());
    }
View Full Code Here


       
        assertEquals("bean", override.getAttribute(attributeName));
       
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType attributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertEquals("bean", attributeType.getContent().get(0));
    }
View Full Code Here

        GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
        override.setAttribute(attributeName, new Bean(), Service.class.getName(), getClass().getClassLoader());
       
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType attributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertEquals(BeanEditor.class.getName(), attributeType.getPropertyEditor());
    }
View Full Code Here

        GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
        override.setAttribute(attributeName, new Bean(), Bean.class.getName(), getClass().getClassLoader());
       
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType attributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertNull(attributeType.getPropertyEditor());
    }
View Full Code Here

        GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
        override.setAttribute(attributeName, new Integer(1), int.class.getName(), getClass().getClassLoader());
       
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType attributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertNull(attributeType.getPropertyEditor());
    }
View Full Code Here

        GBeanOverride override = new GBeanOverride(gbeanType, new JexlExpressionParser());
        override.setAttribute(attributeName, Collections.singleton("test"), Collection.class.getName(), getClass().getClassLoader());
       
        GbeanType copiedGBeanType = override.writeXml();
        assertEquals(1, copiedGBeanType.getAttributeOrReference().size());
        AttributeType attributeType = (AttributeType) copiedGBeanType.getAttributeOrReference().get(0);
        assertNull(attributeType.getPropertyEditor());
    }
View Full Code Here

        comment = gbean.getComment();

        // attributes
        for (Object o : gbean.getAttributeOrReference()) {
            if (o instanceof AttributeType) {
                AttributeType attr = (AttributeType) o;

                String propertyEditor = attr.getPropertyEditor();
                if (null != propertyEditor) {
                    propertyEditors.put(attr.getName(), propertyEditor);
                }
               
                if (attr.isNull()) {
                    getNullAttributes().add(attr.getName());
                } else {
                    String value;
                    try {
                        value = AttributesXmlUtil.extractAttributeValue(attr);
                    } catch (JAXBException e) {
                        throw new InvalidGBeanException("Could not extract attribute value from gbean override", e);
                    } catch (XMLStreamException e) {
                        throw new InvalidGBeanException("Could not extract attribute value from gbean override", e);
                    }
                    if (value == null || value.length() == 0) {
                        setClearAttribute(attr.getName());
                    } else {
                        String truevalue = (String) EncryptionManager.decrypt(value);
                        getAttributes().put(attr.getName(), truevalue);
                    }
                }
            } else if (o instanceof ReferenceType) {
                ReferenceType ref = (ReferenceType) o;
                if (ref.getPattern().isEmpty()) {
View Full Code Here

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

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

        PluginArtifactType instance = PluginXmlUtil.loadPluginArtifactMetadata(in);
        List<GbeanType> gbeans = instance.getConfigXmlContent().get(0).getGbean();
        assertEquals(3, gbeans.size());
        List contents = gbeans.get(0).getAttributeOrReference();
        assertEquals(2, contents.size());
        AttributeType attr = (AttributeType) contents.get(1);
        String value = AttributesXmlUtil.extractAttributeValue(attr);
       
        Document expectedDoc = DOMUtils.load(VALUE);
        Document actualDoc = DOMUtils.load(value);
       
View Full Code Here

TOP

Related Classes of org.apache.geronimo.system.plugin.model.AttributeType

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.