Package org.springframework.remoting.httpinvoker

Examples of org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration


          // the remote transaction a message to rollback.
          String action = commit ? TransactionMgr.COMMIT_TXN : TransactionMgr.ROLLBACK_TXN;
          for (Object invokerObject : transactionData.distributedInvokers) {
            if (invokerObject instanceof HttpInvokerClientConfiguration) {
             
              HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
              HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
              RemoteInvocation call = new RemoteInvocation(action, new Class<?>[0], new Object[0]);
              call.addAttribute(TXN_ID, transactionData.distributedTransactionID);
              try {
                nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
              }
              catch (Exception e) {
                _log.error("Completing distributed transaction failed", e);
              }
            }
            else if (invokerObject instanceof ServiceProxy) {
              ServiceProxy invoker = (ServiceProxy)invokerObject;
              FrameworkUtils.setAppContext(TXN_ID, transactionData.distributedTransactionID);
              invoker.intercept(action, (Object[])null);
              FrameworkUtils.setAppContext(TXN_ID, null);
            }
          }
        }
    }
View Full Code Here


            // If we're the current invoker, then this must have been caused by the remote invocation
            // to which current invoker points aborting the transaction, in which case we don't neeed
            // to re-tell it to abort the transaction
            if (invokerObject != rootData.currentInvoker) {
              if (invokerObject instanceof HttpInvokerClientConfiguration) {
                HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
                HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
                RemoteInvocation call = new RemoteInvocation(ABORT_TXN, new Class<?>[0], new Object[0]);
                  call.addAttribute(TXN_ID, rootData.distributedTransactionID);
                try {
                  nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
                }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
              }
                else if (invokerObject instanceof ServiceProxy) {
                  ServiceProxy invoker = (ServiceProxy)invokerObject;
                  FrameworkUtils.setAppContext(TXN_ID, rootData.distributedTransactionID);
                  try {
                    invoker.intercept(ABORT_TXN, (Object[])null);
                  }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
                  FrameworkUtils.setAppContext(TXN_ID, null);
View Full Code Here

          // the remote transaction a message to rollback.
          String action = commit ? TransactionMgr.COMMIT_TXN : TransactionMgr.ROLLBACK_TXN;
          for (Object invokerObject : transactionData.distributedInvokers) {
            if (invokerObject instanceof HttpInvokerClientConfiguration) {
             
              HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
              HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
              RemoteInvocation call = new RemoteInvocation(action, new Class<?>[0], new Object[0]);
              call.addAttribute(TXN_ID, transactionData.distributedTransactionID);
              try {
                nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
              }
              catch (Exception e) {
                _log.error("Completing distributed transaction failed", e);
              }
            }
            else if (invokerObject instanceof ServiceProxy) {
              ServiceProxy invoker = (ServiceProxy)invokerObject;
              FrameworkUtils.setAppContext(TXN_ID, transactionData.distributedTransactionID);
              invoker.intercept(action, (Object[])null);
              FrameworkUtils.setAppContext(TXN_ID, null);
            }
          }
        }
    }
View Full Code Here

            // If we're the current invoker, then this must have been caused by the remote invocation
            // to which current invoker points aborting the transaction, in which case we don't neeed
            // to re-tell it to abort the transaction
            if (invokerObject != rootData.currentInvoker) {
              if (invokerObject instanceof HttpInvokerClientConfiguration) {
                HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
                HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
                RemoteInvocation call = new RemoteInvocation(ABORT_TXN, new Class<?>[0], new Object[0]);
                  call.addAttribute(TXN_ID, rootData.distributedTransactionID);
                try {
                  nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
                }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
              }
                else if (invokerObject instanceof ServiceProxy) {
                  ServiceProxy invoker = (ServiceProxy)invokerObject;
                  FrameworkUtils.setAppContext(TXN_ID, rootData.distributedTransactionID);
                  try {
                    invoker.intercept(ABORT_TXN, (Object[])null);
                  }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
                  FrameworkUtils.setAppContext(TXN_ID, null);
View Full Code Here

          // the remote transaction a message to rollback.
          String action = commit ? TransactionMgr.COMMIT_TXN : TransactionMgr.ROLLBACK_TXN;
          for (Object invokerObject : transactionData.distributedInvokers) {
            if (invokerObject instanceof HttpInvokerClientConfiguration) {
             
              HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
              HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
              RemoteInvocation call = new RemoteInvocation(action, new Class<?>[0], new Object[0]);
              call.addAttribute(TXN_ID, transactionData.distributedTransactionID);
              try {
                nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
              }
              catch (Exception e) {
                _log.error("Completing distributed transaction failed", e);
              }
            }
            else if (invokerObject instanceof ServiceProxy) {
              ServiceProxy invoker = (ServiceProxy)invokerObject;
              FrameworkUtils.setAppContext(TXN_ID, transactionData.distributedTransactionID);
              invoker.intercept(action, (Object[])null);
              FrameworkUtils.setAppContext(TXN_ID, null);
            }
          }
        }
    }
View Full Code Here

            // If we're the current invoker, then this must have been caused by the remote invocation
            // to which current invoker points aborting the transaction, in which case we don't neeed
            // to re-tell it to abort the transaction
            if (invokerObject != rootData.currentInvoker) {
              if (invokerObject instanceof HttpInvokerClientConfiguration) {
                HttpInvokerClientConfiguration invoker = (HttpInvokerClientConfiguration)invokerObject;
                HttpInvokerRequestExecutor nestedHttpInvokerRequestExecutor = new SimpleHttpInvokerRequestExecutor();
                RemoteInvocation call = new RemoteInvocation(ABORT_TXN, new Class<?>[0], new Object[0]);
                  call.addAttribute(TXN_ID, rootData.distributedTransactionID);
                try {
                  nestedHttpInvokerRequestExecutor.executeRequest(invoker, call);
                }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
              }
                else if (invokerObject instanceof ServiceProxy) {
                  ServiceProxy invoker = (ServiceProxy)invokerObject;
                  FrameworkUtils.setAppContext(TXN_ID, rootData.distributedTransactionID);
                  try {
                    invoker.intercept(ABORT_TXN, (Object[])null);
                  }
                catch (Exception e) {
                  _log.error("Aborting distributed transaction failed", e);
                }
                  FrameworkUtils.setAppContext(TXN_ID, null);
View Full Code Here

    public void testSuccessfulRemoteInvocation() throws Exception {
        TestInvoker invoker = new TestInvoker(Long.valueOf(System.currentTimeMillis()));
        RemoteInvocation invocation = invoker.createRemoteInvocation("testSuccessfulRemoteInvocation");
        invocation.setAttributes(Collections.singletonMap("testSuccessfulRemoteInvocation", (Serializable) Long.valueOf(System.currentTimeMillis())));

        HttpInvokerClientConfiguration config =
                createMockConfiguration(invocation.getMethodName(), "http://hello/world", "http://here/testSuccessfulRemoteInvocation");
        RemoteInvocationResult result = invoker.executeRequest(config, invocation);
        Operation op = assertRemotingOperation(config, invocation, result);
        ExternalResourceDescriptor desc = assertExternalResource(op);
        assertNull("Unexpected external descriptor: " + desc, desc);
View Full Code Here

    public void testFailedRemoteInvocation() throws Exception {
        TestInvoker invoker = new TestInvoker(new UnsupportedOperationException("testFailedRemoteInvocation"));
        RemoteInvocation invocation = invoker.createRemoteInvocation("testFailedRemoteInvocation");
        invocation.setAttributes(Collections.singletonMap("testFailedRemoteInvocation", (Serializable) Long.valueOf(System.currentTimeMillis())));

        HttpInvokerClientConfiguration config =
                createMockConfiguration(invocation.getMethodName(), "http://goodbye/world", "http://there/testFailedRemoteInvocation");
        RemoteInvocationResult result = invoker.executeRequest(config, invocation);
        Operation op = assertRemotingOperation(config, invocation, result);
        ExternalResourceDescriptor desc = assertExternalResource(op);
        assertNull("Unexpected external descriptor: " + desc, desc);
View Full Code Here

    protected static HttpInvokerClientConfiguration createMockConfiguration(String path, String... codebaseUrls) {
        return createMockConfiguration(path, (ArrayUtil.length(codebaseUrls) <= 0) ? Collections.<String>emptyList() : Arrays.asList(codebaseUrls));
    }

    protected static HttpInvokerClientConfiguration createMockConfiguration(String path, Collection<String> codebaseUrls) {
        HttpInvokerClientConfiguration config = Mockito.mock(HttpInvokerClientConfiguration.class);
        Mockito.when(config.getServiceUrl()).thenReturn(TEST_URL + "/" + path);
        Mockito.when(config.getCodebaseUrl()).thenReturn(StringUtil.implode(codebaseUrls, " "));
        return config;
    }
View Full Code Here

    @Test
    public void testSimpleHttpInvokerRequestExecutor() throws Exception {
        RemoteInvocation invocation =
                new RemoteInvocation("testSimpleHttpInvokerRequestExecutor", new Class[]{Long.class}, new Object[]{Long.valueOf(System.nanoTime())});
        TestingSimpleHttpInvokerRequestExecutor executor = new TestingSimpleHttpInvokerRequestExecutor(invocation.getMethodName());
        HttpInvokerClientConfiguration config = createMockConfiguration(executor.getColor(), ArrayUtil.EMPTY_STRINGS);
        RemoteInvocationResult result = executor.executeRequest(config, invocation);
        Object value = result.getValue();
        assertNotNull("No result value", value);
        assertTrue("Bad result value type: " + value.getClass().getSimpleName(), value instanceof RemoteInvocation);
View Full Code Here

TOP

Related Classes of org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration

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.