The Artima Developer Community
Sponsored Link

Java Buzz Forum
Let's leak IoC/DI into standards. You miss them when they aren't there!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Let's leak IoC/DI into standards. You miss them when they aren't there! Posted: Oct 13, 2004 6:43 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Let's leak IoC/DI into standards. You miss them when they aren't there!
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
After working with a DI container such as Spring, Pico, or HiveMind, it is hard to look back. However, the real world means that you often can't just be playing in the sand box with your DI container. You have to talk to the big kids who don't play as nice. I run into this all of the time when working on a web application where I need to do something such as setup a <listener> You have to say in the web.xml: <listener> <listener-class>myproject.ContextLoaderListener</listener-class> </listener> Ok, so now I have got a listener, I may want it to do something. Chances are that I want it to talk to a service that I already have to do that thing. Fortunately, I can grab the context for the container and query for services that I want: public void contextDestroyed(ServletContextEvent event) { ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); CacheManager cm = (CacheManager) appContext.getBean("cacheManager"); cm.shutdown(); } This is OK. It is a lot better than having to have: CacheManager cm = new MyParticullarCacheManager(); However this isn't ideal. I would love to see DI leaking into standards. E.g seeing something in the web.xml like: <listener> <listener-class>myproject.ContextLoaderListener</listener-class> <property name="cacheManager">spring:cacheManager</property> </listener> It would be really cool to define prefixes such as spring, hivemind, pico, etc... which can tie to that particular container. Or, there could be another place where you plugin the container and the web.xml would go to those services to look up the cacheManager.

Read: Let's leak IoC/DI into standards. You miss them when they aren't there!

Topic: Mr. Publisher, I Want To Read Your Online Megazine. But... Previous Topic   Next Topic Topic: Steve Pavlina has a blog

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use