首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何使用Equinox织布和bndtools

我如何使用Equinox织布和bndtools
EN

Stack Overflow用户
提问于 2015-05-13 09:27:02
回答 1查看 770关注 0票数 1

如何将equinox Weavingbndtools结合使用,因为equinox Weaving示例已经过时,无法使其工作。

最新情况:

当尝试运行Hello world的编织示例时

我有两包:

代码语言:javascript
复制
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

代码语言:javascript
复制
-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

方面束:

代码语言:javascript
复制
@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

代码语言:javascript
复制
-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

代码语言:javascript
复制
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

当我运行启动:我得到Hello而不是hello方面,方面编织钩子插件(孵化器)被设置为解决。

有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-13 09:56:08

GitHub上可以找到一个可用的源代码示例。

通常,这里指令也适用于与bndtools一起使用。

添加所需的包

代码语言:javascript
复制
-runbundles: \
  org.eclipse.equinox.weaving.aspectj,\
  org.aspectj.runtime,\
  org.aspectj.weaver

确保org.eclipse.equinox.weaving.hook位于同一位置。

代码语言:javascript
复制
-runpath: org.eclipse.equinox.weaving.hook

并且您需要在*.bndrun中提供以下运行属性

代码语言:javascript
复制
-runproperties:\
   osgi.framework.extensions=org.eclipse.equinox.weaving.hook

下列运行时属性可选地用于调试。注意,输出总是进入std.err流,即使它们正常工作)。

代码语言:javascript
复制
aj.weaving.verbose=true,\
org.aspectj.weaver.showWeaveInfo=true,\
org.aspectj.osgi.verbose=true,\
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30210725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档