Examples of OMFactory


Examples of org.apache.axiom.om.OMFactory

       
        MessageContext mc = new TestMessageContextBuilder()
            .addEntry("xslt-key", XSLTMediator.class.getResource("identity.xslt"))
            .build();
       
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement orgRoot = factory.createOMElement(new QName("root"));
        OMElement orgElement = factory.createOMElement(new QName("urn:mynamespace", "element1"));
        orgElement.setText("test");
        OMAttribute orgAttribute = orgElement.addAttribute("att", "testValue", null);
        orgRoot.addChild(orgElement);
       
        mc.getEnvelope().getBody().addChild(orgRoot);
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public void serialize(SynapseConfiguration synapseConfig) {
        if (log.isDebugEnabled()) {
            log.debug("Serializing Synapse configuration to the file system");
        }

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace synNS = fac.createOMNamespace(XMLConfigConstants.SYNAPSE_NAMESPACE, "syn");
        OMElement definitions = fac.createOMElement("definitions", synNS);

        try {
            currentDirectory = createTempDirectoryStructure();

            if (synapseConfig.getRegistry() != null) {
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

     *
     * @param synapseConfig Current Synapse configuration
     * @throws Exception on file I/O error
     */
    public void serializeSynapseXML(SynapseConfiguration synapseConfig) throws Exception {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace synNS = fac.createOMNamespace(XMLConfigConstants.SYNAPSE_NAMESPACE, "syn");
        OMElement definitions = fac.createOMElement("definitions", synNS);

        if (synapseConfig.getRegistry() != null && !Boolean.valueOf(synapseConfig.getProperty(
                MultiXMLConfigurationBuilder.SEPARATE_REGISTRY_DEFINITION))) {
            RegistrySerializer.serializeRegistry(definitions, synapseConfig.getRegistry());
        }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

*/
public class EventSourceSerializer {

    public static OMElement serializeEventSource(OMElement elem, SynapseEventSource eventSource) {

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace nullNS = fac.createOMNamespace(XMLConfigConstants.NULL_NAMESPACE, "");

        OMElement evenSourceElem =
                fac.createOMElement("eventSource", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
        if (eventSource.getName() != null) {
            evenSourceElem
                    .addAttribute(fac.createOMAttribute("name", nullNS, eventSource.getName()));
        }

        if (eventSource.getSubscriptionManager() != null) {
            OMElement subManagerElem = fac.createOMElement("subscriptionManager",
                    XMLConfigConstants.SYNAPSE_OMNAMESPACE);
            subManagerElem.addAttribute(fac.createOMAttribute("class", nullNS,
                    eventSource.getSubscriptionManager().getClass().getName()));
            Collection<String> names =
                    (Collection<String>) eventSource.getSubscriptionManager().getPropertyNames();
            for (String name : names) {
                String value;
                if (eventSource.isContainsConfigurationProperty(name)) {
                    value = eventSource.getConfigurationProperty(name);
                } else {
                    value = eventSource.getSubscriptionManager().getPropertyValue(name);
                }
                OMElement propElem =
                        fac.createOMElement("property", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                propElem.addAttribute(fac.createOMAttribute("name", nullNS, name));
                propElem.addAttribute(fac.createOMAttribute("value", nullNS, value));
                subManagerElem.addChild(propElem);
            }
            evenSourceElem.addChild(subManagerElem);
            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

        return true;
    }

    private void makePOXFault(MessageContext synCtx, SynapseLog synLog) {

        OMFactory fac = synCtx.getEnvelope().getOMFactory();
        OMElement faultPayload = fac.createOMElement(new QName("Exception"));

        if (faultDetail != null) {

            if (synLog.isTraceOrDebugEnabled()) {
                synLog.traceOrDebug("Setting the fault detail : "
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

      ByteArrayInputStream bais = new ByteArrayInputStream(baos
          .toByteArray());
      return (OMElement) XMLUtils.toOM(bais);

    } else {
      OMFactory fac = OMAbstractFactory.getOMFactory();
      OMElement elem = fac.createOMElement(Constants.ELEM_POLICY_REF,
          Constants.URI_POLICY_NS, Constants.ATTR_WSP);
      elem.addAttribute(Constants.ATTR_URI,
          ((PolicyReference) policyComponent).getURI(), null);
      return elem;
    }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

            throw new IllegalArgumentException();
        }
    }
   
    protected void runTest() throws Throwable {
        OMFactory fac = metaFactory.getOMFactory();

        OMNamespace nsParent = createNamespace(fac, parent);
        OMNamespace nsChildren = createNamespace(fac, children);

        OMElement personElem = fac.createOMElement("person", nsParent);
        OMElement nameElem = fac.createOMElement("name", nsChildren);
        nameElem.setText("John");

        OMElement ageElem = fac.createOMElement("age", nsChildren);
        ageElem.setText("34");

        OMElement weightElem = fac.createOMElement("weight", nsChildren);
        weightElem.setText("50");

        //Add children to the person element
        personElem.addChild(nameElem);
        personElem.addChild(ageElem);
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

    public TestGetTextAsStreamWithSingleTextNode(OMMetaFactory metaFactory) {
        super(metaFactory);
    }

    protected void runTest() throws Throwable {
        OMFactory factory = metaFactory.getOMFactory();
        OMElement element = factory.createOMElement(new QName("a"));
        factory.createOMText(element, "test");
        Reader in = element.getTextAsStream(true);
        assertTrue(in instanceof StringReader);
        assertEquals(element.getText(), IOUtils.toString(in));
    }
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

                   firstElement.getFirstOMChild() instanceof OMText);

    }

    public void testAddDOOMElementAsChild() throws XMLStreamException {
        OMFactory doomFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
        OMFactory llomFactory = OMAbstractFactory.getOMFactory();
        String text = "This was a DOOM Text";

        OMElement llomRoot = llomFactory.createOMElement("root", null);
        OMElement doomElement = doomFactory.createOMElement("second", "test", "a");
        doomElement.setText(text);
        llomRoot.addChild(doomElement);

        OMElement newElement = (OMXMLBuilderFactory.createStAXOMBuilder(this.factory, llomRoot
View Full Code Here

Examples of org.apache.axiom.om.OMFactory

import org.junit.Test;

public class JAXBUtilsTest {
    @Test
    public void testUnmarshalWithDataHandler() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        JAXBContext context = JAXBContext.newInstance(DocumentBean.class);
        DocumentBean orgBean = new DocumentBean();
        orgBean.setId("AB23498");
        orgBean.setContent(new DataHandler("test content", "text/plain"));
        OMElement element = factory.createOMElement(new JAXBOMDataSource(context, orgBean));
        DocumentBean bean = (DocumentBean)JAXBUtils.unmarshal(context, element, true);
        assertEquals(orgBean.getId(), bean.getId());
        assertEquals(orgBean.getContent(), bean.getContent());
    }
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.