Top Fields Constructors Methods
org.apache.derby.impl.sql.execute

public Class JarUtil

extends Object
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, java.net.MalformedURLException, .URISyntaxException, .URI, .URL, java.util.HashMap, .Iterator, .List, .Map, org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Property, .SQLState, org.apache.derby.iapi.security.Securable, .SecurityUtil, org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.services.io.FileUtil, org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.iapi.services.property.PropertyUtil, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.depend.DependencyManager, org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator, .DataDictionary, .FileInfoDescriptor, .SchemaDescriptor, org.apache.derby.iapi.store.access.FileResource, .TransactionController, org.apache.derby.iapi.util.IdUtil, org.apache.derby.io.StorageFile

Field Summary

Modifier and TypeField and Description
private DataDictionary
private DataDescriptorGenerator
private FileResource
private LanguageConnectionContext
private String
private String

Constructor Summary

AccessConstructor and Description
private
JarUtil(LanguageConnectionContext lcc, String schemaName, String sqlName)

Method Summary

Modifier and TypeMethod and Description
private long
add(final InputStream
A stream for reading the content of the file to add.
is
)

Add a jar file to the current connection's database.

public static void
drop(LanguageConnectionContext lcc, String
the name for the schema that holds the jar file.
schemaName
,
String
the sql name for the jar file.
sqlName
)

Drop a jar file from the current connection's database.

private void
drop()

Drop a jar file from the current connection's database.

private static Context
getContextOrNull(final String contextID)

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

private FileInfoDescriptor
getInfo()

Get the FileInfoDescriptor for the Jar file or null if it does not exist.

public static long

Returns:

The generationId for the jar file we add.
install
(LanguageConnectionContext lcc, String
the name for the schema that holds the jar file.
schemaName
,
String
the sql name for the jar file.
sqlName
,
String
the path for the jar file to add.
externalPath
)

install a jar file to the current connection's database.

public static String
mkExternalName(UUID id, String schemaName, String sqlName, char separatorChar)

Make an external name for a jar file stored in the database.

private static String
mkExternalNameInternal(UUID id, String schemaName, String sqlName, char separatorChar, boolean upgrading, boolean newStyle)

private void
notifyLoader(boolean reload)

private static InputStream
openJarURL(final String externalPath)

Open an input stream to read a URL or a file.

public static long

Returns:

The new generationId for the jar file we replace.
replace
(LanguageConnectionContext lcc, String
the name for the schema that holds the jar file.
schemaName
,
String
the sql name for the jar file.
sqlName
,
String
the path for the jar file to add.
externalPath
)

Replace a jar file from the current connection's database with the content of an external file.

private long
replace(InputStream
An input stream for reading the new content of the jar file.
is
)

Replace a jar file in the current connection's database with the content of an external file.

private long
setJar(final String
Name of jar with database structure.
jarExternalName
,
final InputStream
Contents of jar file.
contents
,
final boolean
true to add, false to replace
add
,
final long
generation id of existing version, ignored when adding.
currentGenerationId
)

Copy the jar from the externally obtained input stream into the database

public static void
upgradeJar(TransactionController
transaction controller
tc
,
FileInfoDescriptor
the jar file to be upgraded
fid
)

Upgrade code: upgrade one jar file to new style (>= 10.9)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ddback to summary
private DataDictionary dd
ddgback to summary
private DataDescriptorGenerator ddg
frback to summary
private FileResource fr
lccback to summary
private LanguageConnectionContext lcc
schemaNameback to summary
private String schemaName
sqlNameback to summary
private String sqlName

Constructor Detail

JarUtilback to summary
private JarUtil(LanguageConnectionContext lcc, String schemaName, String sqlName) throws StandardException

Method Detail

addback to summary
private long add(final InputStream is) throws StandardException

Add a jar file to the current connection's database.

The reason for adding the jar file in this private instance method is that it allows us to share set up logic with drop and replace.

Parameters
is:InputStream

A stream for reading the content of the file to add.

Exceptions
StandardException:
Opps
dropback to summary
public static void drop(LanguageConnectionContext lcc, String schemaName, String sqlName) throws StandardException

Drop a jar file from the current connection's database.

Parameters
schemaName:String

the name for the schema that holds the jar file.

sqlName:String

the sql name for the jar file.

Exceptions
StandardException:
Opps
dropback to summary
private void drop() throws StandardException

Drop a jar file from the current connection's database.

The reason for dropping the jar file in this private instance method is that it allows us to share set up logic with add and replace.

Exceptions
StandardException:
Opps
getContextOrNullback to summary
private static Context getContextOrNull(final String contextID)

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

getInfoback to summary
private FileInfoDescriptor getInfo() throws StandardException

Get the FileInfoDescriptor for the Jar file or null if it does not exist.

Exceptions
StandardException:
Ooops
installback to summary
public static long install(LanguageConnectionContext lcc, String schemaName, String sqlName, String externalPath) throws StandardException

install a jar file to the current connection's database.

Parameters
schemaName:String

the name for the schema that holds the jar file.

sqlName:String

the sql name for the jar file.

externalPath:String

the path for the jar file to add.

Returns:long

The generationId for the jar file we add.

Exceptions
StandardException:
Opps
mkExternalNameback to summary
public static String mkExternalName(UUID id, String schemaName, String sqlName, char separatorChar) throws StandardException

Make an external name for a jar file stored in the database.

mkExternalNameInternalback to summary
private static String mkExternalNameInternal(UUID id, String schemaName, String sqlName, char separatorChar, boolean upgrading, boolean newStyle) throws StandardException
notifyLoaderback to summary
private void notifyLoader(boolean reload) throws StandardException
openJarURLback to summary
private static InputStream openJarURL(final String externalPath) throws IOException

Open an input stream to read a URL or a file. URL is attempted first, if the string does not conform to a URL then an attempt to open it as a regular file is tried.
Attempting the file first can throw a security execption when a valid URL is passed in. The security exception is due to not have the correct permissions to access the bogus file path. To avoid this the order was reversed to attempt the URL first and only attempt a file open if creating the URL throws a MalformedURLException.

replaceback to summary
public static long replace(LanguageConnectionContext lcc, String schemaName, String sqlName, String externalPath) throws StandardException

Replace a jar file from the current connection's database with the content of an external file.

Parameters
schemaName:String

the name for the schema that holds the jar file.

sqlName:String

the sql name for the jar file.

externalPath:String

the path for the jar file to add.

Returns:long

The new generationId for the jar file we replace.

Exceptions
StandardException:
Opps
replaceback to summary
private long replace(InputStream is) throws StandardException

Replace a jar file in the current connection's database with the content of an external file.

The reason for adding the jar file in this private instance method is that it allows us to share set up logic with add and drop.

Parameters
is:InputStream

An input stream for reading the new content of the jar file.

Exceptions
StandardException:
Opps
setJarback to summary
private long setJar(final String jarExternalName, final InputStream contents, final boolean add, final long currentGenerationId) throws StandardException

Copy the jar from the externally obtained input stream into the database

Parameters
jarExternalName:String

Name of jar with database structure.

contents:InputStream

Contents of jar file.

add:boolean

true to add, false to replace

currentGenerationId:long

generation id of existing version, ignored when adding.

upgradeJarback to summary
public static void upgradeJar(TransactionController tc, FileInfoDescriptor fid) throws StandardException

Upgrade code: upgrade one jar file to new style (>= 10.9)

Parameters
tc:TransactionController

transaction controller

fid:FileInfoDescriptor

the jar file to be upgraded