use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.
the class SynchronousCallback method setInMessageContext.
public synchronized void setInMessageContext(MessageContext inMessageContext) throws AxisFault {
// thread should have activate by the first message.
if (!isComplete) {
// this code is invoked only if the code use with axis2 at the client side
// when axis2 client receive messages it waits in the sending thread until the response comes.
// so this thread only notify the waiting thread and hence we need to build the message here.
inMessageContext.getEnvelope().build();
OperationContext operationContext = outMessageContext.getOperationContext();
MessageContext msgCtx = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (msgCtx == null) {
// try to see whether there is a piggy back message context
if (outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) != null) {
msgCtx = (MessageContext) outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE);
msgCtx.setTransportIn(inMessageContext.getTransportIn());
msgCtx.setTransportOut(inMessageContext.getTransportOut());
msgCtx.setServerSide(false);
msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE, inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
// FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
msgCtx.setEnvelope(inMessageContext.getEnvelope());
} else {
inMessageContext.setOperationContext(operationContext);
inMessageContext.setServiceContext(outMessageContext.getServiceContext());
if (!operationContext.isComplete()) {
operationContext.addMessageContext(inMessageContext);
}
AxisOperation axisOp = operationContext.getAxisOperation();
AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
inMessageContext.setAxisMessage(inMessage);
inMessageContext.setServerSide(false);
}
} else {
msgCtx.setOperationContext(operationContext);
msgCtx.setServiceContext(outMessageContext.getServiceContext());
AxisOperation axisOp = operationContext.getAxisOperation();
AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
msgCtx.setAxisMessage(inMessage);
msgCtx.setTransportIn(inMessageContext.getTransportIn());
msgCtx.setTransportOut(inMessageContext.getTransportOut());
msgCtx.setServerSide(false);
msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE, inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
// FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
msgCtx.setEnvelope(inMessageContext.getEnvelope());
}
this.inMessageContext = inMessageContext;
isComplete = true;
this.notifyAll();
}
}
use of org.apache.axis2.description.AxisOperation in project MassBank-web by MassBank.
the class AdminActions method doEngageToOperation.
@Action(name = "doEngageToOperation", post = true)
public Redirect doEngageToOperation(HttpServletRequest request) {
String moduleName = request.getParameter("module");
String serviceName = request.getParameter("service");
String operationName = request.getParameter("axisOperation");
Redirect redirect = new Redirect(ENGAGE_TO_OPERATION).withParameter("axisService", serviceName);
try {
AxisOperation od = configContext.getAxisConfiguration().getService(serviceName).getOperation(new QName(operationName));
od.engageModule(configContext.getAxisConfiguration().getModule(moduleName));
redirect.withStatus(true, moduleName + " module engaged to the operation successfully");
} catch (AxisFault axisFault) {
redirect.withStatus(false, axisFault.getMessage());
}
return redirect;
}
use of org.apache.axis2.description.AxisOperation in project MassBank-web by MassBank.
the class AdminActions method processdisengageModule.
@Action(name = "disengageModule", post = true)
public Redirect processdisengageModule(HttpServletRequest req) throws AxisFault {
String type = req.getParameter("type");
String serviceName = req.getParameter("serviceName");
String moduleName = req.getParameter("module");
AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
AxisService service = axisConfiguration.getService(serviceName);
AxisModule module = axisConfiguration.getModule(moduleName);
if (type.equals("operation")) {
if (service.isEngaged(module.getName()) || axisConfiguration.isEngaged(module.getName())) {
return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". This module is engaged at a higher level.");
} else {
String opName = req.getParameter("operation");
AxisOperation op = service.getOperation(new QName(opName));
op.disengageModule(module);
return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from " + "operation " + opName + " in service " + serviceName + ".");
}
} else {
if (axisConfiguration.isEngaged(module.getName())) {
return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". " + "This module is engaged at a higher level.");
} else {
service.disengageModule(axisConfiguration.getModule(moduleName));
return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from" + " service " + serviceName + ".");
}
}
}
use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.
the class ProtocolEndpoint method createMessageContext.
public MessageContext createMessageContext() throws AxisFault {
MessageContext msgContext = listener.createMessageContext();
if (service != null) {
msgContext.setAxisService(service);
// find the operation for the message, or default to one
Parameter operationParam = service.getParameter(BaseConstants.OPERATION_PARAM);
QName operationQName = (operationParam != null ? BaseUtils.getQNameFromString(operationParam.getValue()) : BaseConstants.DEFAULT_OPERATION);
AxisOperation operation = service.getOperation(operationQName);
if (operation != null) {
msgContext.setAxisOperation(operation);
msgContext.setAxisMessage(operation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN));
msgContext.setSoapAction("urn:" + operation.getName().getLocalPart());
}
}
return msgContext;
}
use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.
the class MinConcurrencyTest method runTest.
@Override
protected void runTest() throws Throwable {
int endpointCount = channels.length;
int expectedConcurrency = endpointCount * messages;
final MessageReceiver messageReceiver = new MessageReceiver() {
public void receive(MessageContext msgContext) throws AxisFault {
synchronized (concurrencyReachedLock) {
concurrencyReached++;
concurrencyReachedLock.notifyAll();
}
try {
synchronized (shutdownAwaitLock) {
shutdownAwaitLock.wait();
}
} catch (InterruptedException ex) {
}
}
};
TestResourceSet[] clientResourceSets = new TestResourceSet[endpointCount];
TestResourceSet[] endpointResourceSets = new TestResourceSet[endpointCount];
try {
for (int i = 0; i < endpointCount; i++) {
TestResourceSet clientResourceSet = new TestResourceSet(getResourceSet());
AsyncChannel channel = channels[i];
clientResourceSet.addResource(channel);
AxisAsyncTestClient client = new AxisAsyncTestClient(false);
clientResourceSet.addResource(client);
clientResourceSet.setUp();
clientResourceSets[i] = clientResourceSet;
TestResourceSet endpointResourceSet = new TestResourceSet(clientResourceSet);
endpointResourceSet.addResource(new AxisTestEndpoint() {
@Override
protected AxisOperation createOperation() {
AxisOperation operation = new InOnlyAxisOperation(new QName("in"));
operation.setMessageReceiver(messageReceiver);
return operation;
}
@Override
protected void onTransportError(Throwable ex) {
// TODO Auto-generated method stub
}
});
if (!preloadMessages) {
endpointResourceSet.setUp();
endpointResourceSets[i] = endpointResourceSet;
}
for (int j = 0; j < messages; j++) {
ClientOptions options = new ClientOptions(client, new ContentType(SOAP11Constants.SOAP_11_CONTENT_TYPE), "UTF-8");
AxisMessage message = new AxisMessage();
message.setMessageType(SOAP11Constants.SOAP_11_CONTENT_TYPE);
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
message.setEnvelope(envelope);
client.sendMessage(options, new ContentType(message.getMessageType()), message);
}
if (preloadMessages) {
endpointResourceSet.setUp();
endpointResourceSets[i] = endpointResourceSet;
}
}
long startTime = System.currentTimeMillis();
while (concurrencyReached < expectedConcurrency && System.currentTimeMillis() < (startTime + 5000)) {
synchronized (concurrencyReachedLock) {
concurrencyReachedLock.wait(5000);
}
}
synchronized (shutdownAwaitLock) {
shutdownAwaitLock.notifyAll();
}
if (concurrencyReached < expectedConcurrency) {
fail("Concurrency reached is " + concurrencyReached + ", but expected " + expectedConcurrency);
}
} finally {
for (int i = 0; i < endpointCount; i++) {
if (endpointResourceSets[i] != null) {
endpointResourceSets[i].tearDown();
}
if (clientResourceSets[i] != null) {
clientResourceSets[i].tearDown();
}
}
}
}
Aggregations