Package com.mckoi.database
Class ProcedureManager
- java.lang.Object
-
- com.mckoi.database.ProcedureManager
-
public class ProcedureManager extends java.lang.ObjectA DatabaseConnection procedure manager. This controls adding, updating, deleting and querying/calling stored procedures.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classProcedureManager.ProcedureInternalTableInfoAn object that models the list of procedures as table objects in a transaction.
-
Field Summary
Fields Modifier and Type Field Description private DatabaseConnectionconnectionThe DatabaseConnection.private DatabaseQueryContextcontextThe context.
-
Constructor Summary
Constructors Constructor Description ProcedureManager(DatabaseConnection connection)Constructs the ProcedureManager for a DatabaseConnection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static InternalTableInfocreateInternalTableInfo(Transaction transaction)Returns an InternalTableInfo object used to model the list of procedures that are accessible within the given Transaction object.voiddefineJavaProcedure(ProcedureName procedure_name, java.lang.String java_specification, TType return_type, TType[] param_types, java.lang.String username)Defines a Java stored procedure.voiddeleteProcedure(ProcedureName procedure_name)Deletes the procedure with the given name, or generates an error if the procedure doesn't exist.private TablefindProcedureEntry(DataTable table, ProcedureName procedure_name)Given the SYS_FUNCTION table, this returns a new table that contains the entry with the given procedure name, or an empty result if nothing found.private TObjectinvokeJavaV1Procedure(ProcedureName procedure_name, java.lang.String location_str, TType return_type, TType[] param_types, java.lang.String owner, TObject[] param_values)Invokes a Java (type 1) procedure.TObjectinvokeProcedure(ProcedureName procedure_name, TObject[] params)Invokes the procedure with the given name and the given parameters and returns the procedure return value.static java.lang.reflect.MethodjavaProcedureMethod(java.lang.String location_str, TType[] param_types)Given a Java location_str and a list of parameter types, returns an immutable 'Method' object that can be used to invoke a Java stored procedure.static java.lang.String[]parseJavaLocationString(java.lang.String str)Given a location string as defined for a Java stored procedure, this parses the string into the various parts.booleanprocedureExists(ProcedureName procedure_name)Returns true if the procedure with the given name exists.booleanprocedureExists(TableName procedure_name)Returns true if the procedure with the given table name exists.private static java.lang.StringprocedureInfoString(ProcedureName name, TType ret, TType[] params)Formats a string that gives information about the procedure, return type and param types.private static java.lang.ClassresolveToClass(java.lang.String java_spec)Resolves a Java class specification string to a Java Class object.
-
-
-
Field Detail
-
connection
private DatabaseConnection connection
The DatabaseConnection.
-
context
private DatabaseQueryContext context
The context.
-
-
Constructor Detail
-
ProcedureManager
ProcedureManager(DatabaseConnection connection)
Constructs the ProcedureManager for a DatabaseConnection.
-
-
Method Detail
-
findProcedureEntry
private Table findProcedureEntry(DataTable table, ProcedureName procedure_name)
Given the SYS_FUNCTION table, this returns a new table that contains the entry with the given procedure name, or an empty result if nothing found. Generates an error if more than 1 entry found.
-
procedureInfoString
private static java.lang.String procedureInfoString(ProcedureName name, TType ret, TType[] params)
Formats a string that gives information about the procedure, return type and param types.
-
parseJavaLocationString
public static java.lang.String[] parseJavaLocationString(java.lang.String str)
Given a location string as defined for a Java stored procedure, this parses the string into the various parts. For example, given the string 'com.mycompany.storedprocedures.MyFunctions.minFunction()' this will parse the string out to the class called 'com.mycompany.storedprocedures.MyFunctions' and the method 'minFunction' with no arguments. This function will work event if the method name is not given, or the method name does not have an arguments specification.
-
procedureExists
public boolean procedureExists(ProcedureName procedure_name)
Returns true if the procedure with the given name exists.
-
procedureExists
public boolean procedureExists(TableName procedure_name)
Returns true if the procedure with the given table name exists.
-
defineJavaProcedure
public void defineJavaProcedure(ProcedureName procedure_name, java.lang.String java_specification, TType return_type, TType[] param_types, java.lang.String username) throws DatabaseException
Defines a Java stored procedure. If the procedure with the name has not been defined it is defined. If the procedure has been defined then it is overwritten with this information.If 'return_type' is null then the procedure does not return a value.
- Throws:
DatabaseException
-
deleteProcedure
public void deleteProcedure(ProcedureName procedure_name) throws DatabaseException
Deletes the procedure with the given name, or generates an error if the procedure doesn't exist.- Throws:
DatabaseException
-
createInternalTableInfo
static InternalTableInfo createInternalTableInfo(Transaction transaction)
Returns an InternalTableInfo object used to model the list of procedures that are accessible within the given Transaction object. This is used to model all procedures that have been defined as tables.
-
invokeProcedure
public TObject invokeProcedure(ProcedureName procedure_name, TObject[] params)
Invokes the procedure with the given name and the given parameters and returns the procedure return value.
-
resolveToClass
private static java.lang.Class resolveToClass(java.lang.String java_spec)
Resolves a Java class specification string to a Java Class object. For example, "String" becomes 'java.lang.String.class' and "boolean[]" becomes 'boolean[].class', etc.
-
javaProcedureMethod
public static java.lang.reflect.Method javaProcedureMethod(java.lang.String location_str, TType[] param_types)Given a Java location_str and a list of parameter types, returns an immutable 'Method' object that can be used to invoke a Java stored procedure. The returned object can be cached if necessary. Note that this method will generate an error for the following situations: a) The invokation class or method was not found, b) there is not an invokation method with the required number of arguments or that matches the method specification.Returns null if the invokation method could not be found.
-
invokeJavaV1Procedure
private TObject invokeJavaV1Procedure(ProcedureName procedure_name, java.lang.String location_str, TType return_type, TType[] param_types, java.lang.String owner, TObject[] param_values)
Invokes a Java (type 1) procedure. A type 1 procedure is represented by a single class with a static invokation method (called invoke). The parameters of the static 'invoke' method must be compatible class parameters defined for the procedure, and the return class must also be compatible with the procedure return type.If the invoke method does not contain arguments that are compatible with the parameters given an exception is generated.
The class must only have a single public static 'invoke' method. If there are multiple 'invoke' methods a runtime exception is generated.
-
-