Virgo整合ECF

來源:互聯網
上載者:User

ECF架構是OSGI-RemoteService的聲明實現,其依賴Bundle包括:
org.eclipse.ecf
org.eclipse.ecf.osgi.services.distribution
org.eclipse.ecf.osgi.services.remoteserviceadmin
org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy
org.eclipse.core.runtime
org.eclipse.equinox.app
org.eclipse.ecf.identity
org.eclipse.ecf.discovery
org.eclipse.equinox.concurrent
org.eclipse.equinox.preferences
org.eclipse.core.jobs
org.eclipse.equinox.registry
org.eclipse.osgi.services.remoteserviceadmin
org.eclipse.core.contenttype
org.eclipse.ecf.provider.jmdns
org.eclipse.ecf.sharedobject
org.eclipse.ecf.provider
org.eclipse.ecf.remoteservice
org.eclipse.ecf.provider.remoteservice
ECF架構的很多plugin都設計成了消極式載入模式(Bundle-ActivationPolicy: lazy),因此需要首先修改virgo的設定檔($VTS-HOME/lib/org.eclipse.virgo.kernel.launch.properties).將osgi.compatibility.eagerStart.LazyActivation屬性設定成true,來確保virgo支援消極式載入機制。

另外所聲明服務的bundle(這裡為org.chen.test.service)和發布服務的bundle(這裡為org.chen.test)也需要聲明成消極式載入模式(Bundle-ActivationPolicy: lazy)
一、通過DS方式發布RemoteService
Plan資訊如下:

<?xml version="1.0" encoding="UTF-8"?><plan name="ecf.plan" version="1.0.0" scoped="false" atomic="true"        xmlns="http://www.eclipse.org/virgo/schema/plan"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.eclipse.org/virgo/schema/planhttp://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd"><artifact name="org.eclipse.ecf" type="bundle"/><artifact name="org.eclipse.ecf.osgi.services.distribution" type="bundle"/><artifact name="org.eclipse.ecf.osgi.services.remoteserviceadmin" type="bundle"/><artifact name="org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy" type="bundle"/><artifact name="org.eclipse.core.runtime" type="bundle"/><artifact name="org.eclipse.equinox.app" type="bundle"/><artifact name="org.eclipse.ecf.identity" type="bundle"/><artifact name="org.eclipse.ecf.discovery" type="bundle"/><artifact name="org.eclipse.equinox.concurrent" type="bundle"/><artifact name="org.eclipse.equinox.preferences" type="bundle"/><artifact name="org.eclipse.core.jobs" type="bundle"/><artifact name="org.eclipse.equinox.registry" type="bundle"/><artifact name="org.eclipse.osgi.services.remoteserviceadmin" type="bundle"/><artifact name="org.eclipse.core.contenttype" type="bundle"/><artifact name="org.eclipse.ecf.provider.jmdns" type="bundle"/><artifact name="org.eclipse.ecf.sharedobject" type="bundle"/><artifact name="org.eclipse.ecf.provider" type="bundle"/><artifact name="org.eclipse.ecf.remoteservice" type="bundle"/><artifact name="org.eclipse.ecf.provider.remoteservice" type="bundle"/><artifact name="org.chen.test.service" type="bundle"/><artifact name="org.chen.test" type="bundle"/></plan>

服務發布如下:

<?xml version="1.0" encoding="UTF-8"?><scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" enabled="true" immediate="true" name="hello.ds.host">   <implementation class="org.chen.test.HelloComponent"/>   <property name="service.exported.interfaces" type="String" value="*"/>   <property name="service.exported.configs" type="String" value="ecf.generic.server"/>   <property name="ecf.exported.containerfactoryargs" type="String" value="ecftcp://localhost:3787/server"/>   <service>      <provide interface="org.chen.test.service.IHelloService"/>   </service></scr:component>

二、通過gemini發布、擷取服務
在DS發布環境的基礎上新增cn.com.gei.krp.remoteservice,該bundle用於發布和擷取遠程服務。
1.RemoteServiceExporter用於發布遠程服務,發布配置如下:

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:osgi="http://www.springframework.org/schema/osgi"   xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/osgi       http://www.springframework.org/schema/osgi/spring-osgi.xsd"><bean id="helloService" class="org.chen.test.HelloComponent" /><osgi:reference id="containerManager" interface="org.eclipse.ecf.core.IContainerManager"/><bean id="helloServiceExporter" class="cn.com.gei.krp.remoteservice.RemoteServiceExporter" init-method="start"><property name="containerManager" ref="containerManager"/><!-- 服務介面 --><property name="serviceInterface" value="org.chen.test.service.IHelloService"/><!-- 服務執行個體 --><property name="serviceImplementation" ref="helloService"/><!-- 服務URL --><property name="serviceHostAddress" value="ecftcp://localhost:3788/server" /></bean></beans>

2.RemoteServiceImporter用於擷取遠程服務,配置如下:

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/osgi       http://www.springframework.org/schema/osgi/spring-osgi.xsd"><osgi:reference id="containerManager" interface="org.eclipse.ecf.core.IContainerManager" /><bean id="helloServiceImporter"class="cn.com.gei.krp.remoteservice.RemoteServiceImporter" init-method="start"><property name="containerManager" ref="containerManager" /><property name="serviceInterface"value="org.chen.test.service.IHelloService" /><property name="remoteServiceHostAddress" value="ecftcp://localhost:3788/server" /></bean><bean id="helloService" factory-bean="helloServiceImporter" factory-method="getRemoteService" /><bean id="consumer" class="proxy.remote.Consumer"><property name="service" ref="helloService"></property></bean></beans>

Plan資訊如下:

<?xml version="1.0" encoding="UTF-8"?><plan name="ecf.plan" version="1.0.0" scoped="false" atomic="true"        xmlns="http://www.eclipse.org/virgo/schema/plan"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.eclipse.org/virgo/schema/plan        http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd"><artifact name="org.eclipse.ecf" type="bundle"></artifact><artifact name="org.eclipse.ecf.osgi.services.distribution" type="bundle"></artifact><artifact name="org.eclipse.ecf.osgi.services.remoteserviceadmin" type="bundle"></artifact><artifact name="org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy" type="bundle"></artifact><artifact name="org.eclipse.core.runtime" type="bundle"/><artifact name="org.eclipse.equinox.app" type="bundle"></artifact><artifact name="org.eclipse.ecf.identity" type="bundle"/><artifact name="org.eclipse.ecf.discovery" type="bundle"/><artifact name="org.eclipse.equinox.concurrent" type="bundle"/><artifact name="org.eclipse.equinox.preferences" type="bundle"/><artifact name="org.eclipse.core.jobs" type="bundle"></artifact><artifact name="org.eclipse.equinox.registry" type="bundle"/><artifact name="org.eclipse.osgi.services.remoteserviceadmin" type="bundle"></artifact><artifact name="org.eclipse.core.contenttype" type="bundle"/><artifact name="org.eclipse.ecf.provider.jmdns" type="bundle"/><artifact name="org.eclipse.ecf.sharedobject" type="bundle"/><artifact name="org.eclipse.ecf.provider" type="bundle"/><artifact name="org.eclipse.ecf.remoteservice" type="bundle"/><artifact name="org.eclipse.ecf.provider.remoteservice" type="bundle"></artifact><artifact name="cn.com.gei.krp.remoteservice" type="bundle"/><artifact name="org.chen.test.service" type="bundle"></artifact><artifact name="org.chen.test" type="bundle"></artifact></plan>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.