use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class AxisTestEndpointContext method setUp.
@Setup
@SuppressWarnings("unused")
private void setUp(TransportDescriptionFactory tdf, AxisTestEndpointContextConfigurator[] configurators) throws Exception {
server = new UtilsTransportServer();
TransportOutDescription trpOutDesc = tdf.createTransportOutDescription();
trpInDesc = tdf.createTransportInDescription();
server.addTransport(trpInDesc, trpOutDesc);
for (AxisTestEndpointContextConfigurator configurator : configurators) {
configurator.setupTransport(trpInDesc, trpOutDesc);
}
ConfigurationContext cfgCtx = server.getConfigurationContext();
cfgCtx.setContextRoot("/");
cfgCtx.setServicePath("services");
AxisConfiguration axisConfiguration = server.getAxisConfiguration();
server.start();
}
use of org.apache.axis2.description.TransportOutDescription 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.TransportOutDescription in project wso2-axis2-transports by wso2.
the class XMPPSender method init.
/**
* Initialize the transport sender by reading pre-defined connection factories for
* outgoing messages. These will create sessions (one per each destination dealt with)
* to be used when messages are being sent.
* @param confContext the configuration context
* @param transportOut the transport sender definition from axis2.xml
* @throws AxisFault on error
*/
public void init(ConfigurationContext confContext, TransportOutDescription transportOut) throws AxisFault {
// if connection details are available from axis configuration
// use those & connect to jabber server(s)
serverCredentials = new XMPPServerCredentials();
getConnectionDetailsFromAxisConfiguration(transportOut);
defaultConnectionFactory = new XMPPConnectionFactory();
}
use of org.apache.axis2.description.TransportOutDescription 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.TransportOutDescription in project wso2-axis2-transports by wso2.
the class RabbitMQSender method init.
/**
* Initialize the transport sender by reading pre-defined connection factories for
* outgoing messages.
*
* @param cfgCtx the configuration context
* @param transportOut the transport sender definition from axis2.xml
* @throws AxisFault on error
*/
@Override
public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
try {
super.init(cfgCtx, transportOut);
SecretResolver secretResolver = cfgCtx.getAxisConfiguration().getSecretResolver();
// initialize connection factory and pool
rabbitMQConnectionFactory = new RabbitMQConnectionFactory();
int poolSize = RabbitMQUtils.resolveTransportDescription(transportOut, secretResolver, rabbitMQConnectionFactory);
RabbitMQConnectionPool rabbitMQConnectionPool = new RabbitMQConnectionPool(rabbitMQConnectionFactory, poolSize);
// initialize channel factory and pool
RabbitMQChannelFactory rabbitMQChannelFactory = new RabbitMQChannelFactory(rabbitMQConnectionPool);
rabbitMQChannelPool = new RabbitMQChannelPool(rabbitMQChannelFactory, poolSize);
// initialize confirm channel factory and pool
RabbitMQConfirmChannelFactory rabbitMQConfirmChannelFactory = new RabbitMQConfirmChannelFactory(rabbitMQConnectionPool);
rabbitMQConfirmChannelPool = new RabbitMQChannelPool(rabbitMQConfirmChannelFactory, poolSize);
log.info("RabbitMQ AMQP Transport Sender initialized...");
} catch (AxisRabbitMQException e) {
throw new AxisFault("Error occurred while initializing the RabbitMQ AMQP Transport Sender.", e);
}
}
Aggregations