You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2009/07/21 20:51:41 UTC

svn commit: r796467 [8/25] - in /felix/trunk/sigil: common/core.tests/src/org/apache/felix/sigil/core/ common/core/src/org/apache/felix/sigil/bnd/ common/core/src/org/apache/felix/sigil/config/ common/core/src/org/apache/felix/sigil/core/ common/core/s...

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractBundleRepository.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -44,361 +45,474 @@
 import org.apache.felix.sigil.model.osgi.IRequiredBundle;
 import org.osgi.framework.Version;
 
-public abstract class AbstractBundleRepository implements IBundleRepository {
-	
-	private final String id;
-	private final HashSet<IBundleRepositoryListener> listeners = new HashSet<IBundleRepositoryListener>();
-
-	public AbstractBundleRepository(String id) {
-		this.id = id;
-	}
-	
-	public abstract void accept(IRepositoryVisitor visitor, int options);
-	
-	public void addBundleRepositoryListener(IBundleRepositoryListener listener) {
-		synchronized(listeners) {
-			listeners.add(listener);
-		}
-	}
-
-	public void removeBundleRepositoryListener(IBundleRepositoryListener listener) {
-		synchronized(listeners) {
-			listeners.remove(listener);
-		}
-	}
-	
-	protected void notifyChange() {
-		for ( IBundleRepositoryListener l : listeners ) {
-			l.notifyChange(this);
-		}
-	}
-	
-	public String getId() {
-		return id;
-	}
-		
-	public void accept(IRepositoryVisitor visitor) {
-		accept( visitor, 0 );
-	}
-	
-	public void writeOBR(OutputStream out) throws IOException {
-		throw new UnsupportedOperationException();
-	}
-
-	public Collection<ISigilBundle> findProviders(final ILibrary library, int options) {
-		final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-		
-		final ILicensePolicy policy = findPolicy(library);
-		
-		IRepositoryVisitor visitor = new IRepositoryVisitor() {
-			public boolean visit(ISigilBundle bundle) {
-				if (policy.accept(bundle)) {
-					IBundleModelElement info = bundle.getBundleInfo();
-					for ( IPackageImport pi : library.getImports() ) {
-						for ( IPackageExport e : info.getExports() ) {
-							if ( pi.getPackageName().equals( e.getPackageName() ) && pi.getVersions().contains( e.getVersion() ) ) {
-								found.add(bundle);
-								break;
-							}
-						}
-					}					
-				}
-				return true;
-			}
-		};
-		
-		accept( visitor, options );
-		
-		return found;
-	}
-
-	public Collection<ISigilBundle> findAllProviders(final IRequiredBundle req, int options) {
-		final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-		
-		final ILicensePolicy policy = findPolicy(req);
-		
-		IRepositoryVisitor visitor = new IRepositoryVisitor() {
-			public boolean visit(ISigilBundle bundle) {
-				if (policy.accept(bundle)) {
-					IBundleModelElement info = bundle.getBundleInfo();
-					if ( req.getSymbolicName().equals( info.getSymbolicName() ) && req.getVersions().contains( info.getVersion() ) ) {
-						found.add(bundle);
-					}
-				}
-				return true;
-			}
-		};
-		
-		accept( visitor, options );
-		
-		return found;
-	}
-
-	public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options) {
-		final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-		
-		final ILicensePolicy policy = findPolicy(pi);
-		
-		IRepositoryVisitor visitor = new IRepositoryVisitor() {
-
-			public boolean visit(ISigilBundle bundle) {
-				if (policy.accept(bundle)) {
-					IBundleModelElement info = bundle.getBundleInfo();
-					if ( info != null ) {
-						for ( IPackageExport e : info.getExports() ) {
-							if ( pi.getPackageName().equals( e.getPackageName() ) ) {
-								if ( pi.getVersions().contains( e.getVersion() ) ) {
-									found.add(bundle);
-									break;
-								}
-							}
-						}
-					}
-				}
-				return true;
-			}
-			
-		};
-		
-		accept( visitor, options );
-		
-		return found;
-	}
-
-	public ISigilBundle findProvider(final IPackageImport pi, int options) {
-		final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-		
-		final ILicensePolicy policy = findPolicy(pi);
-		
-		IRepositoryVisitor visitor = new IRepositoryVisitor() {
-			public boolean visit(ISigilBundle bundle) {
-				if (policy.accept(bundle)) {
-					IBundleModelElement info = bundle.getBundleInfo();
-					for ( IPackageExport e : info.getExports() ) {
-						if ( pi.getPackageName().equals( e.getPackageName() ) && pi.getVersions().contains( e.getVersion() ) ) {
-							found.add( bundle );
-							return false;
-						}
-					}
-				}
-				return true;
-			}
-			
-		};
-		
-		accept( visitor, options );
-		
-		return found.isEmpty() ? null : found.iterator().next();
-	}
-
-	public ISigilBundle findProvider(final IRequiredBundle req, int options) {
-		final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-		
-		final ILicensePolicy policy = findPolicy(req);
-		
-		IRepositoryVisitor visitor = new IRepositoryVisitor() {
-
-			public boolean visit(ISigilBundle bundle) {
-				if (policy.accept(bundle)) {
-					IBundleModelElement info = bundle.getBundleInfo();
-					if ( req.getSymbolicName().equals( info.getSymbolicName() ) && req.getVersions().contains( info.getVersion() ) ) {
-						found.add( bundle );
-						return false;
-					}
-				}
-				return true;
-			}
-			
-		};
-		
-		accept( visitor, options );
-		
-		return found.isEmpty() ? null : found.iterator().next();
-	}
-	
-	public IBundleModelElement buildBundleModelElement(Manifest mf) {
-		IBundleModelElement info = null;
-		
-		if ( mf != null ) {
-			Attributes attrs = mf.getMainAttributes();
-			String name = attrs.getValue("Bundle-SymbolicName");
-			if (name == null) {
-    			// framework.jar doesn't have Bundle-SymbolicName!
-    			name = attrs.getValue("Bundle-Name");
-			}
-			
-			if (name != null) {
-				try {
-					info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
-					info.setSymbolicName( name.split(";")[0] );
-					info.setVersion( Version.parseVersion( attrs.getValue( "Bundle-Version" ) ) );
-					info.setName( attrs.getValue( "Bundle-Name" ) );
-					info.setDescription( attrs.getValue( "Bundle-Description" ) );
-					info.setVendor( attrs.getValue( "Bundle-Vendor" ) );
-
-					String str = attrs.getValue( "Import-Package" );
-					if ( str != null ) {
-						addImports( info, str );
-					}
-					
-					str = attrs.getValue( "Export-Package" );
-					if ( str != null ) {
-						addExports( info, str );
-					}
-
-					str = attrs.getValue( "Require-Bundle" );
-					if ( str != null ) {
-						addRequires( info, str );
-					}
-
-					str = attrs.getValue( "Bundle-Classpath" );
-
-					if ( str != null ) {
-						addClasspath( info, str );
-					}
-					
-					str = attrs.getValue( "Fragment-Host" );
-					if ( str != null ) {
-						addHost(info, str);
-					}
-				}
-				catch (RuntimeException e) {
-					BldCore.error( "Failed to read info from bundle " + name, e );
-					// clear elements as clearly got garbage
-					info = null;
-				}
-			}
-		}
-		
-		return info;
-	}
-
-	protected ILicensePolicy findPolicy(IModelElement elem) {
-		ILicenseManager man = BldCore.getLicenseManager();
-		
-/*		ISigilProjectModel p = elem.getAncestor(ISigilProjectModel.class);
-		
-		ILicensePolicy policy = null;
-		
-		if ( p != null ) {
-			policy = man.getPolicy(p);
-		}
-		else {
-			policy = man.getDefaultPolicy();
-		}
-		
-		return policy; */
-		
-		return man.getDefaultPolicy();
-	}
-	
-	private void addClasspath(IBundleModelElement info, String cpStr) {
-		for ( String cp : cpStr.split( "\\s*,\\s*" ) ) {
-			info.addClasspath( cp );
-		}
-	}
-
-	private void addExports(IBundleModelElement info, String exportStr) throws ModelElementFactoryException {
-		for ( String exp : QuoteUtil.split( exportStr ) ) {
-			try { 
-				String[] parts = exp.split( ";" );
-				IPackageExport pe = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
-				pe.setPackageName( parts[0].trim() );
-				
-				if ( parts.length > 1 ) {
-					for (int i = 1; i < parts.length; i++ ) {
-						String check = parts[i];
-						if ( check.toLowerCase().startsWith( "version=" ) ) {
-							pe.setVersion( parseVersion(check.substring("version=".length())));
-						}
-						else if ( check.toLowerCase().startsWith( "specification-version=" ) ) {
-							pe.setVersion( parseVersion( check.substring("specification-version=".length()) ) );
-						}
-						else if ( check.toLowerCase().startsWith( "uses:=" ) ) {
-							for (String use : parseUses( check.substring( "uses:=".length() ) ) ) {
-								pe.addUse(use);
-							}
-						}
-					}
-				}
-				info.addExport(pe);
-			}
-			catch (RuntimeException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-
-	private Collection<String> parseUses(String uses) {
-		if ( uses.startsWith( "\"") ) {
-			uses = uses.substring(1, uses.length() - 2 );
-		}
-		
-		return Arrays.asList( uses.split(",") );
-	}
-
-	private Version parseVersion(String val) {
-        val = val.replaceAll("\"", "");
-        return new Version(val);
-	}
-
-	private void addImports(IBundleModelElement info, String importStr) throws ModelElementFactoryException {
-		for ( String imp : QuoteUtil.split( importStr ) ) {
-			String[] parts = imp.split( ";" );
-			IPackageImport pi = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
-			pi.setPackageName( parts[0].trim() );
-			
-			if ( parts.length > 1 ) {
-				for ( int i = 1; i < parts.length; i++ ) {
-					String p = parts[i];
-					if ( p.toLowerCase().startsWith( "version=" ) ) {
-						pi.setVersions( VersionRange.parseVersionRange(p.substring("version=".length())));
-					}
-					else if ( p.toLowerCase().startsWith( "specification-version=" ) ) {
-						pi.setVersions( VersionRange.parseVersionRange( p.substring("specification-version=".length()) ));
-					}
-					else if ( p.toLowerCase().startsWith( "resolution:=" ) ) {
-						pi.setOptional( p.toLowerCase().substring("resolution:=".length()).equals( "optional") );
-					}
-				}
-			}
-			info.addImport(pi);
-		}
-	}
-
-	private void addRequires(IBundleModelElement info, String reqStr) throws ModelElementFactoryException {
-		for ( String imp : QuoteUtil.split( reqStr ) ) {
-			String[] parts = imp.split( ";" );
-			IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
-			req.setSymbolicName( parts[0] );
-			
-			if ( parts.length > 1 ) {
-				if ( parts[1].toLowerCase().startsWith( "version=" ) ) {
-					req.setVersions( VersionRange.parseVersionRange(parts[1].substring("version=".length())));
-				}
-				else if ( parts[1].toLowerCase().startsWith( "specification-version=" ) ) {
-					req.setVersions( VersionRange.parseVersionRange( parts[1].substring("specification-version=".length()) ));
-				}
-			}
-			info.addRequiredBundle(req);
-		}
-	}
-	
-	/**
-	 * @param info
-	 * @param str
-	 */
-	private void addHost(IBundleModelElement info, String str) {
-		String[] parts = str.split( ";" );
-		IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
-		req.setSymbolicName( parts[0].trim() );
-		
-		if ( parts.length > 1 ) {
-			String part = parts[1].toLowerCase().trim();
-			if ( part.startsWith( "bundle-version=" ) ) {
-				req.setVersions( VersionRange.parseVersionRange(part.substring("bundle-version=".length())));
-			}
-		}
-		info.setFragmentHost(req);
-	}
+
+public abstract class AbstractBundleRepository implements IBundleRepository
+{
+
+    private final String id;
+    private final HashSet<IBundleRepositoryListener> listeners = new HashSet<IBundleRepositoryListener>();
+
+
+    public AbstractBundleRepository( String id )
+    {
+        this.id = id;
+    }
+
+
+    public abstract void accept( IRepositoryVisitor visitor, int options );
+
+
+    public void addBundleRepositoryListener( IBundleRepositoryListener listener )
+    {
+        synchronized ( listeners )
+        {
+            listeners.add( listener );
+        }
+    }
+
+
+    public void removeBundleRepositoryListener( IBundleRepositoryListener listener )
+    {
+        synchronized ( listeners )
+        {
+            listeners.remove( listener );
+        }
+    }
+
+
+    protected void notifyChange()
+    {
+        for ( IBundleRepositoryListener l : listeners )
+        {
+            l.notifyChange( this );
+        }
+    }
+
+
+    public String getId()
+    {
+        return id;
+    }
+
+
+    public void accept( IRepositoryVisitor visitor )
+    {
+        accept( visitor, 0 );
+    }
+
+
+    public void writeOBR( OutputStream out ) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    public Collection<ISigilBundle> findProviders( final ILibrary library, int options )
+    {
+        final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+
+        final ILicensePolicy policy = findPolicy( library );
+
+        IRepositoryVisitor visitor = new IRepositoryVisitor()
+        {
+            public boolean visit( ISigilBundle bundle )
+            {
+                if ( policy.accept( bundle ) )
+                {
+                    IBundleModelElement info = bundle.getBundleInfo();
+                    for ( IPackageImport pi : library.getImports() )
+                    {
+                        for ( IPackageExport e : info.getExports() )
+                        {
+                            if ( pi.getPackageName().equals( e.getPackageName() )
+                                && pi.getVersions().contains( e.getVersion() ) )
+                            {
+                                found.add( bundle );
+                                break;
+                            }
+                        }
+                    }
+                }
+                return true;
+            }
+        };
+
+        accept( visitor, options );
+
+        return found;
+    }
+
+
+    public Collection<ISigilBundle> findAllProviders( final IRequiredBundle req, int options )
+    {
+        final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+
+        final ILicensePolicy policy = findPolicy( req );
+
+        IRepositoryVisitor visitor = new IRepositoryVisitor()
+        {
+            public boolean visit( ISigilBundle bundle )
+            {
+                if ( policy.accept( bundle ) )
+                {
+                    IBundleModelElement info = bundle.getBundleInfo();
+                    if ( req.getSymbolicName().equals( info.getSymbolicName() )
+                        && req.getVersions().contains( info.getVersion() ) )
+                    {
+                        found.add( bundle );
+                    }
+                }
+                return true;
+            }
+        };
+
+        accept( visitor, options );
+
+        return found;
+    }
+
+
+    public Collection<ISigilBundle> findAllProviders( final IPackageImport pi, int options )
+    {
+        final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+
+        final ILicensePolicy policy = findPolicy( pi );
+
+        IRepositoryVisitor visitor = new IRepositoryVisitor()
+        {
+
+            public boolean visit( ISigilBundle bundle )
+            {
+                if ( policy.accept( bundle ) )
+                {
+                    IBundleModelElement info = bundle.getBundleInfo();
+                    if ( info != null )
+                    {
+                        for ( IPackageExport e : info.getExports() )
+                        {
+                            if ( pi.getPackageName().equals( e.getPackageName() ) )
+                            {
+                                if ( pi.getVersions().contains( e.getVersion() ) )
+                                {
+                                    found.add( bundle );
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+                return true;
+            }
+
+        };
+
+        accept( visitor, options );
+
+        return found;
+    }
+
+
+    public ISigilBundle findProvider( final IPackageImport pi, int options )
+    {
+        final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+
+        final ILicensePolicy policy = findPolicy( pi );
+
+        IRepositoryVisitor visitor = new IRepositoryVisitor()
+        {
+            public boolean visit( ISigilBundle bundle )
+            {
+                if ( policy.accept( bundle ) )
+                {
+                    IBundleModelElement info = bundle.getBundleInfo();
+                    for ( IPackageExport e : info.getExports() )
+                    {
+                        if ( pi.getPackageName().equals( e.getPackageName() )
+                            && pi.getVersions().contains( e.getVersion() ) )
+                        {
+                            found.add( bundle );
+                            return false;
+                        }
+                    }
+                }
+                return true;
+            }
+
+        };
+
+        accept( visitor, options );
+
+        return found.isEmpty() ? null : found.iterator().next();
+    }
+
+
+    public ISigilBundle findProvider( final IRequiredBundle req, int options )
+    {
+        final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+
+        final ILicensePolicy policy = findPolicy( req );
+
+        IRepositoryVisitor visitor = new IRepositoryVisitor()
+        {
+
+            public boolean visit( ISigilBundle bundle )
+            {
+                if ( policy.accept( bundle ) )
+                {
+                    IBundleModelElement info = bundle.getBundleInfo();
+                    if ( req.getSymbolicName().equals( info.getSymbolicName() )
+                        && req.getVersions().contains( info.getVersion() ) )
+                    {
+                        found.add( bundle );
+                        return false;
+                    }
+                }
+                return true;
+            }
+
+        };
+
+        accept( visitor, options );
+
+        return found.isEmpty() ? null : found.iterator().next();
+    }
+
+
+    public IBundleModelElement buildBundleModelElement( Manifest mf )
+    {
+        IBundleModelElement info = null;
+
+        if ( mf != null )
+        {
+            Attributes attrs = mf.getMainAttributes();
+            String name = attrs.getValue( "Bundle-SymbolicName" );
+            if ( name == null )
+            {
+                // framework.jar doesn't have Bundle-SymbolicName!
+                name = attrs.getValue( "Bundle-Name" );
+            }
+
+            if ( name != null )
+            {
+                try
+                {
+                    info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
+                    info.setSymbolicName( name.split( ";" )[0] );
+                    info.setVersion( Version.parseVersion( attrs.getValue( "Bundle-Version" ) ) );
+                    info.setName( attrs.getValue( "Bundle-Name" ) );
+                    info.setDescription( attrs.getValue( "Bundle-Description" ) );
+                    info.setVendor( attrs.getValue( "Bundle-Vendor" ) );
+
+                    String str = attrs.getValue( "Import-Package" );
+                    if ( str != null )
+                    {
+                        addImports( info, str );
+                    }
+
+                    str = attrs.getValue( "Export-Package" );
+                    if ( str != null )
+                    {
+                        addExports( info, str );
+                    }
+
+                    str = attrs.getValue( "Require-Bundle" );
+                    if ( str != null )
+                    {
+                        addRequires( info, str );
+                    }
+
+                    str = attrs.getValue( "Bundle-Classpath" );
+
+                    if ( str != null )
+                    {
+                        addClasspath( info, str );
+                    }
+
+                    str = attrs.getValue( "Fragment-Host" );
+                    if ( str != null )
+                    {
+                        addHost( info, str );
+                    }
+                }
+                catch ( RuntimeException e )
+                {
+                    BldCore.error( "Failed to read info from bundle " + name, e );
+                    // clear elements as clearly got garbage
+                    info = null;
+                }
+            }
+        }
+
+        return info;
+    }
+
+
+    protected ILicensePolicy findPolicy( IModelElement elem )
+    {
+        ILicenseManager man = BldCore.getLicenseManager();
+
+        /*		ISigilProjectModel p = elem.getAncestor(ISigilProjectModel.class);
+        		
+        		ILicensePolicy policy = null;
+        		
+        		if ( p != null ) {
+        			policy = man.getPolicy(p);
+        		}
+        		else {
+        			policy = man.getDefaultPolicy();
+        		}
+        		
+        		return policy; */
+
+        return man.getDefaultPolicy();
+    }
+
+
+    private void addClasspath( IBundleModelElement info, String cpStr )
+    {
+        for ( String cp : cpStr.split( "\\s*,\\s*" ) )
+        {
+            info.addClasspath( cp );
+        }
+    }
+
+
+    private void addExports( IBundleModelElement info, String exportStr ) throws ModelElementFactoryException
+    {
+        for ( String exp : QuoteUtil.split( exportStr ) )
+        {
+            try
+            {
+                String[] parts = exp.split( ";" );
+                IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
+                pe.setPackageName( parts[0].trim() );
+
+                if ( parts.length > 1 )
+                {
+                    for ( int i = 1; i < parts.length; i++ )
+                    {
+                        String check = parts[i];
+                        if ( check.toLowerCase().startsWith( "version=" ) )
+                        {
+                            pe.setVersion( parseVersion( check.substring( "version=".length() ) ) );
+                        }
+                        else if ( check.toLowerCase().startsWith( "specification-version=" ) )
+                        {
+                            pe.setVersion( parseVersion( check.substring( "specification-version=".length() ) ) );
+                        }
+                        else if ( check.toLowerCase().startsWith( "uses:=" ) )
+                        {
+                            for ( String use : parseUses( check.substring( "uses:=".length() ) ) )
+                            {
+                                pe.addUse( use );
+                            }
+                        }
+                    }
+                }
+                info.addExport( pe );
+            }
+            catch ( RuntimeException e )
+            {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    private Collection<String> parseUses( String uses )
+    {
+        if ( uses.startsWith( "\"" ) )
+        {
+            uses = uses.substring( 1, uses.length() - 2 );
+        }
+
+        return Arrays.asList( uses.split( "," ) );
+    }
+
+
+    private Version parseVersion( String val )
+    {
+        val = val.replaceAll( "\"", "" );
+        return new Version( val );
+    }
+
+
+    private void addImports( IBundleModelElement info, String importStr ) throws ModelElementFactoryException
+    {
+        for ( String imp : QuoteUtil.split( importStr ) )
+        {
+            String[] parts = imp.split( ";" );
+            IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
+            pi.setPackageName( parts[0].trim() );
+
+            if ( parts.length > 1 )
+            {
+                for ( int i = 1; i < parts.length; i++ )
+                {
+                    String p = parts[i];
+                    if ( p.toLowerCase().startsWith( "version=" ) )
+                    {
+                        pi.setVersions( VersionRange.parseVersionRange( p.substring( "version=".length() ) ) );
+                    }
+                    else if ( p.toLowerCase().startsWith( "specification-version=" ) )
+                    {
+                        pi.setVersions( VersionRange
+                            .parseVersionRange( p.substring( "specification-version=".length() ) ) );
+                    }
+                    else if ( p.toLowerCase().startsWith( "resolution:=" ) )
+                    {
+                        pi.setOptional( p.toLowerCase().substring( "resolution:=".length() ).equals( "optional" ) );
+                    }
+                }
+            }
+            info.addImport( pi );
+        }
+    }
+
+
+    private void addRequires( IBundleModelElement info, String reqStr ) throws ModelElementFactoryException
+    {
+        for ( String imp : QuoteUtil.split( reqStr ) )
+        {
+            String[] parts = imp.split( ";" );
+            IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+            req.setSymbolicName( parts[0] );
+
+            if ( parts.length > 1 )
+            {
+                if ( parts[1].toLowerCase().startsWith( "version=" ) )
+                {
+                    req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "version=".length() ) ) );
+                }
+                else if ( parts[1].toLowerCase().startsWith( "specification-version=" ) )
+                {
+                    req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "specification-version="
+                        .length() ) ) );
+                }
+            }
+            info.addRequiredBundle( req );
+        }
+    }
+
+
+    /**
+     * @param info
+     * @param str
+     */
+    private void addHost( IBundleModelElement info, String str )
+    {
+        String[] parts = str.split( ";" );
+        IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+        req.setSymbolicName( parts[0].trim() );
+
+        if ( parts.length > 1 )
+        {
+            String part = parts[1].toLowerCase().trim();
+            if ( part.startsWith( "bundle-version=" ) )
+            {
+                req.setVersions( VersionRange.parseVersionRange( part.substring( "bundle-version=".length() ) ) );
+            }
+        }
+        info.setFragmentHost( req );
+    }
 }
\ No newline at end of file

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractRepositoryManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractRepositoryManager.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractRepositoryManager.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/AbstractRepositoryManager.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -37,279 +38,369 @@
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.repository.RepositoryChangeEvent.Type;
 
-public abstract class AbstractRepositoryManager implements IRepositoryManager, IBundleRepositoryListener {
 
-	private HashSet<IRepositoryChangeListener> listeners = new HashSet<IRepositoryChangeListener>();
-	
-	private boolean initialised;
-	
-	private HashMap<String, IBundleRepository> repositories = new HashMap<String, IBundleRepository>();
-	private ArrayList<IBundleRepository> order = new ArrayList<IBundleRepository>();
-	private TreeMap<Integer, HashSet<IBundleRepository>> levelMap = new TreeMap<Integer, HashSet<IBundleRepository>>();
-	private int[] levels;
-	
-	private BundleResolver resolver = new BundleResolver(this);
-	
-	private ArrayList<ILibrary> libraries = new ArrayList<ILibrary>();
-	
-	public void initialise() {
-		synchronized( repositories ) {
-			if ( !initialised ) {
-				initialised = true;
-				loadRepositories();
-			}
-		}
-	}
-	
-	protected abstract void loadRepositories();
-
-	public void addRepositoryChangeListener(IRepositoryChangeListener listener) {
-		synchronized(listeners) {
-			listeners.add(listener);			
-		}
-	}
-
-	public void removeRepositoryChangeListener(IRepositoryChangeListener listener) {
-		synchronized(listeners) {
-			listeners.remove(listener);
-		}
-	}
-	
-	public void notifyChange(IBundleRepository repository) {
-		notifyListeners( new RepositoryChangeEvent(repository, Type.CHANGED ) );
-	}
-
-	private void notifyListeners(RepositoryChangeEvent event) {
-		ArrayList<IRepositoryChangeListener> safe = null;
-		synchronized(listeners) {
-			safe = new ArrayList<IRepositoryChangeListener>(listeners);
-		}
-		for ( IRepositoryChangeListener l : safe ) {
-			l.repositoryChanged(event);
-		}
-	}
-	
-	protected void setRepositories(IBundleRepository[] repos) {
-		synchronized( repositories ) {
-			repositories.clear();
-			order.clear();
-			levelMap.clear();
-			resetLevels();
-			if ( repos != null ) {
-				for ( int i = 0; i < repos.length; i++ ) {
-					addRepository(repos[i], i);
-				}
-			}
-		}
-	}
-
-	protected void addRepository(IBundleRepository rep, int level) {
-		Type type = null;
-		
-		synchronized( repositories ) {
-			IBundleRepository old = repositories.put(rep.getId(), rep); 
-			if ( old == null ) {
-				type = Type.ADDED;
-				rep.addBundleRepositoryListener(this);
-			}
-			else {
-				old.removeBundleRepositoryListener(this);
-				type = Type.CHANGED;
-				order.remove(old);
-				clearLevel(rep);
-			}
-			
-			order.add(rep);
-			
-			HashSet<IBundleRepository> set = levelMap.get(level);
-			
-			if ( set == null ) {
-				set = new HashSet<IBundleRepository>();
-				levelMap.put( level, set );
-			}
-			
-			set.add( rep );
-			resetLevels();
-		}
-		
-		notifyListeners( new RepositoryChangeEvent(rep, type ) );
-	}
-	
-	protected void removeRepository(IBundleRepository rep) {
-		Type type = null;
-		
-		synchronized( repositories ) {
-			if ( repositories.remove(rep.getId()) != null ) {
-				order.remove(rep);
-				type = Type.REMOVED;
-				clearLevel(rep);
-				resetLevels();
-			}
-		}
-		
-		if ( type != null ) {
-			notifyListeners( new RepositoryChangeEvent(rep, type ) );
-		}
-	}
-	
-	private void clearLevel(IBundleRepository rep) {
-		for ( Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter.hasNext(); ) {
-			Map.Entry<Integer, HashSet<IBundleRepository>> e = iter.next();
-			if ( e.getValue().remove(rep) ) {
-				if ( e.getValue().isEmpty() ) {
-					iter.remove();
-				}					
-				break;
-			}				
-		}
-	}
-
-	public Collection<IBundleRepository> getRepositories() {
-		initialise();
-		ArrayList<IBundleRepository> safe = null;
-		
-		synchronized( repositories ) {
-			safe = new ArrayList<IBundleRepository>( order );
-		}
-		
-		return safe;
-	}
-
-	private void resetLevels() {
-		Collections.sort(order, new Comparator<IBundleRepository>() {
-			public int compare(IBundleRepository o1, IBundleRepository o2) {
-				int l1 = findLevel(o1);
-				int l2 = findLevel(o2);
-				
-				if ( l1 < l2 ) {
-					return -1;
-				}
-				else if ( l1 > l2 ) {
-					return 1;
-				}
-				else {
-					return 0;
-				}
-			}
-
-			private int findLevel(IBundleRepository rep) {
-				for ( Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet() ) {
-					if ( e.getValue().contains( rep ) ) {
-						return e.getKey();
-					}
-				}
-				throw new IllegalStateException();
-			}
-		});
-		levels = new int[levelMap.size()];
-		int i = 0;
-		for ( Integer v : levelMap.keySet() ) {
-			levels[i++] = v;
-		}			
-	}
-	
-
-	public int[] getPriorityLevels() {
-		initialise();
-		synchronized( repositories ) {
-			return levels;
-		}
-	}
-
-	public Collection<IBundleRepository> getRepositories(int priorityLevel) {
-		initialise();
-		List<IBundleRepository> found = null;
-		
-		synchronized (repositories) {
-			HashSet<IBundleRepository> b = levelMap.get(priorityLevel);
-			if ( b == null ) {
-				found = Collections.emptyList();
-			}
-			else {
-				found = new ArrayList<IBundleRepository>(b);
-			}
-		}
-		
-		return found;
-	}
-
-	public void addLibrary(ILibrary library) {
-		synchronized( libraries ) {
-			libraries.add(library);
-		}
-	}
-	
-	public void removeLibrary(ILibrary library) {
-		synchronized( libraries ) {
-			libraries.remove(library);
-		}
-	}
-	
-	public Collection<ILibrary> getLibraries() {
-		synchronized( libraries ) {
-			return libraries;
-		}
-	}
-
-	public ILibrary resolveLibrary(final ILibraryImport l) {
-		final ArrayList<ILibrary> found = new ArrayList<ILibrary>(1);
-		//ISigilProjectModel p = l.getAncestor(ISigilProjectModel.class);
-		//
-		//IModelWalker w = new IModelWalker() {
-		//	public boolean visit(IModelElement element) {
-		//		if ( element instanceof ILibrary ) {
-		//			updateLibrary(l, (ILibrary) element, found);
-		//			return false;
-		//		}
-		//		
-		//		return true;
-		//	}
-		//};
-		
-		//p.visit( w );
-		
-		//if ( found.isEmpty() ) { // no project specific libraries - check workspace definitions
-			synchronized( libraries ) {
-				for ( ILibrary lib : libraries ) {
-					if ( l.getLibraryName().equals( lib.getName() ) && l.getVersions().contains(lib.getVersion()) ) {
-						updateLibrary(l, lib, found);
-					}
-				}
-			}
-		//}
-		
-		return found.isEmpty() ? null : found.get(0);		
-	}
-
-	protected void updateLibrary(ILibraryImport li, ILibrary l, ArrayList<ILibrary> found) {
-		if ( li.getLibraryName().equals( l.getName() ) && li.getVersions().contains(l.getVersion()) ) {
-			if ( found.isEmpty() ) {
-				found.add( l );
-			}
-			else {
-				ILibrary c = found.get(0);
-				if ( l.getVersion().compareTo(c.getVersion()) > 0 ) {
-					found.remove(0);
-					found.add(l);
-				}
-			}
-		}
-	}
-
-	public IBundleResolver getBundleResolver() {
-		return resolver;
-	}
-
-	public void visit(final IModelWalker walker) {
-		for (IBundleRepository rep : getRepositories()) {
-			IRepositoryVisitor wrapper = new IRepositoryVisitor() {
-				public boolean visit(ISigilBundle bundle) {
-					bundle.visit(walker);
-					// return true as still want to visit other bundles
-					return true;
-				}
-			};
-			rep.accept(wrapper);
-		}
-	}
+public abstract class AbstractRepositoryManager implements IRepositoryManager, IBundleRepositoryListener
+{
+
+    private HashSet<IRepositoryChangeListener> listeners = new HashSet<IRepositoryChangeListener>();
+
+    private boolean initialised;
+
+    private HashMap<String, IBundleRepository> repositories = new HashMap<String, IBundleRepository>();
+    private ArrayList<IBundleRepository> order = new ArrayList<IBundleRepository>();
+    private TreeMap<Integer, HashSet<IBundleRepository>> levelMap = new TreeMap<Integer, HashSet<IBundleRepository>>();
+    private int[] levels;
+
+    private BundleResolver resolver = new BundleResolver( this );
+
+    private ArrayList<ILibrary> libraries = new ArrayList<ILibrary>();
+
+
+    public void initialise()
+    {
+        synchronized ( repositories )
+        {
+            if ( !initialised )
+            {
+                initialised = true;
+                loadRepositories();
+            }
+        }
+    }
+
+
+    protected abstract void loadRepositories();
+
+
+    public void addRepositoryChangeListener( IRepositoryChangeListener listener )
+    {
+        synchronized ( listeners )
+        {
+            listeners.add( listener );
+        }
+    }
+
+
+    public void removeRepositoryChangeListener( IRepositoryChangeListener listener )
+    {
+        synchronized ( listeners )
+        {
+            listeners.remove( listener );
+        }
+    }
+
+
+    public void notifyChange( IBundleRepository repository )
+    {
+        notifyListeners( new RepositoryChangeEvent( repository, Type.CHANGED ) );
+    }
+
+
+    private void notifyListeners( RepositoryChangeEvent event )
+    {
+        ArrayList<IRepositoryChangeListener> safe = null;
+        synchronized ( listeners )
+        {
+            safe = new ArrayList<IRepositoryChangeListener>( listeners );
+        }
+        for ( IRepositoryChangeListener l : safe )
+        {
+            l.repositoryChanged( event );
+        }
+    }
+
+
+    protected void setRepositories( IBundleRepository[] repos )
+    {
+        synchronized ( repositories )
+        {
+            repositories.clear();
+            order.clear();
+            levelMap.clear();
+            resetLevels();
+            if ( repos != null )
+            {
+                for ( int i = 0; i < repos.length; i++ )
+                {
+                    addRepository( repos[i], i );
+                }
+            }
+        }
+    }
+
+
+    protected void addRepository( IBundleRepository rep, int level )
+    {
+        Type type = null;
+
+        synchronized ( repositories )
+        {
+            IBundleRepository old = repositories.put( rep.getId(), rep );
+            if ( old == null )
+            {
+                type = Type.ADDED;
+                rep.addBundleRepositoryListener( this );
+            }
+            else
+            {
+                old.removeBundleRepositoryListener( this );
+                type = Type.CHANGED;
+                order.remove( old );
+                clearLevel( rep );
+            }
+
+            order.add( rep );
+
+            HashSet<IBundleRepository> set = levelMap.get( level );
+
+            if ( set == null )
+            {
+                set = new HashSet<IBundleRepository>();
+                levelMap.put( level, set );
+            }
+
+            set.add( rep );
+            resetLevels();
+        }
+
+        notifyListeners( new RepositoryChangeEvent( rep, type ) );
+    }
+
+
+    protected void removeRepository( IBundleRepository rep )
+    {
+        Type type = null;
+
+        synchronized ( repositories )
+        {
+            if ( repositories.remove( rep.getId() ) != null )
+            {
+                order.remove( rep );
+                type = Type.REMOVED;
+                clearLevel( rep );
+                resetLevels();
+            }
+        }
+
+        if ( type != null )
+        {
+            notifyListeners( new RepositoryChangeEvent( rep, type ) );
+        }
+    }
+
+
+    private void clearLevel( IBundleRepository rep )
+    {
+        for ( Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter
+            .hasNext(); )
+        {
+            Map.Entry<Integer, HashSet<IBundleRepository>> e = iter.next();
+            if ( e.getValue().remove( rep ) )
+            {
+                if ( e.getValue().isEmpty() )
+                {
+                    iter.remove();
+                }
+                break;
+            }
+        }
+    }
+
+
+    public Collection<IBundleRepository> getRepositories()
+    {
+        initialise();
+        ArrayList<IBundleRepository> safe = null;
+
+        synchronized ( repositories )
+        {
+            safe = new ArrayList<IBundleRepository>( order );
+        }
+
+        return safe;
+    }
+
+
+    private void resetLevels()
+    {
+        Collections.sort( order, new Comparator<IBundleRepository>()
+        {
+            public int compare( IBundleRepository o1, IBundleRepository o2 )
+            {
+                int l1 = findLevel( o1 );
+                int l2 = findLevel( o2 );
+
+                if ( l1 < l2 )
+                {
+                    return -1;
+                }
+                else if ( l1 > l2 )
+                {
+                    return 1;
+                }
+                else
+                {
+                    return 0;
+                }
+            }
+
+
+            private int findLevel( IBundleRepository rep )
+            {
+                for ( Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet() )
+                {
+                    if ( e.getValue().contains( rep ) )
+                    {
+                        return e.getKey();
+                    }
+                }
+                throw new IllegalStateException();
+            }
+        } );
+        levels = new int[levelMap.size()];
+        int i = 0;
+        for ( Integer v : levelMap.keySet() )
+        {
+            levels[i++] = v;
+        }
+    }
+
+
+    public int[] getPriorityLevels()
+    {
+        initialise();
+        synchronized ( repositories )
+        {
+            return levels;
+        }
+    }
+
+
+    public Collection<IBundleRepository> getRepositories( int priorityLevel )
+    {
+        initialise();
+        List<IBundleRepository> found = null;
+
+        synchronized ( repositories )
+        {
+            HashSet<IBundleRepository> b = levelMap.get( priorityLevel );
+            if ( b == null )
+            {
+                found = Collections.emptyList();
+            }
+            else
+            {
+                found = new ArrayList<IBundleRepository>( b );
+            }
+        }
+
+        return found;
+    }
+
+
+    public void addLibrary( ILibrary library )
+    {
+        synchronized ( libraries )
+        {
+            libraries.add( library );
+        }
+    }
+
+
+    public void removeLibrary( ILibrary library )
+    {
+        synchronized ( libraries )
+        {
+            libraries.remove( library );
+        }
+    }
+
+
+    public Collection<ILibrary> getLibraries()
+    {
+        synchronized ( libraries )
+        {
+            return libraries;
+        }
+    }
+
+
+    public ILibrary resolveLibrary( final ILibraryImport l )
+    {
+        final ArrayList<ILibrary> found = new ArrayList<ILibrary>( 1 );
+        //ISigilProjectModel p = l.getAncestor(ISigilProjectModel.class);
+        //
+        //IModelWalker w = new IModelWalker() {
+        //	public boolean visit(IModelElement element) {
+        //		if ( element instanceof ILibrary ) {
+        //			updateLibrary(l, (ILibrary) element, found);
+        //			return false;
+        //		}
+        //		
+        //		return true;
+        //	}
+        //};
+
+        //p.visit( w );
+
+        //if ( found.isEmpty() ) { // no project specific libraries - check workspace definitions
+        synchronized ( libraries )
+        {
+            for ( ILibrary lib : libraries )
+            {
+                if ( l.getLibraryName().equals( lib.getName() ) && l.getVersions().contains( lib.getVersion() ) )
+                {
+                    updateLibrary( l, lib, found );
+                }
+            }
+        }
+        //}
+
+        return found.isEmpty() ? null : found.get( 0 );
+    }
+
+
+    protected void updateLibrary( ILibraryImport li, ILibrary l, ArrayList<ILibrary> found )
+    {
+        if ( li.getLibraryName().equals( l.getName() ) && li.getVersions().contains( l.getVersion() ) )
+        {
+            if ( found.isEmpty() )
+            {
+                found.add( l );
+            }
+            else
+            {
+                ILibrary c = found.get( 0 );
+                if ( l.getVersion().compareTo( c.getVersion() ) > 0 )
+                {
+                    found.remove( 0 );
+                    found.add( l );
+                }
+            }
+        }
+    }
+
+
+    public IBundleResolver getBundleResolver()
+    {
+        return resolver;
+    }
+
+
+    public void visit( final IModelWalker walker )
+    {
+        for ( IBundleRepository rep : getRepositories() )
+        {
+            IRepositoryVisitor wrapper = new IRepositoryVisitor()
+            {
+                public boolean visit( ISigilBundle bundle )
+                {
+                    bundle.visit( walker );
+                    // return true as still want to visit other bundles
+                    return true;
+                }
+            };
+            rep.accept( wrapper );
+        }
+    }
 }
\ No newline at end of file

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepository.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepository.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Collection;
@@ -28,32 +29,46 @@
 import org.apache.felix.sigil.model.osgi.IPackageImport;
 import org.apache.felix.sigil.model.osgi.IRequiredBundle;
 
-public interface IBundleRepository {
-	static final int NORMAL_PRIORITY = 0;
-	static final int MAXIMUM_PRIORITY = -500;
-	static final int MINIMUM_PRIORITY = 500;
-	
-	String getId();
-	
-	void addBundleRepositoryListener(IBundleRepositoryListener listener);
-	
-	void removeBundleRepositoryListener(IBundleRepositoryListener listener);
-	
-	void accept(IRepositoryVisitor visitor);
-	
-	void accept(IRepositoryVisitor visitor, int options);
-	
-	void writeOBR(OutputStream out) throws IOException;
-	
-	void refresh();
-	
-	ISigilBundle findProvider(IPackageImport packageImport, int options);
-	
-	ISigilBundle findProvider(IRequiredBundle bundle, int options);
-	
-	Collection<ISigilBundle> findAllProviders(IRequiredBundle bundle, int options);
-	
-	Collection<ISigilBundle> findAllProviders(IPackageImport packageImport, int options);
-	
-	Collection<ISigilBundle> findProviders(ILibrary library, int options);
+
+public interface IBundleRepository
+{
+    static final int NORMAL_PRIORITY = 0;
+    static final int MAXIMUM_PRIORITY = -500;
+    static final int MINIMUM_PRIORITY = 500;
+
+
+    String getId();
+
+
+    void addBundleRepositoryListener( IBundleRepositoryListener listener );
+
+
+    void removeBundleRepositoryListener( IBundleRepositoryListener listener );
+
+
+    void accept( IRepositoryVisitor visitor );
+
+
+    void accept( IRepositoryVisitor visitor, int options );
+
+
+    void writeOBR( OutputStream out ) throws IOException;
+
+
+    void refresh();
+
+
+    ISigilBundle findProvider( IPackageImport packageImport, int options );
+
+
+    ISigilBundle findProvider( IRequiredBundle bundle, int options );
+
+
+    Collection<ISigilBundle> findAllProviders( IRequiredBundle bundle, int options );
+
+
+    Collection<ISigilBundle> findAllProviders( IPackageImport packageImport, int options );
+
+
+    Collection<ISigilBundle> findProviders( ILibrary library, int options );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepositoryListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepositoryListener.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepositoryListener.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleRepositoryListener.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,8 @@
 
 package org.apache.felix.sigil.repository;
 
-public interface IBundleRepositoryListener {
-	void notifyChange(IBundleRepository repository);
+
+public interface IBundleRepositoryListener
+{
+    void notifyChange( IBundleRepository repository );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleResolver.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleResolver.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IBundleResolver.java Tue Jul 21 18:51:33 2009
@@ -19,8 +19,12 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import org.apache.felix.sigil.model.IModelElement;
 
-public interface IBundleResolver {
-	IResolution resolve(IModelElement element, ResolutionConfig config, IResolutionMonitor monitor) throws ResolutionException;
+
+public interface IBundleResolver
+{
+    IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
+        throws ResolutionException;
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IProviderChangeListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IProviderChangeListener.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IProviderChangeListener.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IProviderChangeListener.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,8 @@
 
 package org.apache.felix.sigil.repository;
 
-public interface IProviderChangeListener {
-	void notifyChange(IRepositoryProvider provider);
+
+public interface IProviderChangeListener
+{
+    void notifyChange( IRepositoryProvider provider );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryChangeListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryChangeListener.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryChangeListener.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryChangeListener.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,8 @@
 
 package org.apache.felix.sigil.repository;
 
-public interface IRepositoryChangeListener {
-	void repositoryChanged(RepositoryChangeEvent event);
+
+public interface IRepositoryChangeListener
+{
+    void repositoryChanged( RepositoryChangeEvent event );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryManager.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryManager.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryManager.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.util.Collection;
 
 import org.apache.felix.sigil.model.IModelWalker;
@@ -26,26 +27,38 @@
 import org.apache.felix.sigil.model.eclipse.ILibraryImport;
 import org.eclipse.core.runtime.CoreException;
 
-public interface IRepositoryManager {
-	void addRepositoryChangeListener(IRepositoryChangeListener listener);
-	
-	void removeRepositoryChangeListener(IRepositoryChangeListener listener);
-	
-	Collection<IBundleRepository> getRepositories();
-	
-	Collection<IBundleRepository> getRepositories(int level);
-	
-	void addLibrary(ILibrary library);
-
-	void removeLibrary(ILibrary library);
-
-	Collection<ILibrary> getLibraries();
-
-	ILibrary resolveLibrary(final ILibraryImport l);
-	
-	IBundleResolver getBundleResolver();
 
-	int[] getPriorityLevels();
+public interface IRepositoryManager
+{
+    void addRepositoryChangeListener( IRepositoryChangeListener listener );
+
+
+    void removeRepositoryChangeListener( IRepositoryChangeListener listener );
+
+
+    Collection<IBundleRepository> getRepositories();
+
+
+    Collection<IBundleRepository> getRepositories( int level );
+
+
+    void addLibrary( ILibrary library );
+
+
+    void removeLibrary( ILibrary library );
+
+
+    Collection<ILibrary> getLibraries();
+
+
+    ILibrary resolveLibrary( final ILibraryImport l );
+
+
+    IBundleResolver getBundleResolver();
+
+
+    int[] getPriorityLevels();
+
 
-	void visit(IModelWalker modelWalker);	
+    void visit( IModelWalker modelWalker );
 }
\ No newline at end of file

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryProvider.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryProvider.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryProvider.java Tue Jul 21 18:51:33 2009
@@ -19,8 +19,11 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.util.Properties;
 
-public interface IRepositoryProvider {
-    IBundleRepository createRepository(String id, Properties properties) throws RepositoryException;
+
+public interface IRepositoryProvider
+{
+    IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException;
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryVisitor.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryVisitor.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IRepositoryVisitor.java Tue Jul 21 18:51:33 2009
@@ -19,14 +19,17 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 
-public interface IRepositoryVisitor {
-	/**
-	 * Visit the next bundle in the repository. 
-	 * Return true if should continue visiting other bundles, false otherwise.
-	 * @param bundle
-	 * @return
-	 */
-	boolean visit(ISigilBundle bundle);
+
+public interface IRepositoryVisitor
+{
+    /**
+     * Visit the next bundle in the repository. 
+     * Return true if should continue visiting other bundles, false otherwise.
+     * @param bundle
+     * @return
+     */
+    boolean visit( ISigilBundle bundle );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolution.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolution.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolution.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolution.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import java.util.List;
 import java.util.Set;
 
@@ -26,10 +27,20 @@
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 
-public interface IResolution {
-	Set<ISigilBundle> getBundles();
-	ISigilBundle getProvider(IModelElement requirement);
-	List<IModelElement> getMatchedRequirements(ISigilBundle bundle);
-	void synchronize(IProgressMonitor monitor);
-	boolean isSynchronized();
+
+public interface IResolution
+{
+    Set<ISigilBundle> getBundles();
+
+
+    ISigilBundle getProvider( IModelElement requirement );
+
+
+    List<IModelElement> getMatchedRequirements( ISigilBundle bundle );
+
+
+    void synchronize( IProgressMonitor monitor );
+
+
+    boolean isSynchronized();
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolutionMonitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolutionMonitor.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolutionMonitor.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/IResolutionMonitor.java Tue Jul 21 18:51:33 2009
@@ -19,11 +19,18 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 
-public interface IResolutionMonitor {
-	boolean isCanceled();
-	void startResolution(IModelElement requirement);
-	void endResolution(IModelElement requirement, ISigilBundle sigilBundle);
+
+public interface IResolutionMonitor
+{
+    boolean isCanceled();
+
+
+    void startResolution( IModelElement requirement );
+
+
+    void endResolution( IModelElement requirement, ISigilBundle sigilBundle );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryChangeEvent.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryChangeEvent.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryChangeEvent.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryChangeEvent.java Tue Jul 21 18:51:33 2009
@@ -19,21 +19,33 @@
 
 package org.apache.felix.sigil.repository;
 
-public class RepositoryChangeEvent {
-	public static enum Type { ADDED, CHANGED, REMOVED };
-	
-	private Type type;
-	private IBundleRepository repository;
-	
-	public RepositoryChangeEvent(IBundleRepository repository, Type type) {
-		this.repository = repository;
-		this.type = type;
-	}
-	
-	public Type getType() {
-		return type;
-	}
-	public IBundleRepository getRepository() {
-		return repository;
-	}
+
+public class RepositoryChangeEvent
+{
+    public static enum Type
+    {
+        ADDED, CHANGED, REMOVED
+    };
+
+    private Type type;
+    private IBundleRepository repository;
+
+
+    public RepositoryChangeEvent( IBundleRepository repository, Type type )
+    {
+        this.repository = repository;
+        this.type = type;
+    }
+
+
+    public Type getType()
+    {
+        return type;
+    }
+
+
+    public IBundleRepository getRepository()
+    {
+        return repository;
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryException.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryException.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/RepositoryException.java Tue Jul 21 18:51:33 2009
@@ -19,20 +19,28 @@
 
 package org.apache.felix.sigil.repository;
 
-public class RepositoryException extends Exception {
 
-	private static final long serialVersionUID = 1L;
+public class RepositoryException extends Exception
+{
 
-	public RepositoryException(String msg, Throwable cause) {
-		super(msg, cause);
-	}
+    private static final long serialVersionUID = 1L;
 
-	public RepositoryException(String message) {
-		super(message);
-	}
 
-	public RepositoryException(Throwable cause) {
-		super(cause);
-	}
+    public RepositoryException( String msg, Throwable cause )
+    {
+        super( msg, cause );
+    }
+
+
+    public RepositoryException( String message )
+    {
+        super( message );
+    }
+
+
+    public RepositoryException( Throwable cause )
+    {
+        super( cause );
+    }
 
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionConfig.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionConfig.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionConfig.java Tue Jul 21 18:51:33 2009
@@ -19,43 +19,59 @@
 
 package org.apache.felix.sigil.repository;
 
-public class ResolutionConfig {
-	private int options;
-	
-	public static final int INCLUDE_DEPENDENTS = 1;
-	public static final int INCLUDE_OPTIONAL = 2;
-	public static final int IGNORE_ERRORS = 4;
-	/** Return only bundles that are indexed locally */
-	public static final int INDEXED_ONLY = 8;
-	/** Return only bundles that are stored or cached locally */
-	public static final int LOCAL_ONLY = 16;
-
-	public ResolutionConfig() {
-		this(INCLUDE_DEPENDENTS);
-	}
-	
-	public ResolutionConfig(int options) {
-		this.options = options;
-	}
-
-	public int getOptions() {
-		return options;
-	}
-
-	public boolean isDependents() {
-		return (options & INCLUDE_DEPENDENTS) != 0;
-	}
-
-	public boolean isIgnoreErrors() {
-		return (options & IGNORE_ERRORS) != 0;
-	}
-	
-	public boolean isOptional() {
-		return (options & INCLUDE_OPTIONAL) != 0;
-	}
-
-	public boolean isCalculateLocalDependencies() {
-		// TODO Auto-generated method stub
-		return false;
-	}
+
+public class ResolutionConfig
+{
+    private int options;
+
+    public static final int INCLUDE_DEPENDENTS = 1;
+    public static final int INCLUDE_OPTIONAL = 2;
+    public static final int IGNORE_ERRORS = 4;
+    /** Return only bundles that are indexed locally */
+    public static final int INDEXED_ONLY = 8;
+    /** Return only bundles that are stored or cached locally */
+    public static final int LOCAL_ONLY = 16;
+
+
+    public ResolutionConfig()
+    {
+        this( INCLUDE_DEPENDENTS );
+    }
+
+
+    public ResolutionConfig( int options )
+    {
+        this.options = options;
+    }
+
+
+    public int getOptions()
+    {
+        return options;
+    }
+
+
+    public boolean isDependents()
+    {
+        return ( options & INCLUDE_DEPENDENTS ) != 0;
+    }
+
+
+    public boolean isIgnoreErrors()
+    {
+        return ( options & IGNORE_ERRORS ) != 0;
+    }
+
+
+    public boolean isOptional()
+    {
+        return ( options & INCLUDE_OPTIONAL ) != 0;
+    }
+
+
+    public boolean isCalculateLocalDependencies()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionException.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionException.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionException.java Tue Jul 21 18:51:33 2009
@@ -19,45 +19,61 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import org.apache.felix.sigil.model.IModelElement;
 
-public class ResolutionException extends Exception {
 
-	private static final long serialVersionUID = 1L;
-	
-	private IModelElement[] parsed;
-	
-	public ResolutionException(String message, Throwable cause) {
-		super(message, cause);
-	}
-
-	public ResolutionException(String message) {
-		super(message);
-	}
-
-	public ResolutionException(Throwable cause) {
-		super(cause);
-	}
-
-	public ResolutionException(IModelElement root, IModelElement[] parsed) {
-		super(buildMessage(root, parsed));
-		this.parsed = parsed;
-	}
-	
-	private static String buildMessage(IModelElement root, IModelElement[] parsed) {
-		StringBuilder b = new StringBuilder();
-		b.append( "Failed to resolve " );
-		b.append( root );
-		
-		if ( parsed.length > 0 ) {
-			b.append( " due to missing provider for " );
-			b.append( parsed[parsed.length - 1] );
-		}
-		
-		return b.toString();
-	}
-
-	public IModelElement[] getParsed() {
-		return parsed;
-	}
+public class ResolutionException extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private IModelElement[] parsed;
+
+
+    public ResolutionException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+
+    public ResolutionException( String message )
+    {
+        super( message );
+    }
+
+
+    public ResolutionException( Throwable cause )
+    {
+        super( cause );
+    }
+
+
+    public ResolutionException( IModelElement root, IModelElement[] parsed )
+    {
+        super( buildMessage( root, parsed ) );
+        this.parsed = parsed;
+    }
+
+
+    private static String buildMessage( IModelElement root, IModelElement[] parsed )
+    {
+        StringBuilder b = new StringBuilder();
+        b.append( "Failed to resolve " );
+        b.append( root );
+
+        if ( parsed.length > 0 )
+        {
+            b.append( " due to missing provider for " );
+            b.append( parsed[parsed.length - 1] );
+        }
+
+        return b.toString();
+    }
+
+
+    public IModelElement[] getParsed()
+    {
+        return parsed;
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionMonitorAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionMonitorAdapter.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionMonitorAdapter.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/repository/ResolutionMonitorAdapter.java Tue Jul 21 18:51:33 2009
@@ -19,28 +19,39 @@
 
 package org.apache.felix.sigil.repository;
 
+
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.apache.felix.sigil.model.IModelElement;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
 
-public class ResolutionMonitorAdapter implements IResolutionMonitor {
 
-	private IProgressMonitor monitor;
-	
-	public ResolutionMonitorAdapter(IProgressMonitor monitor) {
-		this.monitor = monitor;
-	}
-
-	public boolean isCanceled() {
-		return monitor.isCanceled();
-	}
-
-	public void startResolution(IModelElement requirement) {
-		monitor.subTask( "Resolving " + requirement);
-	}
-
-	public void endResolution(IModelElement requirement, ISigilBundle provider) {
-		monitor.subTask( (provider == null ? "Failed to resolve " : "Resolved ") + requirement);
-	}
+public class ResolutionMonitorAdapter implements IResolutionMonitor
+{
+
+    private IProgressMonitor monitor;
+
+
+    public ResolutionMonitorAdapter( IProgressMonitor monitor )
+    {
+        this.monitor = monitor;
+    }
+
+
+    public boolean isCanceled()
+    {
+        return monitor.isCanceled();
+    }
+
+
+    public void startResolution( IModelElement requirement )
+    {
+        monitor.subTask( "Resolving " + requirement );
+    }
+
+
+    public void endResolution( IModelElement requirement, ISigilBundle provider )
+    {
+        monitor.subTask( ( provider == null ? "Failed to resolve " : "Resolved " ) + requirement );
+    }
 
 }

Modified: felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/AbstractSigilTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/AbstractSigilTestCase.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/AbstractSigilTestCase.java (original)
+++ felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/AbstractSigilTestCase.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.junit;
 
+
 import java.lang.reflect.Method;
 import java.util.LinkedList;
 import java.util.List;
@@ -30,71 +31,99 @@
 
 import junit.framework.TestCase;
 
-public abstract class AbstractSigilTestCase extends TestCase {
 
-	private final static List<ServiceTracker> trackers = new LinkedList<ServiceTracker>();
-	
-	private BundleContext ctx;
-	
-	public void setBundleContext(BundleContext ctx) {
-		this.ctx = ctx;
-	}
-	
-	protected BundleContext getBundleContext() {
-		return ctx;
-	}
-	
-	@Override
-	protected void setUp() {
-		for ( Class<?> c : getReferences() ) {
-			ServiceTracker t = createBindTracker(c);
-			t.open();
-			trackers.add( t );
-		}
-	}
-
-	@Override
-	protected void tearDown() {
-		for ( ServiceTracker t : trackers ) {
-			t.close();
-		}
-		trackers.clear();
-	}
-
-
-	private ServiceTracker createBindTracker(final Class<?> c) {
-		return new ServiceTracker(ctx, c.getName(), new ServiceTrackerCustomizer() {
-			public Object addingService(ServiceReference reference) {
-				Object o = ctx.getService(reference);
-				Method m = getBindMethod(c);
-				if ( m != null ) invoke( m, o );
-				return o;
-			}
-
-			public void modifiedService(ServiceReference reference,
-					Object service) {
-			}
-
-			public void removedService(ServiceReference reference,
-					Object service) {
-				Method m = getUnbindMethod(c);
-				if ( m != null ) invoke( m, service );
-				ctx.ungetService(reference);
-			}
-		});
-	}
-	
-	private void invoke(Method m, Object o) {
-		try {
-			m.invoke( this,  new Object[] { o } );
-		} catch (Exception e) {
-			throw new IllegalStateException( "Failed to invoke binding method " + m, e);
-		}
-	}
-
-	protected abstract Class<?>[] getReferences();
-	
-	protected abstract Method getBindMethod(Class<?> clazz);
-	
-	protected abstract  Method getUnbindMethod(Class<?> clazz);
+public abstract class AbstractSigilTestCase extends TestCase
+{
+
+    private final static List<ServiceTracker> trackers = new LinkedList<ServiceTracker>();
+
+    private BundleContext ctx;
+
+
+    public void setBundleContext( BundleContext ctx )
+    {
+        this.ctx = ctx;
+    }
+
+
+    protected BundleContext getBundleContext()
+    {
+        return ctx;
+    }
+
+
+    @Override
+    protected void setUp()
+    {
+        for ( Class<?> c : getReferences() )
+        {
+            ServiceTracker t = createBindTracker( c );
+            t.open();
+            trackers.add( t );
+        }
+    }
+
+
+    @Override
+    protected void tearDown()
+    {
+        for ( ServiceTracker t : trackers )
+        {
+            t.close();
+        }
+        trackers.clear();
+    }
+
+
+    private ServiceTracker createBindTracker( final Class<?> c )
+    {
+        return new ServiceTracker( ctx, c.getName(), new ServiceTrackerCustomizer()
+        {
+            public Object addingService( ServiceReference reference )
+            {
+                Object o = ctx.getService( reference );
+                Method m = getBindMethod( c );
+                if ( m != null )
+                    invoke( m, o );
+                return o;
+            }
+
+
+            public void modifiedService( ServiceReference reference, Object service )
+            {
+            }
+
+
+            public void removedService( ServiceReference reference, Object service )
+            {
+                Method m = getUnbindMethod( c );
+                if ( m != null )
+                    invoke( m, service );
+                ctx.ungetService( reference );
+            }
+        } );
+    }
+
+
+    private void invoke( Method m, Object o )
+    {
+        try
+        {
+            m.invoke( this, new Object[]
+                { o } );
+        }
+        catch ( Exception e )
+        {
+            throw new IllegalStateException( "Failed to invoke binding method " + m, e );
+        }
+    }
+
+
+    protected abstract Class<?>[] getReferences();
+
+
+    protected abstract Method getBindMethod( Class<?> clazz );
+
+
+    protected abstract Method getUnbindMethod( Class<?> clazz );
 }

Modified: felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/ReflectiveSigilTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/ReflectiveSigilTestCase.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/ReflectiveSigilTestCase.java (original)
+++ felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/ReflectiveSigilTestCase.java Tue Jul 21 18:51:33 2009
@@ -19,80 +19,107 @@
 
 package org.apache.felix.sigil.junit;
 
+
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-public abstract class ReflectiveSigilTestCase extends AbstractSigilTestCase {
 
-	private Class<?>[] references;
-	private Map<Class<?>, Method> bindMethods;
-	private Map<Class<?>, Method> unbindMethods;
-	
-	@Override
-	protected Class<?>[] getReferences() {
-		introspect();
-		return references;
-	}
-
-	@Override
-	protected Method getBindMethod(Class<?> clazz) {
-		return bindMethods.get(clazz);
-	}
-
-	@Override
-	protected Method getUnbindMethod(Class<?> clazz) {
-		return unbindMethods.get(clazz);
-	}
-
-	private void introspect() {
-		if ( references == null ) {
-			bindMethods = findBindMethods(getClass(), "set", "add");
-			unbindMethods = findBindMethods(getClass(), "set", "remove");
-			
-			HashSet<Class<?>> refs = new HashSet<Class<?>>();
-			refs.addAll( bindMethods.keySet() );
-			refs.addAll( unbindMethods.keySet() );
-			references = refs.toArray( new Class<?>[refs.size()] );
-		}
-	}
-
-	private static Map<Class<?>, Method> findBindMethods(Class<?> clazz, String... prefix) {
-		HashMap<Class<?>, Method> found = new HashMap<Class<?>, Method>();
-		
-		checkDeclaredMethods(clazz, found, prefix);
-		
-		return found;
-	}
-	
-	private static void checkDeclaredMethods(Class<?> clazz, Map<Class<?>, Method> found, String...prefix) {
-		for ( Method m : clazz.getDeclaredMethods() ) {
-			if ( isMethodPrefixed(m, prefix) && isBindSignature(m) ) {
-				found.put( m.getParameterTypes()[0], m );
-			}
-		}
-		
-		Class<?> sup = clazz.getSuperclass();
-		if ( sup != null && sup != Object.class ) {
-			checkDeclaredMethods(sup, found, prefix);
-		}
-		
-		for ( Class<?> i : clazz.getInterfaces() ) {
-			checkDeclaredMethods(i, found, prefix);
-		}
-	}
-
-	private static boolean isMethodPrefixed(Method m, String...prefix) {
-		String n = m.getName();
-		for ( String p : prefix ) {
-			if ( n.startsWith( p ) && n.length() > p.length() ) {
-				return true;
-			}
-		}
-		return false;
-	}
-	private static boolean isBindSignature(Method m) {
-		return m.getReturnType() == Void.TYPE && m.getParameterTypes().length == 1;
-	}
+public abstract class ReflectiveSigilTestCase extends AbstractSigilTestCase
+{
+
+    private Class<?>[] references;
+    private Map<Class<?>, Method> bindMethods;
+    private Map<Class<?>, Method> unbindMethods;
+
+
+    @Override
+    protected Class<?>[] getReferences()
+    {
+        introspect();
+        return references;
+    }
+
+
+    @Override
+    protected Method getBindMethod( Class<?> clazz )
+    {
+        return bindMethods.get( clazz );
+    }
+
+
+    @Override
+    protected Method getUnbindMethod( Class<?> clazz )
+    {
+        return unbindMethods.get( clazz );
+    }
+
+
+    private void introspect()
+    {
+        if ( references == null )
+        {
+            bindMethods = findBindMethods( getClass(), "set", "add" );
+            unbindMethods = findBindMethods( getClass(), "set", "remove" );
+
+            HashSet<Class<?>> refs = new HashSet<Class<?>>();
+            refs.addAll( bindMethods.keySet() );
+            refs.addAll( unbindMethods.keySet() );
+            references = refs.toArray( new Class<?>[refs.size()] );
+        }
+    }
+
+
+    private static Map<Class<?>, Method> findBindMethods( Class<?> clazz, String... prefix )
+    {
+        HashMap<Class<?>, Method> found = new HashMap<Class<?>, Method>();
+
+        checkDeclaredMethods( clazz, found, prefix );
+
+        return found;
+    }
+
+
+    private static void checkDeclaredMethods( Class<?> clazz, Map<Class<?>, Method> found, String... prefix )
+    {
+        for ( Method m : clazz.getDeclaredMethods() )
+        {
+            if ( isMethodPrefixed( m, prefix ) && isBindSignature( m ) )
+            {
+                found.put( m.getParameterTypes()[0], m );
+            }
+        }
+
+        Class<?> sup = clazz.getSuperclass();
+        if ( sup != null && sup != Object.class )
+        {
+            checkDeclaredMethods( sup, found, prefix );
+        }
+
+        for ( Class<?> i : clazz.getInterfaces() )
+        {
+            checkDeclaredMethods( i, found, prefix );
+        }
+    }
+
+
+    private static boolean isMethodPrefixed( Method m, String... prefix )
+    {
+        String n = m.getName();
+        for ( String p : prefix )
+        {
+            if ( n.startsWith( p ) && n.length() > p.length() )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    private static boolean isBindSignature( Method m )
+    {
+        return m.getReturnType() == Void.TYPE && m.getParameterTypes().length == 1;
+    }
 }

Modified: felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/activator/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/activator/Activator.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/activator/Activator.java (original)
+++ felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/activator/Activator.java Tue Jul 21 18:51:33 2009
@@ -19,29 +19,36 @@
 
 package org.apache.felix.sigil.junit.activator;
 
+
 import org.apache.felix.sigil.junit.server.JUnitService;
 import org.apache.felix.sigil.junit.server.impl.JUnitServiceFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
+
 /**
  * @author dave
  */
-public class Activator implements BundleActivator {
-	private ServiceRegistration reg;
-	private JUnitServiceFactory service;
-
-	public void start(final BundleContext ctx) {
-		service = new JUnitServiceFactory();
-		service.start(ctx);
-		reg = ctx.registerService(JUnitService.class.getName(), service, null);
+public class Activator implements BundleActivator
+{
+    private ServiceRegistration reg;
+    private JUnitServiceFactory service;
+
+
+    public void start( final BundleContext ctx )
+    {
+        service = new JUnitServiceFactory();
+        service.start( ctx );
+        reg = ctx.registerService( JUnitService.class.getName(), service, null );
     }
 
-    public void stop(BundleContext ctx) {
-    	reg.unregister();
-    	reg = null;
-    	service.stop(ctx);
-    	service = null;
+
+    public void stop( BundleContext ctx )
+    {
+        reg.unregister();
+        reg = null;
+        service.stop( ctx );
+        service = null;
     }
 }

Modified: felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/JUnitService.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/JUnitService.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/JUnitService.java (original)
+++ felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/JUnitService.java Tue Jul 21 18:51:33 2009
@@ -19,16 +19,21 @@
 
 package org.apache.felix.sigil.junit.server;
 
+
 import java.util.Set;
 
 import org.osgi.framework.BundleContext;
 
 import junit.framework.TestSuite;
 
-public interface JUnitService {
-	Set<String> getTests();
-	
-	TestSuite createTest(String test);
-	
-	TestSuite createTest(String test, BundleContext ctx);
+
+public interface JUnitService
+{
+    Set<String> getTests();
+
+
+    TestSuite createTest( String test );
+
+
+    TestSuite createTest( String test, BundleContext ctx );
 }
\ No newline at end of file

Modified: felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/impl/JUnitServiceFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/impl/JUnitServiceFactory.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/impl/JUnitServiceFactory.java (original)
+++ felix/trunk/sigil/common/junit/src/org/apache/felix/sigil/junit/server/impl/JUnitServiceFactory.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.junit.server.impl;
 
+
 import java.util.HashMap;
 import java.util.Set;
 import java.util.TreeSet;
@@ -31,49 +32,69 @@
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
-public class JUnitServiceFactory implements ServiceFactory {
 
-	private HashMap<String, Class<? extends TestCase>> tests = new HashMap<String, Class<? extends TestCase>>();
-	private TestClassListener listener;
-	
-	public void start(BundleContext ctx) {
-		listener = new TestClassListener(this);
-		ctx.addBundleListener(listener);
-		//listener.index(ctx.getBundle());
-		for ( Bundle b : ctx.getBundles() ) {
-			if ( b.getState() == Bundle.RESOLVED ) {
-				listener.index(b);
-			}
-		}
-	}
-	
-	public void stop(BundleContext ctx) {
-		ctx.removeBundleListener(listener);
-		listener = null;
-	}
-	
-	public Object getService(Bundle bundle, ServiceRegistration reg) {
-		return new JUnitServiceImpl(this, bundle.getBundleContext());
-	}
-
-	public void ungetService(Bundle bundle, ServiceRegistration reg, Object service) {
-	}
-
-	public void registerTest(Class<? extends TestCase> clazz) {
-		tests.put( clazz.getName(), clazz );
-	}
-
-	public void unregister(Class<? extends TestCase> clazz) {
-		tests.remove(clazz.getName());
-	}
-
-	public Set<String> getTests() {
-		return new TreeSet<String>(tests.keySet());
-	}
-
-	public TestSuite getTest(String test) {
-		Class<? extends TestCase> tc = tests.get(test);
-		return tc == null ? null : new TestSuite(tc);
-	}
+public class JUnitServiceFactory implements ServiceFactory
+{
+
+    private HashMap<String, Class<? extends TestCase>> tests = new HashMap<String, Class<? extends TestCase>>();
+    private TestClassListener listener;
+
+
+    public void start( BundleContext ctx )
+    {
+        listener = new TestClassListener( this );
+        ctx.addBundleListener( listener );
+        //listener.index(ctx.getBundle());
+        for ( Bundle b : ctx.getBundles() )
+        {
+            if ( b.getState() == Bundle.RESOLVED )
+            {
+                listener.index( b );
+            }
+        }
+    }
+
+
+    public void stop( BundleContext ctx )
+    {
+        ctx.removeBundleListener( listener );
+        listener = null;
+    }
+
+
+    public Object getService( Bundle bundle, ServiceRegistration reg )
+    {
+        return new JUnitServiceImpl( this, bundle.getBundleContext() );
+    }
+
+
+    public void ungetService( Bundle bundle, ServiceRegistration reg, Object service )
+    {
+    }
+
+
+    public void registerTest( Class<? extends TestCase> clazz )
+    {
+        tests.put( clazz.getName(), clazz );
+    }
+
+
+    public void unregister( Class<? extends TestCase> clazz )
+    {
+        tests.remove( clazz.getName() );
+    }
+
+
+    public Set<String> getTests()
+    {
+        return new TreeSet<String>( tests.keySet() );
+    }
+
+
+    public TestSuite getTest( String test )
+    {
+        Class<? extends TestCase> tc = tests.get( test );
+        return tc == null ? null : new TestSuite( tc );
+    }
 
 }