Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternatives with higher priority are not working on converters #876

Closed
Turini opened this issue Nov 11, 2014 · 1 comment · Fixed by #888
Closed

Alternatives with higher priority are not working on converters #876

Turini opened this issue Nov 11, 2014 · 1 comment · Fixed by #888
Assignees
Labels

Comments

@Turini
Copy link
Member

Turini commented Nov 11, 2014

as reported here https://groups.google.com/forum/#!topic/caelum-vraptor/6SoCRx2tEBM

VRaptor/CDI still run CalendarConverter instead of CustomCalendarConverter:

@Alternative 
@Priority(Interceptor.Priority.APPLICATION)
@Convert(Calendar.class)
public class CustomCalendarConverter implements Converter<Calendar>{

    @Override
    public Calendar convert(String value, Class<? extends Calendar> type) {
        return null; // anything;
    }
}
@Turini Turini added the bug label Nov 11, 2014
@nykolaslima
Copy link
Contributor

This should be happening because DefaultConverters is registering all Converters implementations that CDI founds.
Using @Alternative we do not "remove" the old implementation, so the both CalendarConverter and CustomCalendarConverter are registered.
Using @Specializes we tell to CDI to "remove" other implementations and only consider this implementation CustomCalendarConverter. This way DefaultConverters only register the CustomCalendarConverter.

When we are registering the converter, we may need to check if there is another converter for the same class and if there is, we need to ask CDI whom we should use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants