com.ibm.oti.shared

Class SharedClassURLClasspathHelperImpl

  1. java.lang.Object
  2. extended bycom.ibm.oti.shared.SharedAbstractHelper
  3. extended bycom.ibm.oti.shared.SharedClassAbstractHelper
  4. extended bycom.ibm.oti.shared.SharedClassURLClasspathHelperImpl
All implemented interfaces:
SharedClassHelper, SharedClassURLClasspathHelper, SharedHelper

  1. public class SharedClassURLClasspathHelperImpl
  2. extends SharedClassAbstractHelper
  3. implements SharedClassURLClasspathHelper

Implementation of SharedClassURLClasspathHelper.

Version:
initial
Author:
OTI
See Also:
SharedClassURLClasspathHelper, SharedClassHelperFactory, SharedClassAbstractHelper

Nested Class Summary

Nested classes/interfaces inherited from interface com.ibm.oti.shared.SharedClassURLClasspathHelper
SharedClassURLClasspathHelper.IndexHolder

Method Summary

Modifier and Type Method and Description
  1. void
addClasspathEntry(java.net.URL cpe)
  1. void
confirmAllEntries()
  1. byte[]
findSharedClass(java.lang.String className,SharedClassURLClasspathHelper.IndexHolder indexFoundAtHolder)
  1. byte[]
findSharedClass(java.lang.String partition,java.lang.String className,SharedClassURLClasspathHelper.IndexHolder indexFoundAtHolder)
  1. void
setClasspath(java.net.URL[] newClasspath)
  1. boolean
storeSharedClass(java.lang.Class clazz,int foundAtIndex)
  1. boolean
storeSharedClass(java.lang.String partition,java.lang.Class clazz,int foundAtIndex)
Methods inherited from class com.ibm.oti.shared.SharedClassAbstractHelper
getSharingFilter, isSharedClassCookie, setSharingFilter
Methods inherited from class com.ibm.oti.shared.SharedAbstractHelper
getClassLoader
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.ibm.oti.shared.SharedClassHelper
getSharingFilter, setSharingFilter
Methods inherited from interface com.ibm.oti.shared.SharedHelper
getClassLoader

Method Detail

findSharedClass

  1. public byte[] findSharedClass(java.lang.String className,
  2. SharedClassURLClasspathHelper.IndexHolder indexFoundAtHolder)

Description copied from interface: SharedClassURLClasspathHelper

Find a class in the shared cache using the class name given (implicitly using the caller's classpath).

See Using Classpaths for rules on when a class will be found
Null is returned if the class cannot be found, if it is stale (see Dynamic Cache Updates) or if it is found for an unconfirmed entry (see Using Classpaths).

Specified by:
Parameters:
className - String. The name of the class to be found
indexFoundAtHolder - IndexHolder. The index in the caller ClassLoader's classpath at which the class was found. This parameter can be null if this data is not needed.
Returns:
byte[]. A byte array describing the class found, or null.

findSharedClass

  1. public byte[] findSharedClass(java.lang.String partition,
  2. java.lang.String className,
  3. SharedClassURLClasspathHelper.IndexHolder indexFoundAtHolder)

Description copied from interface: SharedClassURLClasspathHelper

Find a class in the shared cache using the class name and partition given (implicitly using the caller's classpath).

See Finding Classes for rules on when a class will be found
Null is returned if the class cannot be found, if it is stale (see Dynamic Cache Updates) or if it is found for an unconfirmed entry (see Using Classpaths).

Specified by:
Parameters:
partition - String. User-defined partition if finding modified bytecode (see Partitions). Passing null is equivalent of calling non-partition findSharedClass call.
className - String. The name of the class to be found
indexFoundAtHolder - IndexHolder. The index in the caller ClassLoader's classpath at which the class was found. This parameter can be null if this data is not needed.
Returns:
byte[]. A byte array describing the class found, or null.

storeSharedClass

  1. public boolean storeSharedClass( java.lang.Class clazz,
  2. int foundAtIndex)

Description copied from interface: SharedClassURLClasspathHelper

Store a class in the shared cache using the caller's URL classpath.

The class being stored must have been defined by the caller ClassLoader and must exist in the URL location specified.

Returns true if the class is stored successfully or false otherwise.

Will return false if the class being stored was not defined by the caller ClassLoader.

Also returns false if the URL at foundAtIndex is not a file URL or if the resource it refers to does not exist.

Specified by:
Parameters:
clazz - Class. The class to store in the shared cache
foundAtIndex - int. The index in the caller's classpath where the class was loaded from (first entry is 0).
Returns:
boolean. True if the class was stored successfully, false otherwise.

storeSharedClass

  1. public boolean storeSharedClass( java.lang.String partition,
  2. java.lang.Class clazz,
  3. int foundAtIndex)

Description copied from interface: SharedClassURLClasspathHelper

Store a class in the shared cache using the caller's URL classpath and with a user-defined partition.

The class being stored must have been defined by the caller ClassLoader and must exist in the URL location specified.

Returns true if the class is stored successfully or false otherwise.

Will return false if the class being stored was not defined by the caller ClassLoader.

Also returns false if the URL at foundAtIndex is not a file URL or if the resource it refers to does not exist.

Specified by:
Parameters:
partition - String. User-defined partition if storing modified bytecode (see Partitions). Passing null is equivalent of calling non-partition storeSharedClass call.
clazz - Class. The class to store in the shared cache
foundAtIndex - int. The index in the caller's classpath where the class was loaded from (first entry is 0).
Returns:
boolean. True if the class was stored successfully, false otherwise.

addClasspathEntry

  1. public void addClasspathEntry(java.net.URL cpe)

Description copied from interface: SharedClassURLClasspathHelper

Update the helper's classpath by appending a URL (see Usage).

Note: It is ESSENTIAL that the helper's classpath is kept up-to-date with the classloader's.

Specified by:
Parameters:
cpe - URL. The classpath entry to append to the classpath

confirmAllEntries

  1. public void confirmAllEntries()

Description copied from interface: SharedClassURLClasspathHelper

Confirms all entries in the current classpath. Any new entries added will not automatically be confirmed.

Note that if all entries are confirmed, setClasspath cannot be used to modify the classpath, only to append new entries. (see Efficient use...).

Specified by:

setClasspath

  1. public void setClasspath(java.net.URL[] newClasspath)
  2. throws CannotSetClasspathException

Description copied from interface: SharedClassURLClasspathHelper

Update the helper's classpath with a new classpath.

This function is useful for ClassLoaders that compute their classpath lazily. The initial classpath is passed to the constructor optimistically, but if the classloader discovers a change while reading an entry, it can update the classpath using this function.

Note: It is ESSENTIAL that the helper's classpath is kept up-to-date with the classloader's.

The classpath passed to this function must be exactly the same as the original classpath upto and including the right-most entry that classes have been loaded from (the right-most confirmed entry).

Throws a CannotSetClasspathException if this is not the case (see Modifying Classpaths).

Once the classpath has been updated, any indexes passed to storeSharedClass and returned from findSharedClass correspond to the new classpath.

Specified by:
Parameters:
newClasspath - The new URL classpath array
Throws: