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 2010/08/02 19:08:20 UTC
svn commit: r981604 [3/22] - in /felix/trunk/sigil:
common/core.tests/src/org/apache/felix/sigil/common/core/
common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/
common/core/src/org/apache/felix/sigil/common/bnd/ common/core/s...
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -55,7 +54,6 @@ import org.eclipse.core.runtime.IProgres
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.framework.Version;
-
public class BundleResolver implements IBundleResolver
{
@@ -63,36 +61,33 @@ public class BundleResolver implements I
{
private IModelElement requirement;
-
- public BundleOrderComparator( IModelElement requirement )
+ public BundleOrderComparator(IModelElement requirement)
{
this.requirement = requirement;
}
-
- public int compare( ISigilBundle o1, ISigilBundle o2 )
+ public int compare(ISigilBundle o1, ISigilBundle o2)
{
- int c = compareVersions( o1, o2 );
+ int c = compareVersions(o1, o2);
- if ( c == 0 )
+ if (c == 0)
{
- c = compareImports( o1, o2 );
+ c = compareImports(o1, o2);
}
return c;
}
-
- private int compareImports( ISigilBundle o1, ISigilBundle o2 )
+ private int compareImports(ISigilBundle o1, ISigilBundle o2)
{
int c1 = o1.getBundleInfo().getImports().size();
int c2 = o2.getBundleInfo().getImports().size();
- if ( c1 < c2 )
+ if (c1 < c2)
{
return -1;
}
- else if ( c2 > c1 )
+ else if (c2 > c1)
{
return 1;
}
@@ -102,25 +97,24 @@ public class BundleResolver implements I
}
}
-
- private int compareVersions( ISigilBundle o1, ISigilBundle o2 )
+ private int compareVersions(ISigilBundle o1, ISigilBundle o2)
{
Version v1 = null;
Version v2 = null;
- if ( requirement instanceof IPackageImport )
+ if (requirement instanceof IPackageImport)
{
- v1 = findExportVersion( ( IPackageImport ) requirement, o1 );
- v2 = findExportVersion( ( IPackageImport ) requirement, o2 );
+ v1 = findExportVersion((IPackageImport) requirement, o1);
+ v2 = findExportVersion((IPackageImport) requirement, o2);
}
- else if ( requirement instanceof IRequiredBundle )
+ else if (requirement instanceof IRequiredBundle)
{
v1 = o1.getBundleInfo().getVersion();
v2 = o1.getBundleInfo().getVersion();
}
- if ( v1 == null )
+ if (v1 == null)
{
- if ( v2 == null )
+ if (v2 == null)
{
return 0;
}
@@ -131,23 +125,22 @@ public class BundleResolver implements I
}
else
{
- if ( v2 == null )
+ if (v2 == null)
{
return -1;
}
else
{
- return v2.compareTo( v1 );
+ return v2.compareTo(v1);
}
}
}
-
- private Version findExportVersion( IPackageImport pi, ISigilBundle o1 )
+ private Version findExportVersion(IPackageImport pi, ISigilBundle o1)
{
- for ( IPackageExport pe : o1.getBundleInfo().getExports() )
+ for (IPackageExport pe : o1.getBundleInfo().getExports())
{
- if ( pi.getPackageName().equals( pi.getPackageName() ) )
+ if (pi.getPackageName().equals(pi.getPackageName()))
{
return pe.getVersion();
}
@@ -168,72 +161,64 @@ public class BundleResolver implements I
private final Set<IModelElement> parsed = new HashSet<IModelElement>();
private final LinkedList<IModelElement> requirements = new LinkedList<IModelElement>();
-
- public ResolutionContext( IModelElement root, ResolutionConfig config, IResolutionMonitor monitor )
+ public ResolutionContext(IModelElement root, ResolutionConfig config, IResolutionMonitor monitor)
{
this.root = root;
this.config = config;
this.monitor = monitor;
}
-
- public void enterModelElement( IModelElement element )
+ public void enterModelElement(IModelElement element)
{
- parsed.add( element );
+ parsed.add(element);
}
-
- public void exitModelElement( IModelElement element )
+ public void exitModelElement(IModelElement element)
{
- parsed.remove( element );
+ parsed.remove(element);
}
-
- public boolean isNewModelElement( IModelElement element )
+ public boolean isNewModelElement(IModelElement element)
{
- return !parsed.contains( element );
+ return !parsed.contains(element);
}
-
public boolean isValid()
{
return resolution.isSuccess();
}
-
- public void setValid( boolean valid )
+ public void setValid(boolean valid)
{
- resolution.setSuccess( valid );
+ resolution.setSuccess(valid);
}
-
public ResolutionException newResolutionException()
{
- return new ResolutionException( root, requirements.toArray( new IModelElement[requirements.size()] ) );
+ return new ResolutionException(root,
+ requirements.toArray(new IModelElement[requirements.size()]));
}
-
- public void startRequirement( IRequirementModelElement element )
+ public void startRequirement(IRequirementModelElement element)
{
- requirements.add( element );
- monitor.startResolution( element );
+ requirements.add(element);
+ monitor.startResolution(element);
}
-
- public void endRequirement( IRequirementModelElement element )
+ public void endRequirement(IRequirementModelElement element)
{
- ISigilBundle provider = resolution.getProvider( element );
+ ISigilBundle provider = resolution.getProvider(element);
- setValid( provider != null || element.isOptional() || config.isIgnoreErrors() );
+ setValid(provider != null || element.isOptional() || config.isIgnoreErrors());
- if ( isValid() )
+ if (isValid())
{
// only clear stack if valid
// else use it as an aid to trace errors
- requirements.remove( element );
+ requirements.remove(element);
}
- monitor.endResolution( element, provider );
+ monitor.endResolution(element, provider);
}
}
@@ -243,74 +228,66 @@ public class BundleResolver implements I
private Map<IModelElement, ISigilBundle> providers = new HashMap<IModelElement, ISigilBundle>();
private boolean success = true; // assume success
-
- boolean addProvider( IModelElement element, ISigilBundle provider )
+ boolean addProvider(IModelElement element, ISigilBundle provider)
{
- providers.put( element, provider );
+ providers.put(element, provider);
- List<IModelElement> requirements = providees.get( provider );
+ List<IModelElement> requirements = providees.get(provider);
boolean isNewProvider = requirements == null;
- if ( isNewProvider )
+ if (isNewProvider)
{
requirements = new ArrayList<IModelElement>();
- providees.put( provider, requirements );
+ providees.put(provider, requirements);
}
- requirements.add( element );
+ requirements.add(element);
return isNewProvider;
}
-
- void removeProvider( IModelElement element, ISigilBundle provider )
+ void removeProvider(IModelElement element, ISigilBundle provider)
{
- providers.remove( element );
- List<IModelElement> e = providees.get( provider );
- e.remove( element );
- if ( e.isEmpty() )
+ providers.remove(element);
+ List<IModelElement> e = providees.get(provider);
+ e.remove(element);
+ if (e.isEmpty())
{
- providees.remove( provider );
+ providees.remove(provider);
}
}
-
- void setSuccess( boolean success )
+ void setSuccess(boolean success)
{
this.success = success;
}
-
public boolean isSuccess()
{
return success;
}
-
- public ISigilBundle getProvider( IModelElement requirement )
+ public ISigilBundle getProvider(IModelElement requirement)
{
- return providers.get( requirement );
+ return providers.get(requirement);
}
-
public Set<ISigilBundle> getBundles()
{
return providees.keySet();
}
-
- public List<IModelElement> getMatchedRequirements( ISigilBundle bundle )
+ public List<IModelElement> getMatchedRequirements(ISigilBundle bundle)
{
- return providees.get( bundle );
+ return providees.get(bundle);
}
-
public boolean isSynchronized()
{
- for ( ISigilBundle b : getBundles() )
+ for (ISigilBundle b : getBundles())
{
- if ( !b.isSynchronized() )
+ if (!b.isSynchronized())
{
return false;
}
@@ -319,26 +296,25 @@ public class BundleResolver implements I
return true;
}
-
- public void synchronize( IProgressMonitor monitor )
+ public void synchronize(IProgressMonitor monitor)
{
Set<ISigilBundle> bundles = getBundles();
- SubMonitor progress = SubMonitor.convert( monitor, bundles.size() );
+ SubMonitor progress = SubMonitor.convert(monitor, bundles.size());
- for ( ISigilBundle b : bundles )
+ for (ISigilBundle b : bundles)
{
- if ( monitor.isCanceled() )
+ if (monitor.isCanceled())
{
break;
}
try
{
- b.synchronize( progress.newChild( 1 ) );
+ b.synchronize(progress.newChild(1));
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to synchronize " + b, e );
+ BldCore.error("Failed to synchronize " + b, e);
}
}
}
@@ -346,18 +322,16 @@ public class BundleResolver implements I
private static final IResolutionMonitor NULL_MONITOR = new IResolutionMonitor()
{
- public void endResolution( IModelElement requirement, ISigilBundle sigilBundle )
+ public void endResolution(IModelElement requirement, ISigilBundle sigilBundle)
{
}
-
public boolean isCanceled()
{
return false;
}
-
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
}
};
@@ -366,20 +340,26 @@ public class BundleResolver implements I
{
public int compare(IRequirementModelElement o1, IRequirementModelElement o2)
{
- if ( o1 instanceof IPackageImport ) {
- if (o2 instanceof IPackageImport ) {
+ if (o1 instanceof IPackageImport)
+ {
+ if (o2 instanceof IPackageImport)
+ {
return 0;
}
- else {
+ else
+ {
return -1;
}
}
- else // assumes only alternative is IRequiredBundle
+ else
+ // assumes only alternative is IRequiredBundle
{
- if ( o2 instanceof IRequiredBundle) {
+ if (o2 instanceof IRequiredBundle)
+ {
return 0;
}
- else {
+ else
+ {
return 1;
}
}
@@ -388,25 +368,23 @@ public class BundleResolver implements I
private IRepositoryManager repositoryManager;
-
- public BundleResolver( IRepositoryManager repositoryManager )
+ public BundleResolver(IRepositoryManager repositoryManager)
{
this.repositoryManager = repositoryManager;
}
-
- public IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
- throws ResolutionException
+ public IResolution resolve(IModelElement element, ResolutionConfig config,
+ IResolutionMonitor monitor) throws ResolutionException
{
- if ( monitor == null )
+ if (monitor == null)
{
monitor = NULL_MONITOR;
}
- ResolutionContext ctx = new ResolutionContext( element, config, monitor );
+ ResolutionContext ctx = new ResolutionContext(element, config, monitor);
- resolveElement( element, ctx );
+ resolveElement(element, ctx);
- if ( !ctx.isValid() )
+ if (!ctx.isValid())
{
throw ctx.newResolutionException();
}
@@ -414,22 +392,25 @@ public class BundleResolver implements I
return ctx.resolution;
}
- private void resolveElement( IModelElement element, ResolutionContext ctx ) throws ResolutionException
+ private void resolveElement(IModelElement element, ResolutionContext ctx)
+ throws ResolutionException
{
- if ( ctx.isValid() ) {
- for (IRequirementModelElement req : findRequirements(element, ctx)) {
- if ( ctx.monitor.isCanceled())
+ if (ctx.isValid())
+ {
+ for (IRequirementModelElement req : findRequirements(element, ctx))
+ {
+ if (ctx.monitor.isCanceled())
break;
resolveRequirement(req, ctx);
}
}
}
-
+
private List<IRequirementModelElement> findRequirements(IModelElement element,
final ResolutionContext ctx)
{
final LinkedList<IRequirementModelElement> reqs = new LinkedList<IRequirementModelElement>();
-
+
if (element instanceof IRequirementModelElement)
{
reqs.add((IRequirementModelElement) element);
@@ -445,102 +426,106 @@ public class BundleResolver implements I
{
reqs.add((IRequirementModelElement) element);
}
- else if ( element instanceof ILibrary ) {
- ILibrary lib = repositoryManager.resolveLibrary( ( ILibraryImport ) element );
- reqs.addAll( lib.getImports() );
+ else if (element instanceof ILibrary)
+ {
+ ILibrary lib = repositoryManager.resolveLibrary((ILibraryImport) element);
+ reqs.addAll(lib.getImports());
}
-
+
return !ctx.monitor.isCanceled();
}
});
}
- if ( !ctx.monitor.isCanceled() ) {
+ if (!ctx.monitor.isCanceled())
+ {
Collections.sort(reqs, REQUIREMENT_COMPARATOR);
- }
+ }
return reqs;
}
- private void resolveRequirement( IRequirementModelElement requirement, ResolutionContext ctx ) throws ResolutionException
+ private void resolveRequirement(IRequirementModelElement requirement,
+ ResolutionContext ctx) throws ResolutionException
{
- if ( ctx.config.isOptional() || !requirement.isOptional() )
+ if (ctx.config.isOptional() || !requirement.isOptional())
{
- ctx.startRequirement( requirement );
+ ctx.startRequirement(requirement);
try
{
- if ( !findInContext( requirement, ctx ) )
+ if (!findInContext(requirement, ctx))
{
- findInRepositories( requirement, ctx );
+ findInRepositories(requirement, ctx);
}
}
finally
{
- ctx.endRequirement( requirement );
+ ctx.endRequirement(requirement);
}
}
}
-
private boolean findInContext(final IRequirementModelElement requirement,
final ResolutionContext ctx)
{
- for ( final ISigilBundle b : ctx.resolution.providees.keySet() )
+ for (final ISigilBundle b : ctx.resolution.providees.keySet())
{
- b.visit( new IModelWalker()
+ b.visit(new IModelWalker()
{
public boolean visit(IModelElement element)
{
- if ( element instanceof ICapabilityModelElement ) {
- if ( requirement.accepts((ICapabilityModelElement) element) ) {
- ctx.resolution.addProvider( requirement, b );
+ if (element instanceof ICapabilityModelElement)
+ {
+ if (requirement.accepts((ICapabilityModelElement) element))
+ {
+ ctx.resolution.addProvider(requirement, b);
return false;
}
}
return !ctx.monitor.isCanceled();
}
-
+
});
}
-
+
return ctx.resolution.getProvider(requirement) != null;
}
-
private void findInRepositories(IRequirementModelElement requirement,
ResolutionContext ctx) throws ResolutionException
{
int[] priorities = repositoryManager.getPriorityLevels();
- outer: for ( int i = 0; i < priorities.length; i++ )
+ outer: for (int i = 0; i < priorities.length; i++)
{
- List<ISigilBundle> providers = findProvidersAtPriority( priorities[i], requirement, ctx );
+ List<ISigilBundle> providers = findProvidersAtPriority(priorities[i],
+ requirement, ctx);
- if ( !providers.isEmpty() && !ctx.monitor.isCanceled() )
+ if (!providers.isEmpty() && !ctx.monitor.isCanceled())
{
- if ( providers.size() > 1 )
+ if (providers.size() > 1)
{
- Collections.sort( providers, new BundleOrderComparator( requirement ) );
+ Collections.sort(providers, new BundleOrderComparator(requirement));
}
- for ( ISigilBundle provider : providers )
+ for (ISigilBundle provider : providers)
{
// reset validity - if there's another provider it can still be solved
- ctx.setValid( true );
- if ( ctx.resolution.addProvider( requirement, provider ) )
+ ctx.setValid(true);
+ if (ctx.resolution.addProvider(requirement, provider))
{
- if ( ctx.config.isDependents() )
+ if (ctx.config.isDependents())
{
- resolveElement( provider, ctx );
+ resolveElement(provider, ctx);
}
- if ( ctx.isValid() )
+ if (ctx.isValid())
{
break outer;
}
else
{
- ctx.resolution.removeProvider( requirement, provider );
+ ctx.resolution.removeProvider(requirement, provider);
}
}
else
@@ -552,45 +537,44 @@ public class BundleResolver implements I
}
}
-
- private List<ISigilBundle> findProvidersAtPriority( int i, IRequirementModelElement requirement, ResolutionContext ctx )
+ private List<ISigilBundle> findProvidersAtPriority(int i,
+ IRequirementModelElement requirement, ResolutionContext ctx)
throws ResolutionException
{
ArrayList<ISigilBundle> providers = new ArrayList<ISigilBundle>();
- for ( IBundleRepository rep : repositoryManager.getRepositories( i ) )
+ for (IBundleRepository rep : repositoryManager.getRepositories(i))
{
- if ( ctx.monitor.isCanceled() )
+ if (ctx.monitor.isCanceled())
{
break;
}
- providers.addAll( findProviders( requirement, ctx.config, rep ) );
+ providers.addAll(findProviders(requirement, ctx.config, rep));
}
return providers;
}
-
- private Collection<ISigilBundle> findProviders( IRequirementModelElement requirement, ResolutionConfig config,
- IBundleRepository rep ) throws ResolutionException
+ private Collection<ISigilBundle> findProviders(IRequirementModelElement requirement,
+ ResolutionConfig config, IBundleRepository rep) throws ResolutionException
{
ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- if ( requirement instanceof IPackageImport )
+ if (requirement instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) requirement;
- found.addAll( rep.findAllProviders( pi, config.getOptions() ) );
+ IPackageImport pi = (IPackageImport) requirement;
+ found.addAll(rep.findAllProviders(pi, config.getOptions()));
}
- else if ( requirement instanceof IRequiredBundle )
+ else if (requirement instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) requirement;
- found.addAll( rep.findAllProviders( rb, config.getOptions() ) );
+ IRequiredBundle rb = (IRequiredBundle) requirement;
+ found.addAll(rep.findAllProviders(rb, config.getOptions()));
}
else
{
// shouldn't get here - developer error if do
// use isRequirement before getting anywhere near this logic...
- throw new IllegalStateException( "Invalid requirement type " + requirement );
+ throw new IllegalStateException("Invalid requirement type " + requirement);
}
return found;
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -33,61 +32,61 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.model.osgi.IBundleModelElement;
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
-
public class DirectoryHelper
{
- public static void scanBundles( AbstractBundleRepository repository, List<ISigilBundle> bundles, File dir,
- File source, boolean recursive )
+ public static void scanBundles(AbstractBundleRepository repository,
+ List<ISigilBundle> bundles, File dir, File source, boolean recursive)
{
- if ( dir.exists() )
+ if (dir.exists())
{
- for ( File f : dir.listFiles() )
+ for (File f : dir.listFiles())
{
- if ( f.isDirectory() )
+ if (f.isDirectory())
{
- if ( recursive )
+ if (recursive)
{
- scanBundles( repository, bundles, f, source, recursive );
+ scanBundles(repository, bundles, f, source, recursive);
}
}
- else if ( f.isFile() && f.getName().endsWith( ".jar" ) )
+ else if (f.isFile() && f.getName().endsWith(".jar"))
{
JarFile jar = null;
try
{
- jar = new JarFile( f, false );
- ISigilBundle bundle = buildBundle( repository, jar.getManifest(), f );
- if ( bundle != null )
+ jar = new JarFile(f, false);
+ ISigilBundle bundle = buildBundle(repository, jar.getManifest(),
+ f);
+ if (bundle != null)
{
- bundle.setSourcePathLocation( source );
+ bundle.setSourcePathLocation(source);
// TODO shouldn't be hard coded
- bundle.setSourceRootPath( "src" );
- bundles.add( bundle );
+ bundle.setSourceRootPath("src");
+ bundles.add(bundle);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to read jar file " + f, e );
+ BldCore.error("Failed to read jar file " + f, e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to close jar file", e );
+ BldCore.error("Failed to close jar file", e);
}
}
}
@@ -96,18 +95,18 @@ public class DirectoryHelper
}
}
-
- private static ISigilBundle buildBundle( AbstractBundleRepository repository, Manifest manifest, File f )
+ private static ISigilBundle buildBundle(AbstractBundleRepository repository,
+ Manifest manifest, File f)
{
- IBundleModelElement info = repository.buildBundleModelElement( manifest );
+ IBundleModelElement info = repository.buildBundleModelElement(manifest);
ISigilBundle bundle = null;
- if ( info != null )
+ if (info != null)
{
- bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- bundle.addChild( info );
- bundle.setLocation( f );
+ bundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+ bundle.addChild(info);
+ bundle.setLocation(f);
}
return bundle;
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.util.ArrayList;
@@ -27,7 +26,6 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
-
public class FileSystemRepository extends AbstractBundleRepository
{
@@ -35,40 +33,37 @@ public class FileSystemRepository extend
private File dir;
private boolean recurse;
-
- public FileSystemRepository( String id, File dir, boolean recurse )
+ public FileSystemRepository(String id, File dir, boolean recurse)
{
- super( id );
+ super(id);
this.dir = dir;
this.recurse = recurse;
}
-
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
- synchronized ( this )
+ synchronized (this)
{
- if ( bundles == null )
+ if (bundles == null)
{
bundles = new ArrayList<ISigilBundle>();
- DirectoryHelper.scanBundles( this, bundles, dir, null, recurse );
+ DirectoryHelper.scanBundles(this, bundles, dir, null, recurse);
}
}
- for ( ISigilBundle b : bundles )
+ for (ISigilBundle b : bundles)
{
- if ( !visitor.visit( b ) )
+ if (!visitor.visit(b))
{
break;
}
}
}
-
public void refresh()
{
- synchronized ( this )
+ synchronized (this)
{
bundles = null;
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.util.Properties;
@@ -27,20 +26,20 @@ import org.apache.felix.sigil.common.rep
import org.apache.felix.sigil.common.repository.IRepositoryProvider;
import org.apache.felix.sigil.common.repository.RepositoryException;
-
public class FileSystemRepositoryProvider implements IRepositoryProvider
{
- public IBundleRepository createRepository( String id, Properties preferences ) throws RepositoryException
+ public IBundleRepository createRepository(String id, Properties preferences)
+ throws RepositoryException
{
- String dirStr = preferences.getProperty( "dir" );
- File dir = new File( dirStr );
- if ( !dir.isDirectory() )
+ String dirStr = preferences.getProperty("dir");
+ File dir = new File(dirStr);
+ if (!dir.isDirectory())
{
- throw new RepositoryException( "directory '" + dir + "' does not exist." );
+ throw new RepositoryException("directory '" + dir + "' does not exist.");
}
- boolean recurse = Boolean.valueOf( preferences.getProperty( "recurse" ) );
- return new FileSystemRepository( id, dir, recurse );
+ boolean recurse = Boolean.valueOf(preferences.getProperty("recurse"));
+ return new FileSystemRepository(id, dir, recurse);
}
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java Mon Aug 2 17:08:03 2010
@@ -19,72 +19,61 @@
package org.apache.felix.sigil.common.core.repository;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.felix.sigil.common.repository.IResolutionMonitor;
-
public class ProgressWrapper implements IProgressMonitor
{
private IResolutionMonitor monitor;
-
- public ProgressWrapper( IResolutionMonitor monitor )
+ public ProgressWrapper(IResolutionMonitor monitor)
{
this.monitor = monitor;
}
-
public boolean isCanceled()
{
return monitor.isCanceled();
}
-
- public void beginTask( String name, int totalWork )
+ public void beginTask(String name, int totalWork)
{
// TODO Auto-generated method stub
}
-
public void done()
{
// TODO Auto-generated method stub
}
-
- public void internalWorked( double work )
+ public void internalWorked(double work)
{
// TODO Auto-generated method stub
}
-
- public void setCanceled( boolean value )
+ public void setCanceled(boolean value)
{
// TODO Auto-generated method stub
}
-
- public void setTaskName( String name )
+ public void setTaskName(String name)
{
// TODO Auto-generated method stub
}
-
- public void subTask( String name )
+ public void subTask(String name)
{
// TODO Auto-generated method stub
}
-
- public void worked( int work )
+ public void worked(int work)
{
// TODO Auto-generated method stub
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
import java.util.jar.JarFile;
@@ -33,87 +32,85 @@ import org.apache.felix.sigil.common.mod
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
-
public class SystemRepository extends AbstractBundleRepository
{
private final String packages;
private final File frameworkPath;
-
- public SystemRepository( String id, File frameworkPath, String packages )
+ public SystemRepository(String id, File frameworkPath, String packages)
{
- super( id );
+ super(id);
this.frameworkPath = frameworkPath;
this.packages = packages;
}
private static ISigilBundle systemBundle;
-
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
ISigilBundle bundle = loadSystemBundle();
- if ( bundle != null )
+ if (bundle != null)
{
- visitor.visit( bundle );
+ visitor.visit(bundle);
}
}
-
private synchronized ISigilBundle loadSystemBundle()
{
- if ( systemBundle == null )
+ if (systemBundle == null)
{
- systemBundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
+ systemBundle = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
JarFile jar = null;
try
{
final IBundleModelElement info;
- if ( frameworkPath != null )
+ if (frameworkPath != null)
{
- systemBundle.setLocation( frameworkPath );
+ systemBundle.setLocation(frameworkPath);
jar = new JarFile(frameworkPath);
- info = buildBundleModelElement( jar.getManifest() );
+ info = buildBundleModelElement(jar.getManifest());
}
else
{
- info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
+ info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
}
info.setSymbolicName("system bundle");
info.setName("Sigil system bundle");
-
- applyProfile( info );
- systemBundle.addChild( info );
+
+ applyProfile(info);
+ systemBundle.addChild(info);
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to read jar file " + frameworkPath, e );
+ BldCore.error("Failed to read jar file " + frameworkPath, e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- BldCore.error( "Failed to build bundle " + frameworkPath, e );
+ BldCore.error("Failed to build bundle " + frameworkPath, e);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to build bundle " + frameworkPath, e );
+ BldCore.error("Failed to build bundle " + frameworkPath, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to close jar file", e );
+ BldCore.error("Failed to close jar file", e);
}
}
}
@@ -122,21 +119,20 @@ public class SystemRepository extends Ab
return systemBundle;
}
-
- private void applyProfile( IBundleModelElement info )
+ private void applyProfile(IBundleModelElement info)
{
- if ( packages != null )
+ if (packages != null)
{
- for ( String name : packages.split( ",\\s*" ) )
+ for (String name : packages.split(",\\s*"))
{
- IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pe.setPackageName( name );
- info.addExport( pe );
+ IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pe.setPackageName(name);
+ info.addExport(pe);
}
}
}
-
public synchronized void refresh()
{
systemBundle = null;
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
@@ -33,44 +32,46 @@ import org.apache.felix.sigil.common.rep
public class SystemRepositoryProvider implements IRepositoryProvider
{
- public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+ public IBundleRepository createRepository(String id, Properties properties)
+ throws RepositoryException
{
- String fw = properties.getProperty( "framework" );
- File frameworkPath = fw == null ? null : new File( fw );
- String extraPkgs = properties.getProperty( "packages" );
- String profile = properties.getProperty( "profile" );
-
+ String fw = properties.getProperty("framework");
+ File frameworkPath = fw == null ? null : new File(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 );
+ Properties p = readProfile(profile);
+ String pkgs = p.getProperty("org.osgi.framework.system.packages") + ","
+ + extraPkgs;
+ return new SystemRepository(id, frameworkPath, pkgs);
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw new RepositoryException( "Failed to load profile", e );
+ throw new RepositoryException("Failed to load profile", e);
}
}
-
- public static Properties readProfile( String name ) throws IOException
+ public static Properties readProfile(String name) throws IOException
{
- if ( name == null )
+ if (name == null)
{
- String version = System.getProperty( "java.specification.version" );
- String[] split = version.split( "\\." );
- String prefix = ( "6".compareTo( split[1] ) <= 0 ) ? "JavaSE-" : "J2SE-";
+ 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 );
+ InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream(
+ profilePath);
- if ( in == null )
- throw new IOException( "No such profile: " + profilePath );
+ if (in == null)
+ throw new IOException("No such profile: " + profilePath);
Properties p = new Properties();
- p.load( in );
+ p.load(in);
return p;
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java Mon Aug 2 17:08:03 2010
@@ -18,65 +18,66 @@ import org.osgi.framework.Version;
public class ManifestUtil
{
- public static IBundleModelElement buildBundleModelElement( Manifest mf )
+ public static IBundleModelElement buildBundleModelElement(Manifest mf)
{
IBundleModelElement info = null;
- if ( mf != null )
+ if (mf != null)
{
Attributes attrs = mf.getMainAttributes();
- String name = attrs.getValue( "Bundle-SymbolicName" );
- if ( name == null )
+ String name = attrs.getValue("Bundle-SymbolicName");
+ if (name == null)
{
// framework.jar doesn't have Bundle-SymbolicName!
- name = attrs.getValue( "Bundle-Name" );
+ name = attrs.getValue("Bundle-Name");
}
- if ( name != null )
+ if (name != null)
{
try
{
- info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
- info.setSymbolicName( name.split( ";" )[0] );
- info.setVersion( VersionTable.getVersion( attrs.getValue( "Bundle-Version" ) ) );
- info.setName( attrs.getValue( "Bundle-Name" ) );
- info.setDescription( attrs.getValue( "Bundle-Description" ) );
- info.setVendor( attrs.getValue( "Bundle-Vendor" ) );
+ info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
+ info.setSymbolicName(name.split(";")[0]);
+ info.setVersion(VersionTable.getVersion(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 )
+ String str = attrs.getValue("Import-Package");
+ if (str != null)
{
- addImports( info, str );
+ addImports(info, str);
}
- str = attrs.getValue( "Export-Package" );
- if ( str != null )
+ str = attrs.getValue("Export-Package");
+ if (str != null)
{
- addExports( info, str );
+ addExports(info, str);
}
- str = attrs.getValue( "Require-Bundle" );
- if ( str != null )
+ str = attrs.getValue("Require-Bundle");
+ if (str != null)
{
- addRequires( info, str );
+ addRequires(info, str);
}
- str = attrs.getValue( "Bundle-Classpath" );
+ str = attrs.getValue("Bundle-Classpath");
- if ( str != null )
+ if (str != null)
{
- addClasspath( info, str );
+ addClasspath(info, str);
}
- str = attrs.getValue( "Fragment-Host" );
- if ( str != null )
+ str = attrs.getValue("Fragment-Host");
+ if (str != null)
{
- addHost( info, str );
+ addHost(info, str);
}
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to read info from bundle " + name, e );
+ BldCore.error("Failed to read info from bundle " + name, e);
// clear elements as clearly got garbage
info = null;
}
@@ -85,151 +86,152 @@ public class ManifestUtil
return info;
}
- private static void addClasspath( IBundleModelElement info, String cpStr )
+
+ private static void addClasspath(IBundleModelElement info, String cpStr)
{
- for ( String cp : cpStr.split( "\\s*,\\s*" ) )
+ for (String cp : cpStr.split("\\s*,\\s*"))
{
- info.addClasspath( cp );
+ info.addClasspath(cp);
}
}
-
- private static void addExports( IBundleModelElement info, String exportStr ) throws ModelElementFactoryException
+ private static void addExports(IBundleModelElement info, String exportStr)
+ throws ModelElementFactoryException
{
- for ( String exp : QuoteUtil.split( exportStr ) )
+ for (String exp : QuoteUtil.split(exportStr))
{
try
{
- String[] parts = exp.split( ";" );
- IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pe.setPackageName( parts[0].trim() );
+ String[] parts = exp.split(";");
+ IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pe.setPackageName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- for ( int i = 1; i < parts.length; i++ )
+ for (int i = 1; i < parts.length; i++)
{
String check = parts[i];
- if ( check.toLowerCase().startsWith( "version=" ) )
+ if (check.toLowerCase().startsWith("version="))
{
- pe.setVersion( parseVersion( check.substring( "version=".length() ) ) );
+ pe.setVersion(parseVersion(check.substring("version=".length())));
}
- else if ( check.toLowerCase().startsWith( "specification-version=" ) )
+ else if (check.toLowerCase().startsWith("specification-version="))
{
- pe.setVersion( parseVersion( check.substring( "specification-version=".length() ) ) );
+ pe.setVersion(parseVersion(check.substring("specification-version=".length())));
}
- else if ( check.toLowerCase().startsWith( "uses:=" ) )
+ else if (check.toLowerCase().startsWith("uses:="))
{
- for ( String use : parseUses( check.substring( "uses:=".length() ) ) )
+ for (String use : parseUses(check.substring("uses:=".length())))
{
- pe.addUse( use );
+ pe.addUse(use);
}
}
}
}
- info.addExport( pe );
+ info.addExport(pe);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
e.printStackTrace();
}
}
}
-
- private static Collection<String> parseUses( String uses )
+ private static Collection<String> parseUses(String uses)
{
- if ( uses.startsWith( "\"" ) )
+ if (uses.startsWith("\""))
{
- uses = uses.substring( 1, uses.length() - 2 );
+ uses = uses.substring(1, uses.length() - 2);
}
- return Arrays.asList( uses.split( "," ) );
+ return Arrays.asList(uses.split(","));
}
-
- private static Version parseVersion( String val )
+ private static Version parseVersion(String val)
{
- val = val.replaceAll( "\"", "" );
- return VersionTable.getVersion( val );
+ val = val.replaceAll("\"", "");
+ return VersionTable.getVersion(val);
}
-
- private static void addImports( IBundleModelElement info, String importStr ) throws ModelElementFactoryException
+ private static void addImports(IBundleModelElement info, String importStr)
+ throws ModelElementFactoryException
{
- for ( String imp : QuoteUtil.split( importStr ) )
+ for (String imp : QuoteUtil.split(importStr))
{
- String[] parts = imp.split( ";" );
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- pi.setPackageName( parts[0].trim() );
+ String[] parts = imp.split(";");
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ pi.setPackageName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- for ( int i = 1; i < parts.length; i++ )
+ for (int i = 1; i < parts.length; i++)
{
String p = parts[i];
- if ( p.toLowerCase().startsWith( "version=" ) )
+ if (p.toLowerCase().startsWith("version="))
{
- pi.setVersions( VersionRange.parseVersionRange( p.substring( "version=".length() ) ) );
+ pi.setVersions(VersionRange.parseVersionRange(p.substring("version=".length())));
}
- else if ( p.toLowerCase().startsWith( "specification-version=" ) )
+ else if (p.toLowerCase().startsWith("specification-version="))
{
- pi.setVersions( VersionRange
- .parseVersionRange( p.substring( "specification-version=".length() ) ) );
+ pi.setVersions(VersionRange.parseVersionRange(p.substring("specification-version=".length())));
}
- else if ( p.toLowerCase().startsWith( "resolution:=" ) )
+ else if (p.toLowerCase().startsWith("resolution:="))
{
- pi.setOptional( p.toLowerCase().substring( "resolution:=".length() ).equals( "optional" ) );
+ pi.setOptional(p.toLowerCase().substring("resolution:=".length()).equals(
+ "optional"));
}
}
}
- info.addImport( pi );
+ info.addImport(pi);
}
}
-
- private static void addRequires( IBundleModelElement info, String reqStr ) throws ModelElementFactoryException
+ private static void addRequires(IBundleModelElement info, String reqStr)
+ throws ModelElementFactoryException
{
- for ( String imp : QuoteUtil.split( reqStr ) )
+ for (String imp : QuoteUtil.split(reqStr))
{
- String[] parts = imp.split( ";" );
- IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- req.setSymbolicName( parts[0] );
+ String[] parts = imp.split(";");
+ IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ req.setSymbolicName(parts[0]);
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- if ( parts[1].toLowerCase().startsWith( "version=" ) )
+ if (parts[1].toLowerCase().startsWith("version="))
{
- req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "version=".length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(parts[1].substring("version=".length())));
}
- else if ( parts[1].toLowerCase().startsWith( "specification-version=" ) )
+ else if (parts[1].toLowerCase().startsWith("specification-version="))
{
- req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "specification-version="
- .length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(parts[1].substring("specification-version=".length())));
}
}
- info.addRequiredBundle( req );
+ info.addRequiredBundle(req);
}
}
-
/**
* @param info
* @param str
*/
- private static void addHost( IBundleModelElement info, String str )
+ private static void addHost(IBundleModelElement info, String str)
{
- String[] parts = str.split( ";" );
- IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- req.setSymbolicName( parts[0].trim() );
+ String[] parts = str.split(";");
+ IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ req.setSymbolicName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
String part = parts[1].toLowerCase().trim();
- if ( part.startsWith( "bundle-version=" ) )
+ if (part.startsWith("bundle-version="))
{
- req.setVersions( VersionRange.parseVersionRange( part.substring( "bundle-version=".length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(part.substring("bundle-version=".length())));
}
}
- info.setFragmentHost( req );
+ info.setFragmentHost(req);
}
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java Mon Aug 2 17:08:03 2010
@@ -19,43 +19,41 @@
package org.apache.felix.sigil.common.core.util;
-
import java.util.ArrayList;
-
public class QuoteUtil
{
- public static String[] split( String str )
+ public static String[] split(String str)
{
ArrayList<String> split = new ArrayList<String>();
boolean quote = false;
- StringBuffer buf = new StringBuffer( str.length() );
+ StringBuffer buf = new StringBuffer(str.length());
- for ( int i = 0; i < str.length(); i++ )
+ for (int i = 0; i < str.length(); i++)
{
- char c = str.charAt( i );
- switch ( c )
+ char c = str.charAt(i);
+ switch (c)
{
case '"':
quote = !quote;
break;
case ',':
- if ( !quote )
+ if (!quote)
{
- split.add( buf.toString().trim() );
- buf.setLength( 0 );
+ split.add(buf.toString().trim());
+ buf.setLength(0);
break;
}
// else fall through on purpose
default:
- buf.append( c );
+ buf.append(c);
}
}
- if ( buf.length() > 0 )
+ if (buf.length() > 0)
{
- split.add( buf.toString().trim() );
+ split.add(buf.toString().trim());
}
- return split.toArray( new String[split.size()] );
+ return split.toArray(new String[split.size()]);
}
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,37 +19,31 @@
package org.apache.felix.sigil.common.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
{
private static final long serialVersionUID = 1L;
-
- public AbstractCompoundModelElement( String description )
+ public AbstractCompoundModelElement(String description)
{
- super( description );
+ super(description);
}
-
- public boolean addChild( IModelElement child ) throws InvalidModelException
+ public boolean addChild(IModelElement child) throws InvalidModelException
{
- return support.addChild( child );
+ return support.addChild(child);
}
-
- public boolean removeChild( IModelElement child )
+ public boolean removeChild(IModelElement child)
{
- return support.removeChild( child );
+ return support.removeChild(child);
}
-
public IModelElement[] children()
{
return support.children();
@@ -57,85 +51,80 @@ public abstract class AbstractCompoundMo
private static final ThreadLocal<Map<IModelWalker, Set<IModelElement>>> walkedLocal = new ThreadLocal<Map<IModelWalker, Set<IModelElement>>>();
-
- public void visit( IModelWalker walker )
+ public void visit(IModelWalker walker)
{
- if ( walker.visit( this ) )
+ if (walker.visit(this))
{
Map<IModelWalker, Set<IModelElement>> walked = walkedLocal.get();
boolean delete = false;
- if ( walked == null )
+ if (walked == null)
{
walked = new HashMap<IModelWalker, Set<IModelElement>>();
- walkedLocal.set( walked );
+ walkedLocal.set(walked);
}
- Set<IModelElement> check = walked.get( walker );
+ Set<IModelElement> check = walked.get(walker);
- if ( check == null )
+ if (check == null)
{
delete = true;
check = new HashSet<IModelElement>();
}
- check.add( this );
+ check.add(this);
try
{
- for ( IModelElement e : children() )
+ for (IModelElement e : children())
{
- if ( !check.contains( e ) && walker.visit( e ) )
+ if (!check.contains(e) && walker.visit(e))
{
- check.add( e );
- if ( e instanceof ICompoundModelElement )
+ check.add(e);
+ if (e instanceof ICompoundModelElement)
{
- ICompoundModelElement c = ( ICompoundModelElement ) e;
- c.visit( walker );
+ ICompoundModelElement c = (ICompoundModelElement) e;
+ c.visit(walker);
}
}
}
}
finally
{
- if ( delete )
+ if (delete)
{
- walked.remove( walker );
+ walked.remove(walker);
- if ( walked.isEmpty() )
+ if (walked.isEmpty())
{
- walkedLocal.set( null );
+ walkedLocal.set(null);
}
}
}
}
}
-
public Set<Class<? extends IModelElement>> getOptionalChildren()
{
- return support.getChildrenTypes( false );
+ return support.getChildrenTypes(false);
}
-
public Set<Class<? extends IModelElement>> getRequiredChildren()
{
- return support.getChildrenTypes( true );
+ return support.getChildrenTypes(true);
}
-
- public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+ public <T extends IModelElement> T[] childrenOfType(Class<T> type)
{
- return support.childrenOfType( type );
+ return support.childrenOfType(type);
}
-
@Override
public void checkValid() throws InvalidModelException
{
super.checkValid();
- for ( IModelElement e : support.children() )
+ for (IModelElement e : support.children())
{
e.checkValid();
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.common.model;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
public abstract class AbstractModelElement implements IModelElement
{
@@ -41,65 +39,60 @@ public abstract class AbstractModelEleme
protected ModelElementSupport support;
-
- public AbstractModelElement( String description )
+ public AbstractModelElement(String description)
{
- support = new ModelElementSupport( this );
+ support = new ModelElementSupport(this);
this.description = description.intern();
}
-
public String getElementDescription()
{
return description;
}
-
public Map<Object, Object> getMeta()
{
return meta == null ? Collections.emptyMap() : Collections.unmodifiableMap(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();
+ AbstractModelElement clone = (AbstractModelElement) super.clone();
- if ( meta != null ) {
- clone.meta = new HashMap<Object, Object>( meta );
+ if (meta != null)
+ {
+ clone.meta = new HashMap<Object, Object>(meta);
}
-
+
clone.support = new ModelElementSupport(clone);
return clone;
}
- catch ( CloneNotSupportedException e )
+ catch (CloneNotSupportedException e)
{
// can't happen but make compiler happy
- throw new IllegalStateException( e );
+ throw new IllegalStateException(e);
}
}
-
@SuppressWarnings("unchecked")
- public <T extends IModelElement> T getAncestor( Class<T> type )
+ public <T extends IModelElement> T getAncestor(Class<T> type)
{
IModelElement parent = this.parent;
- while ( parent != null )
+ while (parent != null)
{
- if ( type.isInstance( parent ) )
+ if (type.isInstance(parent))
{
- return ( T ) parent;
+ return (T) parent;
}
parent = parent.getParent();
}
@@ -107,107 +100,101 @@ public abstract class AbstractModelEleme
return null;
}
-
public IModelElement getParent()
{
return parent;
}
-
- public void setParent( IModelElement parent )
+ public void setParent(IModelElement parent)
{
- if ( parent != null )
+ if (parent != null)
{
- if ( this.parent != null && this.parent != parent )
+ if (this.parent != null && this.parent != parent)
{
- throw new IllegalStateException( "Parent already installed" );
+ throw new IllegalStateException("Parent already installed");
}
}
this.parent = parent;
}
-
public void checkValid() throws InvalidModelException
{
- for ( String req : getRequiredProperties() )
+ for (String req : getRequiredProperties())
{
try
{
- if ( getProperty( req ) == null )
+ if (getProperty(req) == null)
{
- throw new InvalidModelException( this, "Missing property " + req );
+ throw new InvalidModelException(this, "Missing property " + req);
}
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
- throw new InvalidModelException( this, "No such property " + req );
+ throw new InvalidModelException(this, "No such property " + req);
}
}
}
-
- public Object getProperty( String name ) throws NoSuchMethodException
+ public Object getProperty(String name) throws NoSuchMethodException
{
- return support.getProperty( name );
+ return support.getProperty(name);
}
-
- public void setProperty( String name, Object value ) throws NoSuchMethodException
+ public void setProperty(String name, Object value) throws NoSuchMethodException
{
- support.setProperty( name, value );
+ support.setProperty(name, value);
}
-
- public void addProperty( String name, Object value ) throws NoSuchMethodException
+ public void addProperty(String name, Object value) throws NoSuchMethodException
{
- support.addProperty( name, value );
+ support.addProperty(name, value);
}
-
- public void removeProperty( String name, Object value ) throws NoSuchMethodException
+ public void removeProperty(String name, Object value) throws NoSuchMethodException
{
- support.removeProperty( name, value );
+ support.removeProperty(name, value);
}
-
- public Object getDefaultPropertyValue( String name )
+ public Object getDefaultPropertyValue(String name)
{
- return support.getDefaultPropertyValue( name );
+ return support.getDefaultPropertyValue(name);
}
-
public Set<String> getPropertyNames()
{
return support.getPropertyNames();
}
-
public Set<String> getRequiredProperties()
{
return Collections.emptySet();
}
- public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+ public Class<?> getPropertyType(String name) throws NoSuchMethodException
{
- return support.getPropertyType( name );
+ return support.getPropertyType(name);
}
protected Object writeReplace()
{
AbstractModelElement clone = clone();
- if ( clone.meta != null ) {
- clone.serializedMeta = new HashMap<Serializable, Serializable>(clone.meta.size());
-
- for ( Map.Entry<Object, Object> e : clone.meta.entrySet() )
+ if (clone.meta != null)
+ {
+ clone.serializedMeta = new HashMap<Serializable, Serializable>(
+ clone.meta.size());
+
+ for (Map.Entry<Object, Object> e : clone.meta.entrySet())
{
- if ( e.getKey() instanceof Serializable && e.getValue() instanceof Serializable )
+ if (e.getKey() instanceof Serializable
+ && e.getValue() instanceof Serializable)
{
- clone.serializedMeta.put( ( Serializable ) e.getKey(), ( Serializable ) e.getValue() );
+ clone.serializedMeta.put((Serializable) e.getKey(),
+ (Serializable) e.getValue());
}
}
-
+
clone.meta = null;
}
@@ -216,19 +203,18 @@ public abstract class AbstractModelEleme
protected Object readResolve()
{
- meta = serializedMeta == null ? null : new HashMap<Object, Object>( serializedMeta );
+ meta = serializedMeta == null ? null
+ : new HashMap<Object, Object>(serializedMeta);
serializedMeta = null;
return this;
}
-
public OverrideOptions getOverride()
{
return override;
}
-
- public void setOverride( OverrideOptions override )
+ public void setOverride(OverrideOptions override)
{
this.override = override;
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java Mon Aug 2 17:08:03 2010
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
package org.apache.felix.sigil.common.model;
public interface ICapabilityModelElement extends IModelElement
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.model;
-
import java.util.Set;
-
/**
* Represents a model element that is made up of sub model elements.
*
@@ -38,16 +36,14 @@ public interface ICompoundModelElement e
* @return
* @throws InvalidModelException
*/
- boolean addChild( IModelElement children ) throws InvalidModelException;
-
+ boolean addChild(IModelElement children) throws InvalidModelException;
/**
* Calls the applicable set/remove method of this model to remove the element from this part of the model
* @param children
* @return
*/
- boolean removeChild( IModelElement children );
-
+ boolean removeChild(IModelElement children);
/**
* List all direct child elements of this model element.
@@ -55,14 +51,12 @@ public interface ICompoundModelElement e
*/
IModelElement[] children();
-
/**
* Visits child elements of this model element, recursing down to sub compound elements when found.
*
* @param walker
*/
- void visit( IModelWalker walker );
-
+ void visit(IModelWalker walker);
/**
* Searches the model to find all child model elements which match the specified type
@@ -71,11 +65,9 @@ public interface ICompoundModelElement e
* @param type
* @return
*/
- <T extends IModelElement> T[] childrenOfType( Class<T> type );
-
+ <T extends IModelElement> T[] childrenOfType(Class<T> type);
Set<Class<? extends IModelElement>> getRequiredChildren();
-
Set<Class<? extends IModelElement>> getOptionalChildren();
}
\ No newline at end of file
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.Map;
import java.util.Set;
-
/**
* IModelElement represent static information about a part of a model.
*
@@ -39,7 +37,6 @@ public interface IModelElement extends C
*/
String getElementDescription();
-
/**
* A set of key value pairs designed for use by a machine to classify a particular element.
*
@@ -47,15 +44,13 @@ public interface IModelElement extends C
*/
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 element.
*
* @param meta
*/
- void setMeta( Map<Object, Object> meta );
-
+ void setMeta(Map<Object, Object> meta);
/**
* Check to see if this element defines a complete set of properties. The definition of what constitutes a
@@ -65,16 +60,13 @@ public interface IModelElement extends C
*/
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 );
-
+ void setParent(IModelElement parent);
/**
* Finds the first ancestor up the hierarch of parents which is an instance of the specified
@@ -83,33 +75,24 @@ public interface IModelElement extends C
* @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 setProperty( String name, Object value ) throws NoSuchMethodException;
-
-
- void addProperty( String name, Object value ) throws NoSuchMethodException;
-
+ void addProperty(String name, Object value) throws NoSuchMethodException;
- void removeProperty( String name, Object value ) throws NoSuchMethodException;
+ void removeProperty(String name, Object value) throws NoSuchMethodException;
+ Object getProperty(String name) throws NoSuchMethodException;
- Object getProperty( String name ) throws NoSuchMethodException;
-
-
- Object getDefaultPropertyValue( String name );
-
+ 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/common/model/IModelInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java Mon Aug 2 17:08:03 2010
@@ -19,14 +19,11 @@
package org.apache.felix.sigil.common.model;
-
public interface IModelInfo
{
String getGroupName();
-
String getGroupURI();
-
String getName();
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
/**
* Visitor pattern to traverse nodes in the model.
*
@@ -37,5 +36,5 @@ public interface IModelWalker
*
* @return true to continue walking the model, false otherwise
*/
- boolean visit( IModelElement element );
+ boolean visit(IModelElement element);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,17 +19,13 @@
package org.apache.felix.sigil.common.model;
-
public interface INamedModelElement extends IModelElement
{
- void setName( String name );
-
+ 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/common/model/IRequirementModelElement.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java Mon Aug 2 17:08:03 2010
@@ -19,16 +19,14 @@
package org.apache.felix.sigil.common.model;
-
public interface IRequirementModelElement extends IModelElement
{
- boolean accepts( ICapabilityModelElement provider );
-
+ boolean accepts(ICapabilityModelElement provider);
+
/**
* indicates whether the OSGi attribute "resolution=optional" is specified.
*/
boolean isOptional();
-
- void setOptional( boolean optional );
+ void setOptional(boolean optional);
}
Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java (original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
/**
* @author dave
*
@@ -31,21 +30,18 @@ public class InvalidModelException exten
private IModelElement target;
-
- public InvalidModelException( IModelElement target, String msg )
+ public InvalidModelException(IModelElement target, String msg)
{
- super( msg );
+ super(msg);
this.target = target;
}
-
- public InvalidModelException( IModelElement target, String msg, Throwable t )
+ public InvalidModelException(IModelElement target, String msg, Throwable t)
{
- super( msg, t );
+ super(msg, t);
this.target = target;
}
-
public IModelElement getTarget()
{
return target;