felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r796467 [5/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...
Date Tue, 21 Jul 2009 18:51:41 GMT
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/ProgressWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/ProgressWrapper.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/ProgressWrapper.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/ProgressWrapper.java Tue Jul 21 18:51:33 2009
@@ -19,53 +19,74 @@
 
 package org.apache.felix.sigil.core.repository;
 
+
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.apache.felix.sigil.repository.IResolutionMonitor;
 
-public class ProgressWrapper implements IProgressMonitor {
 
-	private IResolutionMonitor monitor;
-	
-	public ProgressWrapper(IResolutionMonitor monitor) {
-		this.monitor = monitor;
-	}
+public class ProgressWrapper implements IProgressMonitor
+{
+
+    private IResolutionMonitor monitor;
+
+
+    public ProgressWrapper( IResolutionMonitor monitor )
+    {
+        this.monitor = monitor;
+    }
+
+
+    public boolean isCanceled()
+    {
+        return monitor.isCanceled();
+    }
+
+
+    public void beginTask( String name, int totalWork )
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+
+    public void done()
+    {
+        // TODO Auto-generated method stub
+
+    }
 
-	public boolean isCanceled() {
-		return monitor.isCanceled();
-	}
 
-	public void beginTask(String name, int totalWork) {
-		// TODO Auto-generated method stub
+    public void internalWorked( double work )
+    {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	public void done() {
-		// TODO Auto-generated method stub
 
-	}
+    public void setCanceled( boolean value )
+    {
+        // TODO Auto-generated method stub
 
-	public void internalWorked(double work) {
-		// TODO Auto-generated method stub
+    }
 
-	}
 
-	public void setCanceled(boolean value) {
-		// TODO Auto-generated method stub
+    public void setTaskName( String name )
+    {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
-	public void setTaskName(String name) {
-		// TODO Auto-generated method stub
 
-	}
+    public void subTask( String name )
+    {
+        // TODO Auto-generated method stub
 
-	public void subTask(String name) {
-		// TODO Auto-generated method stub
+    }
 
-	}
 
-	public void worked(int work) {
-		// TODO Auto-generated method stub
+    public void worked( int work )
+    {
+        // TODO Auto-generated method stub
 
-	}
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.core.repository;
 
+
 import java.io.IOException;
 import java.util.jar.JarFile;
 
@@ -32,79 +33,110 @@
 import org.apache.felix.sigil.repository.IRepositoryVisitor;
 import org.eclipse.core.runtime.IPath;
 
-public class SystemRepository extends AbstractBundleRepository {
 
-	private final String packages;
-	private final IPath frameworkPath;
+public class SystemRepository extends AbstractBundleRepository
+{
+
+    private final String packages;
+    private final IPath frameworkPath;
+
 
-	public SystemRepository(String id, IPath frameworkPath, String packages) {
-		super(id);
-		this.frameworkPath = frameworkPath;
-		this.packages = packages;
-	}
-
-	private static ISigilBundle systemBundle;
-	
-	@Override
-	public void accept(IRepositoryVisitor visitor, int options) {
-		ISigilBundle bundle = loadSystemBundle();
-		
-		if ( bundle != null ) {
-			visitor.visit(bundle);
-		}
-	}
-
-	private synchronized ISigilBundle loadSystemBundle() {
-		if (systemBundle == null) {
-			systemBundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
-			
-			JarFile jar = null;
-			
-			try {
-    			final IBundleModelElement info;
-				if (frameworkPath != null) {
-        			systemBundle.setLocation(frameworkPath);
-    				jar = new JarFile(frameworkPath.toFile());
-    				info = buildBundleModelElement(jar.getManifest());
-				} else {
-				    info = ModelElementFactory.getInstance().newModelElement(IBundleModelElement.class);
-				}
-				
-    			applyProfile(info);
-    			systemBundle.addChild(info);
-			} catch (IOException e) {
-				BldCore.error( "Failed to read jar file " + frameworkPath, e );
-			} catch (ModelElementFactoryException e) {
-				BldCore.error( "Failed to build bundle " + frameworkPath , e );
-			} catch (RuntimeException e) {
-				BldCore.error( "Failed to build bundle " + frameworkPath , e );
-			}
-			finally {
-				if (jar != null) {
-					try {
-						jar.close();
-					} catch (IOException e) {
-						BldCore.error( "Failed to close jar file", e );
-					}
-				}
-			}
-		}
-		
-		return systemBundle;
-	}
-
-	private void applyProfile(IBundleModelElement info) {
-		if (packages != null) {
-			for (String name : packages.split(",\\s*")) {
-				IPackageExport pe = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
-				pe.setPackageName(name);
-				info.addExport(pe);
-			}
-		}
-	}
-
-	public synchronized void refresh() {
-		systemBundle = null;
-		notifyChange();
-	}
+    public SystemRepository( String id, IPath frameworkPath, String packages )
+    {
+        super( id );
+        this.frameworkPath = frameworkPath;
+        this.packages = packages;
+    }
+
+    private static ISigilBundle systemBundle;
+
+
+    @Override
+    public void accept( IRepositoryVisitor visitor, int options )
+    {
+        ISigilBundle bundle = loadSystemBundle();
+
+        if ( bundle != null )
+        {
+            visitor.visit( bundle );
+        }
+    }
+
+
+    private synchronized ISigilBundle loadSystemBundle()
+    {
+        if ( systemBundle == null )
+        {
+            systemBundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
+
+            JarFile jar = null;
+
+            try
+            {
+                final IBundleModelElement info;
+                if ( frameworkPath != null )
+                {
+                    systemBundle.setLocation( frameworkPath );
+                    jar = new JarFile( frameworkPath.toFile() );
+                    info = buildBundleModelElement( jar.getManifest() );
+                }
+                else
+                {
+                    info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
+                }
+
+                applyProfile( info );
+                systemBundle.addChild( info );
+            }
+            catch ( IOException e )
+            {
+                BldCore.error( "Failed to read jar file " + frameworkPath, e );
+            }
+            catch ( ModelElementFactoryException e )
+            {
+                BldCore.error( "Failed to build bundle " + frameworkPath, e );
+            }
+            catch ( RuntimeException e )
+            {
+                BldCore.error( "Failed to build bundle " + frameworkPath, e );
+            }
+            finally
+            {
+                if ( jar != null )
+                {
+                    try
+                    {
+                        jar.close();
+                    }
+                    catch ( IOException e )
+                    {
+                        BldCore.error( "Failed to close jar file", e );
+                    }
+                }
+            }
+        }
+
+        return systemBundle;
+    }
+
+
+    private void applyProfile( IBundleModelElement info )
+    {
+        if ( packages != null )
+        {
+            for ( String name : packages.split( ",\\s*" ) )
+            {
+                IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
+                pe.setPackageName( name );
+                info.addExport( pe );
+            }
+        }
+    }
+
+
+    public synchronized void refresh()
+    {
+        systemBundle = null;
+        notifyChange();
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.core.repository;
 
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
@@ -28,42 +29,50 @@
 import org.apache.felix.sigil.repository.RepositoryException;
 import org.eclipse.core.runtime.Path;
 
-public class SystemRepositoryProvider implements IRepositoryProvider {
 
-	public IBundleRepository createRepository(String id, Properties properties)
-			throws RepositoryException {
-		String fw = properties.getProperty("framework");
-		Path frameworkPath = fw == null ? null : new Path(fw);
-		String extraPkgs = properties.getProperty("packages");
-		String profile = properties.getProperty("profile");
-		
-		try {
-			Properties p = readProfile(profile);
-    		String pkgs = p.getProperty("org.osgi.framework.system.packages") + "," + extraPkgs;
-			return new SystemRepository(id, frameworkPath, pkgs);
-		} catch (IOException e) {
-			throw new RepositoryException("Failed to load profile", e);
-		}
-	}
-	
-	public static Properties readProfile(String name) throws IOException {
-		if (name == null) {
-			String version = System.getProperty("java.specification.version");
-			String[] split = version.split("\\.");
-			String prefix = ("6".compareTo(split[1]) <= 0) ? "JavaSE-" : "J2SE-";
-			name = prefix + version;
-		}
-		
-		String profilePath = "profiles/" + name + ".profile";
-		InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream(profilePath);
-		
-		if (in == null)
-			throw new IOException("No such profile: " + profilePath);
-		
-		Properties p = new Properties();
-		p.load(in);
-		
-		return p;
-	}
-	
+public class SystemRepositoryProvider implements IRepositoryProvider
+{
+
+    public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+    {
+        String fw = properties.getProperty( "framework" );
+        Path frameworkPath = fw == null ? null : new Path( fw );
+        String extraPkgs = properties.getProperty( "packages" );
+        String profile = properties.getProperty( "profile" );
+
+        try
+        {
+            Properties p = readProfile( profile );
+            String pkgs = p.getProperty( "org.osgi.framework.system.packages" ) + "," + extraPkgs;
+            return new SystemRepository( id, frameworkPath, pkgs );
+        }
+        catch ( IOException e )
+        {
+            throw new RepositoryException( "Failed to load profile", e );
+        }
+    }
+
+
+    public static Properties readProfile( String name ) throws IOException
+    {
+        if ( name == null )
+        {
+            String version = System.getProperty( "java.specification.version" );
+            String[] split = version.split( "\\." );
+            String prefix = ( "6".compareTo( split[1] ) <= 0 ) ? "JavaSE-" : "J2SE-";
+            name = prefix + version;
+        }
+
+        String profilePath = "profiles/" + name + ".profile";
+        InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream( profilePath );
+
+        if ( in == null )
+            throw new IOException( "No such profile: " + profilePath );
+
+        Properties p = new Properties();
+        p.load( in );
+
+        return p;
+    }
+
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/util/QuoteUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/util/QuoteUtil.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/util/QuoteUtil.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/core/util/QuoteUtil.java Tue Jul 21 18:51:33 2009
@@ -19,35 +19,43 @@
 
 package org.apache.felix.sigil.core.util;
 
+
 import java.util.ArrayList;
 
-public class QuoteUtil {
-	public static String[] split(String str) {
-		ArrayList<String> split = new ArrayList<String>();
-		boolean quote = false;
-		StringBuffer buf = new StringBuffer(str.length());
-		
-		for ( int i = 0; i < str.length(); i++ ) {
-			char c = str.charAt(i);
-			switch ( c ) {
-			case '"':
-				quote = !quote;
-				break;
-			case ',':
-				if ( !quote ) {
-					split.add( buf.toString().trim() );
-					buf.setLength(0);
-					break;
-				}
-				// else fall through on purpose
-			default:
-				buf.append( c );
-			}
-		}
-		
-		if ( buf.length() > 0 ) {
-			split.add( buf.toString().trim() );
-		}
-		return split.toArray( new String[split.size()] );
-	}	
+
+public class QuoteUtil
+{
+    public static String[] split( String str )
+    {
+        ArrayList<String> split = new ArrayList<String>();
+        boolean quote = false;
+        StringBuffer buf = new StringBuffer( str.length() );
+
+        for ( int i = 0; i < str.length(); i++ )
+        {
+            char c = str.charAt( i );
+            switch ( c )
+            {
+                case '"':
+                    quote = !quote;
+                    break;
+                case ',':
+                    if ( !quote )
+                    {
+                        split.add( buf.toString().trim() );
+                        buf.setLength( 0 );
+                        break;
+                    }
+                    // else fall through on purpose
+                default:
+                    buf.append( c );
+            }
+        }
+
+        if ( buf.length() > 0 )
+        {
+            split.add( buf.toString().trim() );
+        }
+        return split.toArray( new String[split.size()] );
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractCompoundModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractCompoundModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractCompoundModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractCompoundModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,95 +19,125 @@
 
 package org.apache.felix.sigil.model;
 
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 
-public abstract class AbstractCompoundModelElement extends AbstractModelElement implements ICompoundModelElement {
+public abstract class AbstractCompoundModelElement extends AbstractModelElement implements ICompoundModelElement
+{
+
+    private static final long serialVersionUID = 1L;
+
 
-	private static final long serialVersionUID = 1L;
-	
-	public AbstractCompoundModelElement(String description) {
-		super(description);
-	}
-
-	public boolean addChild(IModelElement child) throws InvalidModelException {
-		return support.addChild(child);
-	}
-
-	public boolean removeChild(IModelElement child) {
-		return support.removeChild(child);
-	}
-
-	public IModelElement[] children() {
-		return support.children();
-	}
-	
-	private static final ThreadLocal<Map<IModelWalker,Set<IModelElement>>> walkedLocal = new ThreadLocal<Map<IModelWalker,Set<IModelElement>>>();
-	
-	public void visit(IModelWalker walker) {
-		if ( walker.visit( this ) ) {
-			Map<IModelWalker,Set<IModelElement>> walked = walkedLocal.get();
-			boolean delete = false;
-			
-			if ( walked == null ) {
-				walked = new HashMap<IModelWalker, Set<IModelElement>>();
-				walkedLocal.set(walked);
-			}
-
-			Set<IModelElement> check = walked.get(walker);
-			
-			if ( check == null ) {
-				delete = true;
-				check = new HashSet<IModelElement>(); 
-			}
-			
-			check.add( this );
-			
-			try {
-				for ( IModelElement e : children() ) {
-					if ( !check.contains( e ) && walker.visit( e ) ) {
-						check.add( e );
-						if ( e instanceof ICompoundModelElement ) {
-							ICompoundModelElement c = (ICompoundModelElement) e;
-							c.visit(walker);
-						}
-					}
-				}
-			}
-			finally {
-				if ( delete ) {
-					walked.remove(walker);
-					
-					if ( walked.isEmpty() ) {
-						walkedLocal.set( null );
-					}
-				}
-			}
-		}
-	}
-
-	public Set<Class<? extends IModelElement>> getOptionalChildren() {
-		return support.getChildrenTypes(false);
-	}
-
-	public Set<Class<? extends IModelElement>> getRequiredChildren() {
-		return support.getChildrenTypes(true);
-	}
-
-	public <T extends IModelElement> T[] childrenOfType(Class<T> type) {
-		return support.childrenOfType( type );
-	}
-
-
-	@Override
-	public void checkValid() throws InvalidModelException {
-		super.checkValid();
-		
-		for ( IModelElement e : support.children() ) {
-			e.checkValid();
-		}
-	}	
+    public AbstractCompoundModelElement( String description )
+    {
+        super( description );
+    }
+
+
+    public boolean addChild( IModelElement child ) throws InvalidModelException
+    {
+        return support.addChild( child );
+    }
+
+
+    public boolean removeChild( IModelElement child )
+    {
+        return support.removeChild( child );
+    }
+
+
+    public IModelElement[] children()
+    {
+        return support.children();
+    }
+
+    private static final ThreadLocal<Map<IModelWalker, Set<IModelElement>>> walkedLocal = new ThreadLocal<Map<IModelWalker, Set<IModelElement>>>();
+
+
+    public void visit( IModelWalker walker )
+    {
+        if ( walker.visit( this ) )
+        {
+            Map<IModelWalker, Set<IModelElement>> walked = walkedLocal.get();
+            boolean delete = false;
+
+            if ( walked == null )
+            {
+                walked = new HashMap<IModelWalker, Set<IModelElement>>();
+                walkedLocal.set( walked );
+            }
+
+            Set<IModelElement> check = walked.get( walker );
+
+            if ( check == null )
+            {
+                delete = true;
+                check = new HashSet<IModelElement>();
+            }
+
+            check.add( this );
+
+            try
+            {
+                for ( IModelElement e : children() )
+                {
+                    if ( !check.contains( e ) && walker.visit( e ) )
+                    {
+                        check.add( e );
+                        if ( e instanceof ICompoundModelElement )
+                        {
+                            ICompoundModelElement c = ( ICompoundModelElement ) e;
+                            c.visit( walker );
+                        }
+                    }
+                }
+            }
+            finally
+            {
+                if ( delete )
+                {
+                    walked.remove( walker );
+
+                    if ( walked.isEmpty() )
+                    {
+                        walkedLocal.set( null );
+                    }
+                }
+            }
+        }
+    }
+
+
+    public Set<Class<? extends IModelElement>> getOptionalChildren()
+    {
+        return support.getChildrenTypes( false );
+    }
+
+
+    public Set<Class<? extends IModelElement>> getRequiredChildren()
+    {
+        return support.getChildrenTypes( true );
+    }
+
+
+    public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+    {
+        return support.childrenOfType( type );
+    }
+
+
+    @Override
+    public void checkValid() throws InvalidModelException
+    {
+        super.checkValid();
+
+        for ( IModelElement e : support.children() )
+        {
+            e.checkValid();
+        }
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/AbstractModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.model;
 
+
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.HashMap;
@@ -26,129 +27,175 @@
 import java.util.Set;
 
 
-public abstract class AbstractModelElement implements IModelElement {
-	
-	private static final long serialVersionUID = 1L;
+public abstract class AbstractModelElement implements IModelElement
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private IModelElement parent;
 
-	private IModelElement parent;
-	
     private String description;
     private transient Map<Object, Object> meta;
     private Map<Serializable, Serializable> serializedMeta;
     private OverrideOptions override;
-    
+
     protected final ModelElementSupport support;
 
-    public AbstractModelElement(String description) {
-    	support = new ModelElementSupport(this);
-    	this.description = description.intern();
+
+    public AbstractModelElement( String description )
+    {
+        support = new ModelElementSupport( this );
+        this.description = description.intern();
         this.meta = new HashMap<Object, Object>();
         this.serializedMeta = new HashMap<Serializable, Serializable>();
     }
 
-    public String getElementDescription() {
+
+    public String getElementDescription()
+    {
         return description;
     }
 
-    public Map<Object, Object> getMeta() {
+
+    public Map<Object, Object> getMeta()
+    {
         return meta;
     }
 
-    public void setMeta(Map<Object, Object> meta) {
+
+    public void setMeta( Map<Object, Object> meta )
+    {
         this.meta = meta;
     }
 
+
     @Override
-    public AbstractModelElement clone() {
-		try {
-	        AbstractModelElement clone = (AbstractModelElement) super.clone();
-	   
-	        clone.meta = new HashMap<Object, Object>(meta);
-
-	        return clone;
-		} catch (CloneNotSupportedException e) {
-			// can't happen but make compiler happy
-			throw new IllegalStateException(e);
-		}
+    public AbstractModelElement clone()
+    {
+        try
+        {
+            AbstractModelElement clone = ( AbstractModelElement ) super.clone();
+
+            clone.meta = new HashMap<Object, Object>( meta );
+
+            return clone;
+        }
+        catch ( CloneNotSupportedException e )
+        {
+            // can't happen but make compiler happy
+            throw new IllegalStateException( e );
+        }
     }
 
+
     @SuppressWarnings("unchecked")
-	public <T extends IModelElement> T getAncestor(Class<T> type) {
-    	IModelElement parent = this.parent;
-    	
-    	while ( parent != null ) {
-    		if ( type.isInstance( parent ) ) {
-    			return (T) parent;
-    		}
-    		parent = parent.getParent();
-    	}
-    	
-		return null;
-	}
-
-	public IModelElement getParent() {
-		return parent;
-	}
-	
-	public void setParent( IModelElement parent ) {
-		if ( parent != null ) {
-			if ( this.parent != null && this.parent != parent ) {
-				throw new IllegalStateException( "Parent already installed");
-			}
-		}
-		
-		this.parent = parent;
-	}
-	
-    public void checkValid() throws InvalidModelException {
-    	for ( String req : getRequiredProperties() ) {
-    		try {
-				if ( getProperty( req ) == null ) {
-					throw new InvalidModelException(this, "Missing property " + req );
-				}
-			} catch (NoSuchMethodException e) {
-				throw new InvalidModelException( this, "No such property " + req );
-			}
-    	}
-	}
-
-	public Object getProperty(String name) throws NoSuchMethodException {
-		return support.getProperty(name);
-	}
-
-	public void setProperty(String name, Object value)
-			throws NoSuchMethodException {
-		support.setProperty(name, value);
-	}
-
-	public void addProperty(String name, Object value)
-			throws NoSuchMethodException {
-		support.addProperty(name, value);
-	}
-
-	public void removeProperty(String name, Object value)
-			throws NoSuchMethodException {
-		support.removeProperty(name, value);
-	}
-
-	public Object getDefaultPropertyValue(String name) {
-		return support.getDefaultPropertyValue( name );
-	}
-
-	public Set<String> getPropertyNames() {
-		return support.getPropertyNames();
-	}
-
-	public Set<String> getRequiredProperties() {
-		return Collections.emptySet();
-	}
+    public <T extends IModelElement> T getAncestor( Class<T> type )
+    {
+        IModelElement parent = this.parent;
+
+        while ( parent != null )
+        {
+            if ( type.isInstance( parent ) )
+            {
+                return ( T ) parent;
+            }
+            parent = parent.getParent();
+        }
 
-	protected Object writeReplace() {
+        return null;
+    }
+
+
+    public IModelElement getParent()
+    {
+        return parent;
+    }
+
+
+    public void setParent( IModelElement parent )
+    {
+        if ( parent != null )
+        {
+            if ( this.parent != null && this.parent != parent )
+            {
+                throw new IllegalStateException( "Parent already installed" );
+            }
+        }
+
+        this.parent = parent;
+    }
+
+
+    public void checkValid() throws InvalidModelException
+    {
+        for ( String req : getRequiredProperties() )
+        {
+            try
+            {
+                if ( getProperty( req ) == null )
+                {
+                    throw new InvalidModelException( this, "Missing property " + req );
+                }
+            }
+            catch ( NoSuchMethodException e )
+            {
+                throw new InvalidModelException( this, "No such property " + req );
+            }
+        }
+    }
+
+
+    public Object getProperty( String name ) throws NoSuchMethodException
+    {
+        return support.getProperty( name );
+    }
+
+
+    public void setProperty( String name, Object value ) throws NoSuchMethodException
+    {
+        support.setProperty( name, value );
+    }
+
+
+    public void addProperty( String name, Object value ) throws NoSuchMethodException
+    {
+        support.addProperty( name, value );
+    }
+
+
+    public void removeProperty( String name, Object value ) throws NoSuchMethodException
+    {
+        support.removeProperty( name, value );
+    }
+
+
+    public Object getDefaultPropertyValue( String name )
+    {
+        return support.getDefaultPropertyValue( name );
+    }
+
+
+    public Set<String> getPropertyNames()
+    {
+        return support.getPropertyNames();
+    }
+
+
+    public Set<String> getRequiredProperties()
+    {
+        return Collections.emptySet();
+    }
+
+
+    protected Object writeReplace()
+    {
         AbstractModelElement clone = clone();
 
-        for (Map.Entry<Object, Object> e : clone.meta.entrySet()) {
-            if (e.getKey() instanceof Serializable && e.getValue() instanceof Serializable) {
-                serializedMeta.put((Serializable) e.getKey(), (Serializable) e.getValue());
+        for ( Map.Entry<Object, Object> e : clone.meta.entrySet() )
+        {
+            if ( e.getKey() instanceof Serializable && e.getValue() instanceof Serializable )
+            {
+                serializedMeta.put( ( Serializable ) e.getKey(), ( Serializable ) e.getValue() );
             }
         }
 
@@ -157,21 +204,29 @@
         return clone;
     }
 
-    public Class<?> getPropertyType(String name) throws NoSuchMethodException {
-		return support.getPropertyType(name);
-	}
 
-	protected Object readResolve() {
-        this.meta = new HashMap<Object, Object>(serializedMeta);
+    public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+    {
+        return support.getPropertyType( name );
+    }
+
+
+    protected Object readResolve()
+    {
+        this.meta = new HashMap<Object, Object>( serializedMeta );
         serializedMeta.clear();
         return this;
     }
 
-	public OverrideOptions getOverride() {
-		return override;
-	}
-
-	public void setOverride(OverrideOptions override) {
-		this.override = override;
-	}
+
+    public OverrideOptions getOverride()
+    {
+        return override;
+    }
+
+
+    public void setOverride( OverrideOptions override )
+    {
+        this.override = override;
+    }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ICompoundModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ICompoundModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ICompoundModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ICompoundModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,20 +19,29 @@
 
 package org.apache.felix.sigil.model;
 
+
 import java.util.Set;
 
-public interface ICompoundModelElement extends IModelElement {
-    boolean addChild(IModelElement children) throws InvalidModelException;
-    
-    boolean removeChild(IModelElement children);
-    
+
+public interface ICompoundModelElement extends IModelElement
+{
+    boolean addChild( IModelElement children ) throws InvalidModelException;
+
+
+    boolean removeChild( IModelElement children );
+
+
     IModelElement[] children();
-    
-    void visit(IModelWalker walker);
-    
+
+
+    void visit( IModelWalker walker );
+
+
     <T extends IModelElement> T[] childrenOfType( Class<T> type );
-    
+
+
     Set<Class<? extends IModelElement>> getRequiredChildren();
-    
-    Set<Class<? extends IModelElement>> getOptionalChildren();    
+
+
+    Set<Class<? extends IModelElement>> getOptionalChildren();
 }
\ No newline at end of file

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

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

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IDependentModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IDependentModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IDependentModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IDependentModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,19 +19,23 @@
 
 package org.apache.felix.sigil.model;
 
-public interface IDependentModelElement extends IModelElement {
+
+public interface IDependentModelElement extends IModelElement
+{
     /**
      * @return
      */
     IDependency[] getDependencies();
-    
+
+
     /**
      * @param dependency
      */
-    void addDependency(IModelElement dependency);
-    
+    void addDependency( IModelElement dependency );
+
+
     /**
      * @param dependency
      */
-    void removeDependency(IModelElement dependency);
+    void removeDependency( IModelElement dependency );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,9 +19,11 @@
 
 package org.apache.felix.sigil.model;
 
+
 import java.util.Map;
 import java.util.Set;
 
+
 /**
  * Descriptors represent static information about component, composite or system. They allow other services to decide
  * how to deal with the given entity without the need to directly interact with the entity.
@@ -29,14 +31,16 @@
  * @author dave
  * 
  */
-public interface IModelElement extends Cloneable {
+public interface IModelElement extends Cloneable
+{
     /**
      * A brief human readable description of the component, composite or system.
      * 
      * @return
      */
     String getElementDescription();
-    
+
+
     /**
      * A set of key value pairs designed for use by a machine to classify a particular component, composite or system.
      * 
@@ -44,13 +48,15 @@
      */
     Map<Object, Object> getMeta();
 
+
     /**
      * Set meta data on this descriptor. Meta data is designed for use by a machine to classify or further enhance a
      * particular component, composite or system.
      * 
      * @param meta
      */
-    void setMeta(Map<Object, Object> meta);
+    void setMeta( Map<Object, Object> meta );
+
 
     /**
      * Check to see if this descriptor defines a complete set of properties. The definition of what constitutes a
@@ -59,15 +65,18 @@
      * @throws InvalidModelException
      */
     void checkValid() throws InvalidModelException;
-    
+
+
     /**
      * Find the parent element of this model element or null if no parent exists.
      * @return
      */
     IModelElement getParent();
-    
+
+
     void setParent( IModelElement parent );
-        
+
+
     /**
      * Finds the first ancestor up the hierarch of parents which is an instance of the specified
      * type.
@@ -75,24 +84,33 @@
      * @param type
      * @return
      */
-    <T extends IModelElement> T getAncestor(Class<T> type);
-    
+    <T extends IModelElement> T getAncestor( Class<T> type );
+
+
     IModelElement clone();
-    
+
+
     Set<String> getPropertyNames();
-    
-    void setProperty(String name, Object value) throws NoSuchMethodException;
-    
-	void addProperty(String name, Object value) throws NoSuchMethodException;
-	
-	void removeProperty(String name, Object value) throws NoSuchMethodException;
-	
-    Object getProperty(String name) throws NoSuchMethodException;
-    
-    Object getDefaultPropertyValue(String name);
-    
+
+
+    void setProperty( String name, Object value ) throws NoSuchMethodException;
+
+
+    void addProperty( String name, Object value ) throws NoSuchMethodException;
+
+
+    void removeProperty( String name, Object value ) throws NoSuchMethodException;
+
+
+    Object getProperty( String name ) throws NoSuchMethodException;
+
+
+    Object getDefaultPropertyValue( String name );
+
+
     Set<String> getRequiredProperties();
 
-	Class<?> getPropertyType(String name) throws NoSuchMethodException;
+
+    Class<?> getPropertyType( String name ) throws NoSuchMethodException;
 
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelInfo.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelInfo.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelInfo.java Tue Jul 21 18:51:33 2009
@@ -19,8 +19,14 @@
 
 package org.apache.felix.sigil.model;
 
-public interface IModelInfo {
-	String getGroupName();
-	String getGroupURI();
-	String getName();
+
+public interface IModelInfo
+{
+    String getGroupName();
+
+
+    String getGroupURI();
+
+
+    String getName();
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelWalker.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelWalker.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelWalker.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/IModelWalker.java Tue Jul 21 18:51:33 2009
@@ -20,6 +20,7 @@
 package org.apache.felix.sigil.model;
 
 
-public interface IModelWalker {
-	boolean visit( IModelElement element );
+public interface IModelWalker
+{
+    boolean visit( IModelElement element );
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/INamedModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/INamedModelElement.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/INamedModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/INamedModelElement.java Tue Jul 21 18:51:33 2009
@@ -19,9 +19,17 @@
 
 package org.apache.felix.sigil.model;
 
-public interface INamedModelElement extends IModelElement {
-	void setName(String name);
-	String getName();
+
+public interface INamedModelElement extends IModelElement
+{
+    void setName( String name );
+
+
+    String getName();
+
+
     OverrideOptions getOverride();
-    void setOverride(OverrideOptions override);	
+
+
+    void setOverride( OverrideOptions override );
 }

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

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/InvalidModelException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/InvalidModelException.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/InvalidModelException.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/InvalidModelException.java Tue Jul 21 18:51:33 2009
@@ -19,27 +19,35 @@
 
 package org.apache.felix.sigil.model;
 
+
 /**
  * @author dave
  * 
  */
-public class InvalidModelException extends RuntimeException {
-	
-	private static final long serialVersionUID = 1L;
-	
-	private IModelElement target;
-	
-    public InvalidModelException(IModelElement target, String msg) {
-        super(msg);
+public class InvalidModelException extends RuntimeException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private IModelElement target;
+
+
+    public InvalidModelException( IModelElement target, String msg )
+    {
+        super( msg );
         this.target = target;
     }
 
-    public InvalidModelException(IModelElement target, String msg, Throwable t) {
-        super(msg, t);
+
+    public InvalidModelException( IModelElement target, String msg, Throwable t )
+    {
+        super( msg, t );
         this.target = target;
     }
-    
-    public IModelElement getTarget() {
-    	return target;
+
+
+    public IModelElement getTarget()
+    {
+        return target;
     }
 }

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ModelElementFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ModelElementFactory.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ModelElementFactory.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/model/ModelElementFactory.java Tue Jul 21 18:51:33 2009
@@ -19,150 +19,213 @@
 
 package org.apache.felix.sigil.model;
 
+
 import java.util.HashMap;
 import java.util.Map;
 
-public abstract class ModelElementFactory {
-	static class ElementInfo {
-		Class<? extends IModelElement> implType;
-		String name;
-		String groupName;
-		String groupURI;
-		
-		public ElementInfo(Class<? extends IModelElement> implType, String name, String groupName, String groupURI) {
-			this.implType = implType;
-			this.name = name;
-			this.groupName = groupName;
-			this.groupURI = groupURI;
-		}
-		
-		public Class<? extends IModelElement> getImplType() {
-			return implType;
-		}
-		public String getName() {
-			return name;
-		}
-		
-		public String getGroupName() {
-			return groupName;
-		}
-
-		public String getGroupURI() {
-			return groupURI;
-		}
-		
-		public String toString() {
-			return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":" + implType.getCanonicalName() + "]";
-		}
-	}
-
-	static class ModelInfo implements IModelInfo {
-
-		private ElementInfo e;
-		
-		public ModelInfo(ElementInfo e) {
-			this.e = e;
-		}
-
-		public String getGroupName() {
-			return e.getGroupName();
-		}
-
-		public String getGroupURI() {
-			return e.getGroupURI();
-		}
-
-		public String getName() {
-			return e.getName();
-		}
-
-	}
-
-	static class DefaultModelElementFactory extends ModelElementFactory {
-		private HashMap<Class<? extends IModelElement>, ElementInfo> elementInfo = new HashMap<Class<? extends IModelElement>, ElementInfo>();
-		
-		@SuppressWarnings("unchecked")
-		@Override
-		public <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException {
-			ElementInfo info = elementInfo.get( type );
-			if ( info == null ) {
-				throw new ModelElementFactoryException( "No implementation registered for " + type );
-			}
-			try {
-				return (T) info.getImplType().newInstance();
-			} catch (InstantiationException e) {
-				throw new ModelElementFactoryException(e);
-			} catch (IllegalAccessException e) {
-				throw new ModelElementFactoryException(e);
-			}
-		}
-
-		@Override
-		public <T extends IModelElement> void register(Class<T> type, Class<? extends T> impl, String name, String groupName, String groupURI ) {
-			elementInfo.put( type, new ElementInfo( impl, name, groupName, groupURI ) );
-		}
-
-		@Override
-		public <T extends IModelElement> void unregister(Class<T> type,
-				Class<? extends T> impl) {
-			ElementInfo info = elementInfo.get( type );
-			if ( info != null && info.getImplType() == impl ) {
-				elementInfo.remove(type);
-			}
-		}
-
-		@Override
-		public IModelInfo getModelInfo(Class<? extends IModelElement> type) {
-			ElementInfo e = findElementInfo( type );
-			
-			if ( e == null ) {
-				return null;
-			}
-			
-			return new ModelInfo( e );
-		}
-
-		@Override
-		public IModelElement newModelElement(String namespaceURI, String localPart) throws ModelElementFactoryException {
-			for ( Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet() ) {
-				ElementInfo i = e.getValue();
-				if ( equal( namespaceURI, i.getGroupURI() ) && equal( i.getName(), localPart ) ) {
-					return newModelElement(e.getKey());
-				}
-			}
-			
-			return null;
-		}
-
-		private boolean equal(String val1, String val2) {
-			return val1 == null ? val2 == null : val1.equals( val2 );
-		}
-
-		private ElementInfo findElementInfo( Class<? extends IModelElement> type ) {
-			for ( ElementInfo e : elementInfo.values() ) {
-				if ( e.getImplType() == type ) {
-					return e;
-				}
-			}
-			
-			return null;
-		}
-
-	}
-
-	public abstract <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException;
-	
-	public abstract IModelElement newModelElement(String namespaceURI, String localPart) throws ModelElementFactoryException;	
-	
-	public abstract <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name, String groupName, String groupURI );
-	
-	public abstract <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl );
-
-	public abstract IModelInfo getModelInfo( Class<? extends IModelElement> type );
-	
-	private static ModelElementFactory instance = new DefaultModelElementFactory();
-
-	public static ModelElementFactory getInstance() {
-		return instance;
-	}
+
+public abstract class ModelElementFactory
+{
+    static class ElementInfo
+    {
+        Class<? extends IModelElement> implType;
+        String name;
+        String groupName;
+        String groupURI;
+
+
+        public ElementInfo( Class<? extends IModelElement> implType, String name, String groupName, String groupURI )
+        {
+            this.implType = implType;
+            this.name = name;
+            this.groupName = groupName;
+            this.groupURI = groupURI;
+        }
+
+
+        public Class<? extends IModelElement> getImplType()
+        {
+            return implType;
+        }
+
+
+        public String getName()
+        {
+            return name;
+        }
+
+
+        public String getGroupName()
+        {
+            return groupName;
+        }
+
+
+        public String getGroupURI()
+        {
+            return groupURI;
+        }
+
+
+        public String toString()
+        {
+            return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":" + implType.getCanonicalName() + "]";
+        }
+    }
+
+    static class ModelInfo implements IModelInfo
+    {
+
+        private ElementInfo e;
+
+
+        public ModelInfo( ElementInfo e )
+        {
+            this.e = e;
+        }
+
+
+        public String getGroupName()
+        {
+            return e.getGroupName();
+        }
+
+
+        public String getGroupURI()
+        {
+            return e.getGroupURI();
+        }
+
+
+        public String getName()
+        {
+            return e.getName();
+        }
+
+    }
+
+    static class DefaultModelElementFactory extends ModelElementFactory
+    {
+        private HashMap<Class<? extends IModelElement>, ElementInfo> elementInfo = new HashMap<Class<? extends IModelElement>, ElementInfo>();
+
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException
+        {
+            ElementInfo info = elementInfo.get( type );
+            if ( info == null )
+            {
+                throw new ModelElementFactoryException( "No implementation registered for " + type );
+            }
+            try
+            {
+                return ( T ) info.getImplType().newInstance();
+            }
+            catch ( InstantiationException e )
+            {
+                throw new ModelElementFactoryException( e );
+            }
+            catch ( IllegalAccessException e )
+            {
+                throw new ModelElementFactoryException( e );
+            }
+        }
+
+
+        @Override
+        public <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
+            String groupName, String groupURI )
+        {
+            elementInfo.put( type, new ElementInfo( impl, name, groupName, groupURI ) );
+        }
+
+
+        @Override
+        public <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl )
+        {
+            ElementInfo info = elementInfo.get( type );
+            if ( info != null && info.getImplType() == impl )
+            {
+                elementInfo.remove( type );
+            }
+        }
+
+
+        @Override
+        public IModelInfo getModelInfo( Class<? extends IModelElement> type )
+        {
+            ElementInfo e = findElementInfo( type );
+
+            if ( e == null )
+            {
+                return null;
+            }
+
+            return new ModelInfo( e );
+        }
+
+
+        @Override
+        public IModelElement newModelElement( String namespaceURI, String localPart )
+            throws ModelElementFactoryException
+        {
+            for ( Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet() )
+            {
+                ElementInfo i = e.getValue();
+                if ( equal( namespaceURI, i.getGroupURI() ) && equal( i.getName(), localPart ) )
+                {
+                    return newModelElement( e.getKey() );
+                }
+            }
+
+            return null;
+        }
+
+
+        private boolean equal( String val1, String val2 )
+        {
+            return val1 == null ? val2 == null : val1.equals( val2 );
+        }
+
+
+        private ElementInfo findElementInfo( Class<? extends IModelElement> type )
+        {
+            for ( ElementInfo e : elementInfo.values() )
+            {
+                if ( e.getImplType() == type )
+                {
+                    return e;
+                }
+            }
+
+            return null;
+        }
+
+    }
+
+
+    public abstract <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException;
+
+
+    public abstract IModelElement newModelElement( String namespaceURI, String localPart )
+        throws ModelElementFactoryException;
+
+
+    public abstract <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
+        String groupName, String groupURI );
+
+
+    public abstract <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl );
+
+
+    public abstract IModelInfo getModelInfo( Class<? extends IModelElement> type );
+
+    private static ModelElementFactory instance = new DefaultModelElementFactory();
+
+
+    public static ModelElementFactory getInstance()
+    {
+        return instance;
+    }
 }

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



Mime
View raw message