use of org.apache.openejb.jee.HandlerChain$JAXB.writeHandlerChain in project tomee by apache.
the class ConfigurationFactory method toHandlerChainInfo.
public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
final List<HandlerChainInfo> handlerChains = new ArrayList<HandlerChainInfo>();
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.jee.HandlerChain$JAXB.writeHandlerChain in project tomee by apache.
the class HandlerChains$JAXB method _read.
public static final HandlerChains _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final HandlerChains handlerChains = new HandlerChains();
context.beforeUnmarshal(handlerChains, LifecycleCallback.NONE);
List<HandlerChain> handlerChain = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("handler-chainsType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, HandlerChains.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, handlerChains);
handlerChains.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("handler-chain" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: handlerChain
final HandlerChain handlerChainItem = readHandlerChain(elementReader, context);
if (handlerChain == null) {
handlerChain = handlerChains.handlerChain;
if (handlerChain != null) {
handlerChain.clear();
} else {
handlerChain = new ArrayList<HandlerChain>();
}
}
handlerChain.add(handlerChainItem);
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "handler-chain"));
}
}
if (handlerChain != null) {
handlerChains.handlerChain = handlerChain;
}
context.afterUnmarshal(handlerChains, LifecycleCallback.NONE);
return handlerChains;
}
use of org.apache.openejb.jee.HandlerChain$JAXB.writeHandlerChain in project tomee by apache.
the class HandlerChains$JAXB method _write.
public static final void _write(final XoXMLStreamWriter writer, final HandlerChains handlerChains, RuntimeContext context) throws Exception {
if (handlerChains == null) {
writer.writeXsiNil();
return;
}
if (context == null) {
context = new RuntimeContext();
}
if (HandlerChains.class != handlerChains.getClass()) {
context.unexpectedSubclass(writer, handlerChains, HandlerChains.class);
return;
}
context.beforeMarshal(handlerChains, LifecycleCallback.NONE);
// ATTRIBUTE: id
final String idRaw = handlerChains.id;
if (idRaw != null) {
String id = null;
try {
id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
} catch (final Exception e) {
context.xmlAdapterError(handlerChains, "id", CollapsedStringAdapter.class, String.class, String.class, e);
}
writer.writeAttribute("", "", "id", id);
}
// ELEMENT: handlerChain
final List<HandlerChain> handlerChain = handlerChains.handlerChain;
if (handlerChain != null) {
for (final HandlerChain handlerChainItem : handlerChain) {
if (handlerChainItem != null) {
writer.writeStartElementWithAutoPrefix("http://java.sun.com/xml/ns/javaee", "handler-chain");
writeHandlerChain(writer, handlerChainItem, context);
writer.writeEndElement();
}
}
}
context.afterMarshal(handlerChains, LifecycleCallback.NONE);
}
use of org.apache.openejb.jee.HandlerChain$JAXB.writeHandlerChain in project tomee by apache.
the class FinderFactory method ensureMinimalClasses.
public static Class<?>[] ensureMinimalClasses(final DeploymentModule module) {
final Collection<Class<?>> finderClasses = new HashSet<>();
if (EjbModule.class.isInstance(module)) {
final EjbModule ejb = EjbModule.class.cast(module);
final EnterpriseBean[] enterpriseBeans = ejb.getEjbJar().getEnterpriseBeans();
ClassLoader classLoader = ejb.getClassLoader();
if (classLoader == null) {
classLoader = Thread.currentThread().getContextClassLoader();
}
for (final EnterpriseBean bean : enterpriseBeans) {
final String name;
if (SessionBean.class.isInstance(bean)) {
final SessionBean sessionBean = SessionBean.class.cast(bean);
if (sessionBean.getProxy() == null) {
name = sessionBean.getEjbClass();
} else {
name = sessionBean.getProxy();
}
} else {
name = bean.getEjbClass();
}
try {
final Class<?> clazz = classLoader.loadClass(name);
finderClasses.addAll(ancestors(clazz));
} catch (final ClassNotFoundException e) {
// no-op
}
}
if (ejb.getWebservices() != null) {
for (final WebserviceDescription webservice : ejb.getWebservices().getWebserviceDescription()) {
for (final PortComponent port : webservice.getPortComponent()) {
if (port.getHandlerChains() == null) {
continue;
}
for (final HandlerChain handlerChain : port.getHandlerChains().getHandlerChain()) {
for (final Handler handler : handlerChain.getHandler()) {
if (handler.getHandlerClass() != null) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(handler.getHandlerClass())));
} catch (final ClassNotFoundException e) {
// no-op
}
}
}
}
}
}
}
for (final org.apache.openejb.jee.Interceptor interceptor : ejb.getEjbJar().getInterceptors()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(interceptor.getInterceptorClass())));
} catch (final ClassNotFoundException e) {
// no-op
}
}
final Beans beans = ejb.getBeans();
if (beans != null && ejb.getEjbJar() != null) {
for (final List<String> managedClasses : beans.getManagedClasses().values()) {
for (final String name : managedClasses) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(name)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
}
for (final String name : beans.getInterceptors()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(name)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
for (final String name : beans.getAlternativeClasses()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(name)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
for (final String name : beans.getDecorators()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(name)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
}
} else if (WebModule.class.isInstance(module)) {
final WebModule web = WebModule.class.cast(module);
final ClassLoader classLoader = web.getClassLoader();
if (web.getWebApp() != null) {
for (final Servlet s : web.getWebApp().getServlet()) {
final String servletClass = s.getServletClass();
if (servletClass == null) {
continue;
}
try {
finderClasses.addAll(ancestors(classLoader.loadClass(servletClass)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
for (final String s : web.getRestClasses()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(s)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
for (final String s : web.getEjbWebServices()) {
try {
finderClasses.addAll(ancestors(classLoader.loadClass(s)));
} catch (final ClassNotFoundException e) {
// no-op
}
}
}
}
return finderClasses.toArray(new Class<?>[finderClasses.size()]);
}
Aggregations