Search in sources :

Example 1 with StAXOMBuilder

use of org.apache.axiom.om.impl.builder.StAXOMBuilder in project wso2-axis2-transports by wso2.

the class ContentTypeRuleTest method setUp.

@Override
public void setUp() throws Exception {
    AxisConfiguration axisCfg = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
    AxisService service = new AxisService();
    InputStream in = ContentTypeRuleTest.class.getResourceAsStream(getName() + ".xml");
    try {
        OMElement element = new StAXOMBuilder(in).getDocumentElement();
        new ServiceBuilder(cfgCtx, service).populateService(element);
    } finally {
        in.close();
    }
    ruleSet = ContentTypeRuleFactory.parse(service.getParameter("test"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) InputStream(java.io.InputStream) AxisService(org.apache.axis2.description.AxisService) OMElement(org.apache.axiom.om.OMElement) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) ServiceBuilder(org.apache.axis2.deployment.ServiceBuilder)

Example 2 with StAXOMBuilder

use of org.apache.axiom.om.impl.builder.StAXOMBuilder in project jaggery by wso2.

the class CommandLineManager method initEngine.

protected static void initEngine() {
    try {
        InputStream inputStream = CommandLineManager.class.getClassLoader().getResourceAsStream("META-INF/hostobjects.xml");
        StAXOMBuilder builder = new StAXOMBuilder(inputStream);
        OMElement document = builder.getDocumentElement();
        Iterator itr = document.getChildrenWithLocalName("hostObject");
        String msg = "Error while registering HostObject : ";
        while (itr.hasNext()) {
            OMElement hostObject = (OMElement) itr.next();
            String name = hostObject.getFirstChildWithName(new QName(null, "name")).getText();
            String className = hostObject.getFirstChildWithName(new QName(null, "className")).getText();
            JavaScriptHostObject ho = new JavaScriptHostObject(name);
            try {
                ho.setClazz(Class.forName(className));
                RHINO_ENGINE.defineHostObject(ho);
            } catch (ClassNotFoundException e) {
                msg += name + " " + e.getMessage();
                log.error(msg, e);
            }
        }
    } catch (XMLStreamException e) {
        log.error("Error while reading the hostobjects.xml", e);
    }
    initGlobalProperties();
//engine.sealEngine();
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) OMElement(org.apache.axiom.om.OMElement)

Aggregations

OMElement (org.apache.axiom.om.OMElement)2 StAXOMBuilder (org.apache.axiom.om.impl.builder.StAXOMBuilder)2 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 QName (javax.xml.namespace.QName)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 ServiceBuilder (org.apache.axis2.deployment.ServiceBuilder)1 AxisService (org.apache.axis2.description.AxisService)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1