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

pack-priv final Class UpdateLoader

Additional top-level class in compilation unit: ClassLoaderLock.

extends Object
implements LockOwner
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.locks.LockOwner
Imports
org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.shared.common.stream.HeaderPrintWriter, org.apache.derby.iapi.util.IdUtil, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.locks.ShExLockable, .ShExQual, .LockFactory, .Latch, .C_LockFactory, .CompatibilitySpace, .LockOwner, org.apache.derby.iapi.services.loader.ClassFactoryContext, .JarReader, org.apache.derby.iapi.services.property.PersistentSet, .PropertyUtil, org.apache.derby.shared.common.reference.Property, .MessageId, .Module, java.io.InputStream, org.apache.derby.shared.common.i18n.MessageService

UpdateLoader implements then functionality of derby.database.classpath. It manages the ClassLoaders (instances of JarLoader) for each installed jar file. Jar files are installed through the sqlj.install_jar procedure.
Each JarLoader delegates any request through standard mechanisms to load a class to this object, which will then ask each jarLoader in order of derby.database.classpath to load the class through an internal api. This means if the third jar in derby.database.classpath tries to load a class, say from the class for a procedure's method making some reference to it, then the request is delegated to UpdateLoader. UpdateLoader will then try to load the class from each of the jars in order of derby.database.classpath using the jar's installed JarLoader.

Field Summary

Modifier and TypeField and Description
private final ShExLockable
private final CompatibilitySpace
private boolean
private JarLoader[]
private JarReader
private final LockFactory
private final ClassLoader
private boolean
private boolean
private DatabaseClasses
private static final String[]
RESTRICTED_PACKAGES

List of packages that Derby will not support being loaded from an installed jar file.

private String
private int
private HeaderPrintWriter

Constructor Summary

AccessConstructor and Description
pack-priv
UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper)

Method Summary

Modifier and TypeMethod and Description
pack-priv Class<T>
checkLoaded(String className, boolean resolve)

pack-priv void
pack-priv int
private String
private static Context
getContextOrNull(final String contextID)

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

pack-priv JarReader
pack-priv InputStream
private static Object
getServiceModule(final Object serviceModule, final String factoryInterface)

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

private void
private void
public boolean
isNestedOwner()

Implements org.apache.derby.iapi.services.locks.LockOwner.isNestedOwner.

Return true if this is a nested owner, e.g., a nested user transaction.

pack-priv Class<T>
loadClass(String className, boolean resolve)

Load the class from the class path.

private boolean
pack-priv synchronized void
pack-priv synchronized void
modifyJar(boolean reload)

pack-priv synchronized void
public boolean
nestsUnder(LockOwner
The other lock owner
other
)

Implements org.apache.derby.iapi.services.locks.LockOwner.nestsUnder.

Return true if this owner nests under another owner.

public boolean

Returns:

false
noWait
()

Implements org.apache.derby.iapi.services.locks.LockOwner.noWait.

Tell the lock manager that we don't want timed waits to time out immediately.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderLockback to summary
private final ShExLockable classLoaderLock
compatback to summary
private final CompatibilitySpace compat
initDoneback to summary
private boolean initDone
jarListback to summary
private JarLoader[] jarList
jarReaderback to summary
private JarReader jarReader
lfback to summary
private final LockFactory lf
myLoaderback to summary
private final ClassLoader myLoader
needReloadback to summary
private boolean needReload
normalizeToUpperback to summary
private boolean normalizeToUpper
parentback to summary
private DatabaseClasses parent
RESTRICTED_PACKAGESback to summary
private static final String[] RESTRICTED_PACKAGES

List of packages that Derby will not support being loaded from an installed jar file.

thisClasspathback to summary
private String thisClasspath
versionback to summary
private int version
vsback to summary
private HeaderPrintWriter vs

Constructor Detail

UpdateLoaderback to summary
pack-priv UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper) throws StandardException

Method Detail

checkLoadedback to summary
pack-priv Class<T> checkLoaded(String className, boolean resolve)
closeback to summary
pack-priv void close()
getClassLoaderVersionback to summary
pack-priv int getClassLoaderVersion()
getClasspathback to summary
private String getClasspath() throws StandardException
getContextOrNullback to summary
private static Context getContextOrNull(final String contextID)

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

getJarReaderback to summary
pack-priv JarReader getJarReader()
getResourceAsStreamback to summary
pack-priv InputStream getResourceAsStream(String name)
getServiceModuleback to summary
private static Object getServiceModule(final Object serviceModule, final String factoryInterface)

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

initializeFromClassPathback to summary
private void initializeFromClassPath(String classpath) throws StandardException
initLoadersback to summary
private void initLoaders()
isNestedOwnerback to summary
public boolean isNestedOwner()

Implements org.apache.derby.iapi.services.locks.LockOwner.isNestedOwner.

Doc from org.apache.derby.iapi.services.locks.LockOwner.isNestedOwner.

Return true if this is a nested owner, e.g., a nested user transaction.

Returns:boolean

true if this is a nested owner, e.g., a nested user transaction

loadClassback to summary
pack-priv Class<T> loadClass(String className, boolean resolve) throws ClassNotFoundException

Load the class from the class path. Called by JarLoader when it has a request to load a class to fulfill the sematics of derby.database.classpath.

Enforces two restrictions:

  • Do not allow classes in certain name spaces to be loaded from installed jars, see RESTRICTED_PACKAGES for the list.
  • Referencing Derby's internal classes (those outside the public api) from installed is disallowed. This is to stop user defined routines bypassing security or taking advantage of security holes in Derby. E.g. allowing a routine to call a public method in derby would allow such routines to call public static methods for system procedures without having been granted permission on them, such as setting database properties.
Exceptions
ClassNotFoundException:
Class can not be found or the installed jar is restricted from loading it.
lockClassLoaderback to summary
private boolean lockClassLoader(ShExQual qualifier) throws StandardException
modifyClasspathback to summary
pack-priv synchronized void modifyClasspath(String classpath) throws StandardException
modifyJarback to summary
pack-priv synchronized void modifyJar(boolean reload) throws StandardException
needReloadback to summary
pack-priv synchronized void needReload()
nestsUnderback to summary
public boolean nestsUnder(LockOwner other)

Implements org.apache.derby.iapi.services.locks.LockOwner.nestsUnder.

Doc from org.apache.derby.iapi.services.locks.LockOwner.nestsUnder.

Return true if this owner nests under another owner.

Parameters
other:LockOwner

The other lock owner

Returns:boolean

true if this owner nests under another owner

noWaitback to summary
public boolean noWait()

Implements org.apache.derby.iapi.services.locks.LockOwner.noWait.

Tell the lock manager that we don't want timed waits to time out immediately.

Returns:boolean

false

reloadback to summary
private void reload() throws StandardException