Package org.jboss.arquillian.warp.impl.shared.command

Examples of org.jboss.arquillian.warp.impl.shared.command.CommandPayload


            eventBusTimer = new Timer();
            eventBusTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    try {
                        CommandPayload payload = execute(eventUrlForGet, CommandPayload.class, null);
                        if (payload != null) {
                            Command command = payload.getCommand();
                            try {
                                operation.performInContext(command);
                            } catch (Throwable e) {
                                payload.setThrowable(e);
                            }
                            payload.setExecuted();
                            execute(eventUrlForGet, Object.class, payload);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
View Full Code Here


        }, ContextualOperation.class);
    }

    public Command executeRemotely(Command command) {
        final String eventUrlForPut = channelUrl + "&operationMode=" + OperationMode.PUT.name();
        final CommandPayload payload = new CommandPayload(command);
        try {
            CommandPayload result = execute(eventUrlForPut, CommandPayload.class, payload);
            if (result.getThrowable() != null) {
                Rethrow.asUnchecked(result.getThrowable());
            }
            return result.getCommand();
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            throw new IllegalStateException("Error executing remote command", e);
View Full Code Here

            eventBusTimer = new Timer();
            eventBusTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    try {
                        CommandPayload payload = execute(eventUrlForGet, CommandPayload.class, null);
                        if (payload != null) {
                            Command command = payload.getCommand();
                            try {
                                operation.performInContext(command);
                            } catch (Throwable e) {
                                payload.setThrowable(e);
                            }
                            payload.setExecuted();
                            execute(eventUrlForGet, Object.class, payload);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
View Full Code Here

        });
    }

    public Command executeRemotely(Command command) {
        final String eventUrlForPut = channelUrl + "&operationMode=" + OperationMode.PUT.name();
        final CommandPayload payload = new CommandPayload(command);
        try {
            CommandPayload result = execute(eventUrlForPut, CommandPayload.class, payload);
            if (result.getThrowable() != null) {
                Rethrow.asUnchecked(result.getThrowable());
            }
            return result.getCommand();
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            throw new IllegalStateException("Error executing remote command", e);
View Full Code Here

     */
    private void executeGetOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException {
        if (request.getContentLength() > 0) {
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
            ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream()));
            CommandPayload paylod = (CommandPayload) input.readObject();
            events.put(currentCall, paylod);
        } else {
            if (events.containsKey(currentCall) && !events.get(currentCall).isExecuted()) {
                response.setStatus(HttpServletResponse.SC_OK);
                ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream());
View Full Code Here

     * Client-to-Container event propagation
     */
    private void executePutOperation(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException {
        if (request.getContentLength() > 0) {
            ObjectInputStream input = new ObjectInputStream(new BufferedInputStream(request.getInputStream()));
            CommandPayload payload = (CommandPayload) input.readObject();
            Command operation = payload.getCommand();
            Manager manager = (Manager)request.getAttribute(ARQUILLIAN_MANAGER_ATTRIBUTE);
            // execute remote Event
            try{
                manager.fire(new ActivateManager(manager));
                manager.inject(operation);
                operation.perform();
                manager.fire(new PassivateManager(manager));
            } catch (Throwable e) {
                payload.setThrowable(e);
            }
            response.setStatus(HttpServletResponse.SC_OK);
            ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream());
            output.writeObject(payload);
            output.flush();
View Full Code Here

    private static long TIMEOUT = 30000;

    @Override
    public <T extends Command> T execute(T operation) {
        String currentId = CommandBusOnServer.getCurrentCall();
        CommandPayload payload = new CommandPayload(operation);
        CommandBusOnServer.getEvents().put(currentId, payload);

        long timeoutTime = System.currentTimeMillis() + TIMEOUT;
        while (timeoutTime > System.currentTimeMillis()) {
           CommandPayload responsePayload = CommandBusOnServer.getEvents().get(currentId);
           if (responsePayload != null && responsePayload.isExecuted()) {
               if (responsePayload.getThrowable() != null) {
                   Rethrow.asUnchecked(responsePayload.getThrowable());
               }
               return (T) responsePayload.getCommand();
           }
           try {
              Thread.sleep(100);
           }
           catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.warp.impl.shared.command.CommandPayload

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.