Java 类javax.persistence.Converter 实例源码

项目:lams    文件:Configuration.java   
/**
 * Adds the AttributeConverter instance to this Configuration.  This form is mainly intended for developers
 * to programatically add their own AttributeConverter instance.  HEM, instead, uses the
 * {@link #addAttributeConverter(Class, boolean)} form
 *
 * @param attributeConverter The AttributeConverter instance.
 */
public void addAttributeConverter(AttributeConverter attributeConverter) {
    boolean autoApply = false;
    Converter converterAnnotation = attributeConverter.getClass().getAnnotation( Converter.class );
    if ( converterAnnotation != null ) {
        autoApply = converterAnnotation.autoApply();
    }

    addAttributeConverter( new AttributeConverterDefinition( attributeConverter, autoApply ) );
}
项目:tomee    文件:AnnotationDeployer.java   
public static void doAutoJpa(final IAnnotationFinder finder, final org.apache.openejb.jee.jpa.unit.PersistenceUnit pu) {
    final String packageName = pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN_PACKAGE);
    String[] packageNames = null;
    if (packageName != null) {
        packageNames = packageName.split(",");
    }

    // no need of meta currently since JPA providers doesn't support it
    final List<Class<?>> classes = new ArrayList<Class<?>>();
    classes.addAll(finder.findAnnotatedClasses(Entity.class));
    classes.addAll(finder.findAnnotatedClasses(Embeddable.class));
    classes.addAll(finder.findAnnotatedClasses(MappedSuperclass.class));
    classes.addAll(finder.findAnnotatedClasses(Converter.class));
    final List<String> existingClasses = pu.getClazz();
    for (final Class<?> clazz : classes) {
        final String name = clazz.getName();
        if (existingClasses.contains(name)) {
            continue;
        }

        if (packageNames == null) {
            pu.getClazz().add(name);
        } else {
            for (final String pack : packageNames) {
                if (name.startsWith(pack)) {
                    pu.getClazz().add(name);
                }
            }
        }
    }
    pu.setScanned(true);
}
项目:rise    文件:PersistenceUnitManagerHelper.java   
public MutablePersistenceUnitInfo createUnit(Class<? extends Annotation> qualifier, String unitName) {
    ClassLoader classLoader = holder.getCurrentReloadableClassLoader();
    MutablePersistenceUnitInfo result = new MutablePersistenceUnitInfo();
    result.setExcludeUnlistedClasses(true);
    result.setValidationMode(ValidationMode.NONE);
    result.setPersistenceUnitName(unitName);
    result.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);

    try {
        result.setPersistenceUnitRootUrl(new URL("http://foo.foo"));
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }

    result.addProperty(PersistenceUnitProperties.SESSION_CUSTOMIZER, CompositeSessionCustomizer.class.getName());

    // search for entities
    {
        Set<Class<?>> jpaAnnotations = new HashSet<>(
                Arrays.asList(Entity.class, MappedSuperclass.class, Embeddable.class));
        for (ClassNode classNode : index.getAllNodes()) {
            String className = Type.getObjectType(classNode.name).getClassName();

            if (classNode.visibleAnnotations == null)
                continue;

            boolean jpaAnnotationFound = false;
            for (AnnotationNode annotation : classNode.visibleAnnotations) {
                Class<?> annotationClass = AsmUtil.loadClass(Type.getType(annotation.desc), classLoader);

                // test if the annotation is one of the jpa annotations
                if (jpaAnnotations.contains(annotationClass))
                    jpaAnnotationFound = true;

            }

            if (jpaAnnotationFound && isPartOfPU(classNode, qualifier, classLoader)) {
                result.addManagedClassName(className);
            }
        }
    }

    // search converters
    {
        index.getAllChildren(AttributeConverter.class).stream()
                .filter(node -> isPartOfPU(node, qualifier, classLoader))
                .map(node -> AsmUtil.loadClass(Type.getObjectType(node.name), classLoader)).forEach(cls -> {
                    Converter converter = cls.getAnnotation(Converter.class);
                    if (converter != null && converter.autoApply())
                        result.addManagedClassName(cls.getName());
                });
    }
    return result;
}
项目:pedal-dialect    文件:CopyAttribute.java   
public Class<? extends Converter> getJpaConverterClass() {
    return getEntityMethod().getAnnotation(Convert.class).converter();
}
项目:pedal-dialect    文件:CopyAttribute.java   
public Class<? extends Converter> getJpaConverterClass() {
    return getEntityMethod().getAnnotation(Convert.class).converter();
}
项目:minnal    文件:ConverterScanner.java   
@Override
protected boolean match(Class<?> clazz) {
    return clazz.isAnnotationPresent(Converter.class);
}
项目:eclipselink-maven-plugin    文件:EclipselinkStaticWeaveMojo.java   
private Set<String> findEntities(ScanResult scanResult)
{
    return new TreeSet<>(scanResult.getNamesOfClassesWithAnnotationsAnyOf(Entity.class, MappedSuperclass.class, Embeddable.class, Converter.class));
}