以下Spring PointCut有什么问题?

时间:2016-06-12 14:26:26

标签: spring spring-aop

我有一个切入点,用于建议在名为Repository的接口内声明的方法。但在运行时,方面不适用。我的切入点怎么了?

这是切入点: -

@Around("execution (* *..Repository+.save*(..))" + " && args(entity,..) && target(target)")
    public Object cacheEvictOnSaveSingle(ProceedingJoinPoint proceedingJoinPoint, Region entity,
            RegionRepositoryCassandraImpl target) {
}

存储库界面如下: -

public interface Repository<ENTITY extends Entity<IDENTITY>, IDENTITY extends Serializable, DATAOBJECT> {

    /**
     * Find.
     *
     * @param id the id
     * @return the t
     */
    public ENTITY find(IDENTITY id);

    /**
     * Save.
     *
     * @param entity the entity
     */
    public void save(ENTITY entity);

    /**
     * Save async.
     *
     * @param entity the entity
     * @return the result set future
     */
    public ResultSetFuture saveAsync(ENTITY entity);

    /**
     * Save.
     *
     * @param entity the entity
     * @param batchStatement the batch statement
     */
    public void save(ENTITY entity, BatchStatement batchStatement);

    /**
     * Save.
     *
     * @param entities the entities
     */
    public void save(List<ENTITY> entities);

    /**
     * Save async.
     *
     * @param entities the entities
     * @return the result set future
     */
    public ResultSetFuture saveAsync(List<ENTITY> entities);

    /**
     * Save.
     *
     * @param entities the entities
     * @param batchStatement the batch statement
     */
    public void save(List<ENTITY> entities, BatchStatement batchStatement);

    /**
     * Delete.
     *
     * @param id the id
     */
    public void delete(IDENTITY id);

    /**
     * Delete async.
     *
     * @param id the id
     * @return the result set future
     */
    public ResultSetFuture deleteAsync(IDENTITY id);

    /**
     * Delete.
     *
     * @param id the id
     * @param batchStatement the batch statement
     */
    public void delete(IDENTITY id, BatchStatement batchStatement);

    /**
     * Delete.
     *
     * @param ids the ids
     */
    public void delete(List<IDENTITY> ids);

    /**
     * Delete async.
     *
     * @param ids the ids
     * @return the result set future
     */
    public ResultSetFuture deleteAsync(List<IDENTITY> ids);

    /**
     * Delete.
     *
     * @param ids the ids
     * @param batchStatement the batch statement
     */
    public void delete(List<IDENTITY> ids, BatchStatement batchStatement);

}

这是在抽象类中实现的: -

@Override
    public void save(ENTITY entity) {
        BatchStatement batchStatement = new BatchStatement();
        addEntityToSaveBatch(batchStatement, entity);

        session.execute(batchStatement);
    }

    /* (non-Javadoc)
     * @see com.byteobject.cloudsanthe.dbclient.repository.Repository#saveAsync(com.byteobject.cloudsanthe.dbclient.dto.compute.Entity)
     */
    @Override
    public ResultSetFuture saveAsync(ENTITY entity) {
        BatchStatement batchStatement = new BatchStatement();
        addEntityToSaveBatch(batchStatement, entity);

        return session.executeAsync(batchStatement);
    }

    /* (non-Javadoc)
     * @see com.byteobject.cloudsanthe.dbclient.repository.Repository#save(com.byteobject.cloudsanthe.dbclient.dto.compute.Entity, com.datastax.driver.core.BatchStatement)
     */
    @Override
    public void save(ENTITY entity, BatchStatement batchStatement) {
        addEntityToSaveBatch(batchStatement, entity);
    }

你能帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我在方法签名中犯了一个错误,应该是: -

@Around("execution (* *..Repository+.save*(..))" + " && args(entity,..) && target(target)")
public Object cacheEvictOnSaveSingle(
    ProceedingJoinPoint proceedingJoinPoint,
    Entity<UUID> entity,
    RegionRepositoryCassandraImpl target
) {
    // ...
}