【发布时间】:2015-07-24 11:58:25
【问题描述】:
我如何将equinox Weaving 与bndtools 一起使用,因为equinox Weaving 示例太旧且无法正常工作?
更新:
尝试运行 Hello world 的编织示例时
我有两个包:
public class HelloService implements BundleActivator {
public void start(final BundleContext context) throws Exception {
System.out.println("Hello world!");
}
public void stop(final BundleContext context) throws Exception {
System.out.println("Good bye world!");
}
}
bnd.bnd
-buildpath: \
osgi.core,\
osgi.cmpn,\
biz.aQute.bnd.annotation,\
${junit}
Bundle-Version: 0.0.0.${tstamp}
Require-Bundle: helloaspect
Export-Package: \
com.weaving.hellohistorytest
Bundle-Activator: com.weaving.hellohistorytest.HelloService
方面捆绑:
@Component
@Aspect
public class HelloAspect {
/**
* Replaces the "Hello world!" output with "Hi from HelloAspect ;-)".
*/
@Before("execution(* HelloService+.*(..))")
public void advice() {
System.out.println("hello aspect");
}
}
bnd.bnd
-buildpath: \
osgi.core,\
osgi.cmpn,\
biz.aQute.bnd.annotation,\
${junit},\
aspectjrt-1.7.3,\
aspectjweaver,\
org.eclipse.equinox.supplement
Bundle-Version: 0.0.0.${tstamp}
Service-Component: \
*
Export-Package: \
com.weaving.helloaspect;aspects="HelloAspect"
Eclipse-SupplementBundle: com.weaving.hellohistorytest
launch.bndrun
runbundles: \
org.apache.felix.gogo.runtime,\
org.apache.felix.gogo.shell,\
org.apache.felix.gogo.command,\
org.eclipse.equinox.weaving.aspectj,\
org.eclipse.equinox.weaving.hook,\
aspectjweaver,\
aspectjrt-1.7.3,\
osgi.cmpn,\
osgi.core,\
cnf.run.equinox.common,\
org.apache.felix.framework,\
osgi.enterprise,\
org.eclipse.equinox.supplement,\
helloaspect;version=latest,\
hellohistorytest;version=latest,\
-runproperties:\
osgi.framework.extensions=org.eclipse.equinox.weaving.hook
-runrequires:\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
-runvm: -Dosgi.framework.extensions=org.eclipse.equinox.weaving.hook,\
-Daj.weaving.verbose=true,\
-Dorg.aspectj.weaver.showWeaveInfo=true,\
-Dorg.aspectj.osgi.verbose=true
当我运行启动时: 我得到你好世界而不是你好方面 还有,Aspect Weaving Hooks Plug-in (Incubation) 设置已解决
有什么问题?
【问题讨论】:
-
还是没有得到任何帮助
-
建议进行(确保 Aspect 在每个步骤之后仍在运行)(1)尝试从 git repo 中获取示例(3.x 或 4.x)。 (2) 移除其他环境 (3) 移除其他方面(只保留您想要使用的那个) (4) 添加您的包 (5) 调整方面以修改您的包非常整洁。这就是为什么我提供了GitHub repo
-
@PeterKirschner。感谢您的帮助。为什么如果我在
int x,y,z; public AfterAspect(int _x,int _y,int _z){ x=_x; y=_y; z=_z; }之前在@After("execution (* example.aspectj.app.Application.methodToModify(..))") public void methodAfter(JoinPoint joinPoint)之前添加一个构造函数,它会打印启动AspectJ 演示应用程序 使用参数"Hi RCP World! 调用 methodToModify 3 次而不进入 methodAfter 内部方面 ??
标签: osgi aspectj equinox load-time-weaving bndtools