當前位置: 首頁>>代碼示例>>Java>>正文


Java Converter類代碼示例

本文整理匯總了Java中javax.persistence.Converter的典型用法代碼示例。如果您正苦於以下問題:Java Converter類的具體用法?Java Converter怎麽用?Java Converter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Converter類屬於javax.persistence包,在下文中一共展示了Converter類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAttributeConverter

import javax.persistence.Converter; //導入依賴的package包/類
/**
 * 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 ) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:Configuration.java

示例2: doAutoJpa

import javax.persistence.Converter; //導入依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:33,代碼來源:AnnotationDeployer.java

示例3: createUnit

import javax.persistence.Converter; //導入依賴的package包/類
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;
}
 
開發者ID:ruediste,項目名稱:rise,代碼行數:55,代碼來源:PersistenceUnitManagerHelper.java

示例4: getJpaConverterClass

import javax.persistence.Converter; //導入依賴的package包/類
public Class<? extends Converter> getJpaConverterClass() {
    return getEntityMethod().getAnnotation(Convert.class).converter();
}
 
開發者ID:eclecticlogic,項目名稱:pedal-dialect,代碼行數:4,代碼來源:CopyAttribute.java

示例5: match

import javax.persistence.Converter; //導入依賴的package包/類
@Override
protected boolean match(Class<?> clazz) {
	return clazz.isAnnotationPresent(Converter.class);
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:5,代碼來源:ConverterScanner.java

示例6: findEntities

import javax.persistence.Converter; //導入依賴的package包/類
private Set<String> findEntities(ScanResult scanResult)
{
    return new TreeSet<>(scanResult.getNamesOfClassesWithAnnotationsAnyOf(Entity.class, MappedSuperclass.class, Embeddable.class, Converter.class));
}
 
開發者ID:ethlo,項目名稱:eclipselink-maven-plugin,代碼行數:5,代碼來源:EclipselinkStaticWeaveMojo.java


注:本文中的javax.persistence.Converter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。