Hi guys!
My osgi-based app structure lists below:
bundle 1: cn.nfs.demo.biz.common, the interface definition of the business logic;
bundle 2: cn.nfs.demo.biz.service, the implementation of the bisiness logic;
bundle 3: WebExtension2, the web tier of the app;
bundle 4: cn.nfs.demo.springaop, the aspects of the business logci.
i want to weave the aspect of bundle4 into bundle2, but it fails.
The aspect definition in bundle 4:
The aop-beans.xml in the path: /META-INF/spring of bundle 4:Code:package cn.nfs.demo.springaop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; @Aspect public class HelloAspect { @Pointcut("execution(* cn.nfs.demo.biz.service.UserMgrImpl.printUserName())") public void pointUserName(){} @Around("pointUserName()") public Object performAspect(ProceedingJoinPoint jp) throws Throwable { System.out.println("In aspects!" ); return jp.proceed(); } }
The MANIFEST.MF of bundle 4:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" default-autowire="byName"> <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"> <property name="proxyTargetClass" value="true"></property> </bean> <bean class="cn.nfs.demo.springaop.HelloAspect" /> </beans>
Code:Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Springaop Plug-in Bundle-SymbolicName: cn.nfs.demo.springaop Bundle-Version: 1.0.0 Bundle-Activator: cn.nfs.demo.springaop.Activator Import-Package: cn.nfs.demo.biz.common, org.osgi.framework;version="1.3.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.springsource.org.aspectj.runtime;bundle-version="1.6.5", org.springframework.aspects;bundle-version="2.5.6", org.springframework;bundle-version="2.5.6" Bundle-ClassPath: .
The biz interface definition in bundle1:
The biz implementation in bundle 2:Code:package cn.nfs.demo.biz.common; import java.util.List; import cn.nfs.demo.biz.common.entity.UserInfo; public interface IUserMgr { void printUserName(); }
Code:package cn.nfs.demo.biz.service; import cn.nfs.demo.biz.common.IUserMgr; public class UserMgrImpl implements IUserMgr{ @Override public void printUserName() { String msg = " OiuNt xOiuNt "; System.out.println(msg); } }Code:id State Bundle 0 ACTIVE org.eclipse.osgi_3.4.0.v20080605-1900 37 ACTIVE org.eclipse.osgi.services_3.1.200.v20071203 38 ACTIVE cn.nfs.demo.mvc_1.0.0 39 ACTIVE org.eclipse.equinox.jsp.jasper_1.0.100.v20080427-0830 40 ACTIVE org.apache.commons.el_1.0.0.v200806031608 41 ACTIVE org.apache.commons.logging_1.0.4.v20080605-1930 42 ACTIVE WebExtension1_1.0.0 43 ACTIVE com.springsource.javax.servlet.jsp.jstl_1.1.2 44 ACTIVE cn.nfs.demo.biz.common_1.0.0 45 ACTIVE org.springframework_2.5.6.SEC01 46 ACTIVE com.springsource.javax.servlet.jsp_2.1.0 47 ACTIVE org.springframework.osgi.extender_1.2.0.rc1 48 ACTIVE org.eclipse.equinox.common_3.4.0.v20080421-2006 49 ACTIVE org.eclipse.equinox.http.jetty_1.1.0.v20080425 50 ACTIVE com.springsource.javax.servlet_2.5.0 51 ACTIVE org.springframework.osgi.core_1.2.0.rc1 53 ACTIVE WebExtension2_1.0.0 54 ACTIVE cn.nfs.demo.mvc.util_1.0.0 55 ACTIVE org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20080427-0830 56 ACTIVE org.eclipse.equinox.http.registry_1.0.100.v20080427-0830 57 ACTIVE com.springsource.org.apache.taglibs.standard_1.1.2 58 ACTIVE org.mortbay.jetty_5.1.14.v200806031611 59 ACTIVE com.springsource.javax.el_1.0.0 60 ACTIVE org.apache.jasper_5.5.17.v200806031609 61 ACTIVE org.springframework.web.servlet_2.5.6.SEC01 62 ACTIVE org.eclipse.equinox.registry_3.4.0.v20080516-0950 63 ACTIVE org.springframework.osgi.web_1.2.0.rc1 64 ACTIVE org.springframework.osgi.io_1.2.0.rc1 65 ACTIVE org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830 66 ACTIVE cn.nfs.demo.biz.service_1.0.0 67 ACTIVE org.eclipse.osgi.util_3.1.300.v20080303 69 ACTIVE com.springsource.org.aspectj.runtime_1.6.5.RELEASE 72 ACTIVE org.springframework.aspects_2.5.6.SEC01 73 ACTIVE cn.nfs.demo.springaop_1.0.0
When i invoke the method UserMgrImpl.printUserName() in web tier, the HelloAspect of bundle 4 does not execute.
In addition, i implement another aspejct bundle using eclipse aspectj, and it works. However, i think maybe it's hard to incorporate with spring based apps, so i try to use the spring aop form of aspectj.
Could anyone help me to find out the problem? If the information isn't enough, i will send more information or the whole application.
Thanks very much!
OiuNt
2010-3-22


