1

私たちのプロジェクト アーキテクチャは、Spring 3 で Struts 1 と Struts 2 を使用しています。例外処理を改善するためにアスペクトを作成しようとしています。Struts 1 は今まで Spring で管理されていなかったので、このリンクに従いました 古い Struts アプリケーションを Spring 3.x と統合して、Spring コンポーネントスキャンが Struts 1 アクションを取得できるようにする方法。

編集: - バージョン

Struts 1 - org.apache.struts.struts-core (1.3.10) Struts 2 - org.apache.struts.struts2-core (2.0.9) 春 - 3.2.2

しかし、私のアスペクトクラスはそれを拾いません。Struts 2 アクションまたはサービス クラスに問題はありません。しかし、ここで何が悪いのか理解できません。

例外アスペクト クラス -

package com.mnm.abc.aop;
public @Aspect @Component class ExceptionHandler {
    @Pointcut("execution(public * abc.web.action.AbcAction+.doExecute(..))")
    public void inStruts1Action() {
    }

/* I tried the following too
* @Pointcut("within(abc.web.action.AbcAction+)")
* @Pointcut("execution(public * abc.web.action.AbcAction.execute(..))")
* @Pointcut("execution(public * abc.web.action.*.doExecute(..)) && within(abc.web.action.AbcAction+)")
*/
    @After("inStruts1Action()")
    public void after() {
        System.out.println("After");
    }
}

Struts 1 アクション クラス -

package abc.web.action;
public @Component class TransactionAction extends AbcAction {
    public @Override ActionForward doExecute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        System.out.println("Hi");
        ActionForward forward = mapping.findForward("success");
        return forward;
    }
}

親クラス -

package abc.web.action;
public abstract class AbcAction extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try {
            return doExecute(mapping, form, request, response);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
    public abstract ActionForward doExecute(ActionMapping mapping,
            ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception;
}

構成クラス -

package com.mnm.abc.config;
@Configuration
@ComponentScan(basePackages = { "abc.web.action", "com.mnm.abc.aop" })
@EnableTransactionManagement
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class DataSourceConfig implements TransactionManagementConfigurer { ... }

デバッグログを調べたところ、次のメッセージが表示されました

Identified candidate component class: file [C:\...\abc\web\action\TransactionAction.class]
...
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Creating shared instance of singleton bean 'transactionAction'
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Creating instance of bean 'transactionAction'
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Eagerly caching bean 'transactionAction' to allow for resolving potential circular references
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator  - Creating implicit proxy for bean 'transactionAction' with 0 common interceptors and 2 specific interceptors
org.springframework.aop.framework.Cglib2AopProxy  - Creating CGLIB2 proxy: target source is SingletonTargetSource for target object [abc.web.action.TransactionAction@1d3981c]
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public org.apache.struts.action.ActionForward abc.web.action.TransactionAction.doExecute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public org.apache.struts.action.ActionForward abc.web.action.AbcAction.execute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected org.apache.struts.util.MessageResources org.apache.struts.action.Action.getResources(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected org.apache.struts.util.MessageResources org.apache.struts.action.Action.getResources(javax.servlet.http.HttpServletRequest,java.lang.String)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public org.apache.struts.action.ActionForward org.apache.struts.action.Action.execute(org.apache.struts.action.ActionMapping,org.apache.struts.action.ActionForm,javax.servlet.ServletRequest,javax.servlet.ServletResponse) throws java.lang.Exception
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected java.util.Locale org.apache.struts.action.Action.getLocale(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.setLocale(javax.servlet.http.HttpServletRequest,java.util.Locale)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public org.apache.struts.action.ActionServlet org.apache.struts.action.Action.getServlet()
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public void org.apache.struts.action.Action.setServlet(org.apache.struts.action.ActionServlet)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected boolean org.apache.struts.action.Action.isCancelled(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected org.apache.struts.action.ActionMessages org.apache.struts.action.Action.getErrors(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.addMessages(javax.servlet.http.HttpServletRequest,org.apache.struts.action.ActionMessages)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.addErrors(javax.servlet.http.HttpServletRequest,org.apache.struts.action.ActionMessages)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected boolean org.apache.struts.action.Action.isTokenValid(javax.servlet.http.HttpServletRequest,boolean)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected boolean org.apache.struts.action.Action.isTokenValid(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.resetToken(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.saveErrors(javax.servlet.http.HttpServletRequest,org.apache.struts.action.ActionMessages)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.saveErrors(javax.servlet.http.HttpServletRequest,org.apache.struts.action.ActionErrors)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.saveMessages(javax.servlet.http.HttpServletRequest,org.apache.struts.action.ActionMessages)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.saveMessages(javax.servlet.http.HttpSession,org.apache.struts.action.ActionMessages)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected void org.apache.struts.action.Action.saveToken(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected java.lang.String org.apache.struts.action.Action.generateToken(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected org.apache.struts.action.ActionMessages org.apache.struts.action.Action.getMessages(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected javax.sql.DataSource org.apache.struts.action.Action.getDataSource(javax.servlet.http.HttpServletRequest)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected javax.sql.DataSource org.apache.struts.action.Action.getDataSource(javax.servlet.http.HttpServletRequest,java.lang.String)
org.springframework.aop.framework.Cglib2AopProxy  - Found finalize() method - using NO_OVERRIDE
org.springframework.aop.framework.Cglib2AopProxy  - Found 'equals' method: public boolean java.lang.Object.equals(java.lang.Object)
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: public java.lang.String java.lang.Object.toString()
org.springframework.aop.framework.Cglib2AopProxy  - Found 'hashCode' method: public native int java.lang.Object.hashCode()
org.springframework.aop.framework.Cglib2AopProxy  - Unable to apply any optimisations to advised method: protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.springframework.aop.Advisor)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.aopalliance.aop.Advice)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isFrozen()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract org.springframework.aop.Advisor[] org.springframework.aop.framework.Advised.getAdvisors()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvice(org.aopalliance.aop.Advice)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(int,org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isPreFiltered()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract java.lang.Class[] org.springframework.aop.framework.Advised.getProxiedInterfaces()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isInterfaceProxied(java.lang.Class)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvisor(org.springframework.aop.Advisor)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.replaceAdvisor(org.springframework.aop.Advisor,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract java.lang.String org.springframework.aop.framework.Advised.toProxyConfigString()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract org.springframework.aop.TargetSource org.springframework.aop.framework.Advised.getTargetSource()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setTargetSource(org.springframework.aop.TargetSource)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setPreFiltered(boolean)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isProxyTargetClass()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setExposeProxy(boolean)
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isExposeProxy()
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(int,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
org.springframework.aop.framework.Cglib2AopProxy  - Method is declared on Advised interface: public abstract java.lang.Class org.springframework.aop.TargetClassAware.getTargetClass()
org.springframework.beans.factory.support.DefaultListableBeanFactory  - Finished creating instance of bean 'transactionAction'

また、抽象メソッド呼び出しと AOP に関するかなりの情報を読みましたが、何も機能していないようです。私を助けてください。

4

0 に答える 0