Java 类javax.persistence.EntityListeners 实例源码

项目:metaworks_framework    文件:DirectCopyClassTransformer.java   
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;

}
项目:SparkCommerce    文件:DirectCopyClassTransformer.java   
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;

}
项目:blcdemo    文件:DirectCopyClassTransformer.java   
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;

}
项目:dragonfly    文件:CallbackResolver.java   
@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();
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
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;
    }
}
项目:olingo-odata2    文件:JPAEdmEntityType.java   
@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);
  }

}