本文整理汇总了Java中org.apache.axis2.context.MessageContext.activate方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.activate方法的具体用法?Java MessageContext.activate怎么用?Java MessageContext.activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.activate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void run() {
try {
System.out.println("MessageSaveAndRestoreTest:Worker thread started");
Thread.sleep(5000);
System.out.println("MessageSaveAndRestoreTest:Resuming processing");
ObjectInputStream objectInputStream =
new ObjectInputStream(new ByteArrayInputStream(serializedMessageContext));
MessageContext reconstitutedMessageContext =
(MessageContext)objectInputStream.readObject();
reconstitutedMessageContext.activate(configurationContext);
AxisEngine.resume(reconstitutedMessageContext);
}
catch (Exception e) {
e.printStackTrace();
fail("An error occurred in the worker thread");
}
}
示例2: run
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void run() {
try {
System.out.println("MessageSaveAndRestoreWithMTOMTest:Worker thread started");
Thread.sleep(5000);
System.out.println("MessageSaveAndRestoreWithMTOMTest:Resuming processing");
ObjectInputStream objectInputStream =
new ObjectInputStream(new ByteArrayInputStream(serializedMessageContext));
MessageContext reconstitutedMessageContext =
(MessageContext)objectInputStream.readObject();
reconstitutedMessageContext.activate(configurationContext);
AxisEngine.resume(reconstitutedMessageContext);
}
catch (Exception e) {
e.printStackTrace();
fail("An error occurred in the worker thread");
}
}
示例3: restoreMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Restores a previously saved message context
*/
public MessageContext restoreMessageContext(File restoreFile, ConfigurationContext cc) {
String title = "restoreMessageContext(): ";
MessageContext restoredMC = null;
File theFile = restoreFile;
String theFilename = null;
// the configuration context to use for message context activation
ConfigurationContext cfgCtx = cc;
boolean restoredOk = false;
if ((theFile != null) && (theFile.exists())) {
theFilename = theFile.getName();
log.debug(title + "temp file = [" + theFilename + "]");
// ---------------------------------------------------------
// restore from the temporary file
// ---------------------------------------------------------
try {
// setup an input stream to the file
FileInputStream inStream = new FileInputStream(theFile);
// attach a stream capable of reading objects from the
// stream connected to the file
ObjectInputStream inObjStream = new ObjectInputStream(inStream);
// try to restore the message context
log.debug(title + "restoring a message context.....");
restoredOk = false;
MessageContext msgContext2 = (MessageContext) inObjStream.readObject();
inObjStream.close();
inStream.close();
msgContext2.activate(cfgCtx);
restoredOk = true;
log.debug(title + "....restored message context.....");
// now put the restored message context in the global
// variable for the test
restoredMC = msgContext2;
}
catch (Exception ex2) {
log.debug(title + "error with restoring message context = [" +
ex2.getClass().getName() + " : " + ex2.getMessage() + "]");
ex2.printStackTrace();
restoredMessageContext = null;
}
assertTrue(restoredOk);
// if the restore of the message context succeeded,
// then don't keep the temporary file around
boolean removeTmpFile = restoredOk;
if (removeTmpFile) {
try {
theFile.delete();
}
catch (Exception e) {
// just absorb it
}
}
}
return restoredMC;
}
示例4: testDynamicPortSingleServiceNoRecreate
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Validate that a message context can be serialized and deserialized with the Axis2
* and JAX-WS description objects not being recreated. This is similar to a message
* being serialized and deserialized without the server being stopped.
*/
public void testDynamicPortSingleServiceNoRecreate() {
try {
ClientMetadataTest.installCachingFactory();
QName svc1QN = new QName(namespaceURI + "?1", svcLocalPart);
Service svc1 = Service.create(svc1QN);
QName portQN = new QName(namespaceURI, dynamicPort + "_1");
svc1.addPort(portQN, bindingID, epr);
Dispatch<String> port1 = svc1.createDispatch(portQN, String.class, Service.Mode.PAYLOAD);
// We need to get the AxisService so we can set in on a MessageContext and test
// serialization / deserialization. We do this using NON-Public, INTERNAL SPIs
// since we need to get at the internals of the engine
org.apache.axis2.jaxws.spi.BindingProvider bindingProvider =
(org.apache.axis2.jaxws.spi.BindingProvider) port1;
EndpointDescription endpointDesc = bindingProvider.getEndpointDescription();
AxisService axisService = endpointDesc.getAxisService();
assertNotNull(axisService);
assertEquals(svc1QN.getLocalPart(), axisService.getName());
// Now that the AxisService is setup, create an Axis2 message context, set the
// AxisService on it. Serialize it out then read it back in.
MessageContext msgCtx = new MessageContext();
msgCtx.setAxisService(axisService);
msgCtx.setAxisServiceGroup(axisService.getAxisServiceGroup());
ByteArrayOutputStream baos = serializeMessageContext(msgCtx);
// Read in the message context and activate it, which is required by message
// context deserialization to connect the message context to existing runtime
// objects such as AxisService
MessageContext mcRead = deserializeMessageContext(baos);
ConfigurationContext configContext = endpointDesc.getServiceDescription().getAxisConfigContext();
assertNotNull(configContext);
mcRead.activate(configContext);
AxisService asRead = mcRead.getAxisService();
assertNotNull(asRead);
assertEquals(axisService.getName(), asRead.getName());
assertSame(axisService, asRead);
AxisServiceGroup agRead = mcRead.getAxisServiceGroup();
assertNotNull(agRead);
// This keeps the port from being GC'd and causing the AxisService to be freed
// before the test method completes.
assertNotNull(port1);
} catch (Exception t) {
t.printStackTrace();
fail("Caught throwable " + t);
} finally {
ClientMetadataTest.restoreOriginalFactory();
}
}