jicarilla-sandbox/platform/container-integration/src/java/org/jicarilla/container/integration/dna ResourceLocatorBasedKeyAwareComponentAdapter.java,NONE,1.1 ResourceLocatorBasedSelector.java,NONE,1.1
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container-integration/src/java/org/jicarilla/container/integration/dna
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28741/platform/container-integration/src/java/org/jicarilla/container/integration/dna
Added Files:
ResourceLocatorBasedKeyAwareComponentAdapter.java
ResourceLocatorBasedSelector.java
Log Message:
support dna in the Builder
--- NEW FILE: ResourceLocatorBasedSelector.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.dna;
import org.jcontainer.dna.ResourceLocator;
import org.jicarilla.lang.Assert;
import org.jicarilla.lang.Selector;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: ResourceLocatorBasedSelector.java,v 1.1 2004/04/03 12:59:18 lsimons Exp $
*/
public class ResourceLocatorBasedSelector implements Selector
{
protected final ResourceLocator m_delegate;
public ResourceLocatorBasedSelector( ResourceLocator delegate )
{
Assert.assertNotNull( "delegate argument may not be null", delegate );
m_delegate = delegate;
}
public boolean select( final Object object )
{
if( object == null )
return false;
return m_delegate.contains( object.toString() );
}
public boolean equals( final Object o )
{
if( this == o ) return true;
if( !(o instanceof ResourceLocatorBasedSelector) ) return false;
final ResourceLocatorBasedSelector resourceLocatorBasedSelector =
(ResourceLocatorBasedSelector)o;
if( !m_delegate.equals( resourceLocatorBasedSelector.m_delegate ) )
return false;
return true;
}
public int hashCode()
{
return m_delegate.hashCode() + 160;
}
}
--- NEW FILE: ResourceLocatorBasedKeyAwareComponentAdapter.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.dna;
import org.jcontainer.dna.MissingResourceException;
import org.jcontainer.dna.ReleaseUtil;
import org.jcontainer.dna.ResourceLocator;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.lang.Assert;
import org.jicarilla.lang.CascadingRuntimeException;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: ResourceLocatorBasedKeyAwareComponentAdapter.java,v 1.1 2004/04/03 12:59:18 lsimons Exp $
*/
public class ResourceLocatorBasedKeyAwareComponentAdapter implements KeyAwareAdapter
{
protected final ResourceLocator m_delegate;
public ResourceLocatorBasedKeyAwareComponentAdapter(
ResourceLocator delegate )
{
Assert.assertNotNull( "delegate argument may not be null", delegate );
m_delegate = delegate;
}
public Object getInstance( final Object key )
{
if( key == null )
return null;
try
{
return m_delegate.lookup( key.toString() );
}
catch( MissingResourceException e )
{
throw new CascadingRuntimeException( e.getMessage(), e );
}
}
public void releaseInstance( final Object component ) throws Exception
{
ReleaseUtil.release( component );
}
}
-------------------------------------------------------
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