Author: nicolas
Date: Mon Feb 25 08:05:05 2008
New Revision: 630905
URL: http://svn.apache.org/viewvc?rev=630905&view=rev
Log:
limited support for Contextualizable and lookups in PlexusContainer
Added:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
(with props)
Modified:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
Modified:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java?rev=630905&r1=630904&r2=630905&view=diff
==============================================================================
---
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
(original)
+++
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusComponentFactoryBean.java
Mon Feb 25 08:05:05 2008
@@ -29,6 +29,7 @@
import java.util.Map;
import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.LoggerManager;
@@ -76,14 +77,14 @@
private ListableBeanFactory beanFactory;
- private Context contextWrapper;
-
private LoggerManager loggerManager;
private TypeConverter typeConverter = new SimpleTypeConverter();
private List instances = new LinkedList();
+ private Context context;
+
public void destroy()
throws Exception
{
@@ -146,7 +147,7 @@
if (component instanceof Contextualizable )
{
- ((Contextualizable) component).contextualize( contextWrapper );
+ ((Contextualizable) component).contextualize( getContext() );
}
if ( component instanceof Initializable )
@@ -170,6 +171,19 @@
}
/**
+ * @return
+ */
+ protected Context getContext()
+ {
+ if (context == null)
+ {
+ PlexusContainer container = (PlexusContainer) beanFactory.getBean(
"plexusContainer" );
+ context = container.getContext();
+ }
+ return context;
+ }
+
+ /**
* Retrieve the loggerManager instance to be used for LogEnabled components
* @return
*/
@@ -250,31 +264,6 @@
this.typeConverter = typeConverter;
}
- /**
- * Create a Map of all available implementation of the expected role
- * @param beanName
- * @return Map<role-hint, component>
- */
- protected Map getRoleMap( String beanName )
- {
- Map map = new HashMap();
- String mask = beanName + HINT;
- String[] beans = beanFactory.getBeanDefinitionNames();
- for ( int i = 0; i < beans.length; i++ )
- {
- String name = beans[i];
- if ( name.startsWith( mask ) )
- {
- map.put( name.substring( mask.length() ), beanFactory.getBean(
name ) );
- }
- }
- if ( beanFactory.containsBean( beanName ) )
- {
- map.put( PlexusConstants.PLEXUS_DEFAULT_HINT, beanFactory.getBean(
beanName ) );
- }
- return map;
- }
-
/**
* Resolve the requirement that this field exposes in the component
@@ -291,11 +280,11 @@
{
// component ask plexus for a Map of all available
// components for the role
- dependency = getRoleMap( beanName );
+ dependency = PlexusToSpringUtils.lookupMap( beanName,
beanFactory );
}
else if ( Collection.class.isAssignableFrom( field.getType() ) )
{
- dependency = new ArrayList( getRoleMap( beanName ).values() );
+ dependency = PlexusToSpringUtils.LookupList( beanName,
beanFactory );
}
else
{
@@ -308,6 +297,11 @@
}
return dependency;
+ }
+
+ protected void setContext( Context context )
+ {
+ this.context = context;
}
}
Added:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java?rev=630905&view=auto
==============================================================================
---
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
(added)
+++
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
Mon Feb 25 08:05:05 2008
@@ -0,0 +1,657 @@
+package org.codehaus.plexus.spring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.composition.CompositionException;
+import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import
org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.DefaultContext;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.LoggerManager;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * An adapter to access Spring ApplicationContext from a plexus component
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Nicolas De Loof</a>
+ */
+public class PlexusContainerAdapter
+ implements PlexusContainer, ApplicationContextAware, InitializingBean
+{
+ private Context context = new DefaultContext();
+
+ private ApplicationContext applicationContext;
+
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet()
+ throws Exception
+ {
+ context.put( "plexus", this );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#addComponentDescriptor(org.codehaus.plexus.component.repository.ComponentDescriptor)
+ */
+ public void addComponentDescriptor( ComponentDescriptor
componentDescriptor )
+ throws ComponentRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#addContextValue(java.lang.Object,
java.lang.Object)
+ */
+ public void addContextValue( Object key, Object value )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#addJarRepository(java.io.File)
+ */
+ public void addJarRepository( File repository )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#addJarResource(java.io.File)
+ */
+ public void addJarResource( File resource )
+ throws PlexusContainerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#autowire(java.lang.Object)
+ */
+ public Object autowire( Object component )
+ throws CompositionException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#createAndAutowire(java.lang.String)
+ */
+ public Object createAndAutowire( String clazz )
+ throws CompositionException, ClassNotFoundException,
InstantiationException, IllegalAccessException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#createChildContainer(java.lang.String,
java.util.List, java.util.Map)
+ */
+ public PlexusContainer createChildContainer( String name, List
classpathJars, Map context )
+ throws PlexusContainerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#createChildContainer(java.lang.String,
java.util.List, java.util.Map, java.util.List)
+ */
+ public PlexusContainer createChildContainer( String name, List
classpathJars, Map context, List discoveryListeners )
+ throws PlexusContainerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#createComponentRealm(java.lang.String,
java.util.List)
+ */
+ public ClassRealm createComponentRealm( String id, List jars )
+ throws PlexusContainerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#dispose()
+ */
+ public void dispose()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getChildContainer(java.lang.String)
+ */
+ public PlexusContainer getChildContainer( String name )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptor(java.lang.String)
+ */
+ public ComponentDescriptor getComponentDescriptor( String role )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptor(java.lang.String,
java.lang.String)
+ */
+ public ComponentDescriptor getComponentDescriptor( String role, String
roleHint )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptor(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public ComponentDescriptor getComponentDescriptor( String role, ClassRealm
realm )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptor(java.lang.String,
java.lang.String, org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public ComponentDescriptor getComponentDescriptor( String role, String
roleHint, ClassRealm realm )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptorList(java.lang.String)
+ */
+ public List getComponentDescriptorList( String role )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptorList(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public List getComponentDescriptorList( String role, ClassRealm
componentRealm )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptorMap(java.lang.String)
+ */
+ public Map getComponentDescriptorMap( String role )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentDescriptorMap(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Map getComponentDescriptorMap( String role, ClassRealm
componentRealm )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getComponentRealm(java.lang.String)
+ */
+ public ClassRealm getComponentRealm( String realmId )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getContainerRealm()
+ */
+ public ClassRealm getContainerRealm()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getContext()
+ */
+ public Context getContext()
+ {
+ return context;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getCreationDate()
+ */
+ public Date getCreationDate()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getLogger()
+ */
+ public Logger getLogger()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getLoggerManager()
+ */
+ public LoggerManager getLoggerManager()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getLookupRealm()
+ */
+ public ClassRealm getLookupRealm()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#getLookupRealm(java.lang.Object)
+ */
+ public ClassRealm getLookupRealm( Object component )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#getName()
+ */
+ public String getName()
+ {
+ return "plexus spring adapter";
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#hasChildContainer(java.lang.String)
+ */
+ public boolean hasChildContainer( String name )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#hasComponent(java.lang.String)
+ */
+ public boolean hasComponent( String role )
+ {
+ return false;
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#hasComponent(java.lang.String,
java.lang.String)
+ */
+ public boolean hasComponent( String role, String roleHint )
+ {
+ return applicationContext.containsBean(
PlexusToSpringUtils.buildSpringId( role, roleHint ) );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#isReloadingEnabled()
+ */
+ public boolean isReloadingEnabled()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.String)
+ */
+ public Object lookup( String componentKey )
+ throws ComponentLookupException
+ {
+ return lookup( componentKey, (String) null );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.Class)
+ */
+ public Object lookup( Class componentClass )
+ throws ComponentLookupException
+ {
+ return lookup( componentClass.getName(), (String) null );
+
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Object lookup( String componentKey, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.String,
java.lang.String)
+ */
+ public Object lookup( String role, String roleHint )
+ throws ComponentLookupException
+ {
+ return applicationContext.getBean( PlexusToSpringUtils.buildSpringId(
role, roleHint ) );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.Class,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Object lookup( Class componentClass, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.Class,
java.lang.String)
+ */
+ public Object lookup( Class role, String roleHint )
+ throws ComponentLookupException
+ {
+ return lookup( role.getName(), roleHint );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.String,
java.lang.String, org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Object lookup( String role, String roleHint, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookup(java.lang.Class,
java.lang.String, org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Object lookup( Class role, String roleHint, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupList(java.lang.String)
+ */
+ public List lookupList( String role )
+ throws ComponentLookupException
+ {
+ return PlexusToSpringUtils.LookupList( role, applicationContext );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupList(java.lang.Class)
+ */
+ public List lookupList( Class role )
+ throws ComponentLookupException
+ {
+ return lookupList( role.getName() );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupList(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public List lookupList( String role, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupList(java.lang.Class,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public List lookupList( Class role, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupMap(java.lang.String)
+ */
+ public Map lookupMap( String role )
+ throws ComponentLookupException
+ {
+ return PlexusToSpringUtils.lookupMap( role, applicationContext );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupMap(java.lang.Class)
+ */
+ public Map lookupMap( Class role )
+ throws ComponentLookupException
+ {
+ return lookupMap( role.getName() );
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupMap(java.lang.String,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Map lookupMap( String role, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#lookupMap(java.lang.Class,
org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public Map lookupMap( Class role, ClassRealm realm )
+ throws ComponentLookupException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#registerComponentDiscoveryListener(org.codehaus.plexus.component.discovery.ComponentDiscoveryListener)
+ */
+ public void registerComponentDiscoveryListener( ComponentDiscoveryListener
listener )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#release(java.lang.Object)
+ */
+ public void release( Object component )
+ throws ComponentLifecycleException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#releaseAll(java.util.Map)
+ */
+ public void releaseAll( Map components )
+ throws ComponentLifecycleException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#releaseAll(java.util.List)
+ */
+ public void releaseAll( List components )
+ throws ComponentLifecycleException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#removeChildContainer(java.lang.String)
+ */
+ public void removeChildContainer( String name )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#removeComponentDiscoveryListener(org.codehaus.plexus.component.discovery.ComponentDiscoveryListener)
+ */
+ public void removeComponentDiscoveryListener( ComponentDiscoveryListener
listener )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#resume(java.lang.Object)
+ */
+ public void resume( Object component )
+ throws ComponentLifecycleException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#setLoggerManager(org.codehaus.plexus.logging.LoggerManager)
+ */
+ public void setLoggerManager( LoggerManager loggerManager )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#setLookupRealm(org.codehaus.plexus.classworlds.realm.ClassRealm)
+ */
+ public ClassRealm setLookupRealm( ClassRealm realm )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#setName(java.lang.String)
+ */
+ public void setName( String name )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.codehaus.plexus.PlexusContainer#setParentPlexusContainer(org.codehaus.plexus.PlexusContainer)
+ */
+ public void setParentPlexusContainer( PlexusContainer container )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#setReloadingEnabled(boolean)
+ */
+ public void setReloadingEnabled( boolean reloadingEnabled )
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see org.codehaus.plexus.PlexusContainer#suspend(java.lang.Object)
+ */
+ public void suspend( Object component )
+ throws ComponentLifecycleException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * [EMAIL PROTECTED]
+ * @see
org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
+ */
+ public void setApplicationContext( ApplicationContext applicationContext )
+ throws BeansException
+ {
+ this.applicationContext = applicationContext;
+ }
+
+
+}
Propchange:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusContainerAdapter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
URL:
http://svn.apache.org/viewvc/maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java?rev=630905&r1=630904&r2=630905&view=diff
==============================================================================
---
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
(original)
+++
maven/archiva/branches/springy/plexus-spring/src/main/java/org/codehaus/plexus/spring/PlexusToSpringUtils.java
Mon Feb 25 08:05:05 2008
@@ -19,11 +19,17 @@
* under the License.
*/
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.StringTokenizer;
import org.apache.commons.lang.ClassUtils;
+import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.springframework.beans.factory.ListableBeanFactory;
/**
* Utility method to convert plexus descriptors to spring bean context.
@@ -109,5 +115,30 @@
private static boolean isDefaultHint( String roleHint )
{
return roleHint == null || roleHint.length() == 0 || "default".equals(
roleHint );
+ }
+
+ public static Map lookupMap( String role, ListableBeanFactory beanFactory )
+ {
+ Map map = new HashMap();
+ String mask = role + '#';
+ String[] beans = beanFactory.getBeanDefinitionNames();
+ for ( int i = 0; i < beans.length; i++ )
+ {
+ String name = beans[i];
+ if ( name.startsWith( mask ) )
+ {
+ map.put( name.substring( mask.length() ), beanFactory.getBean(
name ) );
+ }
+ }
+ if ( beanFactory.containsBean( role ) )
+ {
+ map.put( PlexusConstants.PLEXUS_DEFAULT_HINT, beanFactory.getBean(
role ) );
+ }
+ return map;
+ }
+
+ public static List LookupList( String role, ListableBeanFactory
beanFactory )
+ {
+ return new ArrayList( PlexusToSpringUtils.lookupMap( role, beanFactory
).values() );
}
}