Invoke method, every class will have its own
returns true/false on completion, setting both
errormsg and output as necessary
335601
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_NONE;
        //$this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting result as needed

        // Get the dir containing the file
        $dirpath = required_param('dir', PARAM_PATH);
        $plugintype = $this->get_plugin_type($dirpath);
        $dirpath = $CFG->dirroot . $dirpath;
        $file = $dirpath . '/install.xml';

        // Some variables
        $xmlpath = dirname(str_replace($CFG->dirroot . '/', '', $file));
        $xmlversion = userdate(time(), '%Y%m%d', 99, false);
        $xmlcomment = 'XMLDB file for Moodle ' . dirname($xmlpath);

        $xmltable = strtolower(basename(dirname($xmlpath)));
        if ($plugintype && $plugintype != 'mod') {
            $xmltable = $plugintype.'_'.$xmltable;
        }

        // Initial contents
        $c = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
        $c.= '  <XMLDB PATH="' . $xmlpath . '" VERSION="' . $xmlversion .'" COMMENT="' . $xmlcomment .'">' . "\n";
        $c.= '    <TABLES>' . "\n";
        $c.= '      <TABLE NAME="' . $xmltable . '" COMMENT="Default comment for ' . $xmltable .', please edit me">' . "\n";
        $c.= '        <FIELDS>' . "\n";
        $c.= '          <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />' . "\n";
        $c.= '        </FIELDS>' . "\n";
        $c.= '        <KEYS>' . "\n";
        $c.= '          <KEY NAME="primary" TYPE="primary" FIELDS="id" />' . "\n";
        $c.= '        </KEYS>' . "\n";
        $c.= '      </TABLE>' . "\n";
        $c.= '    </TABLES>' . "\n";
        $c.= '  </XMLDB>';

        if (!file_put_contents($file, $c)) {
            $errormsg = 'Error creando fichero ' . $file;
            $result = false;
        }

        // Launch postaction if exists
        if ($this->getPostAction() && $result) {
            return $this->launch($this->getPostAction());
        }

        // Return ok if arrived here
        return $result;
    }
1225956
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_GENERATE_XML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting result as needed

        // Get the file parameter
        $field =  required_param('field', PARAM_PATH);
        $table =  required_param('table', PARAM_PATH);
        $select = required_param('select', PARAM_ALPHA); //original/edited
        // Get the dir containing the file
        $dirpath = required_param('dir', PARAM_PATH);
        $dirpath = $CFG->dirroot . $dirpath;

        // Get the correct dir
        if ($select == 'original') {
            if (!empty($XMLDB->dbdirs)) {
                $base = $XMLDB->dbdirs[$dirpath];
            }
        } else if ($select == 'edited') {
            if (!empty($XMLDB->editeddirs)) {
                $base = $XMLDB->editeddirs[$dirpath];
            }
        } else {
            $this->errormsg = 'Cannot access to ' . $select . ' info';
            $result = false;
        }
        if ($base) {
            // Only if the directory exists and it has been loaded
            if (!$base->path_exists || !$base->xml_loaded) {
                $this->errormsg = 'Directory ' . $dirpath . ' not loaded';
                return false;
            }
        } else {
            $this->errormsg = 'Problem handling ' . $select . ' files';
            return false;
        }

        // Get the structure
        if ($result) {
            if (!$structure = $base->xml_file->getStructure()) {
                $this->errormsg = 'Error retrieving ' . $select . ' structure';
                $result = false;
            }
        }
        // Get the tables
        if ($result) {
            if (!$tables = $structure->getTables()) {
                $this->errormsg = 'Error retrieving ' . $select . ' tables';
                $result = false;
            }
        }
        // Get the table
        if ($result && !$t = $structure->getTable($table)) {
            $this->errormsg = 'Error retrieving ' . $table . ' table';
            $result = false;
        }
        // Get the fields
        if ($result) {
            if (!$fields = $t->getFields()) {
                $this->errormsg = 'Error retrieving ' . $select . ' fields';
                $result = false;
            }
        }
        // Get the field
        if ($result && !$f = $t->getField($field)) {
            $this->errormsg = 'Error retrieving ' . $field . ' field';
            $result = false;
        }

        if ($result) {
            // Everything is ok. Generate the XML output
            $this->output = $f->xmlOutput();
        } else {
            // Switch to HTML and error
            $this->does_generate = ACTION_GENERATE_HTML;
        }

        // Return ok if arrived here
        return $result;
    }
1098376
@Override
  public Object invokeMethod(String name, Object[] args) {
    ISlot slot = findSlot(name, args);
    PojoGestalt gestalt = createGestalt(slot.getType(), args);
    new Sculpturer().$form(gestalt);
    slot.write(gestalt.getSubject());
    return gestalt.getSubject();
  }
1129558
@Override
	public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
	{
		// Get an instance of the implementing class via Guice
		final Object instance = registry.getInjector().getInstance(clazz);

		return thisMethod.invoke(instance, args);
	}
1049186
private <Output, Input> Response<Output> doInvoke(Request<Input> request,
                                                      RequestConfig requestConfig,
                                                      ExecutionContext executionContext,
                                                      HttpResponseHandler<Output> responseHandler,
                                                      HttpResponseHandler<? extends SdkBaseException> errorResponseHandler) {
        request.setEndpoint(endpoint);
        return client.requestExecutionBuilder()
                .request(request)
                .requestConfig(requestConfig)
                .executionContext(executionContext)
                .errorResponseHandler(errorResponseHandler)
                .execute(responseHandler);
    }
458215
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_NONE;
        //$this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting $result as needed

        // Lets go to add all the db directories available inside Moodle
        // Create the array if it doesn't exists
        if (!isset($XMLDB->dbdirs)) {
            $XMLDB->dbdirs = array();
        }

        // get list of all dirs and create objects with status
        $db_directories = get_db_directories();
        foreach ($db_directories as $path) {
            $dbdir = new stdClass;
            $dbdir->path = $path;
            if (!isset($XMLDB->dbdirs[$dbdir->path])) {
                $XMLDB->dbdirs[$dbdir->path] = $dbdir;
             }
            $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path);  //Update status
         }

        // Sort by key
        ksort($XMLDB->dbdirs);

        // Return ok if arrived here
        return true;
    }
439857
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        //$this->does_generate = ACTION_NONE;
        $this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting result as needed

        if (!data_submitted()) { // Basic prevention
            print_error('wrongcall', 'error');
        }

        // Get parameters
        $dirpath = required_param('dir', PARAM_PATH);
        $dirpath = $CFG->dirroot . $dirpath;

        $tableparam = strtolower(required_param('table', PARAM_PATH));
        $name = substr(trim(strtolower(required_param('name', PARAM_PATH))),0,xmldb_table::NAME_MAX_LENGTH);
        $comment = required_param('comment', PARAM_CLEAN);
        $comment = $comment;

        $dbdir = $XMLDB->dbdirs[$dirpath];

        $editeddir = $XMLDB->editeddirs[$dirpath];
        $structure = $editeddir->xml_file->getStructure();
        $table = $structure->getTable($tableparam);

        $errors = array(); // To store all the errors found

        // Perform some checks
        // Check empty name
        if (empty($name)) {
            $errors[] = $this->str['tablenameempty'];
        }
        // Check incorrect name
        if ($name == 'changeme') {
            $errors[] = $this->str['incorrecttablename'];
        }
        // Check duplicatename
        if ($tableparam != $name && $structure->getTable($name)) {
            $errors[] = $this->str['duplicatetablename'];
        }

        if (!empty($errors)) {
            $temptable = new xmldb_table($name);
                // Prepare the output
            $o = '<p>' .implode(', ', $errors) . '</p>
                  <p>' . $temptable->getName() . '</p>';
            $o.= '<a href="index.php?action=edit_table&amp;table=' . $tableparam .
                 '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
            $this->output = $o;


        // Continue if we aren't under errors
        } else if (empty($errors)) {
            // If there is one name change, do it, changing the prev and next
            // atributes of the adjacent tables
            if ($tableparam != $name) {
                $table->setName($name);
                if ($table->getPrevious()) {
                    $prev = $structure->getTable($table->getPrevious());
                    $prev->setNext($name);
                    $prev->setChanged(true);
                }
                if ($table->getNext()) {
                    $next = $structure->getTable($table->getNext());
                    $next->setPrevious($name);
                    $next->setChanged(true);
                }
                // Table has changed
                $table->setChanged(true);
            }

            // Set comment
            if ($table->getComment() != $comment) {
                $table->setComment($comment);
                // Table has changed
                $table->setChanged(true);
            }

            // Recalculate the hash
            $structure->calculateHash(true);

            // If the hash has changed from the original one, change the version
            // and mark the structure as changed
            $origstructure = $dbdir->xml_file->getStructure();
            if ($structure->getHash() != $origstructure->getHash()) {
                $structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
                $structure->setChanged(true);
            }

            // Launch postaction if exists (leave this here!)
            if ($this->getPostAction() && $result) {
                return $this->launch($this->getPostAction());
            }
        }

        // Return ok if arrived here
        return $result;
    }
643371
@FFDCIgnore(InvocationTargetException.class)
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "invoke", method.toGenericString());

        if (actualMessageObject instanceof JmsMessageImpl) {

            if (((JmsMessageImpl) actualMessageObject).isAsynSendInProgress()) {
                //Async send is in progress... application is trying to access message object
                //throw JMSException

                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(this, tc, "Application is trying to access message object.. when asysn send is in progress.. throwing JMSException");

                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_MESSAGE_ACCESS_CWSIA0516E",
                                                                null, // object[] argument
                                                                tc
                                );

            }
        }

        Object retObject = null;

        try {

            retObject = method.invoke(actualMessageObject, args);

        } catch (InvocationTargetException e) {
            throw e.getCause();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "invoke", retObject);

        //call the method on actual message object.
        return retObject;

    }
894861
Callable<?> invokeMethod(MethodHandler methodHandler, Object[] arguments) {
    return () -> {
      try {
        return methodHandler.invoke(arguments);
      } catch (Throwable th) {
        if (th instanceof FeignException) {
          throw (FeignException) th;
        }
        throw new RuntimeException(th);
      }
    };
  }
225336
public void invoke()
    {
        assert state == State.READ_FRAME_COMPLETE : "Invoke called in invalid state: " + state;

        TTransport inTrans = getInputTransport();
        TProtocol inProt = thriftFactories.inputProtocolFactory.getProtocol(inTrans);
        TProtocol outProt = thriftFactories.outputProtocolFactory.getProtocol(getOutputTransport());

        try
        {
            thriftFactories.processorFactory.getProcessor(inTrans).process(inProt, outProt);
            responseReady();
            return;
        }
        catch (TException te)
        {
            logger.warn("Exception while invoking!", te);
        }
        catch (Throwable t)
        {
            logger.error("Unexpected throwable while invoking!", t);
        }

        // This will only be reached when there is a throwable.
        state = State.AWAITING_CLOSE;
        changeSelectInterests();
    }
1081880
function invoke(target, method, args, ignore) {

  if (method === undefined) {
    method = target;
    target = undefined;
  }

  if ('string' === typeof method) { method = target[method]; }
  if (args && ignore > 0) {
    args = args.length > ignore ? slice.call(args, ignore) : null;
  }

  // Unfortunately in some browsers we lose the backtrace if we rethrow the existing error,
  // so in the event that we don't have an `onerror` handler we don't wrap in a try/catch
  if ('function' === typeof Ember.onerror) {
    try {
      // IE8's Function.prototype.apply doesn't accept undefined/null arguments.
      return method.apply(target || this, args || []);
    } catch (error) {
      Ember.onerror(error);
    }
  } else {
    // IE8's Function.prototype.apply doesn't accept undefined/null arguments.
    return method.apply(target || this, args || []);
  }
}
346068
protected  function invoke($method_name, $request_method, array $arguments = []){
        $method_name = strtolower($request_method).'_'.$this->str->to_snake_case($method_name);
        // Check if method exists
        if( !is_callable([$this, $method_name]) ){
            return false;
        }
        // Check accessibility
        $reflection = new \ReflectionMethod($this, $method_name);
        if( !$reflection->isPublic() || $reflection->isStatic() ){
            return false;
        }
        // Check required arguments length
        if( $reflection->getNumberOfRequiredParameters() > count($arguments) ){
            return false;
        }
        // O.K. It's public method. Call it.
        $this->handle_result(call_user_func_array([$this, $method_name], $arguments));
        return true;
    }
870042
public static Object invokeMethod(Class<?> type,Object instance,String methodName,Class<?>[] inputTypes,Object[] input)
    {
        Method method=null;
        try
        {
            //get method
            method=type.getDeclaredMethod(methodName,inputTypes);
        }
        catch(Exception exception)
        {
            throw new FaxException("Unable to extract method: "+methodName+" from type: "+type,exception);
        }

        //set accessible
        method.setAccessible(true);

        Object output=null;
        try
        {
            //invoke method
            output=method.invoke(instance,input);
        }
        catch(Exception exception)
        {
            throw new FaxException("Unable to invoke method: "+methodName+" of type: "+type,exception);
        }
        
        return output;
    }
1005928
def invoke_in_mainloop(func, *args, **kwargs):
    
    results = queue.Queue()

    @gcall
    def run():
        try:
            data = func(*args, **kwargs)
            results.put(data)
            results.put(None)
        except BaseException:  # XXX: handle
            results.put(None)
            results.put(sys.exc_info())
            raise

    data = results.get()
    exception = results.get()

    if exception is None:
        return data
    else:
        tp, val, tb = results.get()
        raise tp, val, tb
922992
function invoke() {
        parent::invoke();

        $result = true;

        // Set own core attributes
        $this->does_generate = ACTION_GENERATE_HTML;

        // These are always here
        global $CFG, $XMLDB;

        // Do the job, setting $result as needed

        // Get the dir containing the file
        $dirpath = required_param('dir', PARAM_PATH);
        $dirpath = $CFG->dirroot . $dirpath;
        $path = $dirpath.'/install.xml';
        if(!file_exists($path) || !is_readable($path)) {
            return false;
        }

        // Add link back to home
        $b = ' <p class="centerpara buttons">';
        $b .= '&nbsp;<a href="index.php?action=main_view#lastused">[' . $this->str['backtomainview'] . ']</a>';
        $b .= '</p>';
        $this->output=$b;

        $c = ' <p class="centerpara">';
        $c .= $this->str['documentationintro'];
        $c .= '</p>';
        $this->output.=$c;

        if(class_exists('XSLTProcessor')) {
            // Transform XML file and display it
            $doc = new DOMDocument();
            $xsl = new XSLTProcessor();

            $doc->load(__DIR__.'/xmldb.xsl');
            $xsl->importStyleSheet($doc);

            $doc->load($path);
            $this->output.=$xsl->transformToXML($doc);
            $this->output.=$b;
        } else {
            $this->output.=get_string('extensionrequired','tool_xmldb','xsl');
        }

        // Launch postaction if exists (leave this unmodified)
        if ($this->getPostAction() && $result) {
            return $this->launch($this->getPostAction());
        }

        return $result;
    }
1336802
function invoke(methodName) {
  var args = slice.call(arguments, 1)
  return function (object) {
    return object[methodName].apply(object, args)
  }
}
169500
def invoke(*args)
      task_args = TaskArguments.new(arg_names, args)
      invoke_with_call_chain(task_args, InvocationChain::EMPTY)
    end