Package org.openengsb.core.api.remote

Examples of org.openengsb.core.api.remote.MethodCall


     */
    public static void main(String[] args) throws Exception {
        LOGGER.info("initializing");
        init();
        LOGGER.info("initialized");
        MethodCall methodCall =
            new MethodCall("doSomething", new Object[]{ "Hello World!" }, ImmutableMap.of("serviceId",
                "example+example+testlog", "contextId", "foo"));
        LOGGER.info("calling method");
        MethodResult methodResult = call(methodCall, "admin", "password");
        System.out.println(methodResult);

View Full Code Here


        return (Document) domResult.getNode();
    }

    private MethodCallMessage parseMethodCall(Document input) throws JAXBException {
        MethodCallMessage request = unmarshaller.unmarshal(input, MethodCallMessage.class).getValue();
        MethodCall result = request.getMethodCall();
        List<String> classNames = result.getClasses();
        Class<?>[] clazzes = new Class<?>[classNames.size()];
        ClassLoader cl = this.getClass().getClassLoader();
        for (int i = 0; i < classNames.size(); i++) {
            try {
                clazzes[i] = cl.loadClass(classNames.get(i));
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }
        JAXBContext jaxbContext = JAXBContext.newInstance(clazzes);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        Object[] args = result.getArgs();
        for (int i = 0; i < args.length; i++) {
            args[i] = unmarshaller.unmarshal((Node) args[i], clazzes[i]).getValue();
        }
        return request;
    }
View Full Code Here

        });
        setupSecurityManager();
        when(requestHandler.handleCall(any(MethodCall.class))).thenAnswer(new Answer<MethodResult>() {
            @Override
            public MethodResult answer(InvocationOnMock invocation) throws Throwable {
                MethodCall call = (MethodCall) invocation.getArguments()[0];
                return new MethodResult(call.getArgs()[0], call.getMetaData());
            }
        });

        FilterChainFactory<MethodCallMessage, MethodResultMessage> factory =
            new FilterChainFactory<MethodCallMessage, MethodResultMessage>(MethodCallMessage.class,
View Full Code Here

    protected MethodCallMessage prepareSecureRequest() {
        return prepareSecureRequest("test", new Password("password"));
    }

    private MethodCallMessage prepareSecureRequest(String username, Object credentials) {
        MethodCall methodCall = new MethodCall("doSomething", new Object[]{ METHOD_ARG, });
        MethodCallMessage request = new MethodCallMessage(methodCall, "c42");
        request.setPrincipal(username);
        request.setCredentials(BeanDescription.fromObject(credentials));
        return request;
    }
View Full Code Here

        TransformationHandler transformationHandler = TransformationHandler
                .newTransformationHandler(transformationEngine, method, connectorInterface);
        transformationHandler.getTargetMethod();
        Method targetMethod = transformationHandler.getTargetMethod();
        Object[] targetArgs = transformationHandler.transformArguments(args);
        MethodCall methodCall = new MethodCall(targetMethod, targetArgs, metadata);

        if (!registration.isRegistered()) {
            if (targetMethod.getName().equals("getAliveState")) {
                return AliveState.OFFLINE;
            }
View Full Code Here

        objectMapper = new ObjectMapper();
    }

    @Test
    public void testConvertBeanArgument_shouldConvertToBean() throws Exception {
        MethodCall methodCall = new MethodCall("test", new Object[]{ ImmutableMap.of("x", "foo") },
            Arrays.asList(TestBean.class.getName()));
        JsonUtils.convertAllArgs(methodCall);
        Object object = methodCall.getArgs()[0];
        assertThat(object, is(TestBean.class));
        assertThat(((TestBean) object).x, is("foo"));
    }
View Full Code Here

        assertThat(((TestBean) object).x, is("foo"));
    }

    @Test
    public void testConvertListArguments_shouldConvertListValue() throws Exception {
        MethodCall methodCall = new MethodCall("test", new Object[]{ new TestBean[]{ new TestBean("foo") } });
        String stringValue = objectMapper.writeValueAsString(methodCall);
        methodCall = objectMapper.readValue(stringValue, MethodCall.class);
        JsonUtils.convertAllArgs(methodCall);
        Object object = methodCall.getArgs()[0];
        assertThat(object, is(TestBean[].class));
        TestBean[] arg = (TestBean[]) object;
        assertThat(arg[0].x, is("foo"));
    }
View Full Code Here

        Object[] args = new Object[]{ "id", "test" };
        Interface newProxyInstance =
            (Interface) Proxy.newProxyInstance(Interface.class.getClassLoader(), new Class[]{ Interface.class }, proxy);
        String result = newProxyInstance.test("id", "test");

        MethodCall value = captor.getValue();
        assertThat(value.getMethodName(), equalTo("test"));
        assertThat(value.getArgs(), equalTo(args));
        assertThat(value.getMetaData().size(), equalTo(1));
        assertThat(value.getMetaData().get("key"), equalTo("value"));
        assertThat(value.getClasses().size(), equalTo(2));
        assertThat(result, equalTo("id"));
    }
View Full Code Here

    public String doFilter(String input, Map<String, Object> metadata) throws FilterException {
        ObjectMapper objectMapper = JsonUtils.createObjectMapperWithIntroSpectors();
        MethodCallMessage callMessage;
        try {
            callMessage = objectMapper.readValue(input, MethodCallMessage.class);
            MethodCall call = callMessage.getMethodCall();
            Object[] args = call.getArgs();
            for (int i = 0; i < args.length; i++) {
                String className = call.getClasses().get(i);
                Class<?> parameterClass;
                try {
                    parameterClass = getClass().getClassLoader().loadClass(className);
                } catch (ClassNotFoundException e) {
                    throw new FilterException(e);
View Full Code Here

        return requestHandler.getInvocationHistory();
    }

    public static String createCreateMessage(ConnectorDescription connectorDescription) throws IOException {
        String connectorId = "example-remote";
        MethodCall methodCall = new MethodCall("createWithId", new Object[]{ connectorId, connectorDescription });
        Map<String, String> metaData = new HashMap<String, String>();
        metaData.put("serviceId", "connectorManager");
        methodCall.setMetaData(metaData);
        MethodCallMessage methodCallRequest = new MethodCallMessage(methodCall, false);
        BeanDescription auth = BeanDescription.fromObject(new Password("password"));
        methodCallRequest.setPrincipal("admin");
        methodCallRequest.setCredentials(auth);
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.remote.MethodCall

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.