本文整理汇总了Java中org.apache.axiom.om.OMElement.build方法的典型用法代码示例。如果您正苦于以下问题:Java OMElement.build方法的具体用法?Java OMElement.build怎么用?Java OMElement.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axiom.om.OMElement
的用法示例。
在下文中一共展示了OMElement.build方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setClientName
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement setClientName(OMElement name) {
name.build();
name.detach();
String cName = name.getText();
serviceContext.setProperty("cName", cName);
String sName = "anonymous";
Object s = System.getProperty("server_name");
if (s != null) {
sName = (String) s;
}
String msg = "Server " + sName + " started a session with client " + cName;
System.out.println(msg);
name.setText(msg);
return name;
}
示例2: sampleOperation
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement sampleOperation(OMElement param) {
param.build();
param.detach();
String sName = "";
if (System.getProperty("test_mode") != null) {
sName = org.apache.axis2.context.MessageContext.getCurrentMessageContext().getTo().getAddress();
} else {
sName = System.getProperty("server_name");
}
if (sName != null) {
param.setText("Response from server: " + sName);
} else {
param.setText("Response from anonymous server");
}
return param;
}
示例3: sleepOperation
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement sleepOperation(OMElement param) throws AxisFault {
param.build();
param.detach();
OMElement timeElement = param.getFirstChildWithName(new QName("load"));
String time = timeElement.getText();
try {
Thread.sleep(Long.parseLong(time));
} catch (InterruptedException e) {
throw new AxisFault("Service is interrupted while sleeping.");
}
String sName = System.getProperty("server_name");
if (sName != null) {
timeElement.setText("Response from server: " + sName);
} else {
timeElement.setText("Response from anonymous server");
}
return param;
}
示例4: loadOperation
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement loadOperation(OMElement param) throws AxisFault {
param.build();
param.detach();
OMElement loadElement = param.getFirstChildWithName(new QName("load"));
String l = loadElement.getText();
long load = Long.parseLong(l);
for (long i = 0; i < load; i++) {
System.out.println("Iteration: " + i);
}
String sName = System.getProperty("server_name");
if (sName != null) {
loadElement.setText("Response from server: " + sName);
} else {
loadElement.setText("Response from anonymous server");
}
return param;
}
示例5: getPropertyFromAxisConf
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private static String getPropertyFromAxisConf(String parameter) throws IOException, XMLStreamException {
try (InputStream file = new FileInputStream(Paths.get(CarbonBaseUtils.getCarbonConfigDirPath(), "axis2",
"axis2.xml").toString())) {
if(axis2Config == null) {
OMElement element = (OMElement) XMLUtils.toOM(file);
element.build();
axis2Config = element;
}
Iterator parameters = axis2Config.getChildrenWithName(new QName("parameter"));
while (parameters.hasNext()) {
OMElement parameterElement = (OMElement) parameters.next();
if (parameter.equals(parameterElement.getAttribute(new QName("name")).getAttributeValue())) {
return parameterElement.getText();
}
}
return null;
} catch (IOException | XMLStreamException e) {
throw e;
}
}
示例6: updateAxis2_ClientXML
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private void updateAxis2_ClientXML() throws Exception {
String axis2_client_path = CarbonUtils.getCarbonHome() + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2_client.xml";
String mail_transport_config = getResourceLocation()+ File.separator + "resources" + File.separator + "mailTransport.xml";
FileOutputStream fileOutputStream = null;
XMLStreamWriter writer = null;
try {
OMElement axis2_client_xml = AXIOMUtil.stringToOM(FileManager.readFile(axis2_client_path));
axis2_client_xml.addChild(AXIOMUtil.stringToOM(FileManager.readFile(mail_transport_config)));
axis2_client_xml.build();
fileOutputStream = new FileOutputStream(axis2_client_path);
writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream);
axis2_client_xml.serialize(writer);
} catch (Exception e) {
throw new Exception("axis2_client.xml update fails");
} finally {
if (fileOutputStream != null) {
fileOutputStream.close();
}
if (writer != null) {
writer.flush();
}
}
}
示例7: read
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public static OMElement read(String filePath) throws FileNotFoundException,
XMLStreamException {
OMElement documentElement = null;
FileInputStream inputStream = null;
XMLStreamReader parser = null;
File file = new File(filePath);
try {
inputStream = new FileInputStream(filePath);
parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element
documentElement = builder.getDocumentElement();
documentElement.build();
} finally {
if (parser != null) {
parser.close();
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
//ignore
}
}
}
return documentElement;
}
示例8: updateSynapseConfiguration
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private OMElement updateSynapseConfiguration(File synapseFile)
throws IOException, XMLStreamException {
OMElement synapseContent;
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(synapseFile));
XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(bufferedInputStream);
StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
synapseContent = stAXOMBuilder.getDocumentElement();
synapseContent.build();
bufferedInputStream.close();
OMElement targetElement = synapseContent.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "target"));
OMElement outSequenceElement = targetElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "outSequence"));
OMElement dbReportElement = outSequenceElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "dbreport"));
OMElement connectionElement = dbReportElement.getFirstChildWithName(
new QName("http://ws.apache.org/ns/synapse", "connection"));
OMElement poolElement = connectionElement.getFirstElement();
OMElement driverElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "driver"));
OMElement urlElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "url"));
OMElement userElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "user"));
OMElement passwordElemnt = poolElement.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "password"));
driverElemnt.setText(JDBC_DRIVER);
urlElemnt.setText(JDBC_URL);
userElemnt.setText(DB_USER);
passwordElemnt.setText(DB_PASSWORD);
return synapseContent;
}
示例9: buildResponse
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
private static OMElement buildResponse(OMElement omElement) {
omElement.build();
return omElement;
}
示例10: sleepOperation
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement sleepOperation(OMElement topParam) {
topParam.build();
topParam.detach();
OMElement param = topParam.getFirstChildWithName(new QName("load"));
String l = param.getText();
long time = Long.parseLong(l);
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Long c = null;
Object o = serviceContext.getProperty("count");
if (o == null) {
c = new Long(1);
serviceContext.setProperty("count", c);
} else {
c = (Long) o;
c = new Long(c.longValue() + 1);
serviceContext.setProperty("count", c);
}
String cName = "anonymous";
Object cn = serviceContext.getProperty("cName");
if (cn != null) {
cName = (String) cn;
}
String sName = "anonymous";
Object s = System.getProperty("server_name");
if (s != null) {
sName = (String) s;
}
String msg = "Server: " + sName + " processed the request " + c.toString() + " from client: " + cName;
System.out.println(msg);
param.setText(msg);
return topParam;
}
示例11: loadOperation
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement loadOperation(OMElement topParam) {
topParam.build();
topParam.detach();
OMElement param = topParam.getFirstChildWithName(new QName("load"));
String l = param.getText();
long load = Long.parseLong(l);
for (long i = 0; i < load; i++) {
System.out.println("Iteration: " + i);
}
Long c = null;
Object o = serviceContext.getProperty("count");
if (o == null) {
c = new Long(1);
serviceContext.setProperty("count", c);
} else {
c = (Long) o;
c = new Long(c.longValue() + 1);
serviceContext.setProperty("count", c);
}
String cName = "anonymous";
Object cn = serviceContext.getProperty("cName");
if (cn != null) {
cName = (String) cn;
}
String sName = "anonymous";
Object s = System.getProperty("server_name");
if (s != null) {
sName = (String) s;
}
String msg = "Server: " + sName + " processed the request " + c.toString() + " from client: " + cName;
System.out.println(msg);
param.setText(msg);
return topParam;
}
示例12: setClientName
import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement setClientName(OMElement cName) {
cName.build();
cName.detach();
cName.setText("Sessions are not supported in this service.");
return cName;
}