}
@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() );
}
}