incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r925683 - in /incubator/bval/sandbox/guice-integration/src/main/java/org: ./ apache/ apache/bval/ apache/bval/extentions/ apache/bval/extentions/guice/
Date Sat, 20 Mar 2010 21:04:42 GMT
Author: simonetripodi
Date: Sat Mar 20 21:04:41 2010
New Revision: 925683

URL: http://svn.apache.org/viewvc?rev=925683&view=rev
Log:
initial import of guice integration classes

Added:
    incubator/bval/sandbox/guice-integration/src/main/java/org/
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
  (with props)

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bval.extentions.guice;
+
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.bootstrap.GenericBootstrap;
+
+import com.google.inject.Provider;
+
+/**
+ * Provider for javax.validation.Configuration based on
+ * javax.validation.bootstrap.GenericBootstrap.
+ *
+ * @version $Id$
+ */
+public final class ByGenericBootstrapConfigurationProvider implements Provider<Configuration<?>>
{
+
+    /**
+     * The generic bootstrap instance that creates the configuration.
+     */
+    private final GenericBootstrap genericBootstrap = Validation.byDefaultProvider();
+
+    /**
+     * {@inheritDoc}
+     */
+    public Configuration<?> get() {
+        return this.genericBootstrap.configure();
+    }
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ByGenericBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bval.extentions.guice;
+
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.bootstrap.ProviderSpecificBootstrap;
+import javax.validation.spi.ValidationProvider;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * Provider for javax.validation.Configuration based on
+ * javax.validation.bootstrap.ProviderSpecificBootstrap
+ *
+ * @version $Id$
+ */
+public class BySpecificBootstrapConfigurationProvider implements Provider<Configuration<?>>
{
+
+    /**
+     * The delegate Bootstrap that instantiates the 
+     */
+    private final ProviderSpecificBootstrap<?> bootstrap;
+
+    /**
+     * Creates a new javax.validation.Configuration provider based  on the
+     * Bean Validation provider type.
+     *
+     * @param providerType the Bean Validation provider type.
+     */
+    @Inject
+    public BySpecificBootstrapConfigurationProvider(Class<? extends ValidationProvider<?>>
providerType) {
+        this.bootstrap = Validation.byProvider(providerType);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public final Configuration<?> get() {
+        return this.bootstrap.configure();
+    }
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/BySpecificBootstrapConfigurationProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bval.extentions.guice;
+
+import javax.validation.Configuration;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+import com.google.inject.TypeLiteral;
+
+/**
+ * The Google-Guice module for Apache Bean Validation.
+ *
+ * @version $Id$
+ */
+public final class ValidationModule extends AbstractModule {
+
+    /**
+     * 
+     */
+    private final Class<? extends Provider<Configuration<?>>> configurationProviderType;
+
+    /**
+     * 
+     */
+    private Class<? extends Provider<? extends MessageInterpolator>> messageInterpolatorProviderType;
+
+    /**
+     * 
+     */
+    private Class<? extends Provider<? extends TraversableResolver>> traversableResolverProviderType;
+
+    /**
+     * 
+     */
+    private Class<? extends Provider<? extends ConstraintValidatorFactory>> constraintValidatorFactoryProviderType;
+
+    /**
+     * 
+     */
+    public ValidationModule() {
+        this(ByGenericBootstrapConfigurationProvider.class);
+    }
+
+    /**
+     * 
+     *
+     * @param configurationProviderType
+     */
+    public ValidationModule(Class<? extends Provider<Configuration<?>>>
configurationProviderType) {
+        this.configurationProviderType = configurationProviderType;
+    }
+
+    /**
+     * 
+     *
+     * @param messageInterpolatorProviderType
+     */
+    public void setMessageInterpolatorProviderType(Class<? extends Provider<? extends
MessageInterpolator>> messageInterpolatorProviderType) {
+        this.messageInterpolatorProviderType = messageInterpolatorProviderType;
+    }
+
+    /**
+     * 
+     *
+     * @param traversableResolverProviderType
+     */
+    public void setTraversableResolverProviderType(Class<? extends Provider<? extends
TraversableResolver>> traversableResolverProviderType) {
+        this.traversableResolverProviderType = traversableResolverProviderType;
+    }
+
+    /**
+     * 
+     *
+     * @param constraintValidatorFactoryProviderType
+     */
+    public void setConstraintValidatorFactoryProviderType(Class<? extends Provider<?
extends ConstraintValidatorFactory>> constraintValidatorFactoryProviderType) {
+        this.constraintValidatorFactoryProviderType = constraintValidatorFactoryProviderType;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void configure() {
+        this.bind(new TypeLiteral<Configuration<?>>(){}).toProvider(this.configurationProviderType).asEagerSingleton();
+
+        if (this.messageInterpolatorProviderType != null) {
+            this.bind(MessageInterpolator.class).toProvider(this.messageInterpolatorProviderType).asEagerSingleton();
+        }
+        if (this.traversableResolverProviderType != null) {
+            this.bind(TraversableResolver.class).toProvider(this.traversableResolverProviderType).asEagerSingleton();
+        }
+        if (this.constraintValidatorFactoryProviderType != null) {
+            this.bind(ConstraintValidatorFactory.class).toProvider(this.constraintValidatorFactoryProviderType).asEagerSingleton();
+        }
+
+        this.bind(ValidatorFactory.class).toProvider(ValidatorFactoryProvider.class).asEagerSingleton();
+        this.bind(Validator.class).toProvider(ValidatorProvider.class).asEagerSingleton();
+    }
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidationModule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bval.extentions.guice;
+
+import javax.validation.Configuration;
+import javax.validation.ConstraintValidatorFactory;
+import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
+import javax.validation.ValidatorFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * Validator Factory guice provider implementation.
+ *
+ * @author Simone Tripodi
+ * @version $Id$
+ */
+public final class ValidatorFactoryProvider implements Provider<ValidatorFactory> {
+
+    private final Configuration<?> configuration;
+
+    @Inject
+    public ValidatorFactoryProvider(Configuration<?> configuration) {
+        this.configuration = configuration;
+    }
+
+    @Inject(optional = true)
+    public void setMessageInterpolator(MessageInterpolator messageInterpolator) {
+        this.configuration.messageInterpolator(messageInterpolator);
+    }
+
+    @Inject(optional = true)
+    public void setTraversableResolver(TraversableResolver traversableResolver) {
+        this.configuration.traversableResolver(traversableResolver);
+    }
+
+    @Inject(optional = true)
+    public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
{
+        this.configuration.constraintValidatorFactory(constraintValidatorFactory);
+    }
+
+    public ValidatorFactory get() {
+        return this.configuration.buildValidatorFactory();
+    }
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorFactoryProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bval.extentions.guice;
+
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * Validator guice provider implementation.
+ *
+ * @version $Id$
+ */
+public final class ValidatorProvider implements Provider<Validator> {
+
+    /**
+     * The validator reference.
+     */
+    private final Validator validator;
+
+    /**
+     * Build a new ValidatorProvider by ValidatorFactory.
+     *
+     * @param validatorFactory the ValidatorFactory reference.
+     */
+    @Inject
+    public ValidatorProvider(ValidatorFactory validatorFactory) {
+        this.validator = validatorFactory.getValidator();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Validator get() {
+        return this.validator;
+    }
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidatorProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java?rev=925683&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
Sat Mar 20 21:04:41 2010
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Contains Apache Bean Validation support for Google-Guice.
+ *
+ * @version $Id$
+ */
+package org.apache.bval.extentions.guice;

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message