All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.demoiselle.jee.persistence.crud.bootstrap.PersistenceBootstrap Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
/*
 * Demoiselle Framework
 *
 * License: GNU Lesser General Public License (LGPL), version 3 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.demoiselle.jee.persistence.crud.bootstrap;

import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.persistence.Entity;

/**
 *
 * Adding the @Vetoed annotation to all persistent entities is considered a best
 * practice in most cases. The purpose of this annotation is to prevent the
 * BeanManager from managing an entity as a CDI Bean.
 *
 * http://www.cdi-spec.org/faq/ Why is @Vetoed a best practice for persistent
 * (JPA) entities?
 *
 */
public class PersistenceBootstrap implements javax.enterprise.inject.spi.Extension {

    /**
     * Add Vetoed for all entities of application
     *
     * @param pat
     */
    @SuppressWarnings({"rawtypes", "unchecked"})
    public void processAnnotatedType(@Observes final ProcessAnnotatedType pat) {
        final AnnotatedType annotatedType = pat.getAnnotatedType();
        if (annotatedType.getJavaClass().isAnnotationPresent(Entity.class)) {
            pat.veto();
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy