{"id":186940,"date":"2013-07-18T12:00:02","date_gmt":"2013-07-18T08:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=186940"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=186940","title":{"rendered":"<span class=\"post_title\">AOP in action. AspectJ (CTW) + Spring + LTW<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0420\u0435\u0448\u0438\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0410\u041e\u041f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043d\u0435 \u0432\u043d\u0435\u0434\u0440\u0438\u043b. \u041a\u0430\u043a \u0438 \u043f\u043e\u0447\u0435\u043c\u0443, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0443\u0442\u044c \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0410\u041e\u041f, \u0430 \u043e\u043f\u0438\u0448\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f, \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043d\u044f\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<br \/>  \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0432 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 Spring, WebLogic, google.com \u0438 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u0443\u0434\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0410\u041e\u041f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0410\u041e\u041f.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2116 1<\/h4>\n<p>  <i>Spring AOP \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 proxy-based \u043f\u043e\u0434\u0445\u043e\u0434. <\/i><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 (\u0421lassA) \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (methodA, methodB), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c methodB() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 methodA() \u0438 \u0430\u0441\u043f\u0435\u043a\u0442 (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c after) \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 methodA():<\/p>\n<p>  <a name=\"habracut\"><\/a> <\/p>\n<pre><code class=\"java\">public class ClassA {      public void methodA() {         System.out.println(&quot;methodA&quot;);     }      public void methodB() {         System.out.println(&quot;methodB&quot;);         methodA();     } }  public class AspectClass {     public void aspectMethodA() {         System.out.println(&quot;Aspect on method A&quot;);     } } <\/code><\/pre>\n<p>  \u0418 \u043d\u0435\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u043e\u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:  <\/p>\n<pre><code class=\"java\">public void execute() {         \/\/ .....          classA.methodA();         classA.methodB();         \/\/ .....      } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Spring AOP) \u0431\u0443\u0434\u0435\u0442:  <\/p>\n<pre><code class=\"java\">methodA Aspect on method A methodB methodA <\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0435, \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u0430\u0441\u043f\u0435\u043a\u0442 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412 <a href=\"http:\/\/static.springsource.org\/spring\/docs\/2.5.5\/reference\/aop.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b Spring-AOP, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u0435\u0433\u043e, \u0432\u0441\u0435 \u0432\u0441\u0442\u0430\u0435\u0442 \u043d\u0430 \u0441\u0432\u043e\u0438 \u043c\u0435\u0441\u0442\u0430. \u042d\u0442\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2116 2<\/h4>\n<p>  <i>\u041c\u0435\u0442\u043e\u0434\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c public.<\/i> \u0422\u0443\u0442 \u0431\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>  \u0422\u0430\u043a \u0432\u043e\u0442, \u043f\u043e\u0447\u0438\u0442\u0430\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:  <\/p>\n<ul>\n<li>Load-time weaving (LTW).<\/li>\n<li>Compile-time weaving (CTW).<\/li>\n<\/ul>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u043d\u0430\u0448\u0435\u043b \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043f\u043e <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.0.0.RC2\/reference\/html\/ch07s08.html\">LTW<\/a>, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0433\u043e. \u0426\u0435\u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430:  <\/p>\n<ol>\n<li>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e .xml \u0444\u0430\u0439\u043b\u0430, \u043a\u0443\u0434\u0430 \u043c\u044b \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0438 pointcut-\u044b, aspect-\u044b.<\/li>\n<li>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 aop.xml, \u0433\u0434\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0448\u0438 weaver-\u044b (\u043a\u043b\u0430\u0441\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0447\u0443\u0432\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435), aspects-\u044b.<\/li>\n<li>Pointcut-\u044b \u0442\u0435\u043f\u0435\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u0434 aspect-\u0430\u043c\u0438.\n<pre><code class=\"java\">@Before( &quot;execution(*  com.solutions. web.test.WebTestClass.testA())&quot;)     public void testALog() {} <\/code><\/pre>\n<\/li>\n<li>\u041d\u0430\u0434 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f<code> @Aspect<\/code>.<\/li>\n<li>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 JM\/WebLogic:\n<pre><code class=\"java\">-javaagent:${PATH_TO_LIB }\/aspectjweaver.jar <\/code><\/pre>\n<\/li>\n<\/ol>\n<p>  <\/p>\n<h5>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432 <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.0.0.RC2\/reference\/html\/ch07s08.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> (aop.context):  <\/p>\n<pre><code class=\"xml\">     &lt;weaver&gt;         &lt;include within=&quot;foo.*&quot;\/&gt;     &lt;\/weaver&gt;      &lt;aspects&gt;         &lt;aspect name=&quot;foo.ProfilingAspect&quot;\/&gt;     &lt;\/aspects&gt; <\/code><\/pre>\n<p>  \u0414\u0430 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u043e\u0434\u043d\u043e \u041d\u041e \u2014 \u043c\u044b \u0440\u0435\u0434\u043a\u043e \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u0434 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435\/\u043f\u0430\u043a\u0435\u0442\u0435. \u042d\u0442\u0443 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0434\u0435\u0442\u0430\u043b\u044c \u043e\u043d\u0438 \u0443\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u0422\u0430\u043a \u0432\u043e\u0442, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 (ClassA) \u0438 \u0430\u0441\u043f\u0435\u043a\u0442 (AspectA) \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u0430\u0445, \u0442\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 aop.xml:  <\/p>\n<pre><code class=\"xml\">    &lt;weaver&gt;         &lt;include within=&quot;com.example.ClassA&quot;\/&gt; &lt;!-- \u043f\u0443\u0442\u044c \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 --&gt;         &lt;include within=&quot;com.log.* &quot;\/&gt; &lt;!\u2014\u043f\u0443\u0442\u044c \u043a \u043f\u0430\u043a\u0435\u0442\u0443 \u0441 \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c\u0438&gt;     &lt;\/weaver&gt;      &lt;aspects&gt;         &lt;aspect name=&quot;com.log.AspectA&quot;\/&gt;     &lt;\/aspects&gt; <\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u0433\u0435 <code>&lt;weaver&gt;<\/code> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u0430\u0441\u043f\u0435\u043a\u0442\u044b + \u043f\u0430\u043a\u0435\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2116 3<\/h4>\n<p>  <i>LTW \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 EAR\/APP \u0443\u0440\u043e\u0432\u043d\u0435. <\/i>  <\/p>\n<blockquote><p>\u00abAs Costin said, there is unfortunately nothing we can do about this. Load-time weaving only works for specific deployment units such as WARs, and even there it is considered an advanced feature that won&#8217;t work in all runtime environments.\u201d<\/p><\/blockquote>\n<p>  \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u044d\u0442\u043e\u0442 <a href=\"https:\/\/jira.springsource.org\/browse\/SPR-6176\">\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/a> \u044f \u0438\u0441\u043a\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>  <b>\u0420\u0435\u0448\u0435\u043d\u0438\u0435\u043c<\/b> \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043a\u0430\u043a \u0432\u044b \u0434\u043e\u0433\u0430\u0434\u0430\u043b\u0438\u0441\u044c, \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 CTW. \u0426\u0435\u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u0430:  <\/p>\n<ol>\n<li>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 aspect-\u044b \u0438 pointcut-\u044b.<\/li>\n<li>C\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044f \u0410\u041e\u041f \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043e\u0434\u0438\u043d \u043f\u0430\u043a\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 pointcut-\u044b, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<li>\u041d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ajc-\u043a\u043e\u043c\u043f\u0430\u0439\u043b\u0435\u0440, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0435\u0433\u043e \u043a \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 (ant, maven, gradle\u2026).<\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2116 4<\/h4>\n<p>  <i>CTW+LTW \u043d\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438.<\/i><\/p>\n<p>  \u041c\u043e\u0436\u0435\u0442 \u043c\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u043d\u043e \u043f\u043e \u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u043c\u043d\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c LTW \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e \u0432\u0435\u0441\u044c classpath \u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0421TW \u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439:  <\/p>\n<pre><code class=\"java\"> java.lang.Exception: java.lang.NoSuchMethodError: com.aop.example.log.AspectA.aspectOf()Lcom\/aop\/example\/log\/AspectA; <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f LTW.<\/p>\n<h4>\u0418\u0422\u041e\u0413\u041e<\/h4>\n<p>  \u0427\u0442\u043e \u044f \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0432\u044b\u043d\u0435\u0441 \u0438 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c:  <\/p>\n<ol>\n<li>\u0414\u043b\u044f \u0432\u0441\u0435\u0445 public \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f (EAR\/APP, WEB \u0443\u0440\u043e\u0432\u0435\u043d\u044c) \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spring AOP.<\/li>\n<li>\u0414\u043b\u044f \u0432\u0441\u0435\u0433\u043e WEB \u0443\u0440\u043e\u0432\u043d\u044f \u043d\u0435 public \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c LTW (\u0435\u0441\u043b\u0438 \u0421TW \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f).<\/li>\n<li>\u0414\u043b\u044f \u0432\u0441\u0435\u0433\u043e APP \u0443\u0440\u043e\u0432\u043d\u044f \u043d\u0435 public \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CTW (\u0435\u0441\u043b\u0438 LTW \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f).<\/li>\n<li>\u0412 \u0442\u0435\u0433\u0435<code> &lt;weaver&gt;<\/code> \u0444\u0430\u0439\u043b\u0430 app.context \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u0430\u043c\u0438 \u201cweav\u201d \u043a\u043b\u0430\u0441\u0441\u044b \u0442\u0430\u043a \u0438 aspect-\u044b.<\/li>\n<li>CTW \u0438 LTW \u043d\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438.<\/li>\n<\/ol>\n<p>  \u0412 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e WEB \u0438 APP \u0443\u0440\u043e\u0432\u043d\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 Spring AOP + CTW \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c\u0438.<br \/>  \u041e\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c .xml \u0444\u0430\u0439\u043b\u0435 \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438 \u0441\u043b\u0435\u0434\u0430. \u0418\u0437-\u0437\u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u044f \u043d\u0435 \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u044d\u0442\u0443 \u0437\u0430\u0442\u0435\u044e \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<h4>\u041f\u0440\u043e\u0435\u043a\u0442<\/h4>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442-\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0437 <a href=\"https:\/\/github.com\/Liroyd\/aop.git\">github-a<\/a>. \u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 maven-e.<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 Executor \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f spring-bean-\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 execute().<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0435\u043b\u0438, \u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"java\">--methodA-- method Aspect Before for methodCTW --methodCTW-- method Aspect After for method A   --webMethodA-- method Web Aspect Before  for MethodCTW --webMethodForCTW-- method Web Aspect After web method A <\/code><\/pre>\n<h4>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/h4>\n<p>  \u0421\u043f\u0438\u0441\u043e\u043a \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b:  <\/p>\n<ol>\n<li><a href=\"http:\/\/static.springsource.org\/spring\/docs\/2.5.5\/reference\/aop.html\">Spring AOP<\/a>.<\/li>\n<li><a href=\"http:\/\/eclipse.org\/aspectj\/\">AspectJ<\/a>.<\/li>\n<li><a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.0.0.RC2\/reference\/html\/ch07s08.html\">AspectJ+Spring, LTW<\/a>.<\/li>\n<li><a href=\"http:\/\/www.mkyong.com\/spring3\/spring-aop-aspectj-in-xml-configuration-example\/\">Spring3-AOP-AspectJ-XML-Example<\/a>.<\/li>\n<\/ol>\n<p>  C\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0437 \u0425\u0430\u0431\u0440\u0430:  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/112466\/\">AspectJ, Spring, Maven<\/a>.<\/li>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/114649\/\">\u0417\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0410\u041e\u041f<\/a>.<\/li>\n<\/ol>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/186940\/\"> http:\/\/habrahabr.ru\/post\/186940\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0420\u0435\u0448\u0438\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0410\u041e\u041f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043d\u0435 \u0432\u043d\u0435\u0434\u0440\u0438\u043b. \u041a\u0430\u043a \u0438 \u043f\u043e\u0447\u0435\u043c\u0443, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0443\u0442\u044c \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0410\u041e\u041f, \u0430 \u043e\u043f\u0438\u0448\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f, \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043d\u044f\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<br \/>  \u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0432 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 Spring, WebLogic, google.com \u0438 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u0443\u0434\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0410\u041e\u041f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0421\u043a\u0430\u0436\u0443 \u0441\u0440\u0430\u0437\u0443, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0410\u041e\u041f.<\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2116 1<\/h4>\n<p>  <i>Spring AOP \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 proxy-based \u043f\u043e\u0434\u0445\u043e\u0434. <\/i><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 (\u0421lassA) \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (methodA, methodB), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c methodB() \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 methodA() \u0438 \u0430\u0441\u043f\u0435\u043a\u0442 (\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c after) \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 methodA():<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-186940","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/186940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186940"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/186940\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}