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


Java EntityListeners類代碼示例

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


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

示例1: getEntityListeners

import javax.persistence.EntityListeners; //導入依賴的package包/類
protected Annotation getEntityListeners(ConstPool constantPool, Annotation existingEntityListeners, Annotation templateEntityListeners) {
    Annotation listeners = new Annotation(EntityListeners.class.getName(), constantPool);
    ArrayMemberValue listenerArray = new ArrayMemberValue(constantPool);
    Set<MemberValue> listenerMemberValues = new HashSet<MemberValue>();
    {
        ArrayMemberValue templateListenerValues = (ArrayMemberValue) templateEntityListeners.getMemberValue("value");
        listenerMemberValues.addAll(Arrays.asList(templateListenerValues.getValue()));
        logger.debug("Adding template values to new EntityListeners");
    }
    if (existingEntityListeners != null) {
        ArrayMemberValue oldListenerValues = (ArrayMemberValue) existingEntityListeners.getMemberValue("value");
        listenerMemberValues.addAll(Arrays.asList(oldListenerValues.getValue()));
        logger.debug("Adding previous values to new EntityListeners");
    }
    listenerArray.setValue(listenerMemberValues.toArray(new MemberValue[listenerMemberValues.size()]));
    listeners.addMemberValue("value", listenerArray);

    return listeners;

}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:21,代碼來源:DirectCopyClassTransformer.java

示例2: postProcessMetadataContext

import javax.persistence.EntityListeners; //導入依賴的package包/類
@Override
public synchronized void postProcessMetadataContext(TableMetadataContext tableMetadataContext) {
    log.info("Looking up entity callbacks");
    final Collection<Class<?>> entityTypes = tableMetadataContext.getEntityTypes();
    eventHandlers.add(new EntityEventCallback());
    for (Class<?> entityType : entityTypes) {
        if (entityType.isAnnotationPresent(EntityListeners.class)) {
            final EntityListeners listeners = entityType.getAnnotation(EntityListeners.class);
            for (final Class type : listeners.value()) {
                log.info("Registering external callback: " + type);
                eventHandlers.add(new EntityEventCallback(entityType, type));
            }
        }
    }
    handlersFound = true;
    if (contextFound) {
        registerHandlers();
    }
}
 
開發者ID:mmnaseri,項目名稱:dragonfly,代碼行數:20,代碼來源:CallbackResolver.java

示例3: getEntityListeners

import javax.persistence.EntityListeners; //導入依賴的package包/類
private EntityListeners getEntityListeners(Element tree, XMLContext.Default defaults) {
	Element element = tree != null ? tree.element( "entity-listeners" ) : null;
	if ( element != null ) {
		List<Class> entityListenerClasses = new ArrayList<Class>();
		for ( Element subelement : (List<Element>) element.elements( "entity-listener" ) ) {
			String className = subelement.attributeValue( "class" );
			try {
				entityListenerClasses.add(
						ReflectHelper.classForName(
								XMLContext.buildSafeClassName( className, defaults ),
								this.getClass()
						)
				);
			}
			catch ( ClassNotFoundException e ) {
				throw new AnnotationException(
						"Unable to find " + element.getPath() + ".class: " + className, e
				);
			}
		}
		AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
		ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
		return AnnotationFactory.create( ad );
	}
	else if ( defaults.canUseJavaAnnotations() ) {
		return getPhysicalAnnotation( EntityListeners.class );
	}
	else {
		return null;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:JPAOverriddenAnnotationReader.java

示例4: build

import javax.persistence.EntityListeners; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void build() throws ODataJPAModelException, ODataJPARuntimeException {

  Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes = metaModel.getEntities();

  if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true) {
    return;
  } else if (consistentEntityTypes == null) {
    consistentEntityTypes = new EntityTypeList<EntityType>();

  }

  for (javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
    currentEdmEntityType = new EntityType();
    currentJPAEntityType = jpaEntityType;

    // Check for need to Exclude
    if (isExcluded(JPAEdmEntityType.this)) {
      continue;
    }

    JPAEdmNameBuilder.build(JPAEdmEntityType.this);
    JPAEdmMapping jpaEdmMapping = (JPAEdmMapping) currentEdmEntityType.getMapping();
    EntityListeners entityListners = currentJPAEntityType.getJavaType().getAnnotation(EntityListeners.class);
    if (entityListners != null) {
      for (Class<EntityListeners> entityListner : entityListners.value()) {
        if (ODataJPATombstoneEntityListener.class.isAssignableFrom(entityListner)) {
          jpaEdmMapping
              .setODataJPATombstoneEntityListener((Class<? extends ODataJPATombstoneEntityListener>)
              (Object) entityListner);
          break;
        }
      }
    }
    JPAEdmPropertyView propertyView = new JPAEdmProperty(schemaView);
    propertyView.getBuilder().build();

    currentEdmEntityType.setProperties(propertyView.getEdmPropertyList());
    if (propertyView.getJPAEdmNavigationPropertyView() != null) {
      JPAEdmNavigationPropertyView navPropView = propertyView.getJPAEdmNavigationPropertyView();
      if (navPropView.getConsistentEdmNavigationProperties() != null
          && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
        currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
      }
    }
    JPAEdmKeyView keyView = propertyView.getJPAEdmKeyView();
    currentEdmEntityType.setKey(keyView.getEdmKey());

    consistentEntityTypes.add(currentEdmEntityType);
    consistentEntityTypeMap.put(currentJPAEntityType.getName(), currentEdmEntityType);
  }

}
 
開發者ID:apache,項目名稱:olingo-odata2,代碼行數:55,代碼來源:JPAEdmEntityType.java


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