org.ow2.util.archive.impl
Class MemoryArchive

java.lang.Object
  extended by org.ow2.util.archive.impl.AbsArchiveImpl
      extended by org.ow2.util.archive.impl.MemoryArchive
All Implemented Interfaces:
IArchive

public class MemoryArchive
extends AbsArchiveImpl
implements IArchive

Emulate an archive in memory.

Author:
Gael Lalire

Constructor Summary
MemoryArchive()
          Construct an archive in memory.
MemoryArchive(ClassLoader classLoader, List<String> classNames)
          Construct an archive in memory.
 
Method Summary
 void addClassResource(ClassLoader classLoader, List<String> classNames)
           
 void addResource(String resourceName, URL url)
           
 boolean close()
          Close the archive.
 Iterator<String> getEntries()
           
 String getName()
           
 URL getResource(String resourceName)
           
 Iterator<URL> getResources()
           
 Iterator<URL> getResources(String resourceName)
           
 URL getURL()
          The memory archive has no url.
 
Methods inherited from class org.ow2.util.archive.impl.AbsArchiveImpl
getMetadata, readManifest, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ow2.util.archive.api.IArchive
getMetadata
 

Constructor Detail

MemoryArchive

public MemoryArchive()
Construct an archive in memory.


MemoryArchive

public MemoryArchive(ClassLoader classLoader,
                     List<String> classNames)
Construct an archive in memory.

Parameters:
classLoader - this classloader is use to load class by their name
classNames - the name of classes in archive
Method Detail

close

public boolean close()
Close the archive.

Specified by:
close in interface IArchive
Returns:
true

getName

public String getName()
Specified by:
getName in interface IArchive
Returns:
ArchiveInMemory

getResource

public URL getResource(String resourceName)
Specified by:
getResource in interface IArchive
Parameters:
resourceName - the resource name
Returns:
the url of a class.

getResources

public Iterator<URL> getResources()
Specified by:
getResources in interface IArchive
Returns:
all classes url

getResources

public Iterator<URL> getResources(String resourceName)
Specified by:
getResources in interface IArchive
Parameters:
resourceName - the resource name
Returns:
a singleton iterator with url of the class

getURL

public URL getURL()
The memory archive has no url.

Specified by:
getURL in interface IArchive
Returns:
null

addResource

public void addResource(String resourceName,
                        URL url)
Parameters:
resourceName - the resource name
url - the url

addClassResource

public void addClassResource(ClassLoader classLoader,
                             List<String> classNames)
Parameters:
classLoader - this classloader is use to load class by their name
classNames - the name of classes in archive

getEntries

public Iterator<String> getEntries()
Specified by:
getEntries in interface IArchive
Returns:
all resources name


Copyright © 2007-2012 OW2 Consortium. All Rights Reserved.