Package org.switchyard

Examples of org.switchyard.Context


            } else {
                connection = _connectionFactory.createConnection();
            }
            connection.start();
           
            Context context = exchange.getContext();
            session = connection.createSession(getTxEnabledFromContext(context), getAcknowledgeModeFromContext(context));
            MessageProducer producer = session.createProducer(getDestinationFromContext(session, context));
           
            Message msg;
            switch (getOutputMessageTypeFromContext(context)) {
View Full Code Here


     * @param message the message
     * @param name the name
     * @return the property
     */
    protected Object getObject(Exchange exchange, Message message, String name) {
        Context context = message != null ? exchange.getContext(message) : exchange.getContext();
        return context.getPropertyValue(name);
    }
View Full Code Here

                exchangeIn = serviceReference.createExchange(operationName, handler);
            } else {
                exchangeIn = serviceReference.createExchange(handler);
            }
            Message messageIn = exchangeIn.createMessage();
            Context contextIn = exchangeIn.getContext(messageIn);
            for (Map.Entry<String,Object> entry : request.getContext().entrySet()) {
                contextIn.setProperty(entry.getKey(), entry.getValue());
            }
            Object contentIn = request.getContent();
            if (contentIn != null) {
                messageIn.setContent(contentIn);
            }
View Full Code Here

            }
           
            if (ExchangePattern.IN_OUT.equals(exchange.getPattern())) {
                Message msg = exchange.createMessage();
                msg.setContent(reply.getContent());
                Context replyCtx = reply.getContext();
                if (replyCtx != null) {
                    replyCtx.mergeInto(exchange.getContext());
                }
                if (reply.isFault()) {
                    exchange.sendFault(msg);
                } else {
                    exchange.send(msg);
View Full Code Here

    @Test
    public void mapToTest() throws Exception {
        RESTEasyContextMapper rcm = new RESTEasyContextMapper();
        RESTEasyBindingData rbd = new RESTEasyBindingData();

        Context context = new DefaultContext();
        context.setProperty("one", Integer.valueOf(1));
       
        rcm.mapTo(context, rbd);
        Iterator<Map.Entry<String, List<String>>> entries = rbd.getHeaders().entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<String, List<String>> entry = entries.next();
            List<String> values = entry.getValue();
            Assert.assertTrue(values.size() == 1);
            Assert.assertTrue(entry.getKey().equals("one"));
            Assert.assertTrue(values.get(0).equals("1"));
        }
       
        RESTEasyBindingData rbd2 = new RESTEasyBindingData();
        context.removeProperties();
        List<Integer> list = new ArrayList<Integer>();
        list.add(Integer.valueOf(1));
        list.add(Integer.valueOf(2));
        list.add(Integer.valueOf(3));
        context.setProperty("numbers", list);
        rcm.mapTo(context, rbd2);
        entries = rbd2.getHeaders().entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<String, List<String>> entry = entries.next();
            List<String> values = entry.getValue();
View Full Code Here

            if (_connectionFactory == null) {
                return;
            }
           
            // Process replyTo and faultTo if ConnectionFactory is available
            Context context = exchange.getContext();
            Connection connection = null;
           
            try {
                if (_userName != null) {
                    connection = _connectionFactory.createConnection(_userName, _password);
View Full Code Here

                throw BPMMessages.MESSAGES.unsupportedOperationType(operationType);
            }
        }
        if (ExchangePattern.IN_OUT.equals(exchangePattern)) {
            Message outputMessage = exchange.createMessage();
            Context outputContext = exchange.getContext(outputMessage);
            if (sessionId != null && sessionId.intValue() > 0) {
                outputContext.setProperty(BPMConstants.SESSION_ID_PROPERTY, sessionId);
            }
            if (processInstanceId != null && processInstanceId.longValue() > 0) {
                outputContext.setProperty(BPMConstants.PROCESSS_INSTANCE_ID_PROPERTY, processInstanceId);
            }
            setFaults(outputMessage, operation, expressionVariables);
            if (outputMessage.getContent() != null) {
                exchange.sendFault(outputMessage);
            } else {
View Full Code Here

    public void handleMessage(SoapMessage message) throws Fault {
        if (ContextUtils.isOutbound(message)) {
            AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, true, false);
            WrappedMessageContext soapContext = new WrappedMessageContext(message, Scope.APPLICATION);
            if (soapContext.containsKey(SOAPUtil.SWITCHYARD_CONTEXT)) {
                Context context = (Context)soapContext.get(SOAPUtil.SWITCHYARD_CONTEXT);

                String property = (String)context.getPropertyValue(SOAPUtil.WSA_ACTION_STR);
                AttributedURIType uri = null;
                EndpointReferenceType ref = null;
                if (property != null) {
                    uri.setValue(property);
                    maps.setAction(uri);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_FROM_STR);
                if (property != null) {
                    uri = new AttributedURIType();
                    uri.setValue(property);
                    ref = new EndpointReferenceType();
                    ref.setAddress(uri);
                    maps.setFrom(ref);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_TO_STR);
                if (property != null) {
                    uri = new AttributedURIType();
                    uri.setValue(property);
                    ref = new EndpointReferenceType();
                    ref.setAddress(uri);
                    maps.setTo(ref);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_FAULTTO_STR);
                if (property != null) {
                    uri = new AttributedURIType();
                    uri.setValue(property);
                    ref = new EndpointReferenceType();
                    ref.setAddress(uri);
                    maps.setFaultTo(ref);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_REPLYTO_STR);
                if (property != null) {
                    uri = new AttributedURIType();
                    uri.setValue(property);
                    ref = new EndpointReferenceType();
                    ref.setAddress(uri);
                    maps.setReplyTo(ref);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_RELATESTO_STR);
                if (property != null) {
                    RelatesToType relatesTo = new RelatesToType();
                    relatesTo.setValue(property);
                    maps.setRelatesTo(relatesTo);
                }
                property = (String)context.getPropertyValue(SOAPUtil.WSA_MESSAGEID_STR);
                if (property != null) {
                    uri = new AttributedURIType();
                    uri.setValue(property);
                    maps.setMessageID(uri);
                }
View Full Code Here

    public void testInject() {
        Invoker invoker = _testKit.newInvoker("InjectService.doSomething");
        SynchronousInOutHandler handler = new SynchronousInOutHandler();
        Exchange exchange = invoker.createExchange(handler);
        Message message = exchange.createMessage();
        Context context = exchange.getContext(message);
        context.setProperty("someProp", "somePropVal");
        message.setContent("blah");
        DataSource attach = new TestDataSource("someAttach", "text/plain", "someAttachData");
        message.addAttachment(attach.getName(), attach);
        exchange.send(message);
        Exchange outExchange = handler.waitForOut();
View Full Code Here

                throw RulesMessages.MESSAGES.unsupportedOperationType(operationType.toString());
            }
        }
        if (ExchangePattern.IN_OUT.equals(exchangePattern)) {
            Message outputMessage = exchange.createMessage();
            Context outputContext = exchange.getContext(outputMessage);
            if (sessionId != null && sessionId.intValue() > 0) {
                outputContext.setProperty(RulesConstants.SESSION_ID_PROPERTY, sessionId);
            }
            setFaults(outputMessage, operation, expressionVariables);
            if (outputMessage.getContent() != null) {
                exchange.sendFault(outputMessage);
            } else {
View Full Code Here

TOP

Related Classes of org.switchyard.Context

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.