1 50 package org.apache.avalon.excalibur.pool; 51 52 import java.lang.reflect.Constructor ; 53 54 65 public class DefaultObjectFactory 66 implements ObjectFactory 67 { 68 protected Constructor m_constructor; 69 protected Object [] m_arguements; 70 71 public DefaultObjectFactory( final Constructor constructor, final Object [] arguements ) 72 { 73 m_arguements = arguements; 74 m_constructor = constructor; 75 } 76 77 public DefaultObjectFactory( final Class clazz, 78 final Class [] arguementClasses, 79 final Object [] arguements ) 80 throws NoSuchMethodException 81 { 82 this( clazz.getConstructor( arguementClasses ), arguements ); 83 } 84 85 public DefaultObjectFactory( final Class clazz ) 86 throws NoSuchMethodException 87 { 88 this( clazz, null, null ); 89 } 90 91 public Class getCreatedClass() 92 { 93 return m_constructor.getDeclaringClass(); 94 } 95 96 public Object newInstance() 97 { 98 try 99 { 100 return (Poolable)m_constructor.newInstance( m_arguements ); 101 } 102 catch( final Exception e ) 103 { 104 throw new Error ( "Failed to instantiate the class " + 105 m_constructor.getDeclaringClass().getName() + " due to " + e ); 106 } 107 } 108 109 public void decommission( final Object object ) 110 { 111 } 113 } 114 | Popular Tags |