jicarilla-sandbox/platform/container/impl/src/java/org/jicarilla/container/factories AbstractFactory.java,NONE,1.1 BeanFactory.java,NONE,1.1 ManualFactory.java,NONE,1.1 Type1Factory.java,NONE,1.1 Type25Factory.java,NONE,1.1 Type2Factory.java,NONE,1.1 Type35Factory.java,NONE,1.1 Type3Factory.java,NONE,1.1 AbstractComponentFactory.java,1.9,NONE BeanComponentFactory.java,1.8,NONE ManualComponentFactory.java,1.4,NONE Type1ComponentFactory.java,1.8,NONE Type25ComponentFactory.java,1.9,NONE Type2ComponentFactory.java,1.8,NONE Type35ComponentFactory.java,1.8,NONE Type3ComponentFactory.java,1.8,NONE
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container/impl/src/java/org/jicarilla/container/factories
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16122/container/impl/src/java/org/jicarilla/container/factories
Added Files:
AbstractFactory.java BeanFactory.java ManualFactory.java
Type1Factory.java Type25Factory.java Type2Factory.java
Type35Factory.java Type3Factory.java
Removed Files:
AbstractComponentFactory.java BeanComponentFactory.java
ManualComponentFactory.java Type1ComponentFactory.java
Type25ComponentFactory.java Type2ComponentFactory.java
Type35ComponentFactory.java Type3ComponentFactory.java
Log Message:
Get rid of a bunch of "Component" parts in classnames. And probably some other misc. updates.
--- AbstractComponentFactory.java DELETED ---
--- Type3ComponentFactory.java DELETED ---
--- Type25ComponentFactory.java DELETED ---
--- Type2ComponentFactory.java DELETED ---
--- Type1ComponentFactory.java DELETED ---
--- NEW FILE: AbstractFactory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.CyclicDependencyException;
import org.jicarilla.container.Factory;
import org.jicarilla.container.JicarillaClassNotFoundException;
import org.jicarilla.container.JicarillaException;
import org.jicarilla.container.JicarillaIllegalAccessException;
import org.jicarilla.container.JicarillaInstantiationException;
import org.jicarilla.container.JicarillaInvocationTargetException;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.ReflectionUtil;
import org.jicarilla.framework.Assert;
import org.jicarilla.framework.LifecycleUtil;
import java.lang.reflect.InvocationTargetException;
/**
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: AbstractFactory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public abstract class AbstractFactory implements Factory
{
// ----------------------------------------------------------------------
// Properties
// ----------------------------------------------------------------------
protected final Resolver m_resolver;
protected final String m_className;
protected Class m_clazz;
protected boolean m_inTheProcessOfConstructingAnInstance = false;
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
public AbstractFactory( final Resolver resolver,
final String className )
{
Assert.assertNotNull( "resolver argument may not be null", resolver );
Assert.assertNotNull( "className argument may not be null", className );
m_resolver = resolver;
m_className = className;
}
// ----------------------------------------------------------------------
// Interface: Factory
// ----------------------------------------------------------------------
public Object newInstance()
{
lazyInitialization();
Object instance = null;
try
{
try
{
instance = doNewInstance();
}
catch( InstantiationException e )
{
throw new JicarillaInstantiationException( e );
}
catch( IllegalAccessException e )
{
throw new JicarillaIllegalAccessException( e );
}
catch( InvocationTargetException e )
{
throw new JicarillaInvocationTargetException( e );
}
}
catch( CyclicDependencyException cde )
{
handleCyclicDependencyException( cde );
}
finally
{
disableCyclicDependencyChecking();
}
initialize( instance );
return instance;
}
public void releaseInstance( final Object component ) throws Exception
{
doReleaseInstance( component );
}
protected void doReleaseInstance( final Object component ) throws Exception
{
dispose( component );
}
protected abstract Object doNewInstance() throws IllegalAccessException, InvocationTargetException, InstantiationException;
// ----------------------------------------------------------------------
// Getters/Setters
// ----------------------------------------------------------------------
protected Resolver getResolver()
{
return m_resolver;
}
protected String getClassName()
{
return m_className;
}
protected Class getClazz()
{
return m_clazz;
}
// ----------------------------------------------------------------------
// Helper Methods
// ----------------------------------------------------------------------
protected void enableCyclicDependencyChecking()
{
m_inTheProcessOfConstructingAnInstance = true;
}
protected void checkCyclicDependency( final Class[] parameterTypes )
{
if( m_inTheProcessOfConstructingAnInstance )
throw new CyclicDependencyException( parameterTypes );
}
protected void disableCyclicDependencyChecking()
{
m_inTheProcessOfConstructingAnInstance = false;
}
protected void handleCyclicDependencyException(
final CyclicDependencyException cde )
{
throw cde;
}
protected void lazyInitialization()
{
if( m_clazz == null )
try
{
m_clazz = ReflectionUtil.loadClass( getClassName() );
}
catch( ClassNotFoundException e )
{
throw new JicarillaClassNotFoundException( e );
}
}
protected void initialize( Object instance )
{
try
{
LifecycleUtil.initialize( instance );
}
catch( Throwable t )
{
throw new JicarillaInstantiationException( t );
}
}
protected void dispose( Object instance ) throws Exception
{
try
{
LifecycleUtil.dispose( instance );
}
catch( Throwable t )
{
if( t instanceof Exception )
throw (Exception)t;
if( t instanceof RuntimeException )
throw (RuntimeException)t;
if( t instanceof Error )
throw (Error)t;
throw new JicarillaException( t );
}
}
}
--- BeanComponentFactory.java DELETED ---
--- NEW FILE: Type2Factory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type2Util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* XWork semantics.
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: Type2Factory.java,v 1.3 2003/12/30 13:35:18 lsimons
* Exp $
*/
public class Type2Factory extends AbstractFactory
{
public Type2Factory( final Resolver resolver, final String className )
{
super( resolver, className );
}
protected Object doNewInstance()
throws IllegalAccessException, InstantiationException,
InvocationTargetException
{
final Object instance = super.getClazz().newInstance();
final Method[] methods = Type2Util.getAwarenessMethods( super.getClazz() );
Type2Util.checkDepencenciesAreSatisfiable(
super.getClazz(), methods, super.getResolver() );
final Class[] dependencyClasses = Type2Util.getType2DependencyClasses( methods );
super.checkCyclicDependency( dependencyClasses );
super.enableCyclicDependencyChecking();
Type2Util.callAwarenessMethods( instance, super.getResolver() );
return instance;
}
}
--- NEW FILE: Type1Factory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.apache.avalon.framework.container.ContainerUtil;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type1Util;
/**
* Avalon-Framework semantics.
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: Type1Factory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public class Type1Factory extends AbstractFactory
{
public Type1Factory( final Resolver resolver,
final String className )
{
super( resolver, className );
}
protected Object doNewInstance()
throws IllegalAccessException, InstantiationException
{
super.checkCyclicDependency( new Class[] { super.getClazz() } );
super.enableCyclicDependencyChecking();
final Object instance = super.getClazz().newInstance();
Type1Util.startAvalonLifecycle( instance, super.getResolver() );
return instance;
}
protected void doReleaseInstance( final Object o )
throws Exception
{
ContainerUtil.shutdown( o );
}
}
--- NEW FILE: BeanFactory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.Factory;
import org.jicarilla.container.JicarillaIllegalAccessException;
import org.jicarilla.container.JicarillaInstantiationException;
import org.jicarilla.container.JicarillaInvocationTargetException;
import org.jicarilla.container.NoPublicConstructorAvailableException;
import org.jicarilla.container.NoSatisfiableConstructorAvailableException;
import org.jicarilla.container.util.Type3Util;
import org.jicarilla.framework.Assert;
import org.jicarilla.framework.LifecycleUtil;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: BeanFactory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public class BeanFactory implements Factory
{
// ----------------------------------------------------------------------
// Properties
// ----------------------------------------------------------------------
protected final Class m_clazz;
protected final Map m_properties;
protected final List m_constructorParameters;
protected final BeanInfo m_beanInfo;
// ----------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------
public BeanFactory( final Class clazz )
throws IntrospectionException
{
this( clazz, null );
}
public BeanFactory( final Class clazz, final Map properties )
throws IntrospectionException
{
this( clazz, properties, null );
}
public BeanFactory( final Class clazz, final Map properties,
final List constructorParameters ) throws IntrospectionException
{
Assert.assertNotNull( "clazz argument may not be null", clazz );
m_clazz = clazz;
m_properties = properties;
m_constructorParameters = constructorParameters;
m_beanInfo = Introspector.getBeanInfo( clazz );
}
// ----------------------------------------------------------------------
// Interface: Factory
// ----------------------------------------------------------------------
public Object newInstance()
{
final Constructor constructor = getGreediestSatisfiableConstructor(
m_clazz, m_constructorParameters );
final Object instance;
if( m_constructorParameters != null )
{
try
{
instance =
constructor.newInstance( m_constructorParameters.toArray() );
}
catch( InstantiationException e )
{
throw new JicarillaInstantiationException( e );
}
catch( IllegalAccessException e )
{
throw new JicarillaIllegalAccessException( e );
}
catch( InvocationTargetException e )
{
throw new JicarillaInvocationTargetException( e );
}
}
else
{
try
{
instance = m_clazz.newInstance();
}
catch( InstantiationException e )
{
throw new JicarillaInstantiationException( e );
}
catch( IllegalAccessException e )
{
throw new JicarillaIllegalAccessException( e );
}
}
try
{
callSetterMethods( m_beanInfo, instance, m_properties );
}
catch( IllegalAccessException e )
{
throw new JicarillaIllegalAccessException( e );
}
catch( InvocationTargetException e )
{
throw new JicarillaInvocationTargetException( e );
}
try
{
LifecycleUtil.initialize( instance );
}
catch( Throwable t )
{
throw new JicarillaInstantiationException( t );
}
return instance;
}
public void releaseInstance( final Object o ) throws Exception
{
try
{
LifecycleUtil.dispose( o );
}
catch( Throwable t ) {}
}
// ----------------------------------------------------------------------
// Helper Methods
// ----------------------------------------------------------------------
public static void callSetterMethods( final BeanInfo beanInfo,
final Object instance, final Map properties )
throws IllegalAccessException, InvocationTargetException
{
if( properties == null )
return;
final PropertyDescriptor[] pd = beanInfo.getPropertyDescriptors();
for( int i = 0; i < pd.length; i++ )
{
final PropertyDescriptor descriptor = pd[i];
final String name = descriptor.getName();
if( !properties.containsKey( name ) )
continue;
final Method m = descriptor.getWriteMethod();
if( m == null )
continue;
final Object value = properties.get( name );
m.invoke( instance, new Object[] { value } );
}
}
public static Constructor getGreediestSatisfiableConstructor( final Class clazz,
final List constructorParameters )
{
// this is the picocontainer algorithm, modified
// to use specified parameters, and modified
// to return the parameters that were not used
Assert.assertNotNull( "clazz argument may not be null", clazz );
final Constructor[] constructors = clazz.getConstructors();
Type3Util.sortConstructorsByGreediness( constructors );
Constructor constructor = null;
if( constructorParameters == null )
{
try
{
constructor = clazz.getConstructor( new Class[0] );
}
catch( NoSuchMethodException e )
{
throw new NoPublicConstructorAvailableException( clazz );
}
}
else
{
final int size = constructorParameters.size();
for( int i = 0; i < constructors.length; i++ )
{
if( constructors[i].getParameterTypes().length == size)
{
constructor = constructors[i];
break;
}
}
}
if( constructor == null )
{
final Constructor simplestConstructor =
constructors[constructors.length-1];
final Class[] parameterTypes = simplestConstructor.getParameterTypes();
int unsatisfied = 0;
if( constructorParameters != null )
unsatisfied =
constructorParameters.size() - parameterTypes.length;
final Class[] unsatisfiedDependencies = new Class[unsatisfied];
System.arraycopy(
parameterTypes,
constructorParameters.size()-1,
unsatisfiedDependencies,
0,
unsatisfied
);
final HashSet set = new HashSet();
set.addAll( Arrays.asList( unsatisfiedDependencies ) );
throw new NoSatisfiableConstructorAvailableException(
clazz, simplestConstructor, set );
}
return constructor;
}
}
--- NEW FILE: Type25Factory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type2Util;
import org.jicarilla.container.util.Type3Util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* XWork + PicoContainer semantics.
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: Type25Factory.java,v 1.3 2003/12/30 13:35:18 lsimons
* Exp $
*/
public class Type25Factory extends Type3Factory
{
public Type25Factory( final Resolver resolver, final String className )
{
super( resolver, className );
}
protected Object doNewInstance()
throws IllegalAccessException, InvocationTargetException,
InstantiationException
{
final Class[] constructorDependencyClasses =
m_constructor.getParameterTypes();
final Method[] methods = Type2Util.getAwarenessMethods(
super.getClazz() );
Type2Util.checkDepencenciesAreSatisfiable(
super.getClazz(), methods, super.getResolver() );
final Class[] methodDependencyClasses =
Type2Util.getType2DependencyClasses( methods );
final Class[] dependencyClasses = joinArrays(
constructorDependencyClasses,
methodDependencyClasses );
super.checkCyclicDependency( dependencyClasses );
super.enableCyclicDependencyChecking();
final Object instance = Type3Util.newType3Instance(
super.getClazz(), super.getConstructor(),
super.getResolver() );
Type2Util.callAwarenessMethods( instance, super.getResolver() );
return instance;
}
protected static Class[] joinArrays( final Class[] array1,
final Class[] array2 )
{
final Class[] result = new Class[array1.length+array2.length];
System.arraycopy(array1,0,result,0,array1.length);
System.arraycopy(array2,0,result,array1.length,array2.length);
return result;
}
}
--- NEW FILE: Type3Factory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type3Util;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
/**
* PicoContainer semantics.
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: Type3Factory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public class Type3Factory extends AbstractFactory
{
protected Constructor m_constructor;
public Type3Factory( final Resolver resolver,
final String className )
{
super( resolver, className );
}
protected Object doNewInstance()
throws IllegalAccessException, InvocationTargetException,
InstantiationException
{
lazyInitialization();
final Class[] parameterTypes = getConstructor().getParameterTypes();
super.checkCyclicDependency( parameterTypes );
super.enableCyclicDependencyChecking();
Object instance = Type3Util.newType3Instance(
super.getClazz(),
getConstructor(),
super.getResolver()
);
return instance;
}
protected void lazyInitialization()
{
super.lazyInitialization();
if( getConstructor() == null )
findGreediestSatisfiableConstructor();
}
protected void findGreediestSatisfiableConstructor()
{
m_constructor = Type3Util.getGreediestSatisfiableConstructor(
super.getClazz(), super.getResolver() );
}
protected Constructor getConstructor()
{
return m_constructor;
}
}
--- ManualComponentFactory.java DELETED ---
--- Type35ComponentFactory.java DELETED ---
--- NEW FILE: ManualFactory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.jicarilla.container.Factory;
import org.jicarilla.framework.Assert;
/**
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: ManualFactory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public class ManualFactory implements Factory
{
final Object m_instance;
public ManualFactory( final Object instance )
{
Assert.assertNotNull( "instance argument may not be null", instance );
m_instance = instance;
}
public Object newInstance()
{
return m_instance;
}
public void releaseInstance( final Object o ) throws Exception
{
}
}
--- NEW FILE: Type35Factory.java ---
/* ====================================================================
The Jicarilla Software License
Copyright (c) 2003 Leo Simons.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
==================================================================== */
package org.jicarilla.container.factories;
import org.apache.avalon.framework.container.ContainerUtil;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.util.Type1Util;
import java.lang.reflect.InvocationTargetException;
/**
* Avalon-Framework + PicoContainer + XWork semantics.
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: Type35Factory.java,v 1.1 2004/03/17 14:14:16 lsimons Exp $
*/
public class Type35Factory extends Type25Factory
{
public Type35Factory( final Resolver resolver,
final String className )
{
super( resolver, className );
}
protected Object doNewInstance()
throws IllegalAccessException, InvocationTargetException,
InstantiationException
{
final Object instance = super.doNewInstance();
Type1Util.startAvalonLifecycle( instance, super.getResolver() );
return instance;
}
protected void doReleaseInstance( final Object o )
throws Exception
{
ContainerUtil.shutdown( o );
super.doReleaseInstance( o );
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click