Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container-integration/src/java/org/jicarilla/container/integration/spring
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19900/container-integration/src/java/org/jicarilla/container/integration/spring
Added Files:
JicarillaBasedSpringFactory.java PicoBasedSpringFactory.java
SpringBasedComponentAdapter.java
SpringBasedKeyAwareComponentAdapter.java
SpringBasedPicoComponentAdapter.java
SpringClassNotFoundBeansException.java
SpringComponentAdapterForPrototypeFactories.java
SpringComponentFactory.java SpringFactoryBasedSelector.java
SpringIllegalAccessBeansException.java
SpringInstantiationBeansException.java
SpringInvocationTargetBeansException.java
SpringPicoBeansException.java SpringReference.java
SpringSelector.java
Log Message:
split out integration code from the main container project
--- NEW FILE: JicarillaBasedSpringFactory.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.integration.spring;
import org.jicarilla.container.Adapter;
import org.jicarilla.container.DefaultContainer;
import org.jicarilla.container.JicarillaClassNotFoundException;
import org.jicarilla.container.JicarillaIllegalAccessException;
import org.jicarilla.container.JicarillaInstantiationException;
import org.jicarilla.container.JicarillaInvocationTargetException;
import org.jicarilla.container.adapters.SingletonAdapter;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.AutowireCapableBeanFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanIsNotAFactoryException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import java.util.Map;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: JicarillaBasedSpringFactory.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class JicarillaBasedSpringFactory extends DefaultContainer
implements BeanFactory, AutowireCapableBeanFactory
{
public Object getBean( final String name ) throws BeansException
{
if( name == null )
throw new NoSuchBeanDefinitionException( name,
"The name parameter was null, which is not allowed!");
if( !name.startsWith( "&") && !super.getResolver().contains( name ) )
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
try
{
Object instance = super.getResolver().get( name );
if( instance == null )
{
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
}
if( instance instanceof FactoryBean )
{
if( !name.startsWith( "&" ) )
{
try
{
instance = ((FactoryBean)instance).getObject();
if( instance instanceof BeanNameAware )
{
((BeanNameAware)instance).setBeanName( name );
}
if( instance instanceof BeanFactoryAware )
{
((BeanFactoryAware)instance).setBeanFactory( this );
}
}
catch( Exception e )
{
throw new FatalBeanException(
"Unable to get instance for " + name +
" from FactoryBean associated with it",
e
);
}
}
}
else if( name.startsWith( "&" ) )
{
throw new BeanIsNotAFactoryException( name, instance );
}
return instance;
}
catch( JicarillaIllegalAccessException e )
{
throw new SpringIllegalAccessBeansException( e.getMessage(), e );
}
catch( JicarillaInvocationTargetException e )
{
throw new SpringInvocationTargetBeansException(
e.getMessage(), e );
}
catch( JicarillaInstantiationException e )
{
throw new SpringInstantiationBeansException(
e.getMessage(), e );
}
catch( JicarillaClassNotFoundException e )
{
throw new SpringClassNotFoundBeansException(
e.getMessage(), e );
}
}
public Object getBean( final String name, final Class requiredType )
throws BeansException
{
if( name == null )
throw new NoSuchBeanDefinitionException( name,
"The name parameter was null, which is not allowed!");
if( requiredType == null )
throw new NoSuchBeanDefinitionException( name,
"The requiredTupe parameter was null, which is not " +
"allowed!");
if( !super.getResolver().contains( name ) )
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
Object result = null;
try
{
result = super.getResolver().get( name );
if( requiredType.isInstance( result ) )
return result;
else
throw new BeanNotOfRequiredTypeException( name, requiredType,
result );
}
catch( JicarillaIllegalAccessException e )
{
throw new SpringIllegalAccessBeansException( e.getMessage(), e );
}
catch( JicarillaInvocationTargetException e )
{
throw new SpringInvocationTargetBeansException(
e.getMessage(), e );
}
catch( JicarillaInstantiationException e )
{
throw new SpringInstantiationBeansException(
e.getMessage(), e );
}
catch( JicarillaClassNotFoundException e )
{
throw new SpringClassNotFoundBeansException(
e.getMessage(), e );
}
finally
{
try
{
super.getResolver().releaseInstance( result );
}
catch( Exception e )
{
}
}
}
public boolean containsBean( final String name ) throws BeansException
{
return super.getResolver().contains( name );
}
public boolean isSingleton( final String name )
throws NoSuchBeanDefinitionException
{
if( !super.getResolver().contains( name ) )
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
final Adapter adapter =
(Adapter)super.getSwitch().get( name );
if( adapter instanceof SpringComponentAdapterForPrototypeFactories )
{
if( name.startsWith( "&" ) )
return true;
else
return false;
}
if( adapter instanceof SingletonAdapter )
return true;
return false;
}
public String[] getAliases( final String name )
throws NoSuchBeanDefinitionException
{
return new String[0];
}
// ----------------------------------------------------------------------
// Autowire interfaces
// ----------------------------------------------------------------------
public Object autowire( final Class beanClass ) throws BeansException
{
return null;
}
public Object autowireConstructor( final Class beanClass )
throws BeansException
{
return null;
}
public void autowireBeanProperties( final Object existingBean, final int autowireMode,
final boolean dependencyCheck ) throws BeansException
{
}
public Object applyBeanPostProcessors( final Object existingBean, final String name )
throws BeansException
{
return null;
}
public int getBeanDefinitionCount()
{
return 0;
}
public String[] getBeanDefinitionNames()
{
return new String[0];
}
public String[] getBeanDefinitionNames( final Class type )
{
return new String[0];
}
public boolean containsBeanDefinition( final String name )
{
return false;
}
public Map getBeansOfType( final Class type, final boolean includePrototypes,
final boolean includeFactoryBeans ) throws BeansException
{
return null;
}
}
--- NEW FILE: PicoBasedSpringFactory.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.integration.spring;
import org.picocontainer.ComponentAdapter;
import org.picocontainer.PicoContainer;
import org.picocontainer.PicoException;
import org.picocontainer.defaults.InstanceComponentAdapter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: PicoBasedSpringFactory.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class PicoBasedSpringFactory implements BeanFactory
{
protected final PicoContainer m_container;
public PicoBasedSpringFactory( final PicoContainer container )
{
m_container = container;
}
public Object getBean( final String name ) throws BeansException
{
if( name == null )
throw new NoSuchBeanDefinitionException( name,
"The name parameter was null, which is not allowed!");
if( !m_container.hasComponent( name ) )
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
try
{
return m_container.getComponentInstance( name );
}
catch( PicoException pe )
{
throw new SpringPicoBeansException( pe.getMessage(), pe );
}
}
public Object getBean( final String name, final Class requiredType )
throws BeansException
{
if( name == null )
throw new NoSuchBeanDefinitionException( name,
"The name parameter was null, which is not allowed!");
if( requiredType == null )
throw new NoSuchBeanDefinitionException( name,
"The requiredTupe parameter was null, which is not " +
"allowed!");
if( !m_container.hasComponent( name ) )
throw new NoSuchBeanDefinitionException( name,
"No entry exists for the bean name '" +
name + "'");
try
{
final Object result = m_container.getComponentInstance( name );
if( requiredType.isInstance( result ) )
return result;
else
throw new BeanNotOfRequiredTypeException( name, requiredType,
result );
}
catch( PicoException pe )
{
throw new SpringPicoBeansException( pe.getMessage(), pe );
}
}
public boolean containsBean( final String name ) throws BeansException
{
return m_container.hasComponent( name );
}
public boolean isSingleton( final String name )
throws NoSuchBeanDefinitionException
{
final ComponentAdapter adapter = m_container.findComponentAdapter( name );
if( adapter instanceof InstanceComponentAdapter )
return true;
return false;
}
public String[] getAliases( final String name )
throws NoSuchBeanDefinitionException
{
return new String[0];
}
}
--- NEW FILE: SpringBasedComponentAdapter.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.integration.spring;
import org.jicarilla.container.Adapter;
import org.jicarilla.framework.Assert;
import org.springframework.beans.factory.BeanFactory;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringBasedComponentAdapter.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringBasedComponentAdapter implements Adapter
{
protected final BeanFactory m_factory;
protected final String m_instanceName;
protected final Class m_requiredType;
public SpringBasedComponentAdapter( final BeanFactory factory,
final String instanceName )
{
this( factory, instanceName, null );
}
public SpringBasedComponentAdapter( final BeanFactory factory,
final String instanceName, final Class requiredType )
{
Assert.assertNotNull( "factory argument may not be null", factory );
Assert.assertNotNull( "requiredType argument may not be null",
requiredType );
m_factory = factory;
m_instanceName = instanceName;
m_requiredType = requiredType;
}
public Object getInstance()
{
if( m_requiredType == null )
return m_factory.getBean( m_instanceName );
else
return m_factory.getBean( m_instanceName, m_requiredType );
}
public void releaseInstance( final Object component ) throws Exception
{
}
public BeanFactory getSpringFactory()
{
return m_factory;
}
}
--- NEW FILE: SpringBasedKeyAwareComponentAdapter.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.integration.spring;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.framework.Assert;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.DisposableBean;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: SpringBasedKeyAwareComponentAdapter.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringBasedKeyAwareComponentAdapter
implements KeyAwareAdapter
{
protected final BeanFactory m_factory;
public SpringBasedKeyAwareComponentAdapter(
final BeanFactory factory )
{
Assert.assertNotNull( "factory argument may not be null", factory );
m_factory = factory;
}
public Object getInstance( final Object key )
{
if( key == null )
return null;
if( key instanceof Class )
{
final Class classKey = (Class)key;
return m_factory.getBean( classKey.toString(), classKey );
}
return m_factory.getBean( key.toString() );
}
public void releaseInstance( final Object component ) throws Exception
{
if(component instanceof DisposableBean )
((DisposableBean)component).destroy();
}
}
--- NEW FILE: SpringBasedPicoComponentAdapter.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.integration.spring;
import org.picocontainer.ComponentAdapter;
import org.picocontainer.MutablePicoContainer;
import org.picocontainer.PicoContainer;
import org.picocontainer.PicoInitializationException;
import org.picocontainer.PicoIntrospectionException;
import org.picocontainer.defaults.NoSatisfiableConstructorsException;
import org.springframework.beans.factory.BeanFactory;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringBasedPicoComponentAdapter.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringBasedPicoComponentAdapter
implements ComponentAdapter
{
protected BeanFactory m_factory;
protected String m_instanceName;
protected Class m_requiredType;
public Object getComponentKey()
{
return m_instanceName;
}
public Class getComponentImplementation()
{
return m_factory.getBean( m_instanceName ).getClass();
}
public Object getComponentInstance(
final MutablePicoContainer dependencyContainer )
throws PicoInitializationException, PicoIntrospectionException
{
return m_factory.getBean( m_instanceName );
}
public void verify( final PicoContainer picoContainer )
throws NoSatisfiableConstructorsException
{
}
}
--- NEW FILE: SpringClassNotFoundBeansException.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.integration.spring;
import org.springframework.beans.BeansException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringClassNotFoundBeansException.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringClassNotFoundBeansException extends BeansException
{
public SpringClassNotFoundBeansException( final String message,
final Throwable e )
{
super( message, e );
}
}
--- NEW FILE: SpringComponentAdapterForPrototypeFactories.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.integration.spring;
import org.jicarilla.container.Factory;
import org.jicarilla.container.adapters.SingleUseAdapter;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringComponentAdapterForPrototypeFactories.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringComponentAdapterForPrototypeFactories
extends SingleUseAdapter
{
public SpringComponentAdapterForPrototypeFactories(
final Factory factory )
{
super( factory );
}
}
--- NEW FILE: SpringComponentFactory.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.integration.spring;
import org.jicarilla.container.JicarillaInstantiationException;
import org.jicarilla.container.factories.BeanComponentFactory;
import org.jicarilla.framework.Assert;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import java.beans.IntrospectionException;
import java.util.List;
import java.util.Map;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringComponentFactory.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringComponentFactory extends BeanComponentFactory
{
final String m_name;
final BeanFactory m_factory;
public SpringComponentFactory( final String name, final Class clazz,
final BeanFactory factory )
throws IntrospectionException
{
this( name, clazz, factory, null );
}
public SpringComponentFactory( final String name, final Class clazz,
final BeanFactory factory, final Map properties )
throws IntrospectionException
{
this( name, clazz, factory, properties, null );
}
public SpringComponentFactory( final String name, final Class clazz,
final BeanFactory factory, final Map properties, final List constructorParameters )
throws IntrospectionException
{
super( clazz, properties, constructorParameters );
Assert.assertNotNull( "name argument may not be null", name );
m_name = name;
Assert.assertNotNull( "factory argument may not be null", factory );
m_factory = factory;
}
public Object newInstance()
{
final Object instance = super.newInstance();
if( instance instanceof InitializingBean )
{
try
{
((InitializingBean)instance).afterPropertiesSet();
}
catch( Exception e )
{
throw new JicarillaInstantiationException( e );
}
}
if( instance instanceof BeanNameAware )
{
((BeanNameAware)instance).setBeanName( m_name );
}
if( instance instanceof BeanFactoryAware )
{
((BeanFactoryAware)instance).setBeanFactory( m_factory );
}
return instance;
}
public void releaseInstance( final Object o ) throws Exception
{
if( o instanceof DisposableBean )
{
((DisposableBean)o).destroy();
}
super.releaseInstance( o );
}
}
--- NEW FILE: SpringFactoryBasedSelector.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.integration.spring;
import org.jicarilla.framework.Assert;
import org.jicarilla.framework.Selector;
import org.springframework.beans.factory.BeanFactory;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: SpringFactoryBasedSelector.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringFactoryBasedSelector implements Selector
{
protected final BeanFactory m_factory;
public SpringFactoryBasedSelector( final BeanFactory factory )
{
Assert.assertNotNull( "factory argument may not be null", factory );
m_factory = factory;
}
public boolean select( final Object object )
{
if( object == null )
return false;
if( m_factory.containsBean( object.toString() ) )
return true;
return false;
}
public boolean equals( final Object o )
{
if( this == o )
return true;
if( !(o instanceof SpringFactoryBasedSelector) )
return false;
final SpringFactoryBasedSelector springFactoryBasedSelector =
(SpringFactoryBasedSelector)o;
if( !m_factory.equals( springFactoryBasedSelector.m_factory ) )
return false;
return true;
}
public int hashCode()
{
return m_factory.hashCode();
}
}
--- NEW FILE: SpringIllegalAccessBeansException.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.integration.spring;
import org.springframework.beans.BeansException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringIllegalAccessBeansException.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringIllegalAccessBeansException extends BeansException
{
public SpringIllegalAccessBeansException( final String msg, final Throwable t )
{
super( msg, t );
}
}
--- NEW FILE: SpringInstantiationBeansException.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.integration.spring;
import org.springframework.beans.BeansException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringInstantiationBeansException.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringInstantiationBeansException extends BeansException
{
public SpringInstantiationBeansException( final String message,
final Throwable e )
{
super( message, e );
}
}
--- NEW FILE: SpringInvocationTargetBeansException.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.integration.spring;
import org.springframework.beans.BeansException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringInvocationTargetBeansException.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringInvocationTargetBeansException extends
BeansException
{
public SpringInvocationTargetBeansException( final String message,
final Throwable e )
{
super( message, e );
}
}
--- NEW FILE: SpringPicoBeansException.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.integration.spring;
import org.springframework.beans.BeansException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringPicoBeansException.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringPicoBeansException extends BeansException
{
public SpringPicoBeansException( final String message,
final Throwable pe )
{
super( message, pe );
}
}
--- NEW FILE: SpringReference.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.integration.spring;
import junit.framework.Assert;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringReference.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringReference
{
protected String m_referenceName;
public SpringReference( final String referenceName )
{
Assert.assertNotNull( "referenceName argument may not be null",
referenceName );
}
public String getReferenceName()
{
return m_referenceName;
}
public boolean equals( final Object o )
{
if( this == o ) return true;
if( !(o instanceof SpringReference) ) return false;
final SpringReference springReference = (SpringReference)o;
if( !m_referenceName.equals( springReference.m_referenceName ) ) return false;
return true;
}
public int hashCode()
{
return m_referenceName.hashCode();
}
}
--- NEW FILE: SpringSelector.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.integration.spring;
import org.jicarilla.framework.Assert;
import org.jicarilla.framework.CriterionExposingSelector;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: SpringSelector.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringSelector implements CriterionExposingSelector
{
protected String m_name;
public SpringSelector( final String name )
{
Assert.assertNotNull( "name argument may not be null", name );
m_name = name;
}
public boolean select( final Object object )
{
if( object == null )
return false;
String string = object.toString();
if( string.startsWith( "&" ) )
{
string = string.substring( 1 );
}
return m_name.equals( string );
}
public Object getCriterion()
{
return m_name;
}
public boolean equals( final Object o )
{
if( this == o )
return true;
if( !(o instanceof SpringSelector) )
return false;
final SpringSelector springSelector = (SpringSelector)o;
if( !m_name.equals( springSelector.m_name ) )
return false;
return true;
}
public int hashCode()
{
return m_name.hashCode();
}
}
-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.