zoukankan      html  css  js  c++  java
  • 《深入理解OSGi:Equinox原理、应用与最佳实践》笔记_2_建立开发环境

    本文对应书本5.1.3的内容

     书本中通过CVS下载的源码

    但是笔者实践的时候发现无法下载...地址已经失效了(也许是笔者的失误输错地址所致)

    可以用git下载 

    地址是:

    http://git.eclipse.org/c/equinox

    进入需要下载的组件的页面 在最下面有git clone的地址

    http://git.eclipse.org/c/equinox/rt.equinox.framework.git/ 写道
    Clone
    git://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git
    ssh://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git
    http://git.eclipse.org/gitroot/equinox/rt.equinox.framework.git

    在eclipse中下载很简单 打开git仓库的面板 输入地址即可



     

    选择需要的导入就可以了



     

    接下来配置run configuration

    和书中一样这里截图略过:



     

     

    接下来是dev.properties文件和conf.ini文件 如下:

    Properties代码  收藏代码
    1. BundleHelloworld=bin   
    2. org.eclipse.osgi=bin  
    3. @ignoredot@=true  

     conf.ini:

    Java代码  收藏代码
    1. #和书中相比多了很多其他的bundle 这些是启动console必需的  
    2. osgi.bundles=reference:file:G:/osgi_workbench/test/BundleHelloworld@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.command_0.10.0.v201209301215.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.apache.felix.gogo.shell_0.10.0.v201212101605.jar@start,reference:file:E:/eclipseForEE/osgi_test/eclipse/plugins/org.eclipse.equinox.console_1.0.100.v20130429-0953.jar@start  
    3.   
    4. osgi.bundles.defaultStartLevel=4  
    5.   
    6. osgi.framework=file:H:/repository/git/rt.equinox.framework/rt.equinox.framework/bundles/org.eclipse.osgi  
    7.   
    8. #osgi.framework=file/:E:/eclipseForEE/osgi_test/eclipse/plugins/org.eclipse.osgi_3.9.1.v20130814-1242.jar  
    9.   
    10. eclipse.ignoreApp=true  
    11.   
    12. osgi.noShutdown=true  
    13.   
    14. osgi.console=  

    有关以上比书本上多的那几个jar 看:

    http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fconsole_shell.htm

    可以直接用eclipse的plugins文件夹下的

    没有那几个jar BundleHelloworld可以运行 但不会出现 osgi>

    并且会有错误信息 如下:

    log 写道
    !SESSION 2013-12-23 13:33:04.949 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.7.0_40
    java.vendor=Oracle Corporation
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
    Command-line arguments: -dev file:E:/eclipseForEE/osgi_test/config/dev.properties

    !ENTRY org.eclipse.osgi 4 0 2013-12-23 13:33:05.347
    !MESSAGE Could not find bundle: false
    !STACK 0
    org.osgi.framework.BundleException: Could not find bundle: false
    at org.eclipse.core.runtime.internal.adaptor.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:58)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:323)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:222)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

    注意bundle中的文件前应该有 reference:file: 不然会提示找不到

    在以上新建的java application中点run 会出现以下信息就代表运行成功:



     

  • 相关阅读:
    从零实现一个功能完善的迷你区块链
    Merkle Tree理解起来并不难
    微信、支付宝个人收款的一种实现思路
    PostgreSQL的登录、创建用户、数据库并赋权
    java list 按照多字段排序
    2019年最新全国省市区街道共46462条数据(统计局MySQL数据库)
    一份非常值得一看的Java面试题
    spring scope prototype与singleton
    http请求与响应,TCP三次握手&四次分手
    HTTP协议三次握手过程
  • 原文地址:https://www.cnblogs.com/timssd/p/5100905.html
Copyright © 2011-2022 走看看