org.switchyard.Property - java examples

Here are the examples of the java api org.switchyard.Property taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

72 Examples 7

19 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperties(Scope scope) {
    for (Property property : getProperties(scope)) {
        removeProperty(property);
    }
}

19 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Property getProperty(String name) {
    Property property = getProperty(name, Scope.MESSAGE);
    return property == null ? getProperty(name, Scope.EXCHANGE) : property;
}

19 View Complete Implementation : SOAPContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public void mapTo(Context context, SOAPBindingData target) throws Exception {
    super.mapTo(context, target);
    SOAPMessage soapMessage = target.getSOAPMessage();
    SOAPHeader soapHeader = soapMessage.getSOAPHeader();
    for (Property property : context.getProperties(Scope.EXCHANGE)) {
        target = mapToExchangeScope(property, soapHeader, target);
    }
    for (Property property : context.getProperties(Scope.MESSAGE)) {
        target = mapToMessageScope(property, soapHeader, target);
    }
}

19 View Complete Implementation : SymbolServiceImpl.java
Copyright Apache License 2.0
Author : jboss-switchyard
public String getSymbol(String companyName) {
    String symbol = "";
    if (companyName.equals("headers")) {
        StringBuffer headers = new StringBuffer();
        for (Property property : context.getProperties(Scope.MESSAGE)) {
            if (property.hasLabel(EndpointLabel.HTTP.label()) && (property.getValue() instanceof String)) {
                headers.append(property.getName());
                headers.append("=");
                headers.append(property.getValue());
            }
        }
        return headers.toString();
    }
    if (companyName.equals("requestInfo")) {
        Property prop = context.getProperty(HttpComposition.HTTP_REQUEST_INFO);
        return ((HttpRequestInfo) prop.getValue()).toString();
    }
    // Note the property becomes lower cased when executed on AS7
    Property prop = context.getProperty("content-type");
    if (prop == null) {
        prop = context.getProperty("Content-type");
    }
    if (prop == null) {
        prop = context.getProperty("Content-Type");
    }
    String contentType = (prop == null) ? null : (String) prop.getValue();
    if (contentType != null) {
        if (contentType.contains("text/plain")) {
            if (companyName.equalsIgnoreCase("vineyard")) {
                symbol = "WINE";
            }
        }
    }
    // TODO: Currently not possible to set property on return path for CDI Beans
    /*if (symbol.equals("")) {
            context.setProperty(HttpContextMapper.HTTP_RESPONSE_STATUS, 404).addLabels(new String[]{EndpointLabel.HTTP.label()});
        }*/
    return symbol;
}

19 View Complete Implementation : CamelCompositeContextTest.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Test
public void testHeaderCaseSensitivityFromExchange() throws Exception {
    String lowerCaseHeaderKey = "lowercase_header";
    String lowerCaseHeaderValue = "lowercase_value";
    String mixedCaseHeaderKey = "mixedCASE_HEADER";
    String mixedCaseHeaderValue = "mixedCASE_VALUE";
    String upperCaseHeaderKey = "UPPERCASE_HEADER";
    String upperCaseHeaderValue = "UPPERCASE_VALUE";
    DefaultMessage message = new DefaultMessage();
    message.setHeader(lowerCaseHeaderKey, lowerCaseHeaderValue);
    message.setHeader(mixedCaseHeaderKey, mixedCaseHeaderValue);
    message.setHeader(upperCaseHeaderKey, upperCaseHeaderValue);
    CamelCompositeContext ctx = new CamelCompositeContext(new DefaultExchange(new SwitchYardCamelContextImpl(false)), message);
    boolean foundLowerCaseValue = false;
    boolean foundMixedCaseValue = false;
    boolean foundUpperCaseValue = false;
    for (Property p : ctx.getProperties(Scope.MESSAGE)) {
        System.out.println(p.getName() + "=>" + p.getValue());
        if (lowerCaseHeaderKey.equals(p.getName())) {
            foundLowerCaseValue = true;
        }
        if (mixedCaseHeaderKey.equals(p.getName())) {
            foundMixedCaseValue = true;
        }
        if (upperCaseHeaderKey.equals(p.getName())) {
            foundUpperCaseValue = true;
        }
    }
    if (!foundLowerCaseValue || !foundMixedCaseValue || !foundUpperCaseValue) {
        StringBuilder failMessage = new StringBuilder();
        failMessage.append("Could not find MESSAGE-scoped properties: ");
        if (!foundLowerCaseValue) {
            failMessage.append(lowerCaseHeaderKey);
            failMessage.append(", ");
        }
        if (!foundMixedCaseValue) {
            failMessage.append(mixedCaseHeaderKey);
            failMessage.append(", ");
        }
        if (!foundUpperCaseValue) {
            failMessage.append(upperCaseHeaderKey);
            failMessage.append(", ");
        }
        failMessage.delete(failMessage.length() - 2, failMessage.length() - 1);
        replacedert.fail(failMessage.toString());
    }
}

19 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public Object remove(Object key) {
    if (key != null) {
        Property property = getProperty(key.toString(), _scope);
        if (property != null) {
            removeProperty(property);
            return property.getValue();
        }
    }
    return null;
}

19 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Set<Property> getProperties(String label) {
    Set<Property> properties = new HashSet<Property>();
    for (Property property : getProperties()) {
        if (property.hasLabel(label)) {
            properties.add(property);
        }
    }
    return properties;
}

19 View Complete Implementation : SOAPUtil.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * Get the To header if it is set.
 *
 * @param context The SwitchYard Context
 * @return The To address
 */
public static String getToAddress(Context context) {
    String address = null;
    Property toProp = context.getProperty(WSA_TO_STR);
    if (toProp == null) {
        toProp = context.getProperty(WSA_TO_STR.toLowerCase());
    }
    if (toProp != null) {
        Element toEl = (Element) toProp.getValue();
        address = toEl.getFirstChild().getNodeValue();
    }
    return address;
}

19 View Complete Implementation : CamelPropertyBase.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClreplaced() != obj.getClreplaced()) {
        return false;
    }
    Property other = (Property) obj;
    if (getName() == null) {
        if (other.getName() != null) {
            return false;
        }
    } else if (!getName().equals(other.getName())) {
        return false;
    }
    if (getScope() != other.getScope()) {
        return false;
    }
    if (getValue() == null) {
        if (other.getValue() != null) {
            return false;
        }
    } else if (!getValue().equals(other.getValue())) {
        return false;
    }
    return true;
}

19 View Complete Implementation : ContextProxy.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public void removeProperty(Property property) {
    getContext().removeProperty(property);
}

19 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperties(String label) {
    for (Property p : getProperties()) {
        if (p.hasLabel(label)) {
            removeProperty(p);
        }
    }
}

19 View Complete Implementation : CompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperty(Property property) {
    for (Entry<Scope, Context> entry : _contexts.entrySet()) {
        if (entry.getKey() == property.getScope()) {
            entry.getValue().removeProperty(property);
        }
    }
}

19 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperties(String label) {
    for (Property property : getProperties()) {
        if (property.hasLabel(label)) {
            removeProperty(property);
        }
    }
}

19 View Complete Implementation : JCAJMSServiceImpl.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void onMessage(String name) {
    if (!name.equals("onMessagetest")) {
        throw new RuntimeException("expected content is 'onMessagetest' but was '" + name + "'");
    }
    final String val = _context.getProperty("testProp").getValue().toString();
    if (!val.equals("testVal")) {
        throw new RuntimeException("'testProp' property is '" + val + "' while it should be 'testVal'");
    }
    ;
    Property jmsMessageId = _context.getProperty(JMSContextMapper.HEADER_JMS_MESSAGE_ID);
    if (jmsMessageId == null) {
        throw new RuntimeException("Couldn't find javax.jms.JMSMessageID context property");
    }
    if (!jmsMessageId.hasLabel(PropertyLabel.HEADER.label())) {
        throw new RuntimeException("javax.jmsJMSMessageID context property doesn't have HEADER label");
    }
    if (jmsMessageId.getValue().toString() == null) {
        throw new RuntimeException("javax.jmsJMSMessageID context property has null value");
    }
    ;
    _storeResult.onMessage(name);
}

19 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public boolean containsValue(Object value) {
    if (value != null) {
        for (Property property : getProperties(_scope)) {
            if (value.equals(property.getValue())) {
                return true;
            }
        }
    }
    return false;
}

19 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public Object get(Object key) {
    if (key != null) {
        Property property = getProperty(key.toString(), _scope);
        if (property != null) {
            return property.getValue();
        }
    }
    return null;
}

19 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperties() {
    for (Property property : getProperties()) {
        removeProperty(property);
    }
}

19 View Complete Implementation : ContextUtil.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * Copy properties from source context to destination context. Properties with
 * TRANSIENT label will be skipped.
 *
 * @param source Source context.
 * @param destination Destination context.
 * @return Destination context.
 */
public static Context copy(Context source, Context destination) {
    for (Property property : source.getProperties()) {
        if (!property.hasLabel(BehaviorLabel.TRANSIENT.label())) {
            destination.setProperty(property.getName(), property.getValue()).addLabels(property.getLabels());
        }
    }
    return destination;
}

18 View Complete Implementation : PropertyAccessor.java
Copyright Apache License 2.0
Author : Governance
/**
 * {@inheritDoc}
 */
@Override
public Set<String> keySet() {
    java.util.Set<String> ret = new java.util.HashSet<String>();
    if (_context != null) {
        for (Property prop : _context.getProperties(Scope.MESSAGE)) {
            ret.add(prop.getName());
        }
    }
    return (ret);
}

18 View Complete Implementation : ExchangeMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * Map from SwitchYard context property to camel exchange property or camel message header.
 * @param syContext switchyard context
 * @param camelExchange camel exchange
 * @param camelMessage camel message
 */
public static void mapSwitchYardPropertiesToCamel(org.switchyard.Context syContext, org.apache.camel.Exchange camelExchange, org.apache.camel.Message camelMessage) {
    for (Property property : syContext.getProperties()) {
        if (property.hasLabel(BehaviorLabel.TRANSIENT.label()) || ContextPropertyUtil.isReservedProperty(property.getName(), property.getScope())) {
            continue;
        }
        if (Scope.EXCHANGE.equals(property.getScope())) {
            camelExchange.setProperty(property.getName(), property.getValue());
        } else if (camelMessage != null) {
            camelMessage.setHeader(property.getName(), property.getValue());
        }
    }
}

18 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public Collection<Object> values() {
    Collection<Object> values = new ArrayList<Object>();
    for (Property property : getProperties(_scope)) {
        values.add(property.getValue());
    }
    return values;
}

18 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public void removeProperty(Property property) {
    _context.removeProperty(property);
}

18 View Complete Implementation : SOAPContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
private void copyToSOAPHeader(SOAPHeader soapHeader, Property property) throws IOException, SOAPException {
    if ((property != null) && (matches(property.getName(), getIncludeRegexes(), new ArrayList<Pattern>()))) {
        String v = property.getValue().toString();
        QName qname = new QName(HEADER_NAMESPACE_PROPAGATION, property.getName());
        if (SOAPHeadersType.XML.equals(_soapHeadersType)) {
            try {
                Element xmlElement = new ElementPuller().pull(new StringReader(v));
                Node xmlNode = soapHeader.getOwnerDoreplacedent().importNode(xmlElement, true);
                soapHeader.appendChild(xmlNode);
            } catch (Throwable t) {
                soapHeader.addChildElement(qname).setValue(v);
            }
        } else {
            soapHeader.addChildElement(qname).setValue(v);
        }
    }
}

18 View Complete Implementation : TransformSequence.java
Copyright Apache License 2.0
Author : jboss-switchyard
private static TransformSequence get(final Exchange exchange) {
    Property sequenceProperty = exchange.getContext().getProperty(TransformSequence.clreplaced.getName());
    if (sequenceProperty != null) {
        return (TransformSequence) sequenceProperty.getValue();
    } else {
        return null;
    }
}

18 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void mergeInto(Context context) {
    for (Property property : getProperties()) {
        if (ContextPropertyUtil.isReservedProperty(property.getName(), property.getScope()) || property.hasLabel(BehaviorLabel.TRANSIENT.label())) {
            continue;
        }
        context.setProperty(property.getName(), property.getValue(), property.getScope()).addLabels(property.getLabels());
    }
}

18 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Context setProperties(Set<Property> properties) {
    for (Property property : properties) {
        Set<String> labels = property.getLabels();
        setProperty(property.getName(), property.getValue(), property.getScope()).addLabels(labels.toArray(new String[labels.size()]));
    }
    return this;
}

18 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
@SuppressWarnings("unchecked")
public <T> T getPropertyValue(String name) {
    Property property = getProperty(name);
    return property == null ? null : (T) property.getValue();
}

18 View Complete Implementation : TransactionHandler.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void handleFault(Exchange exchange) {
    // if no TM is available, there's nothing to do
    if (_transactionManager == null) {
        return;
    }
    try {
        Property rollbackOnFaultProperty = exchange.getContext().getProperty(Exchange.ROLLBACK_ON_FAULT);
        if (rollbackOnFaultProperty != null && rollbackOnFaultProperty.getValue() != null && Boolean.clreplaced.cast(rollbackOnFaultProperty.getValue())) {
            Transaction transaction = getCurrentTransaction();
            if (transaction != null) {
                transaction.setRollbackOnly();
            }
        }
        handleAfter(exchange);
    } catch (Exception e) {
        _log.error(e);
    }
}

18 View Complete Implementation : CompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Context setProperties(Set<Property> properties) {
    for (Property property : properties) {
        setProperty(property.getName(), property.getValue(), property.getScope());
    }
    return this;
}

18 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
@SuppressWarnings("unchecked")
public <T> T getPropertyValue(String name) {
    Property prop = _properties.get(name);
    if (prop != null) {
        return (T) prop.getValue();
    }
    return null;
}

18 View Complete Implementation : ExchangeFormatter.java
Copyright Apache License 2.0
Author : jboss-switchyard
private static void dumpContext(StringBuilder summary, Set<Property> properties) {
    Set<Property> orderedProperties = new TreeSet<Property>(new Comparator<Property>() {

        public int compare(Property p1, Property p2) {
            return p1.getName().compareTo(p2.getName());
        }
    });
    int maxLength = 0;
    for (Property property : properties) {
        int curLength = property.getName().length();
        if (curLength > maxLength) {
            maxLength = curLength;
        }
        orderedProperties.add(property);
    }
    for (Property orderedProperty : orderedProperties) {
        String name = orderedProperty.getName();
        int difLength = maxLength - name.length();
        String pad = difLength > 0 ? Strings.repeat(".", difLength) : "";
        summary.append(indent(1) + name + " " + pad + ": " + orderedProperty.getValue());
    }
}

17 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public Set<Entry<String, Object>> entrySet() {
    Map<String, Object> entries = new HashMap<String, Object>();
    for (Property property : getProperties(_scope)) {
        entries.put(property.getName(), property.getValue());
    }
    return entries.entrySet();
}

17 View Complete Implementation : SOAPContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
public SOAPBindingData mapToMessageScope(Property property, SOAPHeader soapHeader, SOAPBindingData data) throws Exception {
    Object value = property.getValue();
    SOAPBindingData target = data;
    if (value != null) {
        String name = property.getName();
        QName qname = XMLHelper.createQName(name);
        boolean qualifiedForSoapHeader = Strings.trimToNull(qname.getNamespaceURI()) != null;
        if (qualifiedForSoapHeader && matches(qname)) {
            if (value instanceof Node) {
                Node domNode = soapHeader.getOwnerDoreplacedent().importNode((Node) value, true);
                soapHeader.appendChild(domNode);
            } else if (value instanceof Configuration) {
                Element configElement = new ElementPuller().pull(new StringReader(value.toString()));
                Node configNode = soapHeader.getOwnerDoreplacedent().importNode(configElement, true);
                soapHeader.appendChild(configNode);
            } else {
                String v = value.toString();
                if (SOAPHeadersType.XML.equals(_soapHeadersType)) {
                    try {
                        Element xmlElement = new ElementPuller().pull(new StringReader(v));
                        Node xmlNode = soapHeader.getOwnerDoreplacedent().importNode(xmlElement, true);
                        soapHeader.appendChild(xmlNode);
                    } catch (Throwable t) {
                        soapHeader.addChildElement(qname).setValue(v);
                    }
                } else {
                    soapHeader.addChildElement(qname).setValue(v);
                }
            }
        } else if (matches(name) || property.hasLabel(EndpointLabel.HTTP.label())) {
            if (HTTP_RESPONSE_STATUS.equalsIgnoreCase(name)) {
                if (value instanceof String) {
                    target.setStatus(Integer.parseInt((String) value));
                } else if (value instanceof Integer) {
                    target.setStatus((Integer) value);
                }
            } else if (HTTP_HEADERS_EXCLUDED.contains(name.toLowerCase())) {
            // Excluding HTTP headers which should not be set manually
            } else {
                if (value instanceof List) {
                    List<String> stringValues = new ArrayList<String>();
                    for (Object v : List.clreplaced.cast(value)) {
                        if (v == null || v instanceof String) {
                            stringValues.add((String) v);
                        }
                    }
                    if (!stringValues.isEmpty()) {
                        target.getHttpHeaders().put(name, stringValues);
                    }
                } else if (value instanceof String) {
                    target.getHttpHeaders().put(name, Collections.singletonList((String) value));
                }
            }
        } else {
            copyToSOAPHeader(soapHeader, property);
        }
    }
    return target;
}

17 View Complete Implementation : SOAPContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
public SOAPBindingData mapToExchangeScope(Property property, SOAPHeader soapHeader, SOAPBindingData data) throws Exception {
    Object value = property.getValue();
    SOAPBindingData target = data;
    if (value != null) {
        String name = property.getName();
        QName qname = XMLHelper.createQName(name);
        boolean qualifiedForSoapHeader = Strings.trimToNull(qname.getNamespaceURI()) != null;
        if (qualifiedForSoapHeader && matches(qname)) {
            if (value instanceof Node) {
                Node domNode = soapHeader.getOwnerDoreplacedent().importNode((Node) value, true);
                soapHeader.appendChild(domNode);
            } else if (value instanceof Configuration) {
                Element configElement = new ElementPuller().pull(new StringReader(value.toString()));
                Node configNode = soapHeader.getOwnerDoreplacedent().importNode(configElement, true);
                soapHeader.appendChild(configNode);
            } else {
                String v = value.toString();
                if (SOAPHeadersType.XML.equals(_soapHeadersType)) {
                    try {
                        Element xmlElement = new ElementPuller().pull(new StringReader(v));
                        Node xmlNode = soapHeader.getOwnerDoreplacedent().importNode(xmlElement, true);
                        soapHeader.appendChild(xmlNode);
                    } catch (Throwable t) {
                        soapHeader.addChildElement(qname).setValue(v);
                    }
                } else {
                    soapHeader.addChildElement(qname).setValue(v);
                }
            }
        } else if (matches(name) || property.hasLabel(EndpointLabel.HTTP.label())) {
            if (HTTP_RESPONSE_STATUS.equalsIgnoreCase(name)) {
                if (value instanceof String) {
                    target.setStatus(Integer.parseInt((String) value));
                } else if (value instanceof Integer) {
                    target.setStatus((Integer) value);
                }
            } else if (HTTP_HEADERS_EXCLUDED.contains(name.toLowerCase())) {
            // Excluding HTTP headers which should not be set manually
            } else {
                if (value instanceof List) {
                    List<String> stringValues = new ArrayList<String>();
                    for (Object v : List.clreplaced.cast(value)) {
                        if (v == null || v instanceof String) {
                            stringValues.add((String) v);
                        }
                    }
                }
            }
        } else {
            copyToSOAPHeader(soapHeader, property);
        }
    }
    return target;
}

17 View Complete Implementation : SOAPContextMapperTest.java
Copyright Apache License 2.0
Author : jboss-switchyard
// SWITCHYARD-2969
@Test
public void testHTTPHeaderMessageScopeMapping() throws Exception {
    // Test that HTTP headers are added to message scope but not to exchange scope
    SOAPContextMapper mapper = new SOAPContextMapper();
    mapper.setSOAPHeadersType(SOAPHeadersType.XML);
    // test mapFrom
    SOAPMessage sourceMessage = newSourceMessage();
    Context targetContext = newContext();
    SOAPBindingData data = new SOAPBindingData(sourceMessage);
    Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
    ArrayList<String> values = new ArrayList<String>();
    values.add("foo");
    httpHeaders.put("bar", values);
    data.setHttpHeaders(httpHeaders);
    mapper.mapFrom(data, targetContext);
    Set<Property> msgProperties = targetContext.getProperties(Scope.MESSAGE);
    boolean found = false;
    for (Property msg : msgProperties) {
        if (msg.getName().equals("bar")) {
            found = true;
        }
    }
    replacedert.replacedertTrue(found);
    Set<Property> exchProperties = targetContext.getProperties(Scope.EXCHANGE);
    found = false;
    for (Property msg : exchProperties) {
        if (msg.getName().equals("bar")) {
            found = true;
        }
    }
    replacedert.replacedertFalse(found);
}

17 View Complete Implementation : MessageMetricsCollectionTest.java
Copyright Apache License 2.0
Author : jboss-switchyard
private void defaultExpectations(Exchange ex) {
    when(ex.getConsumer().getName()).thenReturn(TEST_SERVICE);
    when(ex.getProvider().getName()).thenReturn(TEST_PROMOTED_SERVICE);
    when(ex.getState()).thenReturn(ExchangeState.OK);
    Property property = mock(Property.clreplaced);
    when(property.getValue()).thenReturn(new Long(10));
    when(ex.getContext().getProperty(ExchangeCompletionEvent.EXCHANGE_DURATION)).thenReturn(property);
}

17 View Complete Implementation : PolicyUtil.java
Copyright Apache License 2.0
Author : jboss-switchyard
@SuppressWarnings("unchecked")
private static Set<Policy> getPolicies(Exchange exchange, String propertyName) {
    Property intentsProperty = exchange.getContext().getProperty(propertyName, Scope.EXCHANGE);
    Set<Policy> intents = new HashSet<Policy>();
    if (intentsProperty != null) {
        intents.addAll((Set<Policy>) intentsProperty.getValue());
    }
    return intents;
}

17 View Complete Implementation : CamelCompositeContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperty(Property property) {
    switch(property.getScope()) {
        case EXCHANGE:
            _exchange.removeProperty(property.getName());
            break;
        default:
            _message.removeHeader(property.getName());
            break;
    }
}

17 View Complete Implementation : TransactionHandler.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void handleMessage(Exchange exchange) throws TransactionFailureException {
    // if no TM is available, there's nothing to do
    if (_transactionManager == null) {
        return;
    }
    Property prop = exchange.getContext().getProperty(BEFORE_INVOKED_PROPERTY, Scope.EXCHANGE);
    if (prop != null && Boolean.clreplaced.cast(prop.getValue())) {
        // OUT phase in IN_OUT exchange or 2nd invocation in IN_ONLY exchange
        handleAfter(exchange);
    } else {
        exchange.getContext().setProperty(BEFORE_INVOKED_PROPERTY, Boolean.TRUE, Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label());
        handleBefore(exchange);
    }
}

17 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public void removeProperty(Property property) {
    checkScope(_scope, property.getScope());
    _properties.remove(property.getName());
}

17 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Property setProperty(String name, Object val) {
    Property p = new ContextProperty(name, _scope, val);
    _properties.put(p.getName(), p);
    return p;
}

17 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Context setProperties(Set<Property> properties) {
    for (Property p : properties) {
        _properties.put(p.getName(), p);
    }
    return this;
}

17 View Complete Implementation : DefaultContext.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Override
public Set<Property> getProperties(String label) {
    Set<Property> props = new HashSet<Property>();
    for (Property p : getProperties()) {
        if (p.hasLabel(label)) {
            props.add(p);
        }
    }
    return props;
}

17 View Complete Implementation : CamelTransformer.java
Copyright Apache License 2.0
Author : jboss-switchyard
private void copyProperties(Context context, Exchange exchange) {
    for (Property property : context.getProperties()) {
        if (property.hasLabel(BehaviorLabel.TRANSIENT.label()) || ContextPropertyUtil.isReservedProperty(property.getName(), property.getScope())) {
            continue;
        }
        if (Scope.EXCHANGE.equals(property.getScope())) {
            exchange.setProperty(property.getName(), property.getValue());
        } else {
            exchange.getIn().setHeader(property.getName(), property.getValue());
        }
    }
}

16 View Complete Implementation : ContextMap.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public Set<String> keySet() {
    Set<String> keySet = new HashSet<String>();
    for (Property property : getProperties(_scope)) {
        keySet.add(property.getName());
    }
    return keySet;
}

16 View Complete Implementation : HttpContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public void mapTo(Context context, HttpBindingData target) throws Exception {
    super.mapTo(context, target);
    Map<String, List<String>> httpHeaders = target.getHeaders();
    for (Property property : context.getProperties()) {
        String name = property.getName();
        Object value = property.getValue();
        if ((value != null) && (matches(name) || property.hasLabel(EndpointLabel.HTTP.label()))) {
            if (HTTP_RESPONSE_STATUS.equalsIgnoreCase(name) && (target instanceof HttpResponseBindingData)) {
                HttpResponseBindingData response = (HttpResponseBindingData) target;
                if (value instanceof String) {
                    response.setStatus(Integer.parseInt((String) value));
                } else if (value instanceof Integer) {
                    response.setStatus((Integer) value);
                }
            } else {
                if (value instanceof List) {
                    // We need to check through the list for non-string values and map .toString()
                    // values to those entries
                    List<String> vals = new ArrayList<String>();
                    List valueList = (List) value;
                    for (Object obj : valueList) {
                        if (obj instanceof String) {
                            vals.add((String) obj);
                        } else {
                            vals.add(obj.toString());
                        }
                    }
                    httpHeaders.put(name, vals);
                } else if (value instanceof String) {
                    List<String> list = new ArrayList<String>();
                    list.add(String.valueOf(value));
                    httpHeaders.put(name, list);
                }
            }
        } else if ((value != null) && matches(name, getIncludeRegexes(), new ArrayList<Pattern>())) {
            if (value instanceof List) {
                // We need to check through the list for non-string values and map .toString()
                // values to those entries
                List<String> vals = new ArrayList<String>();
                List valueList = (List) value;
                for (Object obj : valueList) {
                    if (obj instanceof String) {
                        vals.add((String) obj);
                    } else {
                        vals.add(obj.toString());
                    }
                }
                httpHeaders.put(name, vals);
            } else if (value instanceof String) {
                List<String> list = new ArrayList<String>();
                list.add(String.valueOf(value));
                httpHeaders.put(name, list);
            }
        }
    }
}

16 View Complete Implementation : JMSContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
public void mapTo(Context context, JMSBindingData target) throws Exception {
    super.mapTo(context, target);
    Message message = target.getMessage();
    for (Property property : context.getProperties()) {
        String name = property.getName();
        if (matches(name)) {
            Object value = property.getValue();
            if (value == null) {
                continue;
            }
            try {
                // process JMS headers
                if (name.equals(HEADER_JMS_DESTINATION)) {
                    message.setJMSDestination(Destination.clreplaced.cast(value));
                } else if (name.equals(HEADER_JMS_DELIVERY_MODE)) {
                    message.setJMSDeliveryMode(Integer.parseInt(value.toString()));
                } else if (name.equals(HEADER_JMS_EXPIRATION)) {
                    message.setJMSExpiration(Long.parseLong(value.toString()));
                } else if (name.equals(HEADER_JMS_PRIORITY)) {
                    message.setJMSPriority(Integer.parseInt(value.toString()));
                } else if (name.equals(HEADER_JMS_MESSAGE_ID)) {
                    message.setJMSMessageID(value.toString());
                } else if (name.equals(HEADER_JMS_TIMESTAMP)) {
                    message.setJMSTimestamp(Long.parseLong(value.toString()));
                } else if (name.equals(HEADER_JMS_CORRELATION_ID)) {
                    message.setJMSCorrelationID(value.toString());
                } else if (name.equals(HEADER_JMS_REPLY_TO)) {
                    message.setJMSReplyTo(Destination.clreplaced.cast(value));
                } else if (name.equals(HEADER_JMS_TYPE)) {
                    message.setJMSType(value.toString());
                } else if (name.equals(HEADER_JMS_REDELIVERED)) {
                    message.setJMSRedelivered(Boolean.parseBoolean(value.toString()));
                // process JMS properties
                } else {
                    message.setObjectProperty(name, value);
                }
            } catch (Throwable t) {
                continue;
            }
        } else if (matches(name, getIncludeRegexes(), new ArrayList<Pattern>())) {
            Object value = property.getValue();
            if (value == null) {
                continue;
            }
            message.setObjectProperty(name, value);
        }
    }
}

16 View Complete Implementation : RESTEasyContextMapper.java
Copyright Apache License 2.0
Author : jboss-switchyard
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public void mapTo(Context context, RESTEasyBindingData target) throws Exception {
    super.mapTo(context, target);
    Map<String, List<String>> httpHeaders = target.getHeaders();
    for (Property property : context.getProperties()) {
        String name = property.getName();
        Object value = property.getValue();
        if ((value != null) && (matches(name) || property.hasLabel(EndpointLabel.HTTP.label()))) {
            if (HTTP_RESPONSE_STATUS.equals(name)) {
                target.setStatusCode((Integer) property.getValue());
            } else {
                if (value instanceof List) {
                    List<String> stringList = new ArrayList<String>();
                    for (Object obj : ((List) value)) {
                        if (obj != null) {
                            stringList.add(obj.toString());
                        } else {
                            stringList.add(null);
                        }
                    }
                    httpHeaders.put(name, stringList);
                } else if (value instanceof String) {
                    List<String> list = new ArrayList<String>();
                    list.add(String.valueOf(value));
                    httpHeaders.put(name, list);
                }
            }
        }
    }
}

16 View Complete Implementation : SOAPGatewayTest.java
Copyright Apache License 2.0
Author : jboss-switchyard
@Test
public void invokeCustomFaultWithDetails() throws Exception {
    String faultString = "<CustomFaultMessage>" + "errorcode=1000;" + "Invalid name: Looks like you did not specify a name!" + "</CustomFaultMessage>";
    String input = "<test:sayHello xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">" + "   <arg0></arg0>" + "</test:sayHello>";
    String faultStr = "SOAPFaultInfo [_actor=null, _codeAsQName={http://schemas.xmlsoap.org/soap/envelope/}Server.AppError, " + "_reasonTexts={}, _role=null, _string=Invalid name, _stringLocale=null, _subcodes=[], _detail=[detail: null]]";
    MockHandler handler = new MockHandler();
    Exchange ex = _consumerService11.operation("sayHello").createExchange(handler);
    Message requestMsg = ex.createMessage().setContent(input);
    ex.send(requestMsg);
    handler.waitForFaultMessage();
    Exchange exchange = handler.getFaults().iterator().next();
    Property faultInfoProperty = exchange.getContext().getProperty(SOAPComposition.SOAP_FAULT_INFO);
    replacedert.replacedertNotNull(faultInfoProperty);
    replacedert.replacedertEquals(faultStr, faultInfoProperty.getValue().toString());
}

16 View Complete Implementation : TransformHandler.java
Copyright Apache License 2.0
Author : jboss-switchyard
private void setContentType(Exchange exchange) {
    QName currentType = TransformSequence.getCurrentMessageType(exchange);
    if (currentType != null) {
        exchange.getContext().setProperty(Exchange.CONTENT_TYPE, currentType).addLabels(BehaviorLabel.TRANSIENT.label());
    } else {
        // make sure no property is used for current scope
        Property p = exchange.getContext().getProperty(Exchange.CONTENT_TYPE);
        if (p != null) {
            exchange.getContext().removeProperty(p);
        }
    }
}