Package org.mule.api.transport

Examples of org.mule.api.transport.PropertyScope


        {
            // ignore and use defaults
            return;
        }

        PropertyScope ps = PropertyScope.get(scope.toLowerCase().trim());
        if (ps == null)
        {
            throw new IllegalArgumentException(String.format("'%s' is not a valid property scope.", scope));
        }
        this.scope = ps;
View Full Code Here


        StringBuilder buf = new StringBuilder();
        buf.append(SystemUtils.LINE_SEPARATOR).append("Message properties:").append(SystemUtils.LINE_SEPARATOR);

        for (int i = 0; i < PropertyScope.ALL_SCOPES.length; i++)
        {
            PropertyScope scope = PropertyScope.ALL_SCOPES[i];
            try
            {
                Set names = new TreeSet(m.getPropertyNames(scope));
                buf.append("  ").append(scope.getScopeName().toUpperCase()).append(" scoped properties:").append(SystemUtils.LINE_SEPARATOR);

                for (Object name : names)
                {
                    Object value = m.getProperty(name.toString(), scope);
                    if (name.equals("password") || name.toString().contains("secret") || name.equals("pass"))
View Full Code Here

    public static final String NAME = "header";

    public void enrich(String expression, MuleMessage message, Object object)
    {
        String propertyName = expression;
        PropertyScope scope = ExpressionUtils.getScope(expression);
        if (scope != null)
        {
            // cut-off leading scope and separator
            propertyName = expression.substring(scope.getScopeName().length() + 1);
        }
        else
        {
            // default
            scope = PropertyScope.OUTBOUND;
View Full Code Here

    @SuppressWarnings("unchecked")
    protected static <T> T getPropertyInternal(String expression, PropertyScope scope, boolean parseScope, MuleMessage msg, Class<T> type)
    {
        if (parseScope)
        {
            PropertyScope tempScope = getScope(expression);
            if (tempScope != null)
            {
                // cut-off leading scope and separator
                expression = expression.substring(tempScope.getScopeName().length() + 1);
                scope = tempScope;
            }
        }

        if (expression.contains(ALL_ARGUMENT))
        {
            WildcardFilter filter = new WildcardFilter(expression);
            if (Map.class.isAssignableFrom(type))
            {
                Map<String, Object> props = new HashMap<String, Object>();
                for (String name : msg.getPropertyNames(scope))
                {
                    if (filter.accept(name))
                    {
                        props.put(name, msg.getProperty(name, scope));
                    }
                }
                return (T) returnMap(props, scope);
            }
            else if (List.class.isAssignableFrom(type))
            {
                List<Object> values = new ArrayList<Object>();
                for (String name : msg.getPropertyNames(scope))
                {
                    if (filter.accept(name))
                    {
                        values.add(msg.getProperty(name, scope));
                    }
                }
                return (T) returnList(values, scope);
            }
            else
            {
                //TODO i18n
                throw new IllegalArgumentException("Type specified is not a collection type but '" + ALL_ARGUMENT + "' was specified for all properties. Type is: " + type);
            }
        }
        else if (Map.class.isAssignableFrom(type))
        {
            String[] names = expression.split(DELIM);
            Map<String, Object> props = new HashMap<String, Object>();
            for (String name : names)
            {
                boolean required = true;
                name = name.trim();
                PropertyScope entryScope = scope;
                if (parseScope)
                {
                    entryScope = getScope(name);
                    if (entryScope != null)
                    {
                        // cut-off leading scope and separator
                        name = name.substring(entryScope.getScopeName().length() + 1);
                    }
                    else
                    {
                        entryScope = scope;
                    }
                }
                if (name.endsWith(OPTIONAL_ARGUMENT))
                {
                    name = name.substring(0, name.length() - OPTIONAL_ARGUMENT.length());
                    required = false;
                }
                Object value = msg.getProperty(name, entryScope);
                if (value == null && required)
                {
                    throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers", entryScope.getScopeName() + ":" + name));
                }
                else if (value != null)
                {
                    props.put(name, value);
                }
            }
            return (T) returnMap(props, scope);
        }
        else if (List.class.isAssignableFrom(type))
        {
            String[] names = expression.split(DELIM);
            List<Object> values = new ArrayList<Object>();
            for (String name : names)
            {
                boolean required = true;
                name = name.trim();
                PropertyScope itemScope = scope;
                if (parseScope)
                {
                    itemScope = getScope(name);
                    if (itemScope != null)
                    {
                        // cut-off leading scope and separator
                        name = name.substring(itemScope.getScopeName().length() + 1);
                    }
                    else
                    {
                        itemScope = scope;
                    }
                }
                if (name.endsWith(OPTIONAL_ARGUMENT))
                {
                    name = name.substring(0, name.length() - OPTIONAL_ARGUMENT.length());
                    required = false;
                }
                name = name.trim();
                Object value = msg.getProperty(name, itemScope);
                if (value == null && required)
                {
                    throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers-list", itemScope.getScopeName() + ":" + name));
                }
                else if (value != null)
                {
                    values.add(value);
                }
View Full Code Here

    protected static PropertyScope getScope(String expression)
    {
        // see if scope has been specified explicitly
        final String[] tokens = expression.split(":", 2); // note we split only once, not on every separator
        PropertyScope scope;
        if (tokens.length == 2)
        {
            final String candidate = tokens[0];
            scope = PropertyScope.get(candidate.toLowerCase());
            if (scope == null)
View Full Code Here

    public static final String NAME = "header";

    public void enrich(String expression, MuleMessage message, Object object)
    {
        String propertyName = expression;
        PropertyScope scope = ExpressionUtils.getScope(expression);
        if (scope != null)
        {
            // cut-off leading scope and separator
            propertyName = expression.substring(scope.getScopeName().length() + 1);
        }
        else
        {
            // default
            scope = PropertyScope.OUTBOUND;
View Full Code Here

    @SuppressWarnings("unchecked")
    protected static <T> T getPropertyInternal(String expression, PropertyScope scope, boolean parseScope, MuleMessage msg, Class<T> type)
    {
        if (parseScope)
        {
            PropertyScope tempScope = getScope(expression);
            if (tempScope != null)
            {
                // cut-off leading scope and separator
                expression = expression.substring(tempScope.getScopeName().length() + 1);
                scope = tempScope;
            }
        }

        if (expression.contains(ALL_ARGUMENT))
        {
            WildcardFilter filter = new WildcardFilter(expression);
            if (Map.class.isAssignableFrom(type))
            {
                Map<String, Object> props = new HashMap<String, Object>();
                for (String name : msg.getPropertyNames(scope))
                {
                    if (filter.accept(name))
                    {
                        props.put(name, msg.getProperty(name, scope));
                    }
                }
                return (T) returnMap(props, scope);
            }
            else if (List.class.isAssignableFrom(type))
            {
                List<Object> values = new ArrayList<Object>();
                for (String name : msg.getPropertyNames(scope))
                {
                    if (filter.accept(name))
                    {
                        values.add(msg.getProperty(name, scope));
                    }
                }
                return (T) returnList(values, scope);
            }
            else
            {
                //TODO i18n
                throw new IllegalArgumentException("Type specified is not a collection type but '" + ALL_ARGUMENT + "' was specified for all properties. Type is: " + type);
            }
        }
        else if (Map.class.isAssignableFrom(type))
        {
            String[] names = expression.split(DELIM);
            Map<String, Object> props = new HashMap<String, Object>();
            for (String name : names)
            {
                boolean required = true;
                name = name.trim();
                PropertyScope entryScope = scope;
                if (parseScope)
                {
                    entryScope = getScope(name);
                    if (entryScope != null)
                    {
                        // cut-off leading scope and separator
                        name = name.substring(entryScope.getScopeName().length() + 1);
                    }
                    else
                    {
                        entryScope = scope;
                    }
                }
                if (name.endsWith(OPTIONAL_ARGUMENT))
                {
                    name = name.substring(0, name.length() - OPTIONAL_ARGUMENT.length());
                    required = false;
                }
                Object value = msg.getProperty(name, entryScope);
                if (value == null && required)
                {
                    throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers", entryScope.getScopeName() + ":" + name));
                }
                else if (value != null)
                {
                    props.put(name, value);
                }
            }
            return (T) returnMap(props, scope);
        }
        else if (List.class.isAssignableFrom(type))
        {
            String[] names = expression.split(DELIM);
            List<Object> values = new ArrayList<Object>();
            for (String name : names)
            {
                boolean required = true;
                name = name.trim();
                PropertyScope itemScope = scope;
                if (parseScope)
                {
                    itemScope = getScope(name);
                    if (itemScope != null)
                    {
                        // cut-off leading scope and separator
                        name = name.substring(itemScope.getScopeName().length() + 1);
                    }
                    else
                    {
                        itemScope = scope;
                    }
                }
                if (name.endsWith(OPTIONAL_ARGUMENT))
                {
                    name = name.substring(0, name.length() - OPTIONAL_ARGUMENT.length());
                    required = false;
                }
                name = name.trim();
                Object value = msg.getProperty(name, itemScope);
                if (value == null && required)
                {
                    throw new RequiredValueException(CoreMessages.expressionEvaluatorReturnedNull("headers-list", itemScope.getScopeName() + ":" + name));
                }
                else if (value != null)
                {
                    values.add(value);
                }
View Full Code Here

    protected static PropertyScope getScope(String expression)
    {
        // see if scope has been specified explicitly
        final String[] tokens = expression.split(":", 2); // note we split only once, not on every separator
        PropertyScope scope;
        if (tokens.length == 2)
        {
            final String candidate = tokens[0];
            scope = PropertyScope.get(candidate.toLowerCase());
            if (scope == null)
View Full Code Here

        {
            // ignore and use defaults
            return;
        }

        PropertyScope ps = PropertyScope.get(scope.toLowerCase().trim());
        if (ps == null)
        {
            throw new IllegalArgumentException(String.format("'%s' is not a valid property scope.", scope));
        }
        this.scope = ps;
View Full Code Here

        StringBuilder buf = new StringBuilder();
        buf.append(SystemUtils.LINE_SEPARATOR).append("Message properties:").append(SystemUtils.LINE_SEPARATOR);

        for (int i = 0; i < PropertyScope.ALL_SCOPES.length; i++)
        {
            PropertyScope scope = PropertyScope.ALL_SCOPES[i];
            try
            {
                Set<Object> names = new TreeSet<Object>(m.getPropertyNames(scope));
                buf.append("  ").append(scope.getScopeName().toUpperCase()).append(" scoped properties:").append(SystemUtils.LINE_SEPARATOR);

                for (Object name : names)
                {
                    Object value = m.getProperty(name.toString(), scope);
                    // avoid calling toString recursively on MuleMessages
View Full Code Here

TOP

Related Classes of org.mule.api.transport.PropertyScope

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.