Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/container-integration/src/java/org/jicarilla/container/integration/builder
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19900/container-integration/src/java/org/jicarilla/container/integration/builder
Added Files:
ComponentManagerHelper.java FortressContainerHelper.java
JicarillaBuilder.java PicoComponentAdapterHelper.java
PicoContainerHelper.java ServiceManagerHelper.java
SpringBeanFactoryHelper.java
Log Message:
split out integration code from the main container project
--- NEW FILE: ComponentManagerHelper.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.builder;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.WrapperServiceManager;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.integration.avalon.ServiceManagerBasedKeyAwareComponentAdapter;
import org.jicarilla.container.integration.avalon.ServiceManagerBasedSelector;
import org.jicarilla.container.builder.BuilderHelper;
import org.jicarilla.framework.Selector;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: ComponentManagerHelper.java,v 1.1 2004/03/08 21:05:24 lsimons Exp $
*/
public class ComponentManagerHelper implements BuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider )
throws Exception
{
final ServiceManager sm = new WrapperServiceManager(
(ComponentManager)provider
);
return new ServiceManagerBasedKeyAwareComponentAdapter( sm );
}
public Selector getSelector( final Object provider ) throws Exception
{
final ServiceManager sm = new WrapperServiceManager(
(ComponentManager)provider
);
return new ServiceManagerBasedSelector( sm );
}
}
--- NEW FILE: FortressContainerHelper.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.builder;
import org.apache.avalon.fortress.Container;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.builder.BuilderHelper;
import org.jicarilla.container.integration.avalon.FortressBasedKeyAwareComponentAdapter;
import org.jicarilla.container.integration.avalon.FortressContainerBasedSelector;
import org.jicarilla.framework.Selector;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: FortressContainerHelper.java,v 1.1 2004/03/08 21:05:24 lsimons Exp $
*/
public class FortressContainerHelper implements BuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider )
throws Exception
{
return new FortressBasedKeyAwareComponentAdapter(
(Container)provider
);
}
public Selector getSelector( final Object provider ) throws Exception
{
return new FortressContainerBasedSelector(
(Container)provider );
}
}
--- NEW FILE: JicarillaBuilder.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.builder;
import org.jicarilla.container.Container;
import org.jicarilla.container.Adapter;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.ResolverProvider;
import org.jicarilla.container.KeyRelayingContainer;
import org.jicarilla.container.DefaultKeyRelayingContainer;
import org.jicarilla.container.builder.DefaultBuilder;
import org.jicarilla.container.builder.Builder;
import org.jicarilla.container.builder.ResolverProviderHelper;
import org.jicarilla.container.builder.ResolverHelper;
import org.jicarilla.container.builder.KeyAwareComponentAdapterHelper;
import org.jicarilla.container.builder.AdapterHelper;
import org.jicarilla.container.builder.EntryHelper;
import org.jicarilla.container.builder.SingletonType35Helper;
import org.jicarilla.container.builder.DefaultHelper;
import org.jicarilla.framework.Assert;
import org.picocontainer.PicoContainer;
import org.springframework.beans.factory.BeanFactory;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.component.ComponentManager;
/**
* <p>A Builder implementation that's backed by a container itself. In essence,
* we're using a container to help build a container. The documentation for the
* builder API may be a bit complex, but the usage is actually quite easy.
* Just take a look at the following example:</p>
*
* <pre>
* PicoContainer picoContainer = getPicoContainer();
* Container fortressContainer = getFortressContainer();
* Resolver parentContainerResolver = getParentResolver();
* Resolver resolver =
* JicarillaBuilder.newInstance()
* .addComponent( HomerImpl.class )
* .addComponent( YoungHomer.class )
*
* .addComponent( new HomerImpl() )
* .addComponent( new BartImpl() )
* .addComponent(
* new ClassSelector( Marge.class ),
* new SingletonAdapter(
* new ManualComponentFactory(
* new MargeImpl()
* )
* )
* )
* .addComponent( LisaImpl.class )
* .addComponent( parentContainerResolver )
* .addComponent( picoContainer )
* .addComponent( fortressContainer )
* .create();
* </pre>
*
* <p>Note a Builder instance is single-use, and you should create a new
* instance (using {@link #newInstance()} every time you call
* {@link #create()}.</p>
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: JicarillaBuilder.java,v 1.1 2004/03/08 21:05:24 lsimons Exp $
*/
public class JicarillaBuilder extends DefaultBuilder
{
// ----------------------------------------------------------------------
// Constructor and factory method
// ----------------------------------------------------------------------
/**
* Create a new builder that will be used to populate the provided
* container.
*
* @param container the container to populate.
*/
protected JicarillaBuilder( KeyRelayingContainer container )
{
super( container );
}
/**
* Create a new builder.
*
* @return a new builder instance to be used in building a single new
* container instance.
*/
public static Builder newInstance()
{
return new JicarillaBuilder( new DefaultKeyRelayingContainer() );
}
/**
* Add a new <em>provider</em> to the container. A provider can be lots of
* things: another {@link Container container} or a generic
* {@link ResolverProvider resolver provider{, a {@link Resolver}, a
* different kind of container (a {@link PicoContainer},
* {@link BeanFactory}, or {@link ServiceManager} for example), an
* {@link Adapter}, {@link KeyAwareAdapter}, {@link Entry entry}, a
* {@link Class}, an {@link Object instance}, and several other things.
* The builder will figure out what to do with the provider. Subclasses
* may add helpers for other kinds of providers.
*
* @param provider the provider to add to the container.
* @return the current instance.
*/
public Builder addComponent( final Object provider )
{
super.addComponent( provider );
Assert.assertNotNull( "provider argument may not be null",
provider );
m_componentProviders.add( provider );
return this;
}
protected void addHelpers()
{
addHelperHelpers();
// --------------------------------------------------------------------
// Jicarilla support
// --------------------------------------------------------------------
addHelper(
Adapter.class,
AdapterHelper.class
);
addHelper(
KeyAwareAdapter.class,
KeyAwareComponentAdapterHelper.class
);
addHelper(
Resolver.class,
ResolverHelper.class
);
addHelper(
ResolverProvider.class,
ResolverProviderHelper.class
);
addHelper(
Entry.class,
EntryHelper.class
);
// --------------------------------------------------------------------
// Avalon support
// --------------------------------------------------------------------
addHelper(
org.apache.avalon.fortress.Container.class,
FortressContainerHelper.class
);
addHelper(
ServiceManager.class,
ServiceManagerHelper.class
);
addHelper(
ComponentManager.class,
ComponentManagerHelper.class
);
// --------------------------------------------------------------------
// PicoContainer support
// --------------------------------------------------------------------
addHelper(
PicoContainer.class,
PicoContainerHelper.class
);
addHelper(
org.picocontainer.ComponentAdapter.class,
PicoComponentAdapterHelper.class
);
// --------------------------------------------------------------------
// XWork support
// --------------------------------------------------------------------
// todo
// --------------------------------------------------------------------
// Springframework support
// --------------------------------------------------------------------
addHelper(
BeanFactory.class,
SpringBeanFactoryHelper.class
);
// --------------------------------------------------------------------
// DNA support
// --------------------------------------------------------------------
// todo
// --------------------------------------------------------------------
// Loom support
// --------------------------------------------------------------------
// todo
// --------------------------------------------------------------------
// Basics
// --------------------------------------------------------------------
addHelper(
Class.class,
SingletonType35Helper.class
);
addHelper(
Object.class,
DefaultHelper.class
);
}
}
--- NEW FILE: PicoComponentAdapterHelper.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.builder;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.Resolver;
import org.jicarilla.container.builder.ContainerAwareBuilderHelper;
import org.jicarilla.container.adapters.AdapterBasedKeyAwareAdapter;
import org.jicarilla.container.integration.pico.PicoBasedJicarillaComponentAdapter;
import org.jicarilla.container.integration.pico.PicoComponentAdapterBasedSelector;
import org.jicarilla.container.integration.pico.ResolverBasedPicoContainer;
import org.jicarilla.framework.Selector;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: PicoComponentAdapterHelper.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class PicoComponentAdapterHelper implements ContainerAwareBuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider,
final Resolver resolver ) throws Exception
{
return new AdapterBasedKeyAwareAdapter(
new PicoBasedJicarillaComponentAdapter(
(org.picocontainer.ComponentAdapter)provider,
new ResolverBasedPicoContainer( resolver )
)
);
}
public Selector getSelector( final Object provider ) throws Exception
{
return new PicoComponentAdapterBasedSelector(
(org.picocontainer.ComponentAdapter)provider
);
}
}
--- NEW FILE: PicoContainerHelper.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.builder;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.builder.BuilderHelper;
import org.jicarilla.container.integration.pico.PicoBasedKeyAwareComponentAdapter;
import org.jicarilla.container.integration.pico.PicoContainerBasedSelector;
import org.jicarilla.framework.Selector;
import org.picocontainer.PicoContainer;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: PicoContainerHelper.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class PicoContainerHelper implements BuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider )
throws Exception
{
return new PicoBasedKeyAwareComponentAdapter(
(PicoContainer)provider );
}
public Selector getSelector( final Object provider ) throws Exception
{
return new PicoContainerBasedSelector( (PicoContainer)provider );
}
}
--- NEW FILE: ServiceManagerHelper.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.builder;
import org.apache.avalon.framework.service.ServiceManager;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.builder.BuilderHelper;
import org.jicarilla.container.integration.avalon.ServiceManagerBasedKeyAwareComponentAdapter;
import org.jicarilla.container.integration.avalon.ServiceManagerBasedSelector;
import org.jicarilla.framework.Selector;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: ServiceManagerHelper.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class ServiceManagerHelper implements BuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider )
throws Exception
{
return new ServiceManagerBasedKeyAwareComponentAdapter(
(ServiceManager)provider
);
}
public Selector getSelector( final Object provider ) throws Exception
{
return new ServiceManagerBasedSelector(
(ServiceManager)provider
);
}
}
--- NEW FILE: SpringBeanFactoryHelper.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.builder;
import org.jicarilla.container.KeyAwareAdapter;
import org.jicarilla.container.builder.BuilderHelper;
import org.jicarilla.container.integration.spring.SpringBasedKeyAwareComponentAdapter;
import org.jicarilla.container.integration.spring.SpringFactoryBasedSelector;
import org.jicarilla.framework.Selector;
import org.springframework.beans.factory.BeanFactory;
/**
*
*
* @author <a href="mail at leosimons dot com">Leo Simons</a>
* @version $Id: SpringBeanFactoryHelper.java,v 1.1 2004/03/08 21:05:25 lsimons Exp $
*/
public class SpringBeanFactoryHelper implements BuilderHelper
{
public KeyAwareAdapter getAdapter( final Object provider )
throws Exception
{
return new SpringBasedKeyAwareComponentAdapter(
(BeanFactory)provider
);
}
public Selector getSelector( final Object provider ) throws Exception
{
return new SpringFactoryBasedSelector(
(BeanFactory)provider
);
}
}
-------------------------------------------------------
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.