mirror of https://github.com/apache/cloudstack.git
Fix issues with @DB support in Spring environment
This commit is contained in:
parent
8af85b04d0
commit
af67d87662
|
|
@ -39,13 +39,25 @@
|
|||
-->
|
||||
<aop:config proxy-target-class="true">
|
||||
<aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
|
||||
<aop:pointcut id="captureAnyMethod"
|
||||
expression="execution(* *(..))" />
|
||||
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/>
|
||||
<aop:pointcut id="captureAnyMethod"
|
||||
expression="execution(* *(..))"
|
||||
/>
|
||||
|
||||
<aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/>
|
||||
</aop:aspect>
|
||||
|
||||
<aop:aspect id="actionEventInterceptorAspect" ref="actionEventInterceptor">
|
||||
<aop:pointcut id="captureEventMethod"
|
||||
expression="execution(* *(..)) and @annotation(com.cloud.event.ActionEvent)"
|
||||
/>
|
||||
<aop:around pointcut-ref="captureEventMethod" method="AroundAnyMethod"/>
|
||||
</aop:aspect>
|
||||
|
||||
</aop:config>
|
||||
|
||||
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
|
||||
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
|
||||
|
||||
|
||||
<!--
|
||||
RPC/Async/EventBus
|
||||
|
|
@ -77,4 +89,6 @@
|
|||
|
||||
<bean id="eventBus" class = "org.apache.cloudstack.framework.eventbus.EventBusBase" />
|
||||
|
||||
<bean id="apiServlet" class = "com.cloud.api.ApiServlet" />
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public class AgentMonitor extends Thread implements Listener {
|
|||
private Map<Long, Long> _pingMap;
|
||||
|
||||
public AgentMonitor() {
|
||||
_pingMap = new ConcurrentHashMap<Long, Long>(10007);
|
||||
}
|
||||
|
||||
public AgentMonitor(long msId, HostDao hostDao, VMInstanceDao vmDao, DataCenterDao dcDao, HostPodDao podDao, AgentManagerImpl agentMgr, AlertManager alertMgr, long pingTimeout) {
|
||||
|
|
|
|||
|
|
@ -53,8 +53,6 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.cloud.async.AsyncCommandQueued;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dao.EntityManager;
|
||||
import com.cloud.exception.AccountLimitException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -67,7 +65,6 @@ import com.cloud.user.AccountManager;
|
|||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public class ApiServlet extends HttpServlet {
|
|||
public static final Logger s_logger = Logger.getLogger(ApiServlet.class.getName());
|
||||
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
|
||||
|
||||
ApiServer _apiServer;
|
||||
AccountService _accountMgr;
|
||||
@Inject ApiServer _apiServer;
|
||||
@Inject AccountService _accountMgr;
|
||||
|
||||
public ApiServlet() {
|
||||
super();
|
||||
|
|
|
|||
|
|
@ -20,24 +20,15 @@ import java.lang.reflect.AnnotatedElement;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
import com.cloud.user.UserContext;
|
||||
|
||||
@Aspect
|
||||
public class ActionEventInterceptor {
|
||||
|
||||
public ActionEventInterceptor() {
|
||||
}
|
||||
|
||||
@Pointcut(value="execution( * *(..))")
|
||||
public void anyMethod() {
|
||||
}
|
||||
|
||||
@Around("anyMethod() && @annotation(ActionEvent)")
|
||||
public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable {
|
||||
MethodSignature methodSignature = (MethodSignature)call.getSignature();
|
||||
Method targetMethod = methodSignature.getMethod();
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
|
|||
|
||||
static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
|
||||
|
||||
@Inject AccountService _accountSvc = null;
|
||||
@Inject ConfigurationDao _configDao = null;
|
||||
@Inject UserDao _userDao = null;
|
||||
@Inject AccountService _accountSvc;
|
||||
@Inject ConfigurationDao _configDao;
|
||||
@Inject UserDao _userDao;
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@ import javax.ejb.Local;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Component
|
||||
@Local(value={UserDao.class})
|
||||
@DB
|
||||
public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao {
|
||||
protected SearchBuilder<UserVO> UsernamePasswordSearch;
|
||||
protected SearchBuilder<UserVO> UsernameSearch;
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ public class TransactionContextBuilder implements MethodInterceptor {
|
|||
private boolean needToIntercept(Method method) {
|
||||
DB db = method.getAnnotation(DB.class);
|
||||
if (db != null) {
|
||||
return db.txn();
|
||||
return true;
|
||||
}
|
||||
|
||||
Class<?> clazz = method.getDeclaringClass();
|
||||
do {
|
||||
db = clazz.getAnnotation(DB.class);
|
||||
if (db != null) {
|
||||
return db.txn();
|
||||
return true;
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
} while (clazz != Object.class && clazz != null);
|
||||
|
|
|
|||
Loading…
Reference in New Issue