Search in sources :

Example 1 with GeneratedMethod

use of org.apache.derby.iapi.services.loader.GeneratedMethod in project derby by apache.

the class DirectCall method getMethod.

public GeneratedMethod getMethod(String simpleName) throws StandardException {
    GeneratedMethod rm = methodCache.get(simpleName);
    if (rm != null)
        return rm;
    // Only look for methods that take no arguments
    try {
        if ((simpleName.length() == 2) && simpleName.startsWith("e")) {
            int id = ((int) simpleName.charAt(1)) - '0';
            rm = directs[id];
        } else {
            Method m = getJVMClass().getMethod(simpleName, (Class[]) null);
            rm = new ReflectMethod(m);
        }
        methodCache.put(simpleName, rm);
        return rm;
    } catch (NoSuchMethodException nsme) {
        throw StandardException.newException(SQLState.GENERATED_CLASS_NO_SUCH_METHOD, nsme, getName(), simpleName);
    }
}
Also used : GeneratedMethod(org.apache.derby.iapi.services.loader.GeneratedMethod) Method(java.lang.reflect.Method) GeneratedMethod(org.apache.derby.iapi.services.loader.GeneratedMethod)

Example 2 with GeneratedMethod

use of org.apache.derby.iapi.services.loader.GeneratedMethod in project derby by apache.

the class MatchingClauseConstantAction method executeConstantAction.

public void executeConstantAction(Activation activation, TemporaryRowHolderImpl thenRows) throws StandardException {
    // nothing to do if no rows qualified
    if (thenRows == null) {
        return;
    }
    CursorResultSet sourceRS = thenRows.getResultSet();
    GeneratedMethod actionGM = ((BaseActivation) activation).getMethod(_actionMethodName);
    // 
    try {
        activation.pushConstantAction(_thenAction);
        try {
            // 
            // Poke the temporary table into the variable which will be pushed as
            // an argument to the INSERT/UPDATE/DELETE action.
            // 
            Field resultSetField = activation.getClass().getField(_resultSetFieldName);
            resultSetField.set(activation, sourceRS);
            Activation cursorActivation = sourceRS.getActivation();
            // 
            // Now execute the generated method which creates an InsertResultSet,
            // UpdateResultSet, or DeleteResultSet.
            // 
            Method actionMethod = activation.getClass().getMethod(_actionMethodName);
            _actionRS = (ResultSet) actionMethod.invoke(activation, null);
        } catch (Exception e) {
            throw StandardException.plainWrapException(e);
        }
        // this is where the INSERT/UPDATE/DELETE is processed
        _actionRS.open();
    } finally {
        activation.popConstantAction();
    }
}
Also used : Field(java.lang.reflect.Field) CursorResultSet(org.apache.derby.iapi.sql.execute.CursorResultSet) Activation(org.apache.derby.iapi.sql.Activation) GeneratedMethod(org.apache.derby.iapi.services.loader.GeneratedMethod) Method(java.lang.reflect.Method) GeneratedMethod(org.apache.derby.iapi.services.loader.GeneratedMethod) StandardException(org.apache.derby.shared.common.error.StandardException) IOException(java.io.IOException)

Aggregations

Method (java.lang.reflect.Method)2 GeneratedMethod (org.apache.derby.iapi.services.loader.GeneratedMethod)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Activation (org.apache.derby.iapi.sql.Activation)1 CursorResultSet (org.apache.derby.iapi.sql.execute.CursorResultSet)1 StandardException (org.apache.derby.shared.common.error.StandardException)1