net.sf.implessbean
Class BeanFactory

java.lang.Object
  extended bynet.sf.implessbean.BeanFactory

public class BeanFactory
extends java.lang.Object

Factory class to create a JavaBeans proxy that converts setter/getter access to it to get/set method invocation of a Map specified.

This class creates a proxy instance that behave as an instance of a class which implements specified interfaces. Invocations of the accessor method of the proxy instance result in get()/set() method invocations of a Map instance. So you don't have to implement accessor method, just define an interface.

If you have:

 public interface Customer {
	String getName();
	void setName(String name);
	int getId();
	void setId(int id);
 }
 

Then you can write as:

 Customer customer = (Customer) BeanFactory.newBeanInstance(Customer.class);
 customer.setId(10);
 customer.setName("Kohji Nakamura");
 int id = customer.getId();
 String name = customer.getName();
 

This factory provides some factory methods to create a proxy instance and you can use any of them.

Since:
1.0
Version:
$Revision: 1.2 $
Author:
Kohji Nakamura

Field Summary
static KeyMapper CAPITAL_STRING_MAPPER
           
static KeyMapper STRING_MAPPER
           
 
Constructor Summary
BeanFactory()
           
 
Method Summary
static java.lang.Object newBeanInstance(java.lang.Class ifClass)
          Returns a proxy instance that implements the interface specified by ifClass.
static java.lang.Object newBeanInstance(java.lang.Class[] ifClasses, KeyMapper keyMapper, java.util.Map values)
          Returns a proxy instance that implements the interfaces specified by ifClasses.
static java.lang.Object newBeanInstance(java.lang.Class ifClass, KeyMapper keyMapper)
          Returns a proxy instance that implements the interface specified by ifClass.
static java.lang.Object newBeanInstance(java.lang.Class ifClass, KeyMapper keyMapper, java.util.Map values)
          Returns a proxy instance that implements the interface specified by ifClass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_MAPPER

public static final KeyMapper STRING_MAPPER
See Also:
StringKeyMapper

CAPITAL_STRING_MAPPER

public static final KeyMapper CAPITAL_STRING_MAPPER
See Also:
CapitalStringKeyMapper
Constructor Detail

BeanFactory

public BeanFactory()
Method Detail

newBeanInstance

public static java.lang.Object newBeanInstance(java.lang.Class ifClass)
Returns a proxy instance that implements the interface specified by ifClass. STRING_MAPPER is used as a default key mapper.

Parameters:
ifClass - A class object of an interface or a class.
Returns:
A proxy instance which implements ifClass. The proxy also implements IBaseBean
Since:
1.0
See Also:
IBaseBean

newBeanInstance

public static java.lang.Object newBeanInstance(java.lang.Class ifClass,
                                               KeyMapper keyMapper)
Returns a proxy instance that implements the interface specified by ifClass.

Parameters:
ifClass - A class object of an interface or a class.
keyMapper - a KeyMapper object. See KeyMapper.
Returns:
A proxy instance which implements ifClass. The proxy also implements IBaseBean
Since:
1.0
See Also:
IBaseBean

newBeanInstance

public static java.lang.Object newBeanInstance(java.lang.Class ifClass,
                                               KeyMapper keyMapper,
                                               java.util.Map values)
Returns a proxy instance that implements the interface specified by ifClass. Object.equals(Object obj) method invocations are delegated to the `values' object.

Parameters:
ifClass - A class object of an interface or a class.
keyMapper - a KeyMapper object. See KeyMapper.
values - A value container for the proxy instance returned by this method. Changing `values' affects the proxy, vice versa, even after the proxy creation because the `values' parameter would not be copied.
Returns:
A proxy instance which implements ifClass. The proxy also implements IBaseBean
Since:
1.0
See Also:
IBaseBean

newBeanInstance

public static java.lang.Object newBeanInstance(java.lang.Class[] ifClasses,
                                               KeyMapper keyMapper,
                                               java.util.Map values)
Returns a proxy instance that implements the interfaces specified by ifClasses. Object.equals(Object obj) method invocations are delegated to the `values' object.

Parameters:
ifClasses - Class objects of interfaces or a classes.
keyMapper - a KeyMapper object. See KeyMapper.
values - A value container for the proxy instance returned by this method. Changing `values' affects the proxy, vice versa, even after the proxy creation because the `values' parameter would not be copied.
Returns:
A proxy instance which implements ifClass. The proxy also implements IBaseBean
Since:
1.0
See Also:
IBaseBean

Copyright (C) 2004 Kohji Nakamura. All rights reserved.