Package org.apache.onami.configuration.variables

Examples of org.apache.onami.configuration.variables.VariablesMap


    }

    @Override
    protected void configure()
    {
        final VariablesMap variablesMap = new VariablesMap( parser );

        for ( final Element element : elements )
        {
            element.acceptVisitor( new DefaultElementVisitor<Void>()
            {

                @Override
                public <T> Void visit( Binding<T> binding )
                {
                    Key<?> bindingKey = binding.getKey();

                    if ( stringLiteral.equals( bindingKey.getTypeLiteral() )
                            && bindingKey.getAnnotation() != null
                            && ( Named.class.isAssignableFrom( bindingKey.getAnnotationType() )
                                            || javax.inject.Named.class.isAssignableFrom( bindingKey.getAnnotationType() ) ) )
                    {
                        String propertyKey;

                        if ( Named.class.isAssignableFrom( bindingKey.getAnnotationType() ) )
                        {
                            propertyKey = ( (Named) bindingKey.getAnnotation() ).value();
                        }
                        else
                        {
                            propertyKey = ( (javax.inject.Named) bindingKey.getAnnotation() ).value();
                        }

                        String propertyValue = (String) binding.getProvider().get();

                        variablesMap.put( propertyKey, propertyValue );
                    }

                    return super.visit( binding );
                }

            });
        }

        for ( Entry<String, String> variable : variablesMap.entrySet() )
        {
            bindConstant().annotatedWith( named( variable.getKey() ) ).to( variable.getValue() );
        }
    }
View Full Code Here


     * Set up some variables use cases to test on
     */
    @Before
    public void setUp()
    {
        variablesMap = new VariablesMap( new AntStyleParser() );

        variablesMap.put( "prop.1", "One" );
        variablesMap.put( "prop.2", "Two" );
        variablesMap.put( "prop.3", "Three" );
        variablesMap.put( "found", "I'm here" );
View Full Code Here

TOP

Related Classes of org.apache.onami.configuration.variables.VariablesMap

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.