Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
package org.dspace.app.launcher;

import orgjava.dspacelang.core.ConfigurationManager;
import org.dspace.servicemanager.DSpaceKernelImplreflect.Method;
import org.dspace.servicemanager.DSpaceKernelInit;
import org.dspace.services.RequestService;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.lang.reflect.Method;

public class ScriptLauncher
{ DSRUNStep extends Step {


    /**public The service manager kernel */int exec(String[] args) {

    private static transient DSpaceKernelImpl kernelImpl;

    /**
     * Execute the DSpace script launcher
     *
     * @param args Any parameters required to be passed to the scripts it executes
     */
    public static void main(String[] args)
    {

        //...

        CommandService service = kernelImpl.getServiceManager().getServiceByName(null,CommandService.class);

        // Establish the request service startup
        RequestService requestService = kernelImpl.getServiceManager().getServiceByName(RequestService.class.getName(), RequestService.class);
        if (requestService == null) {
             throw new IllegalStateException("Could not get the DSpace RequestService to start the request transaction");
        }Step ds = new Step();

        try {
            service.exec(Arrays.copyOfRange(args,1,args.lengthds.setArguments(this.getArguments());

        } catch (Exception e) {System.out.println(args.length);
            System.errout.println("Exception: " + e.getMessage());args[0]);


        if (args.length <  e.printStackTrace(1);
        {
    // ...
       throw }
        finallynew RuntimeException("Error in launcher: DSRun Step Missing class name.");
        {}

        /* get the classname from arguments /*/...
        }ds.setClassName(args[0]);


        // The command wasn't found
ds.setPassUserArgs(true);

        /* Execute the  System.err.println("Command not found: " + args[0]);
    requested class with the appropriate args (remove  classname) */
    display(commands);
        System.exit(1)return ds.exec(Arrays.copyOfRange(args,1,args.length));
    }

}

Adding Commands in other Addon Modules

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-2.5.xsd">

   <bean class="org.dspace.app.launcher.Command">
      <property name="name" value="update-discovery-index"/>
      <property name="description" value="Update Discovery Solr Search Index"/>
      <property name="steps">
        <list>
          <bean class="org.dspace.app.launcher.Step">
             <property name="className" value="org.dspace.discovery.IndexClient"/>
          </bean>
        </list>
      </property>
    </bean>
</beans>

Statistics (dspace/trunk/dspace-statistics/src/main/resources/spring)

...