Java7 Wish: Object/Bean Factory
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
Related posts:



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>
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();
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
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 ?
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.