Class JarUtil
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.JarUtil
-
public class JarUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private DataDictionaryddprivate DataDescriptorGeneratorddgprivate FileResourcefrprivate LanguageConnectionContextlccprivate java.lang.StringschemaNameprivate java.lang.StringsqlName
-
Constructor Summary
Constructors Modifier Constructor Description privateJarUtil(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private longadd(java.io.InputStream is)Add a jar file to the current connection's database.private voiddrop()Drop a jar file from the current connection's database.static voiddrop(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName)Drop a jar file from the current connection's database.private static ContextgetContextOrNull(java.lang.String contextID)Privileged lookup of a Context.private FileInfoDescriptorgetInfo()Get the FileInfoDescriptor for the Jar file or null if it does not exist.static longinstall(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName, java.lang.String externalPath)install a jar file to the current connection's database.static java.lang.StringmkExternalName(UUID id, java.lang.String schemaName, java.lang.String sqlName, char separatorChar)Make an external name for a jar file stored in the database.private static java.lang.StringmkExternalNameInternal(UUID id, java.lang.String schemaName, java.lang.String sqlName, char separatorChar, boolean upgrading, boolean newStyle)private voidnotifyLoader(boolean reload)private static java.io.InputStreamopenJarURL(java.lang.String externalPath)Open an input stream to read a URL or a file.private longreplace(java.io.InputStream is)Replace a jar file in the current connection's database with the content of an external file.static longreplace(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName, java.lang.String externalPath)Replace a jar file from the current connection's database with the content of an external file.private longsetJar(java.lang.String jarExternalName, java.io.InputStream contents, boolean add, long currentGenerationId)Copy the jar from the externally obtained input stream into the databasestatic voidupgradeJar(TransactionController tc, FileInfoDescriptor fid)Upgrade code: upgrade one jar file to new style (>= 10.9)
-
-
-
Field Detail
-
lcc
private LanguageConnectionContext lcc
-
schemaName
private java.lang.String schemaName
-
sqlName
private java.lang.String sqlName
-
fr
private FileResource fr
-
dd
private DataDictionary dd
-
ddg
private DataDescriptorGenerator ddg
-
-
Constructor Detail
-
JarUtil
private JarUtil(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName) throws StandardException
- Throws:
StandardException
-
-
Method Detail
-
install
public static long install(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName, java.lang.String externalPath) throws StandardException
install a jar file to the current connection's database.- Parameters:
schemaName- the name for the schema that holds the jar file.sqlName- the sql name for the jar file.externalPath- the path for the jar file to add.- Returns:
- The generationId for the jar file we add.
- Throws:
StandardException- Opps
-
add
private long add(java.io.InputStream is) throws StandardExceptionAdd 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- A stream for reading the content of the file to add.- Throws:
StandardException- Opps
-
drop
public static void drop(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName) throws StandardException
Drop a jar file from the current connection's database.- Parameters:
schemaName- the name for the schema that holds the jar file.sqlName- the sql name for the jar file.- Throws:
StandardException- Opps
-
drop
private void drop() throws StandardExceptionDrop 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.
- Throws:
StandardException- Opps
-
replace
public static long replace(LanguageConnectionContext lcc, java.lang.String schemaName, java.lang.String sqlName, java.lang.String externalPath) throws StandardException
Replace a jar file from the current connection's database with the content of an external file.- Parameters:
schemaName- the name for the schema that holds the jar file.sqlName- the sql name for the jar file.externalPath- the path for the jar file to add.- Returns:
- The new generationId for the jar file we replace.
- Throws:
StandardException- Opps
-
replace
private long replace(java.io.InputStream is) throws StandardExceptionReplace 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- An input stream for reading the new content of the jar file.- Throws:
StandardException- Opps
-
getInfo
private FileInfoDescriptor getInfo() throws StandardException
Get the FileInfoDescriptor for the Jar file or null if it does not exist.- Throws:
StandardException- Ooops
-
notifyLoader
private void notifyLoader(boolean reload) throws StandardException- Throws:
StandardException
-
openJarURL
private static java.io.InputStream openJarURL(java.lang.String externalPath) throws java.io.IOExceptionOpen 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.- Throws:
java.io.IOException
-
setJar
private long setJar(java.lang.String jarExternalName, java.io.InputStream contents, boolean add, long currentGenerationId) throws StandardExceptionCopy the jar from the externally obtained input stream into the database- Parameters:
jarExternalName- Name of jar with database structure.contents- Contents of jar file.add- true to add, false to replacecurrentGenerationId- generation id of existing version, ignored when adding.- Throws:
StandardException
-
mkExternalName
public static java.lang.String mkExternalName(UUID id, java.lang.String schemaName, java.lang.String sqlName, char separatorChar) throws StandardException
Make an external name for a jar file stored in the database.- Throws:
StandardException
-
mkExternalNameInternal
private static java.lang.String mkExternalNameInternal(UUID id, java.lang.String schemaName, java.lang.String sqlName, char separatorChar, boolean upgrading, boolean newStyle) throws StandardException
- Throws:
StandardException
-
upgradeJar
public static void upgradeJar(TransactionController tc, FileInfoDescriptor fid) throws StandardException
Upgrade code: upgrade one jar file to new style (>= 10.9)- Parameters:
tc- transaction controllerfid- the jar file to be upgraded- Throws:
StandardException
-
getContextOrNull
private static Context getContextOrNull(java.lang.String contextID)
Privileged lookup of a Context. Must be private so that user code can't call this entry point.
-
-