本文整理匯總了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;
}
示例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();
}
}
示例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;
}
}
示例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);
}
}