Top Description Fields Constructors Methods
org.apache.derby.impl.services.reflect

pack-priv abstract Class DatabaseClasses

extends Object
implements ClassFactory, ModuleControl
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.monitor.ModuleControl, org.apache.derby.iapi.services.loader.ClassFactory
Known Direct Subclasses
org.apache.derby.impl.services.reflect.ReflectClassesJava2
Imports
java.io.File, .FileOutputStream, .IOException, .ObjectStreamClass, java.util.Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.MessageId, .Property, .SQLState, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.services.loader.ClassFactory, .ClassInspector, .GeneratedClass, org.apache.derby.iapi.services.monitor.ModuleControl, .ModuleFactory, .Monitor, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.stream.HeaderPrintWriter, org.apache.derby.iapi.util.ByteArray

An abstract implementation of the ClassFactory. This package can be extended to fully implement a ClassFactory. Implementations can differ in two areas, how they load a class and how they invoke methods of the generated class.

This class manages a hash table of loaded generated classes and their GeneratedClass objects. A loaded class may be referenced multiple times -- each class has a reference count associated with it. When a load request arrives, if the class has already been loaded, its ref count is incremented. For a remove request, the ref count is decremented unless it is the last reference, in which case the class is removed. This is transparent to users.

See Also
org.apache.derby.iapi.services.loader.ClassFactory

Field Summary

Modifier and TypeField and Description
private UpdateLoader
private ClassInspector

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
boot(boolean
True if the database should be created
create
,
Properties
Configuration properties
startParams
)

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Boot this module with the given properties.

public ClassInspector
public int
getClassLoaderVersion()

Implements org.apache.derby.iapi.services.loader.ClassFactory.getClassLoaderVersion.

Return the in-memory "version" of the class manager.

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

public boolean
isApplicationClass(Class<T>
The class in question
theClass
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.isApplicationClass.

Was the passed in class loaded by a ClassManager.

public final Class<T>
loadApplicationClass(String
The name of the class to load
className
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Load an application class, or a class that is potentially an application class.

public final Class<T>
loadApplicationClass(ObjectStreamClass
Descriptor for class
classDescriptor
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Load an application class, or a class that is potentially an application class.

pack-priv abstract Class<T>
public final GeneratedClass
loadGeneratedClass(String
Full name of the class
fullyQualifiedName
,
ByteArray
The byte code of the class
classDump
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadGeneratedClass.

Here we load the newly added class now, rather than waiting for the findGeneratedClass().

pack-priv abstract LoadedGeneratedClass
loadGeneratedClassFromData(String fullyQualifiedName, ByteArray classDump)

protected ClassInspector
makeClassInspector(DatabaseClasses dc)

For creating the class inspector.

public void
notifyModifyClasspath(String
The classpath being modified
classpath
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyClasspath.

Notify the class manager that the classpath has been modified.

public void
notifyModifyJar(boolean
Restart any attached class loader
reload
)

Implements org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyJar.

Notify the class manager that a jar file has been modified.

public void
private static void
WriteClassFile(String fullyQualifiedName, ByteArray bytecode, Throwable t)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationLoaderback to summary
private UpdateLoader applicationLoader
classInspectorback to summary
private ClassInspector classInspector

Constructor Detail

DatabaseClassesback to summary
pack-priv DatabaseClasses()

Method Detail

bootback to summary
public void boot(boolean create, Properties startParams) throws StandardException

Implements org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.boot.

Boot this module with the given properties. Creates a module instance that can be found using the findModule() methods of Monitor. The module can only be found using one of these findModule() methods once this method has returned.

An implementation's boot method can throw StandardException. If it is thrown the module is not registered by the monitor and therefore cannot be found through a findModule(). In this case the module's stop() method is not called, thus throwing this exception must free up any resources.

When create is true the contents of the properties object will be written to the service.properties of the persistent service. Thus any code that requires an entry in service.properties must explicitly place the value in this properties set using the put method.
Typically the properties object contains one or more default properties sets, which are not written out to service.properties. These default sets are how callers modify the create process. In a JDBC connection database create the first set of defaults is a properties object that contains the attributes that were set on the jdbc:derby: URL. This attributes properties set has the second default properties set as its default. This set (which could be null) contains the properties that the user set on their DriverManager.getConnection() call, and are thus not owned by Derby code, and thus must not be modified by Derby code.

When create is false the properties object contains all the properties set in the service.properties file plus a limited number of attributes from the JDBC URL attributes or connection properties set. This avoids properties set by the user compromising the boot process. An example of a property passed in from the JDBC world is the bootPassword for encrypted databases.

Code should not hold onto the passed in properties reference after boot time as its contents may change underneath it. At least after the complete boot is completed, the links to all the default sets will be removed.

Parameters
create:boolean

True if the database should be created

startParams:Properties

Configuration properties

Exceptions
StandardException:
Module cannot be started.
getClassInspectorback to summary
public ClassInspector getClassInspector()

Implements org.apache.derby.iapi.services.loader.ClassFactory.getClassInspector.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.getClassInspector.

Return a ClassInspector object

Returns:ClassInspector

the class inspector object

getClassLoaderVersionback to summary
public int getClassLoaderVersion()

Implements org.apache.derby.iapi.services.loader.ClassFactory.getClassLoaderVersion.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.getClassLoaderVersion.

Return the in-memory "version" of the class manager. The version is bumped everytime the classes are re-loaded.

Returns:int

the version of the class loader

getMonitorback to summary
private static ModuleFactory getMonitor()

Must be private so that user code can't call this entry point.

isApplicationClassback to summary
public boolean isApplicationClass(Class<T> theClass)

Implements org.apache.derby.iapi.services.loader.ClassFactory.isApplicationClass.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.isApplicationClass.

Was the passed in class loaded by a ClassManager.

Parameters
theClass:Class<T>

The class in question

Returns:boolean

true if the class was loaded by a Derby class manager, false it is was loaded by the system class loader, or another class loader.

loadApplicationClassback to summary
public final Class<T> loadApplicationClass(String className) throws ClassNotFoundException

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Load an application class, or a class that is potentially an application class.

Parameters
className:String

The name of the class to load

Returns:Class<T>

the corresponding class object

Exceptions
ClassNotFoundException:
Class cannot be found, or a SecurityException or LinkageException was thrown loading the class.
loadApplicationClassback to summary
public final Class<T> loadApplicationClass(ObjectStreamClass classDescriptor) throws ClassNotFoundException

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.loadApplicationClass.

Load an application class, or a class that is potentially an application class.

Parameters
classDescriptor:ObjectStreamClass

Descriptor for class

Returns:Class<T>

the corresponding class

Exceptions
ClassNotFoundException:
Class cannot be found, or a SecurityException or LinkageException was thrown loading the class.
loadClassNotInDatabaseJarback to summary
pack-priv abstract Class<T> loadClassNotInDatabaseJar(String className) throws ClassNotFoundException
loadGeneratedClassback to summary
public final GeneratedClass loadGeneratedClass(String fullyQualifiedName, ByteArray classDump) throws StandardException

Implements org.apache.derby.iapi.services.loader.ClassFactory.loadGeneratedClass.

Here we load the newly added class now, rather than waiting for the findGeneratedClass(). Thus we are assuming that the class is going to be used sometime soon. Delaying the load would mean storing the class data in a file, this wastes cycles and compilcates the cleanup.

Parameters
fullyQualifiedName:String

Doc from org.apache.derby.iapi.services.loader.ClassFactory.loadGeneratedClass.

Full name of the class

classDump:ByteArray

Doc from org.apache.derby.iapi.services.loader.ClassFactory.loadGeneratedClass.

The byte code of the class

Returns:GeneratedClass

Doc from org.apache.derby.iapi.services.loader.ClassFactory.loadGeneratedClass.

the corresponding generated class

Exceptions
StandardException:
Class format is bad.
See Also
ClassFactory#loadGeneratedClass
loadGeneratedClassFromDataback to summary
pack-priv abstract LoadedGeneratedClass loadGeneratedClassFromData(String fullyQualifiedName, ByteArray classDump)
makeClassInspectorback to summary
protected ClassInspector makeClassInspector(DatabaseClasses dc)

For creating the class inspector.

notifyModifyClasspathback to summary
public void notifyModifyClasspath(String classpath) throws StandardException

Implements org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyClasspath.

Notify the class manager that the classpath has been modified.

Parameters
classpath:String

Doc from org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyClasspath.

The classpath being modified

Exceptions
StandardException:
thrown on error
notifyModifyJarback to summary
public void notifyModifyJar(boolean reload) throws StandardException

Implements org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyJar.

Doc from org.apache.derby.iapi.services.loader.ClassFactory.notifyModifyJar.

Notify the class manager that a jar file has been modified.

Parameters
reload:boolean

Restart any attached class loader

Exceptions
StandardException:
thrown on error
stopback to summary
public void stop()

Implements org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Doc from org.apache.derby.iapi.services.monitor.ModuleControl.stop.

Stop the module. The module may be found via a findModule() method until some time after this method returns. Therefore the factory must be prepared to reject requests to it once it has been stopped. In addition other modules may cache a reference to the module and make requests of it after it has been stopped, these requests should be rejected as well.

WriteClassFileback to summary
private static void WriteClassFile(String fullyQualifiedName, ByteArray bytecode, Throwable t)