use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class AxisTestClientContext method setUp.
@Setup
@SuppressWarnings("unused")
private void setUp(TransportDescriptionFactory tdf, AxisTestClientContextConfigurator[] configurators) throws Exception {
cfgCtx = ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
axisCfg.addTransportOut(trpOutDesc);
sender = trpOutDesc.getSender();
sender.init(cfgCtx, trpOutDesc);
boolean useListener = false;
for (AxisTestClientContextConfigurator configurator : configurators) {
if (configurator.isTransportListenerRequired()) {
useListener = true;
break;
}
}
TransportInDescription trpInDesc;
if (useListener) {
trpInDesc = tdf.createTransportInDescription();
} else {
trpInDesc = null;
}
for (AxisTestClientContextConfigurator configurator : configurators) {
configurator.setupTransport(trpInDesc, trpOutDesc);
}
if (useListener) {
listenerManager = new ListenerManager();
listenerManager.init(cfgCtx);
cfgCtx.setTransportManager(listenerManager);
listenerManager.addListener(trpInDesc, false);
listenerManager.start();
}
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class UDPTest method getClientCfgCtx.
public ConfigurationContext getClientCfgCtx() throws Exception {
ConfigurationContext cfgCtx = ConfigurationContextFactory.createConfigurationContext(new CustomAxisConfigurator());
AxisConfiguration axisCfg = cfgCtx.getAxisConfiguration();
axisCfg.engageModule("addressing");
TransportInDescription trpInDesc = new TransportInDescription("udp");
trpInDesc.setReceiver(new UDPListener());
axisCfg.addTransportIn(trpInDesc);
TransportOutDescription trpOutDesc = new TransportOutDescription("udp");
trpOutDesc.setSender(new UDPSender());
axisCfg.addTransportOut(trpOutDesc);
return cfgCtx;
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class XMPPPacketListener method createMessageContext.
/**
* Creates message context using values received in XMPP packet
* @param packet
* @return MessageContext
* @throws AxisFault
*/
private MessageContext createMessageContext(Packet packet) throws AxisFault {
Message message = (Message) packet;
Boolean isServerSide = (Boolean) message.getProperty(XMPPConstants.IS_SERVER_SIDE);
String serviceName = (String) message.getProperty(XMPPConstants.SERVICE_NAME);
String action = (String) message.getProperty(XMPPConstants.ACTION);
MessageContext msgContext = null;
TransportInDescription transportIn = configurationContext.getAxisConfiguration().getTransportIn("xmpp");
TransportOutDescription transportOut = configurationContext.getAxisConfiguration().getTransportOut("xmpp");
if ((transportIn != null) && (transportOut != null)) {
msgContext = configurationContext.createMessageContext();
msgContext.setTransportIn(transportIn);
msgContext.setTransportOut(transportOut);
if (isServerSide != null) {
msgContext.setServerSide(isServerSide.booleanValue());
}
msgContext.setProperty(CONTENT_TYPE, "text/xml");
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
msgContext.setIncomingTransportName("xmpp");
Map services = configurationContext.getAxisConfiguration().getServices();
AxisService axisService = (AxisService) services.get(serviceName);
msgContext.setAxisService(axisService);
msgContext.setSoapAction(action);
// pass the configurationFactory to transport sender
msgContext.setProperty("XMPPConfigurationFactory", this.xmppConnectionFactory);
if (packet.getFrom() != null) {
msgContext.setFrom(new EndpointReference(packet.getFrom()));
}
if (packet.getTo() != null) {
msgContext.setTo(new EndpointReference(packet.getTo()));
}
XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
xmppOutTransportInfo.setConnectionFactory(this.xmppConnectionFactory);
String packetFrom = packet.getFrom();
if (packetFrom != null) {
EndpointReference fromEPR = new EndpointReference(packetFrom);
xmppOutTransportInfo.setFrom(fromEPR);
xmppOutTransportInfo.setDestinationAccount(packetFrom);
}
// Save Message-Id to set as In-Reply-To on reply
String xmppMessageId = packet.getPacketID();
if (xmppMessageId != null) {
xmppOutTransportInfo.setInReplyTo(xmppMessageId);
}
xmppOutTransportInfo.setSequenceID((String) message.getProperty(XMPPConstants.SEQUENCE_ID));
msgContext.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO, xmppOutTransportInfo);
buildSOAPEnvelope(packet, msgContext);
} else {
throw new AxisFault("Either transport in or transport out is null");
}
return msgContext;
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class MailTransportSender method waitForReply.
private void waitForReply(MessageContext msgContext, String mailMessageID) throws AxisFault {
// message context in asnych model
if (!(msgContext.getAxisOperation() instanceof OutInAxisOperation) && (msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null)) {
return;
}
ConfigurationContext configContext = msgContext.getConfigurationContext();
// if the mail message listner has not started we need to start it
if (!configContext.getListenerManager().isListenerRunning(MailConstants.TRANSPORT_NAME)) {
TransportInDescription mailTo = configContext.getAxisConfiguration().getTransportIn(MailConstants.TRANSPORT_NAME);
if (mailTo == null) {
handleException("Could not find the transport receiver for " + MailConstants.TRANSPORT_NAME);
}
configContext.getListenerManager().addListener(mailTo, false);
}
SynchronousCallback synchronousCallback = new SynchronousCallback(msgContext);
Map callBackMap = (Map) msgContext.getConfigurationContext().getProperty(BaseConstants.CALLBACK_TABLE);
callBackMap.put(mailMessageID, synchronousCallback);
synchronized (synchronousCallback) {
try {
synchronousCallback.wait(msgContext.getOptions().getTimeOutInMilliSeconds());
} catch (InterruptedException e) {
handleException("Error occured while waiting ..", e);
}
}
if (!synchronousCallback.isComplete()) {
// when timeout occurs remove this entry.
callBackMap.remove(mailMessageID);
handleException("Timeout while waiting for a response");
}
}
use of org.apache.axis2.description.TransportInDescription in project wso2-axis2-transports by wso2.
the class AbstractTransportListener method init.
/**
* Initialize the generic transport. Sets up the transport and the thread pool to be used
* for message processing. Also creates an AxisObserver that gets notified of service
* life cycle events for the transport to act on
* @param cfgCtx the axis configuration context
* @param transportIn the transport-in description
* @throws AxisFault on error
*/
public void init(ConfigurationContext cfgCtx, TransportInDescription transportIn) throws AxisFault {
this.cfgCtx = cfgCtx;
this.transportIn = transportIn;
this.transportOut = cfgCtx.getAxisConfiguration().getTransportOut(getTransportName());
this.config = TransportConfiguration.getConfiguration(getTransportName());
if (useAxis2ThreadPool) {
// this.workerPool = cfgCtx.getThreadPool(); not yet implemented
throw new AxisFault("Unsupported thread pool for task execution - Axis2 thread pool");
} else {
if (this.workerPool == null) {
// FIXME <-- workaround for AXIS2-4552
this.workerPool = WorkerPoolFactory.getWorkerPool(config.getServerCoreThreads(), config.getServerMaxThreads(), config.getServerKeepalive(), config.getServerQueueLen(), getTransportName() + "Server Worker thread group", getTransportName() + "-Worker");
}
}
// register to receive updates on services for lifetime management
serviceTracker = new AxisServiceTracker(cfgCtx.getAxisConfiguration(), new AxisServiceFilter() {
public boolean matches(AxisService service) {
return // these are "private" services
!service.getName().startsWith("__") && BaseUtils.isUsingTransport(service, getTransportName());
}
}, new AxisServiceTrackerListener() {
public void serviceAdded(AxisService service) {
internalStartListeningForService(service);
}
public void serviceRemoved(AxisService service) {
internalStopListeningForService(service);
}
});
// register with JMX
if (mbeanSupport == null) {
// FIXME <-- workaround for AXIS2-4552
mbeanSupport = new TransportMBeanSupport(this, getTransportName());
mbeanSupport.register();
}
}
Aggregations