[servicemix-user] XmlWebApplicationContext

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

[servicemix-user] XmlWebApplicationContext

Craig Walls

As I mentioned in a 10/31 e-mail, I think that the
org.servicemix.jbi.config.XmlWebApplicationContext class, as it exists in
2.0, is useless. That's because it doesn't do anything to load the context
using org.servicemix.jbi.config.spring.XBeanProcessor. Thus, the
ServiceMix-specific tags won't work if my container is part of a web

With the other ServiceMix-specific versions of the Spring application
contexts, I get to specify an XBeanProcessor when I load the context. But
in the case of XmlWebApplicationContext, I don't load the context
directly. Instead it is loaded by DispatcherServlet and I can't tell it to
use XBean.

To fix this, I've created a custom XmlWebApplicationContext that
subclasses the XBean class of the same name instead of the Spring version.
In its default constructor it makes the appropriate call to super() to set
the XBeanProcessor. Here's what I've got:

package org.servicemix.jbi.config;

import java.util.Arrays;
import org.servicemix.jbi.config.spring.XBeanProcessor;

public class XmlWebApplicationContext
    extends org.xbean.spring.context.XmlWebApplicationContext {

  public XmlWebApplicationContext() {
    super(Arrays.asList(new Object[] {new XBeanProcessor()}));

I offer this as a replacement for the current
org.servicemix.jbi.config.XmlWebApplicationContext and hope it (or some
equivalent) makes it into a maintenance release for ServiceMix 2.0, so
that I won't have to carry my own custom version around in my own code.