org.jboss.classloading.spi.vfs.policy
Class VFSClassLoaderPolicy

java.lang.Object
  extended by org.jboss.classloader.spi.base.BaseClassLoaderPolicy
      extended by org.jboss.classloader.spi.ClassLoaderPolicy
          extended by org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy

public class VFSClassLoaderPolicy
extends ClassLoaderPolicy

VFSClassLoaderPolicy.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Ales Justin, Anil Saldhana

Constructor Summary
VFSClassLoaderPolicy(String name, org.jboss.virtual.VirtualFile[] roots)
          Create a new VFSClassLoaderPolicy.
VFSClassLoaderPolicy(String name, org.jboss.virtual.VirtualFile[] roots, org.jboss.virtual.VirtualFile[] excludedRoots)
          Create a new VFSClassLoaderPolicy.
VFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots)
          Create a new VFSClassLoaderPolicy.
VFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots, org.jboss.virtual.VirtualFile[] excludedRoots)
          Create a new VFSClassLoaderPolicy.
 
Method Summary
protected  boolean checkFilters(String path, String context)
          Check the filters
static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name, org.jboss.virtual.VirtualFile... roots)
          Create a new VFSClassLoaderPolicy.
static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name, org.jboss.virtual.VirtualFile[] roots, org.jboss.virtual.VirtualFile[] excludedRoots)
          Create a new VFSClassLoaderPolicy.
static VFSClassLoaderPolicy createVFSClassLoaderPolicy(org.jboss.virtual.VirtualFile... roots)
          Create a new VFSClassLoaderPolicy.
static VFSClassLoaderPolicy createVFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots, org.jboss.virtual.VirtualFile[] excludedRoots)
          Create a new VFSClassLoaderPolicy.
protected  org.jboss.virtual.VirtualFile findChild(String path)
          Find a child from a path
protected  org.jboss.virtual.VirtualFile findRoot(String path)
          Find a root from a path
protected  org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.VirtualFileInfo findVirtualFileInfo(String path)
          Find the virtual file information for a path
 PackageInformation getClassPackageInformation(String className, String packageName)
          Get the package information for a class
 List<? extends DelegateLoader> getDelegates()
          Get the delegate loaders for imported stuff
 ClassFilter getExcluded()
          Get the excluded.
 ClassFilter getExcludedExport()
          Get the excludedExport.
 ExportAll getExportAll()
          Get the exportAll.
 DelegateLoader getExported()
          Get the delegate loader for exported stuff
 String[] getExportedPackages()
          Get the exported packages
 ClassFilter getIncluded()
          Get the included.
 String getName()
          Get a simple name for the classloader
 String[] getPackageNames()
          Get the exported packages
protected  ProtectionDomain getProtectionDomain(String className, String path)
          Get the protection domain
 URL getResource(String path)
          Get the resource
 InputStream getResourceAsStream(String path)
          Get the resource as a stream
 void getResources(String name, Set<URL> urls)
          Get resources
 boolean isBlackListable()
          Whether to cache misses
 boolean isCacheable()
          Whether to cache
 boolean isImportAll()
          Whether to import all exports from other classloaders in the domain
 boolean isUseRealURL()
          Do we use real url.
 void setBlackListable(boolean blackListable)
          Set the blackListable.
 void setCacheable(boolean cacheable)
          Set the cacheable.
 void setDelegates(List<? extends DelegateLoader> delegates)
          Set the delegates.
 void setExcluded(ClassFilter excluded)
          Set the excluded.
 void setExcludedExport(ClassFilter excludedExport)
          Set the excludedExport.
 void setExportAll(ExportAll exportAll)
          Set the exportAll.
 void setExportedPackages(String[] exportedPackages)
          Set the exportedPackages.
 void setImportAll(boolean importAll)
          Set the importAll.
 void setIncluded(ClassFilter included)
          Set the included.
 void setUseRealURL(boolean useRealURL)
          Set use real url flag.
protected  void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
 
Methods inherited from class org.jboss.classloader.spi.ClassLoaderPolicy
getObjectName, getPackageInformation, isJDKRequest
 
Methods inherited from class org.jboss.classloader.spi.base.BaseClassLoaderPolicy
addTranslator, clearBlackList, getAccessControlContext, getDomainName, getTranslators, removeTranslator, setTranslators, shutdownPolicy, toLongString, toString, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VFSClassLoaderPolicy

public VFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots)
Create a new VFSClassLoaderPolicy.

Parameters:
roots - the roots
Throws:
IllegalArgumentException - for null roots

VFSClassLoaderPolicy

public VFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots,
                            org.jboss.virtual.VirtualFile[] excludedRoots)
Create a new VFSClassLoaderPolicy.

Parameters:
roots - the roots
excludedRoots - the excluded roots
Throws:
IllegalArgumentException - for null roots

VFSClassLoaderPolicy

public VFSClassLoaderPolicy(String name,
                            org.jboss.virtual.VirtualFile[] roots)
Create a new VFSClassLoaderPolicy.

Parameters:
name - the name
roots - the roots
Throws:
IllegalArgumentException - for null roots

VFSClassLoaderPolicy

public VFSClassLoaderPolicy(String name,
                            org.jboss.virtual.VirtualFile[] roots,
                            org.jboss.virtual.VirtualFile[] excludedRoots)
Create a new VFSClassLoaderPolicy.

Parameters:
name - the name
roots - the roots
excludedRoots - the excluded roots
Throws:
IllegalArgumentException - for null roots
Method Detail

createVFSClassLoaderPolicy

public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(org.jboss.virtual.VirtualFile... roots)
Create a new VFSClassLoaderPolicy.

Parameters:
roots - the roots
Returns:
the classloader policy
Throws:
IllegalArgumentException - for null roots

createVFSClassLoaderPolicy

public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name,
                                                              org.jboss.virtual.VirtualFile... roots)
Create a new VFSClassLoaderPolicy.

Parameters:
name - a name of the policy
roots - the roots
Returns:
the classloader policy
Throws:
IllegalArgumentException - for null roots

createVFSClassLoaderPolicy

public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(org.jboss.virtual.VirtualFile[] roots,
                                                              org.jboss.virtual.VirtualFile[] excludedRoots)
Create a new VFSClassLoaderPolicy.

Parameters:
roots - the roots
excludedRoots - the excluded roots
Returns:
the classloader policy
Throws:
IllegalArgumentException - for null roots

createVFSClassLoaderPolicy

public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name,
                                                              org.jboss.virtual.VirtualFile[] roots,
                                                              org.jboss.virtual.VirtualFile[] excludedRoots)
Create a new VFSClassLoaderPolicy.

Parameters:
name - a name of the policy
roots - the roots
excludedRoots - the excluded roots
Returns:
the classloader policy
Throws:
IllegalArgumentException - for null roots

getName

public String getName()
Description copied from class: BaseClassLoaderPolicy
Get a simple name for the classloader

Overrides:
getName in class BaseClassLoaderPolicy
Returns:
the name

getDelegates

public List<? extends DelegateLoader> getDelegates()
Description copied from class: ClassLoaderPolicy
Get the delegate loaders for imported stuff

There are no imports by default

NOTE: Protected access for security reasons

Overrides:
getDelegates in class ClassLoaderPolicy
Returns:
the delegate loaders

setDelegates

public void setDelegates(List<? extends DelegateLoader> delegates)
Set the delegates.

Parameters:
delegates - the delegates.

getIncluded

public ClassFilter getIncluded()
Get the included.

Returns:
the included.

setIncluded

public void setIncluded(ClassFilter included)
Set the included.

Parameters:
included - the included.

getExcluded

public ClassFilter getExcluded()
Get the excluded.

Returns:
the excluded.

setExcluded

public void setExcluded(ClassFilter excluded)
Set the excluded.

Parameters:
excluded - the excluded.

getExcludedExport

public ClassFilter getExcludedExport()
Get the excludedExport.

Returns:
the excludedExport.

setExcludedExport

public void setExcludedExport(ClassFilter excludedExport)
Set the excludedExport.

Parameters:
excludedExport - the excludedExport.

getExportAll

public ExportAll getExportAll()
Get the exportAll.

Returns:
the exportAll.

setExportAll

public void setExportAll(ExportAll exportAll)
Set the exportAll.

Parameters:
exportAll - the exportAll.

getExportedPackages

public String[] getExportedPackages()
Get the exported packages

Returns:
the exported packages

setExportedPackages

public void setExportedPackages(String[] exportedPackages)
Set the exportedPackages.

Parameters:
exportedPackages - the exportedPackages.

getPackageNames

public String[] getPackageNames()
Description copied from class: ClassLoaderPolicy
Get the exported packages

Provides a hint for indexing

No packages are exported by default

The returned package names can be null to indicate nothing is exported, but if an array is returned it should not include a null package element.

Overrides:
getPackageNames in class ClassLoaderPolicy
Returns:
the package names

isImportAll

public boolean isImportAll()
Description copied from class: ClassLoaderPolicy
Whether to import all exports from other classloaders in the domain

False by default

Overrides:
isImportAll in class ClassLoaderPolicy
Returns:
true to import all

setImportAll

public void setImportAll(boolean importAll)
Set the importAll.

Parameters:
importAll - the importAll.

isCacheable

public boolean isCacheable()
Description copied from class: ClassLoaderPolicy
Whether to cache

True by default

Overrides:
isCacheable in class ClassLoaderPolicy
Returns:
true to cache

setCacheable

public void setCacheable(boolean cacheable)
Set the cacheable.

Parameters:
cacheable - the cacheable.

isBlackListable

public boolean isBlackListable()
Description copied from class: ClassLoaderPolicy
Whether to cache misses

True by default

Overrides:
isBlackListable in class ClassLoaderPolicy
Returns:
true to cache misses

setBlackListable

public void setBlackListable(boolean blackListable)
Set the blackListable.

Parameters:
blackListable - the blackListable.

getExported

public DelegateLoader getExported()
Description copied from class: ClassLoaderPolicy
Get the delegate loader for exported stuff

By default this uses ClassLoaderPolicy.getPackageNames() to create a FilteredDelegateLoader

Overrides:
getExported in class ClassLoaderPolicy
Returns:
the delegate loader

getResource

public URL getResource(String path)
Description copied from class: ClassLoaderPolicy
Get the resource

Specified by:
getResource in class ClassLoaderPolicy
Parameters:
path - the path
Returns:
the url or null if not found

getResourceAsStream

public InputStream getResourceAsStream(String path)
Description copied from class: ClassLoaderPolicy
Get the resource as a stream

Uses ClassLoaderPolicy.getResource(String) by default

Overrides:
getResourceAsStream in class ClassLoaderPolicy
Parameters:
path - the path
Returns:
the stream or null if not found

isUseRealURL

public boolean isUseRealURL()
Do we use real url.

Returns:
true if real url should be used

setUseRealURL

public void setUseRealURL(boolean useRealURL)
Set use real url flag.

Parameters:
useRealURL - the real url flag

getResources

public void getResources(String name,
                         Set<URL> urls)
                  throws IOException
Description copied from class: ClassLoaderPolicy
Get resources

Specified by:
getResources in class ClassLoaderPolicy
Parameters:
name - the resource name
urls - the list of urls to add to
Throws:
IOException - for any error

findChild

protected org.jboss.virtual.VirtualFile findChild(String path)
Find a child from a path

Parameters:
path - the path
Returns:
the child if found in the roots

findRoot

protected org.jboss.virtual.VirtualFile findRoot(String path)
Find a root from a path

Parameters:
path - the path
Returns:
the root if found in the roots

findVirtualFileInfo

protected org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy.VirtualFileInfo findVirtualFileInfo(String path)
Find the virtual file information for a path

Parameters:
path - the path
Returns:
the virtual file information

getClassPackageInformation

public PackageInformation getClassPackageInformation(String className,
                                                     String packageName)
Description copied from class: ClassLoaderPolicy
Get the package information for a class

The default is to invoke getPackageInformation for the class's package

Overrides:
getClassPackageInformation in class ClassLoaderPolicy
Parameters:
className - name the class name
packageName - the package information
Returns:
the information or null if there is none

toLongString

protected void toLongString(StringBuilder builder)
Description copied from class: BaseClassLoaderPolicy
For subclasses to add information for toLongString()

Overrides:
toLongString in class ClassLoaderPolicy
Parameters:
builder - the builder

getProtectionDomain

protected ProtectionDomain getProtectionDomain(String className,
                                               String path)
Description copied from class: ClassLoaderPolicy
Get the protection domain

By default there is no protection domain

NOTE: Protected access for security reasons

Overrides:
getProtectionDomain in class ClassLoaderPolicy
Parameters:
className - the class name
path - the path
Returns:
the protection domain

checkFilters

protected boolean checkFilters(String path,
                               String context)
Check the filters

Parameters:
path - the path to check
context - the context
Returns:
true if it fails the filters


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.