use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.
the class HandlerResolverImplTest method testBasic.
public void testBasic() throws Exception {
final HandlerChains handlerChains = readHandlerChains("/handlers.xml");
assertEquals(3, handlerChains.getHandlerChain().size());
final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
List<Handler> handlers = null;
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
assertEquals(3, handlers.size());
}
use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.
the class HandlerResolverImplTest method testServiceMatching.
public void testServiceMatching() throws Exception {
final HandlerChains handlerChains = readHandlerChains("/handlers_service.xml");
assertEquals(3, handlerChains.getHandlerChain().size());
final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
List<Handler> handlers = null;
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
assertEquals(0, handlers.size());
final QName serviceName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName1));
assertEquals(1, handlers.size());
final QName serviceName2 = new QName("http://java.sun.com/xml/ns/javaee", "Foo");
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName2));
assertEquals(2, handlers.size());
final QName serviceName3 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName3));
assertEquals(1, handlers.size());
final QName serviceName4 = new QName("http://java.sun.com/xml/ns/javaee", "BarFoo");
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName4));
assertEquals(0, handlers.size());
}
use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.
the class AppInfoBuilder method configureWebservices.
private List<PortInfo> configureWebservices(final Webservices webservices) {
final List<PortInfo> portMap = new ArrayList<>();
if (webservices == null) {
return portMap;
}
for (final WebserviceDescription desc : webservices.getWebserviceDescription()) {
final String wsdlFile = desc.getWsdlFile();
final String serviceName = desc.getWebserviceDescriptionName();
for (final PortComponent port : desc.getPortComponent()) {
final PortInfo portInfo = new PortInfo();
final ServiceImplBean serviceImplBean = port.getServiceImplBean();
portInfo.serviceId = desc.getId();
portInfo.portId = port.getId();
portInfo.serviceLink = serviceImplBean.getEjbLink();
if (portInfo.serviceLink == null) {
portInfo.serviceLink = serviceImplBean.getServletLink();
}
portInfo.seiInterfaceName = port.getServiceEndpointInterface();
portInfo.portName = port.getPortComponentName();
portInfo.binding = port.getProtocolBinding();
portInfo.serviceName = serviceName;
portInfo.wsdlFile = wsdlFile;
portInfo.mtomEnabled = port.isEnableMtom();
portInfo.wsdlPort = port.getWsdlPort();
portInfo.wsdlService = port.getWsdlService();
portInfo.location = port.getLocation();
final List<HandlerChainInfo> handlerChains = ConfigurationFactory.toHandlerChainInfo(port.getHandlerChains());
portInfo.handlerChains.addAll(handlerChains);
// todo configure jaxrpc mappings here
portMap.add(portInfo);
}
}
return portMap;
}
use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.
the class ConfigurationFactory method toHandlerChainInfo.
public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
final List<HandlerChainInfo> handlerChains = new ArrayList<>();
if (chains == null) {
return handlerChains;
}
for (final HandlerChain handlerChain : chains.getHandlerChain()) {
final HandlerChainInfo handlerChainInfo = new HandlerChainInfo();
handlerChainInfo.serviceNamePattern = handlerChain.getServiceNamePattern();
handlerChainInfo.portNamePattern = handlerChain.getPortNamePattern();
handlerChainInfo.protocolBindings.addAll(handlerChain.getProtocolBindings());
for (final Handler handler : handlerChain.getHandler()) {
final HandlerInfo handlerInfo = new HandlerInfo();
handlerInfo.handlerName = handler.getHandlerName();
handlerInfo.handlerClass = handler.getHandlerClass();
handlerInfo.soapHeaders.addAll(handler.getSoapHeader());
handlerInfo.soapRoles.addAll(handler.getSoapRole());
for (final ParamValue param : handler.getInitParam()) {
handlerInfo.initParams.setProperty(param.getParamName(), param.getParamValue());
}
handlerChainInfo.handlers.add(handlerInfo);
}
handlerChains.add(handlerChainInfo);
}
return handlerChains;
}
use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.
the class HandlerResolverImplTest method testPortMatching.
public void testPortMatching() throws Exception {
final HandlerChains handlerChains = readHandlerChains("/handlers_port.xml");
assertEquals(3, handlerChains.getHandlerChain().size());
final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
List<Handler> handlers = null;
handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
assertEquals(0, handlers.size());
final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
handlers = resolver.getHandlerChain(new TestPortInfo(null, portName1, null));
assertEquals(1, handlers.size());
final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Foo");
handlers = resolver.getHandlerChain(new TestPortInfo(null, portName2, null));
assertEquals(2, handlers.size());
final QName portName3 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
handlers = resolver.getHandlerChain(new TestPortInfo(null, portName3, null));
assertEquals(1, handlers.size());
final QName portName4 = new QName("http://java.sun.com/xml/ns/javaee", "BarFoo");
handlers = resolver.getHandlerChain(new TestPortInfo(null, portName4, null));
assertEquals(0, handlers.size());
}
Aggregations