Permalink
Browse files

FELIX-3708 use java 5-isms in DS

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1415461 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 9656847 commit 2053bfbb3d3f78648ee123bda4ca145498924594 David Jencks committed Nov 29, 2012
Showing with 458 additions and 530 deletions.
  1. +10 −11 scr/src/main/java/org/apache/felix/scr/impl/Activator.java
  2. +21 −23 scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
  3. +35 −31 scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
  4. +97 −98 scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
  5. +1 −1 scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java
  6. +3 −3 scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java
  7. +64 −109 scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
  8. +28 −29 scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
  9. +5 −5 scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
  10. +1 −7 scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java
  11. +90 −92 scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
  12. +55 −66 scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
  13. +7 −7 scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
  14. +24 −31 scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
  15. +10 −10 scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
  16. +2 −2 scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
  17. +2 −2 scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java
  18. +1 −1 scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java
  19. +2 −2 scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
@@ -61,7 +61,7 @@
private static ServiceTracker m_packageAdmin;
// map of BundleComponentActivator instances per Bundle indexed by Bundle id
- private Map m_componentBundles;
+ private Map<Long, BundleComponentActivator> m_componentBundles;
// registry of managed component
private ComponentRegistry m_componentRegistry;
@@ -85,7 +85,7 @@ public void start( BundleContext context ) throws Exception
m_logService.open();
// prepare component registry
- m_componentBundles = new HashMap();
+ m_componentBundles = new HashMap<Long, BundleComponentActivator>();
m_componentRegistry = new ComponentRegistry( context );
// get the configuration
@@ -191,9 +191,8 @@ else if ( event.getType() == BundleEvent.STOPPING )
private void loadAllComponents( BundleContext context )
{
Bundle[] bundles = context.getBundles();
- for ( int i = 0; i < bundles.length; i++ )
+ for ( Bundle bundle : bundles )
{
- Bundle bundle = bundles[i];
if ( ComponentRegistry.isBundleActive( bundle ) )
{
loadComponents( bundle );
@@ -234,7 +233,7 @@ private void loadComponents( Bundle bundle )
// FELIX-2231 Mark bundle loaded early to prevent concurrent loading
// if LAZY_ACTIVATION and STARTED event are fired at the same time
final boolean loaded;
- final Long bundleId = new Long( bundle.getBundleId() );
+ final Long bundleId = bundle.getBundleId();
synchronized ( m_componentBundles )
{
if ( m_componentBundles.containsKey( bundleId ) )
@@ -243,7 +242,7 @@ private void loadComponents( Bundle bundle )
}
else
{
- m_componentBundles.put( bundleId, bundleId );
+ m_componentBundles.put( bundleId, null );
loaded = false;
}
}
@@ -306,7 +305,7 @@ private void disposeComponents( Bundle bundle )
final Object ga;
synchronized ( m_componentBundles )
{
- ga = m_componentBundles.remove( new Long( bundle.getBundleId() ) );
+ ga = m_componentBundles.remove( bundle.getBundleId() );
}
if ( ga instanceof BundleComponentActivator )
@@ -334,11 +333,11 @@ private void disposeAllComponents()
m_componentBundles.clear();
}
- for ( int i = 0; i < activators.length; i++ )
+ for ( Object activator : activators )
{
- if ( activators[i] instanceof BundleComponentActivator )
+ if ( activator instanceof BundleComponentActivator )
{
- final BundleComponentActivator ga = ( BundleComponentActivator ) activators[i];
+ final BundleComponentActivator ga = ( BundleComponentActivator ) activator;
try
{
final Bundle bundle = ga.getBundleContext().getBundle();
@@ -349,7 +348,7 @@ private void disposeAllComponents()
catch ( Exception e )
{
log( LogService.LOG_ERROR, m_context.getBundle(), "Error while disposing components of bundle "
- + bundle.getSymbolicName() + "/" + bundle.getBundleId(), e );
+ + bundle.getSymbolicName() + "/" + bundle.getBundleId(), e );
}
}
catch ( IllegalStateException e )
@@ -61,7 +61,7 @@
private BundleContext m_context = null;
// This is a list of component instance managers that belong to a particular bundle
- private List m_managers = new ArrayList();
+ private List<ComponentHolder> m_managers = new ArrayList<ComponentHolder>();
// The Configuration Admin tracker providing configuration for components
private ServiceTracker m_logService;
@@ -144,16 +144,15 @@ private void initialize( String descriptorLocations )
}
// load from the descriptors
- for ( int i = 0; i < descriptorURLs.length; i++ )
+ for ( URL descriptorURL : descriptorURLs )
{
- loadDescriptor( descriptorURLs[i] );
+ loadDescriptor( descriptorURL );
}
}
//enable all the enabled components
- for (Iterator it = m_managers.iterator(); it.hasNext();)
+ for ( ComponentHolder componentHolder : m_managers )
{
- ComponentHolder componentHolder = ( ComponentHolder ) it.next();
- if (componentHolder.getComponentMetadata().isEnabled())
+ if ( componentHolder.getComponentMetadata().isEnabled() )
{
componentHolder.enableComponents( false );
}
@@ -191,19 +190,19 @@ private void initialize( String descriptorLocations )
}
// find the entries
- final Enumeration entries = bundle.findEntries( path, filePattern, false );
+ final Enumeration<URL> entries = bundle.findEntries( path, filePattern, false );
if ( entries == null || !entries.hasMoreElements() )
{
return new URL[0];
}
// create the result list
- List urls = new ArrayList();
+ List<URL> urls = new ArrayList<URL>();
while ( entries.hasMoreElements() )
{
urls.add( entries.nextElement() );
}
- return ( URL[] ) urls.toArray( new URL[urls.size()] );
+ return urls.toArray( new URL[urls.size()] );
}
@@ -227,10 +226,9 @@ private void loadDescriptor( final URL descriptorURL )
// 112.4.2 Component descriptors may contain a single, root component element
// or one or more component elements embedded in a larger document
- Iterator i = handler.getComponentMetadataList().iterator();
- while ( i.hasNext() )
+ for ( Object o : handler.getComponentMetadataList() )
{
- ComponentMetadata metadata = ( ComponentMetadata ) i.next();
+ ComponentMetadata metadata = ( ComponentMetadata ) o;
ComponentRegistryKey key = null;
try
{
@@ -313,7 +311,7 @@ void dispose( int reason )
while ( m_managers.size() != 0 )
{
- ComponentHolder holder = ( ComponentHolder ) m_managers.get( 0 );
+ ComponentHolder holder = m_managers.get( 0 );
try
{
m_managers.remove( holder );
@@ -333,7 +331,7 @@ void dispose( int reason )
}
log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] STOPPED", new Object[]
- { new Long( m_context.getBundle().getBundleId() ) }, null, null );
+ {m_context.getBundle().getBundleId()}, null, null );
if (m_logService != null) {
m_logService.close();
@@ -393,16 +391,16 @@ public void enableComponent( final String name )
return;
}
- for ( int i = 0; i < holder.length; i++ )
+ for ( ComponentHolder aHolder : holder )
{
try
{
- log( LogService.LOG_DEBUG, "Enabling Component", holder[i].getComponentMetadata(), null );
- holder[i].enableComponents( true );
+ log( LogService.LOG_DEBUG, "Enabling Component", aHolder.getComponentMetadata(), null );
+ aHolder.enableComponents( true );
}
catch ( Throwable t )
{
- log( LogService.LOG_ERROR, "Cannot enable component", holder[i].getComponentMetadata(), t );
+ log( LogService.LOG_ERROR, "Cannot enable component", aHolder.getComponentMetadata(), t );
}
}
}
@@ -425,16 +423,16 @@ public void disableComponent( final String name )
return;
}
- for ( int i = 0; i < holder.length; i++ )
+ for ( ComponentHolder aHolder : holder )
{
try
{
- log( LogService.LOG_DEBUG, "Disabling Component", holder[i].getComponentMetadata(), null );
- holder[i].disableComponents( true );
+ log( LogService.LOG_DEBUG, "Disabling Component", aHolder.getComponentMetadata(), null );
+ aHolder.disableComponents( true );
}
catch ( Throwable t )
{
- log( LogService.LOG_ERROR, "Cannot disable component", holder[i].getComponentMetadata(), t );
+ log( LogService.LOG_ERROR, "Cannot disable component", aHolder.getComponentMetadata(), t );
}
}
}
@@ -460,7 +458,7 @@ public void disableComponent( final String name )
// if all components are selected
if ( name == null )
{
- return ( ComponentHolder[] ) m_managers.toArray( new ComponentHolder[m_managers.size()] );
+ return m_managers.toArray( new ComponentHolder[m_managers.size()] );
}
ComponentHolder componentHolder = m_componentRegistry.getComponentHolder( m_context.getBundle(), name );
Oops, something went wrong.

0 comments on commit 2053bfb

Please sign in to comment.