String appid = AOPUtils.getFirstArgOfString(args);
if (indexedAnno != null) {
switch (indexedAnno.action()) {
case ADD:
ParaObject addMe = AOPUtils.getArgOfParaObject(args);
if (Utils.isValidObject(addMe)) {
result = mi.proceed();
search.index(appid, addMe);
logger.debug("{}: Indexed {}->{}", cn, appid, addMe.getId());
} else {
logger.debug("{}: Invalid object {}->{}", cn, appid, addMe);
}
break;
case REMOVE:
result = mi.proceed();
ParaObject removeMe = AOPUtils.getArgOfParaObject(args);
search.unindex(appid, removeMe);
logger.debug("{}: Unindexed {}->{}", cn, appid, (removeMe == null) ? null : removeMe.getId());
break;
case ADD_ALL:
List<ParaObject> addUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
removeSpecialClasses(addUs);
result = mi.proceed();
search.indexAll(appid, addUs);
logger.debug("{}: Indexed all {}->#{}", cn, appid, (addUs == null) ? null : addUs.size());
break;
case REMOVE_ALL:
List<ParaObject> removeUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
removeSpecialClasses(removeUs);
result = mi.proceed();
search.unindexAll(appid, removeUs);
logger.debug("{}: Unindexed all {}->#{}", cn, appid, (removeUs == null) ? null : removeUs.size());
break;
default:
break;
}
}
if (cachedAnno != null) {
switch (cachedAnno.action()) {
case GET:
String getMeId = (String) args[1];
if (cache.contains(appid, getMeId)) {
result = cache.get(appid, getMeId);
logger.debug("{}: Cache hit: {}->{}", cn, appid, getMeId);
} else if (getMeId != null) {
if (result == null) {
result = mi.proceed();
}
if (result != null) {
cache.put(appid, getMeId, result);
logger.debug("{}: Cache miss: {}->{}", cn, appid, getMeId);
}
}
break;
case PUT:
ParaObject putMe = AOPUtils.getArgOfParaObject(args);
if (putMe != null) {
cache.put(appid, putMe.getId(), putMe);
logger.debug("{}: Cache put: {}->{}", cn, appid, putMe.getId());
}
break;
case DELETE:
ParaObject deleteMe = AOPUtils.getArgOfParaObject(args);
if (deleteMe != null) {
cache.remove(appid, deleteMe.getId());
logger.debug("{}: Cache delete: {}->{}", cn, appid, deleteMe.getId());
}
break;
case GET_ALL:
List<String> getUs = AOPUtils.getArgOfListOfType(args, String.class);
if (getUs != null) {