Package org.dspace.services

Examples of org.dspace.services.RequestService


                        }
                        useargs = argsnew;
                    }

                    // 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");
                    }

                    // Establish a request related to the current session
                    // that will trigger the various request listeners
                    requestService.startRequest();

                    // Run the main() method
                    try
                    {
                        Object[] arguments = {useargs};

                        // Useful for debugging, so left in the code...
                        /**System.out.print("About to execute: " + className);
                        for (String param : useargs)
                        {
                            System.out.print(" " + param);
                        }
                        System.out.println("");**/

                        Method main = target.getMethod("main", argTypes);
                        Object output = main.invoke(null, arguments);

                        // ensure we close out the request (happy request)
                        requestService.endRequest(null);


                    }
                    catch (Exception e)
                    {
                        // Failure occurred in the request so we destroy it
                        requestService.endRequest(e);

                      if (kernelImpl != null)
                        {
                            kernelImpl.destroy();
                            kernelImpl = null;
View Full Code Here


     * Execute the {@link Runnable} which is contained in this object,
     * the same as calling {@link #run()}.
     * @throws RequestInterceptor.RequestInterruptionException if the method fails
     */
    public void execute() {
        RequestService requestService = this.requestServiceRef.get();
        if (requestService == null) {
            throw new IllegalStateException("it is no longer possible to execute this because the RequestService is no longer valid");
        }
        String requestId = null;
        if (useExistingRequestIfPossible) {
            requestId = requestService.getCurrentRequestId();
        }
        boolean newRequest = false;
        if (requestId == null) {
            // start new request
            requestId = requestService.startRequest();
            newRequest = true;
        }
        try {
            this.toExecute.run();
            if (newRequest) {
                // end the request here if it was a new one
                requestService.endRequest(null);
            }
        } catch (Exception e) {
            requestService.endRequest(e);
            throw new RequestInterceptor.RequestInterruptionException("Failure during execution of Runnable (" + toExecute + ") in request ("+requestId+"):" + e.getMessage(), e);
        }
    }
View Full Code Here

        // now do some DSpace stuff
        //try {
            DSpaceKernel kernel = getKernel();

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

            // establish a request related to the current session
            requestService.startRequest(request, response); // will trigger the various request listeners
            try {
                // invoke the next filter
                chain.doFilter(request, response);

                // ensure we close out the request (happy request)
                requestService.endRequest(null);
            } catch (Exception e) {
                // failure occurred in the request so we destroy it
                requestService.endRequest(e);
                throw new ServletException(e); // rethrow the exception
            }
            /*
        } catch (Exception e) {
            String message = "Failure in the DSpaceWebappServletFilter: " + e.getMessage();
View Full Code Here

                }
                useargs = argsnew;
            }

            // 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");
            }

            // Establish a request related to the current session
            // that will trigger the various request listeners
            requestService.startRequest();

            // Run the main() method
            try
            {
                Object[] arguments = {useargs};

                // Useful for debugging, so left in the code...
                /**System.out.print("About to execute: " + className);
                for (String param : useargs)
                {
                    System.out.print(" " + param);
                }
                System.out.println("");**/

                Method main = target.getMethod("main", argTypes);
                main.invoke(null, arguments);

                // ensure we close out the request (happy request)
                requestService.endRequest(null);
            }
            catch (Exception e)
            {
                // Failure occurred in the request so we destroy it
                requestService.endRequest(e);

                // Exceptions from the script are reported as a 'cause'
                Throwable cause = e.getCause();
                System.err.println("Exception: " + cause.getMessage());
                cause.printStackTrace();
View Full Code Here

TOP

Related Classes of org.dspace.services.RequestService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.