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"));
}
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();
}
Aggregations