camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: git commit: [CAMEL-7212] Bean Validator now uses OSGi-friendly ValidationProviderResolver if deployed into OSGi environment.
Date Mon, 17 Feb 2014 06:54:53 GMT
On Sun, Feb 16, 2014 at 5:28 PM,  <hekonsek@apache.org> wrote:
> Repository: camel
> Updated Branches:
>   refs/heads/master 87bd524dc -> 9b7ab4263
>
>
> [CAMEL-7212] Bean Validator now uses OSGi-friendly ValidationProviderResolver if deployed
into OSGi environment.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9b7ab426
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9b7ab426
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9b7ab426
>
> Branch: refs/heads/master
> Commit: 9b7ab4263f1c99c230f0bc5089c2f200b63a5fb2
> Parents: 87bd524
> Author: Henryk Konsek <hekonsek@gmail.com>
> Authored: Sun Feb 16 17:28:17 2014 +0100
> Committer: Henryk Konsek <hekonsek@gmail.com>
> Committed: Sun Feb 16 17:28:17 2014 +0100
>
> ----------------------------------------------------------------------
>  .../component/bean/validator/BeanValidatorComponent.java     | 8 ++++++++
>  1 file changed, 8 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/9b7ab426/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
> ----------------------------------------------------------------------
> diff --git a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
> index 15bf42b..55ef4e3 100644
> --- a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
> +++ b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
> @@ -38,6 +38,8 @@ import org.apache.camel.impl.ProcessorEndpoint;
>   */
>  public class BeanValidatorComponent extends DefaultComponent {
>
> +    private static final String OSGI_CONTEXT_CLASS_PREFIX = "Osgi";
> +
>      @Override
>      protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
>          BeanValidator beanValidator = new BeanValidator();
> @@ -51,6 +53,8 @@ public class BeanValidatorComponent extends DefaultComponent {
>          GenericBootstrap bootstrap = Validation.byDefaultProvider();
>          if (validationProviderResolver != null) {
>              bootstrap.providerResolver(validationProviderResolver);
> +        } else if (isOsgiContext()) {
> +            bootstrap.providerResolver(new HibernateValidationProviderResolver());
>          }
>          Configuration<?> configuration = bootstrap.configure();
>
> @@ -76,4 +80,8 @@ public class BeanValidatorComponent extends DefaultComponent {
>          return new ProcessorEndpoint(uri, this, beanValidator);
>      }
>
> +    protected boolean isOsgiContext() {
> +        return getCamelContext().getClass().getSimpleName().startsWith(OSGI_CONTEXT_CLASS_PREFIX);
> +    }
> +

Henryk, can you check camel-blueprint what the CamelContext class name
is there, it may not start with OSGi and thus your check would fail
for blueprint users.


>  }
> \ No newline at end of file
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Mime
View raw message