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


Java PersistenceContext.properties方法代碼示例

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


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

示例1: getPersistenceContextProperties

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
private static Map<String, Object> getPersistenceContextProperties(final PersistenceContext persistenceContext) {
    final Map<String, Object> properties = new HashMap<>();
    for (final PersistenceProperty property : persistenceContext.properties()) {
        String propertyValue = property.value();
        Matcher matcher = PROPERTY_PATTERN.matcher(propertyValue);

        while(matcher.find()) {
            String p = matcher.group();
            String systemProperty = p.substring(2, p.length() - 1);
            propertyValue = propertyValue.replace(p, System.getProperty(systemProperty, p));
        }

        properties.put(property.name(), propertyValue);
    }
    return properties;
}
 
開發者ID:dadrus,項目名稱:jpa-unit,代碼行數:17,代碼來源:JpaUnitContext.java

示例2: createJPARule

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
private static JPARule createJPARule(PersistenceContext ctx, Object test) {
    DatabaseConfiguration config = findOnTest(DatabaseConfiguration.class, test);

    if (config == null) {
        return new JPARule(ctx, H2, DEFAULT_STORAGE, DEFAULT_MODE);
    }

    switch (config.value()) {
        case H2:
            return new JPARule(ctx, H2, config.h2().storage(), config.h2().mode());
        case UNDEFINED:
        default:
            Map<String, String> properties = new HashMap<>();
            for (PersistenceProperty property : ctx.properties()) {
                properties.put(property.name(), property.value());
            }
            return unitName(ctx.unitName())
                    .database(UNDEFINED)
                    .noInternalProperties()
                    .properties(properties)
                    .build();
    }
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:24,代碼來源:InjectionRunner.java

示例3: PersistenceElement

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
public PersistenceElement(Member member, AnnotatedElement ae, PropertyDescriptor pd) {
	super(member, pd);
	PersistenceContext pc = ae.getAnnotation(PersistenceContext.class);
	PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class);
	Class<?> resourceType = EntityManager.class;
	if (pc != null) {
		if (pu != null) {
			throw new IllegalStateException("Member may only be annotated with either " +
					"@PersistenceContext or @PersistenceUnit, not both: " + member);
		}
		Properties properties = null;
		PersistenceProperty[] pps = pc.properties();
		if (!ObjectUtils.isEmpty(pps)) {
			properties = new Properties();
			for (PersistenceProperty pp : pps) {
				properties.setProperty(pp.name(), pp.value());
			}
		}
		this.unitName = pc.unitName();
		this.type = pc.type();
		this.synchronizedWithTransaction = (synchronizationAttribute == null ||
				"SYNCHRONIZED".equals(ReflectionUtils.invokeMethod(synchronizationAttribute, pc).toString()));
		this.properties = properties;
	}
	else {
		resourceType = EntityManagerFactory.class;
		this.unitName = pu.unitName();
	}
	checkResourceType(resourceType);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:31,代碼來源:PersistenceAnnotationBeanPostProcessor.java

示例4: JPARule

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
JPARule(PersistenceContext unit, DB db, H2Storage storage, Mode mode) {
    for (PersistenceProperty property : unit.properties()) {
        properties.put(property.name(), property.value());
    }
    unitName = unit.unitName();
    this.storage = storage;
    this.mode = mode;
    this.db = db;
}
 
開發者ID:Tibor17,項目名稱:javaee-samples,代碼行數:10,代碼來源:JPARule.java

示例5: PersistenceElement

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
public PersistenceElement(Member member, PropertyDescriptor pd) {
	super(member, pd);
	AnnotatedElement ae = (AnnotatedElement) member;
	PersistenceContext pc = ae.getAnnotation(PersistenceContext.class);
	PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class);
	Class<?> resourceType = EntityManager.class;
	if (pc != null) {
		if (pu != null) {
			throw new IllegalStateException("Member may only be annotated with either " +
					"@PersistenceContext or @PersistenceUnit, not both: " + member);
		}
		Properties properties = null;
		PersistenceProperty[] pps = pc.properties();
		if (!ObjectUtils.isEmpty(pps)) {
			properties = new Properties();
			for (PersistenceProperty pp : pps) {
				properties.setProperty(pp.name(), pp.value());
			}
		}
		this.unitName = pc.unitName();
		this.type = pc.type();
		this.properties = properties;
	}
	else {
		resourceType = EntityManagerFactory.class;
		this.unitName = pu.unitName();
	}
	checkResourceType(resourceType);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:30,代碼來源:PersistenceAnnotationBeanPostProcessor.java

示例6: assertEq

import javax.persistence.PersistenceContext; //導入方法依賴的package包/類
private static void assertEq(final PersistenceContext annotation, final PersistenceContextAnn wrapper) {
    if (annotation.name().length() > 0) {
        assertEquals(annotation.name(), wrapper.name());
    }
    assertEquals(annotation.unitName(), wrapper.unitName());
    assertEquals(annotation.type().toString(), wrapper.type());

    final Map<String, String> properties = new HashMap<String, String>();
    for (final PersistenceProperty property : annotation.properties()) {
        properties.put(property.name(), property.value());
    }
    assertEquals(properties, wrapper.properties());
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:14,代碼來源:PersistenceContextAnnFactoryTest.java


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