use of org.apache.openejb.jee.HandlerChains 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.jee.HandlerChains in project tomee by apache.
the class ServiceRef$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final ServiceRef serviceRef, RuntimeContext context) throws Exception {
if (serviceRef == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
if (ServiceRef.class != serviceRef.getClass()) {
context.unexpectedSubclass(writer, serviceRef, ServiceRef.class);
return;
}
context.beforeMarshal(serviceRef, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = serviceRef.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: descriptions
Text[] descriptions = null;
try {
descriptions = serviceRef.getDescriptions();
} catch (final Exception e) {
context.getterError(serviceRef, "descriptions", ServiceRef.class, "getDescriptions", e);
}
if (descriptions != null) {
for (final Text descriptionsItem : descriptions) {
if (descriptionsItem != null) {
writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
writeText(writer, descriptionsItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "descriptions");
}
}
}
// ELEMENT: displayNames
Text[] displayNames = null;
try {
displayNames = serviceRef.getDisplayNames();
} catch (final Exception e) {
context.getterError(serviceRef, "displayNames", ServiceRef.class, "getDisplayNames", e);
}
if (displayNames != null) {
for (final Text displayNamesItem : displayNames) {
if (displayNamesItem != null) {
writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
writeText(writer, displayNamesItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "displayNames");
}
}
}
// ELEMENT: icon
final LocalCollection<Icon> icon = serviceRef.icon;
if (icon != null) {
for (final Icon iconItem : icon) {
if (iconItem != null) {
writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
writeIcon(writer, iconItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "icon");
}
}
}
// ELEMENT: serviceRefName
final String serviceRefNameRaw = serviceRef.serviceRefName;
String serviceRefName = null;
try {
serviceRefName = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "serviceRefName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (serviceRefName != null) {
writer.writeStartElement(prefix, "service-ref-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(serviceRefName);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "serviceRefName");
}
// ELEMENT: serviceInterface
final String serviceInterfaceRaw = serviceRef.serviceInterface;
String serviceInterface = null;
try {
serviceInterface = Adapters.collapsedStringAdapterAdapter.marshal(serviceInterfaceRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "serviceInterface", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (serviceInterface != null) {
writer.writeStartElement(prefix, "service-interface", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(serviceInterface);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "serviceInterface");
}
// ELEMENT: serviceRefType
final String serviceRefTypeRaw = serviceRef.serviceRefType;
String serviceRefType = null;
try {
serviceRefType = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "serviceRefType", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (serviceRefType != null) {
writer.writeStartElement(prefix, "service-ref-type", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(serviceRefType);
writer.writeEndElement();
}
// ELEMENT: wsdlFile
final String wsdlFileRaw = serviceRef.wsdlFile;
String wsdlFile = null;
try {
wsdlFile = Adapters.collapsedStringAdapterAdapter.marshal(wsdlFileRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "wsdlFile", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (wsdlFile != null) {
writer.writeStartElement(prefix, "wsdl-file", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(wsdlFile);
writer.writeEndElement();
}
// ELEMENT: jaxrpcMappingFile
final String jaxrpcMappingFileRaw = serviceRef.jaxrpcMappingFile;
String jaxrpcMappingFile = null;
try {
jaxrpcMappingFile = Adapters.collapsedStringAdapterAdapter.marshal(jaxrpcMappingFileRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "jaxrpcMappingFile", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (jaxrpcMappingFile != null) {
writer.writeStartElement(prefix, "jaxrpc-mapping-file", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(jaxrpcMappingFile);
writer.writeEndElement();
}
// ELEMENT: serviceQname
final QName serviceQname = serviceRef.serviceQname;
if (serviceQname != null) {
writer.writeStartElement(prefix, "service-qname", "http://java.sun.com/xml/ns/javaee");
writer.writeQName(serviceQname);
writer.writeEndElement();
}
// ELEMENT: portComponentRef
final List<PortComponentRef> portComponentRef = serviceRef.portComponentRef;
if (portComponentRef != null) {
for (final PortComponentRef portComponentRefItem : portComponentRef) {
if (portComponentRefItem != null) {
writer.writeStartElement(prefix, "port-component-ref", "http://java.sun.com/xml/ns/javaee");
writePortComponentRef(writer, portComponentRefItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "portComponentRef");
}
}
}
// ELEMENT: handler
final List<Handler> handler = serviceRef.handler;
if (handler != null) {
for (final Handler handlerItem : handler) {
if (handlerItem != null) {
writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
writeHandler(writer, handlerItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "handler");
}
}
}
// ELEMENT: handlerChains
final HandlerChains handlerChains = serviceRef.handlerChains;
if (handlerChains != null) {
writer.writeStartElement(prefix, "handler-chains", "http://java.sun.com/xml/ns/javaee");
writeHandlerChains(writer, handlerChains, context);
writer.writeEndElement();
}
// ELEMENT: mappedName
final String mappedNameRaw = serviceRef.mappedName;
String mappedName = null;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (mappedName != null) {
writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(mappedName);
writer.writeEndElement();
}
// ELEMENT: injectionTarget
final Set<InjectionTarget> injectionTarget = serviceRef.injectionTarget;
if (injectionTarget != null) {
for (final InjectionTarget injectionTargetItem : injectionTarget) {
if (injectionTargetItem != null) {
writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
writeInjectionTarget(writer, injectionTargetItem, context);
writer.writeEndElement();
} else {
context.unexpectedNullValue(serviceRef, "injectionTarget");
}
}
}
// ELEMENT: lookupName
final String lookupNameRaw = serviceRef.lookupName;
String lookupName = null;
try {
lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(serviceRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
}
if (lookupName != null) {
writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
writer.writeCharacters(lookupName);
writer.writeEndElement();
}
context.afterMarshal(serviceRef, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.HandlerChains 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());
}
use of org.apache.openejb.jee.HandlerChains in project tomee by apache.
the class HandlerResolverImplTest method testBindingMatching.
public void testBindingMatching() throws Exception {
final HandlerChains handlerChains = readHandlerChains("/handlers_bindings.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());
handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP12_HTTP", null, null));
assertEquals(0, handlers.size());
handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));
assertEquals(2, handlers.size());
handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP_MTOM", null, null));
assertEquals(1, handlers.size());
}
use of org.apache.openejb.jee.HandlerChains in project tomee by apache.
the class HandlerResolverImplTest method testMixedMatching.
public void testMixedMatching() throws Exception {
final HandlerChains handlerChains = readHandlerChains("/handlers_mixed.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");
final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
final String binding1 = "##XML_HTTP";
handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName1, serviceName1));
assertEquals(3, handlers.size());
final String binding2 = "##SOAP11_HTTP";
handlers = resolver.getHandlerChain(new TestPortInfo(binding2, portName1, serviceName1));
assertEquals(2, handlers.size());
final QName serviceName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName2, serviceName2));
assertEquals(1, handlers.size());
}
Aggregations