Announcement Announcement Module
Collapse
No announcement yet.
How to configure for multiple products? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to configure for multiple products?

    We have multiple products. For simplicity, let's call them an orders system ("orders") and a billing system ("billing"). Customers may buy 1 or more of our products. No product must require another product to exist in order to function but the products are built such that if another of our products exist, the products will use the other. For example, if orders sees that there is a billing system (i.e. has a non-null billing services injected into it), each order will create a bill. Likewise, if the billing system sees that there is an orders system, non-payment will cause the cancellation of outstanding orders.

    Each product is packaged as an ear but, if needed, I can merge them into one master ear containing each of the purchased product wars. Target platforms are Websphere 6.1 to start with JBoss and others in the future.

    How to configure this in Spring? What I think I want is one global, singleton context where all definitions are merged. That way, I can inject (or look up if needed) orders sevices into billing services and vise versa. This would also allow me to share some common configuration. The trick is how to set this up?

    I have a ContextLoaderListener for each war but I can't include the other products applicationContext files because the other products may or may not have been purchased.

    As seen above, the products forms cycles, so I can't load one product as the parent of another.

    I've tried using "parentContextKey" off of each ContextLoaderListener but all I get is a shared parent context with two child product contexts that can't see each other. I've also looked at defining a beanRefFactory.xml for each war but I still only get multiple child product contexts that can't see each other.

  • #2
    I managed to make the singleton context work but I wanted to ask to see if I've caused myself other problems. I did:

    Code:
    public class SingletonXmlWebApplicationContext extends XmlWebApplicationContext {
    
    	@Override
    	protected DefaultListableBeanFactory createBeanFactory() {
    		BeanFactory bf = getInternalParentBeanFactory();
    		return (bf == null) ? new DefaultListableBeanFactory(null) : (DefaultListableBeanFactory)bf;
    	}
    }
    with
    Code:
    <context-param>
    	<param-name>contextClass</param-name>
    	<param-value>SingletonXmlWebApplicationContext</param-value>
    </context-param>
    Which causes all child contexts to reuse the parent's bean factory. Is there a better way?

    Comment


    • #3
      Just as a warning to others reading this, I've had to remove this. It causes the bean post processors to run multiple times (due to refresh() at the end of context loading). I ended up having 8 levels of transactional proxies around some of the services.

      Comment

      Working...
      X