Java7 Wish: Object/Bean Factory

Friday, May 9, 2008 3:02
Posted in category Notes




One of the most critic point for java


return Class.forName(className).newInstance();

Upon since it seems this method bring the ultimate extensibility power to java.

But Now server & client applications became more and more complicated this feature became insufficient.


Today lots of projects try to solve this problem on their own. But one single interface would solve lots of this problems and make it easy to integrate these API’s easily. another point this would bring Factory Pattern info J2SDK


public interface ObjectFactory{

public Object getInstance(objectName);

}

some example implantations:

http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/beans/factory/BeanFactory.html
http://www.opensymphony.com/xwork/api/com/opensymphony/xwork/class-use/ObjectFactory.html
http://hivemind.apache.org/hivemind1/hivemind-lib/apidocs/org/apache/hivemind/lib/BeanFactory.html

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • Wists
  • Technorati
  • YahooMyWeb
  • Furl
  • Slashdot
  • Google Bookmarks
  • Reddit
  • TwitThis
  • StumbleUpon
  • E-mail this story to a friend!

Related posts:

  1. who needs implementations?
  2. Spring is totally losing its invisibility
  3. Object Model vs Database Schema Design
  4. Are you clearing your cache manually ?
  5. Runtime Java Stack

You can leave a response, or trackback from your own site.
Tags: ,

5 Responses to “Java7 Wish: Object/Bean Factory”

  1. peter lawrey says:

    May 9th, 2008 at 4:17 pm

    I use the following interface which is fairly extensible.

    interface Factory<D, E> {
    public E acquire(D description);
    }

    So you could have a Factory<String, Socket> or Factory<Map<String, Object>, DataValue>

  2. Laird Nelson says:

    May 12th, 2008 at 9:09 am

    final Object o = java.beans.Beans.instantiate(someClassLoader, “fargBarg”);

    Or:

    final Object o = someJNDIContext.lookup(”fargBarg”);

    (Have a look at http://java.sun.com/products/jndi/tutorial/objects/factory/index.html in conjunction with this.)

    Or:

    final Iterator allInstances = java.util.ServiceLoader.load(someInterface).iterator();

  3. RogerV says:

    December 23rd, 2008 at 5:39 pm

    I’ve build a bean factory DSL and library approach to solving this for Java. Let me know what you think:

    is JFig language syntax efficient and clear (and better than Spring-Framework’s XML DSL)?
    http://stackoverflow.com/questions/384890/is-jfig-language-syntax-efficient-and-clear-and-better-than-spring-frameworks-x

    JFig™ – alternative metadata config language for Spring
    http://dobbscodetalk.com/index.php?option=com_content&task=view&id=922&Itemid=85

  4. altuure says:

    December 23rd, 2008 at 5:53 pm

    very interesting notation and project indeed , wish you good luck
    but I have some serious question:
    XML is invented and and used to get rid of this type configuration, isn’t it ?

  5. RogerV says:

    December 24th, 2008 at 5:35 am

    There’s a rebellion underway regards XML. JSON has rapidly supplanted it on the web in general for AJAX purposes.

    Spring started supporting alternative config langugages due to user demand and the general distaste of XML (which was tending to be counter Spring’s argument that it is an antidote to J2EE and EJB – as that was all steeped in myriad XML config files).

    Here’s Terrence Parr’s take on the subject matter:

    Humans should not have to grok XML
    (Answers to the question “When shouldn’t you use XML?”)
    http://www.ibm.com/developerworks/xml/library/x-sbxml.html

    Then finally, contrast these two files in respect to the application.properties include and the first two bean descriptors:

    http://vossnet.org/applicationContext.xml

    http://vossnet.org/applicationContext.jfig.html

    The old-style Spring XML version is very verbose.

Leave a Reply