|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2011-2015 by the original author(s). |
|
|
|
* Copyright 2011-2016 by the original author(s). |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -20,8 +20,6 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.context.ApplicationListener; |
|
|
|
import org.springframework.context.ApplicationListener; |
|
|
|
import org.springframework.core.GenericTypeResolver; |
|
|
|
import org.springframework.core.GenericTypeResolver; |
|
|
|
|
|
|
|
|
|
|
|
import com.mongodb.DBObject; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Base class to implement domain class specific {@link ApplicationListener}s. |
|
|
|
* Base class to implement domain class specific {@link ApplicationListener}s. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -95,20 +93,6 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures source element before conversion. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param source will never be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onBeforeConvert(BeforeConvertEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onBeforeConvert(E source) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
|
|
|
|
LOG.debug("onBeforeConvert({})", source); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Captures {@link BeforeConvertEvent}. |
|
|
|
* Captures {@link BeforeConvertEvent}. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -116,21 +100,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onBeforeConvert(BeforeConvertEvent<E> event) { |
|
|
|
public void onBeforeConvert(BeforeConvertEvent<E> event) { |
|
|
|
onBeforeConvert(event.getSource()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures source element and {@link com.mongodb.DBObject} representation before save. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param source will never be {@literal null}. |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onBeforeSave(BeforeSaveEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onBeforeSave(E source, DBObject dbo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onBeforeSave({}, {})", source, dbo); |
|
|
|
LOG.debug("onBeforeConvert({})", event.getSource()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -141,21 +113,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onBeforeSave(BeforeSaveEvent<E> event) { |
|
|
|
public void onBeforeSave(BeforeSaveEvent<E> event) { |
|
|
|
onBeforeSave(event.getSource(), event.getDBObject()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures source element and {@link com.mongodb.DBObject} representation after save. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param source will never be {@literal null}. |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onAfterSave(AfterSaveEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onAfterSave(E source, DBObject dbo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onAfterSave({}, {})", source, dbo); |
|
|
|
LOG.debug("onBeforeSave({}, {})", event.getSource(), event.getDBObject()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -166,20 +126,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onAfterSave(AfterSaveEvent<E> event) { |
|
|
|
public void onAfterSave(AfterSaveEvent<E> event) { |
|
|
|
onAfterSave(event.getSource(), event.getDBObject()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures raw {@link com.mongodb.DBObject} when read from MongoDB. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onAfterLoad(AfterLoadEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onAfterLoad(DBObject dbo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onAfterLoad({})", dbo); |
|
|
|
LOG.debug("onAfterSave({}, {})", event.getSource(), event.getDBObject()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -190,21 +139,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onAfterLoad(AfterLoadEvent<E> event) { |
|
|
|
public void onAfterLoad(AfterLoadEvent<E> event) { |
|
|
|
onAfterLoad(event.getDBObject()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures raw {@link com.mongodb.DBObject} and converted domain type after conversion. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @param source will never be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onAfterConvert(AfterConvertEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onAfterConvert(DBObject dbo, E source) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onAfterConvert({}, {})", dbo, source); |
|
|
|
LOG.debug("onAfterLoad({})", event.getDBObject()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -215,21 +152,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onAfterConvert(AfterConvertEvent<E> event) { |
|
|
|
public void onAfterConvert(AfterConvertEvent<E> event) { |
|
|
|
onAfterConvert(event.getDBObject(), event.getSource()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Captures {@link com.mongodb.DBObject} after delete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onAfterDelete(AfterDeleteEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onAfterDelete(DBObject dbo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onAfterDelete({})", dbo); |
|
|
|
LOG.debug("onAfterConvert({}, {})", event.getDBObject(), event.getSource()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -240,20 +165,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onAfterDelete(AfterDeleteEvent<E> event) { |
|
|
|
public void onAfterDelete(AfterDeleteEvent<E> event) { |
|
|
|
onAfterDelete(event.getDBObject()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Capture {@link com.mongodb.DBObject} before delete. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param dbo can be {@literal null}. |
|
|
|
|
|
|
|
* @deprecated since 1.8. Please use {@link #onBeforeDelete(BeforeDeleteEvent)}. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void onBeforeDelete(DBObject dbo) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
LOG.debug("onBeforeDelete({})", dbo); |
|
|
|
LOG.debug("onAfterDelete({})", event.getDBObject()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -264,6 +178,9 @@ public abstract class AbstractMongoEventListener<E> implements ApplicationListen |
|
|
|
* @since 1.8 |
|
|
|
* @since 1.8 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void onBeforeDelete(BeforeDeleteEvent<E> event) { |
|
|
|
public void onBeforeDelete(BeforeDeleteEvent<E> event) { |
|
|
|
onBeforeDelete(event.getDBObject()); |
|
|
|
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) { |
|
|
|
|
|
|
|
LOG.debug("onBeforeDelete({})", event.getDBObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|