struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Preferred Way to Inject Dependency in plugin
Date Mon, 03 Dec 2012 20:05:20 GMT
2012/11/30 Umesh Awasthi <umeshawasthi@gmail.com>:
> Hi All,
>
> I am creating a plugin to enable JSR303 validation, idea is to provide a
> generic interface and let user provide which bean Validator they want to
> use be it Hibernate Bean Validator or Apache one or any other which follow
> specifications.
>
> I was thinking about what can be best way to inject that provider in my
> plugin.
>
> I checked how Spring's  LocalValidatorFactoryBean
> <http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-context/3.0.0.RELEASE/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java>Class
> doing this, they have a default implementation but provide a way to let use
> inject there own bean validation provider
>
> private Class providerClass;
>
> public void setProviderClass(Class<? extends ValidationProvider>
> providerClass) {
>
> this.providerClass = providerClass;
>
> }
>
> What can be possible and best way to achieve this?
> I do not want to use any other external API to add extra dependency

You may create a custom interface (BeanValidationManagerProvider) with
default implementation base on Apache, this way your plugin will be
useable out of the box. User will always have an option to implement
their own class and provide desired dependency.


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message