今天继续《OSGi原理与最佳实践》。看到第四章。做 HelloWorld-cxf 的样例

照着样例敲来着,整个样例敲完了,执行。一直报错,

----------------这里是解决方法------------------

	Dictionary<String, String> props = new Hashtable<String, String>();

        props.put("osgi.remote.interfaces", "*");
props.put("osgi.remote.configuration.type", "pojo");
props.put("osgi.remote.configuration.pojo.address", "http://localhost:9000/hello_world"); registration = bundleContext.registerService(HelloWorldServiceInterfaces.class.getName(),
new HelloWorldImple(), props);

把上面的内容改成以下

	Dictionary<String, String> props = new Hashtable<String, String>();

        <span style="color:#ff0000;">props.put("service.exported.interfaces", "*");
props.put("service.exported.configs", "org.apache.cxf.ws");
props.put("org.apache.cxf.ws.address", "http://localhost:9000/hello_world");</span> registration = bundleContext.registerService(HelloWorldServiceInterfaces.class.getName(),
new HelloWorldImple(), props);

bundle配置例如以下,我没有单独到处servlet和osgi,直接用的eclipse里面的

---------------以下是故事。能够不看-------------------

不行,复制原来的代码直接贴过去(网上找的资源)还是一样。

各种缺包的提示。尝试着加入各种bundle。最后都要吐来了。还是提示缺。并且是越来越缺,全然一个无底洞。一定那里出问题了。

删除项目又一次建,还好,这次不提示缺包了,这让我想起了,上一篇里面提到的,有可能是bundle以来问题,应该简单操作一下即可了,详细操作请查看

http://blog.csdn.net/q821424508/article/details/46604279

言归正传,说下今天的问题。

把项目弄好之后启动项目。没有错误提示,訪问的时候抱404错误,控制台提示httpservice startup at 8080 ,这事什么意思,我代码里不是这么写的

	Dictionary<String, String> props = new Hashtable<String, String>();

        props.put("osgi.remote.interfaces", "*");
props.put("osgi.remote.configuration.type", "pojo");
props.put("osgi.remote.configuration.pojo.address", "http://localhost:9000/hello_world"); registration = bundleContext.registerService(HelloWorldServiceInterfaces.class.getName(),
new HelloWorldImple(), props);

这问题就来了。启动不报错。可是訪问不到路径。一定还是那里配置错误,

亲,没错的,代码都是复制过来的。那问题可有可能是版本号的问题,我的环境。cxf插件下载的事最新的cxf-dosgi-ri-singlebundle-distribution-1.2.jar,

osgi也是比书里面的新,

别问我为什么不依照书里面的版本号弄。我也想。仅仅是有些资源时找不到的。所以就依照自己eclipse的默认版本号来了。

说到版本号不同,那就找下官网吧。

Service Provider properties For Configuring SOAP-based services and consumers

Note: for backwards compatibility old values marked below are still supported.

Property Name

Data Type

Example

Description

service.exported.interfaces

(previously:osgi.remote.interfaces)

String

org.example.BarService,org.example.FooService*

Denotes the interfaces to be exposed remotely. This is a comma-separated list of fully qualified Java interfaces that should be made available remotely. A special value of * can be provided meaning that all of the interfaces passed to
the BundleContext.registerService() call are suitable for remoting.

service.exported.configs (previously:osgi.remote.configuration.type)

String

org.apache.cxf.ws

Specifies the mechanism for configuring the service exposure. Possible values:

  • org.apache.cxf.ws (previously: pojo) the OSGi Service is exposed as a Web Service.
  • wsdl configuration driven from WSDL

这个事官网的,

Note: for backwards compatibility old values marked below are still supported.

这句翻译过来,应该是为了兼容老的功能,以下呗标记出来的依旧支持吧,高中水平。不知道是不是这么翻译的。

可是依照翻译来说,我依照书上敲(别扣字眼。是复制来的我知道)的代码应该没问题

继续看

org.apache.cxf.ws configuration type

When the service.exported.configs=org.apache.cxf.ws (or osgi.remote.configuration.type=pojo) property is specified, the following properties may also be specified.

突然来了一句,这句的大概意思是 假设service.exported.configs=org.apache.cxf.ws (or osgi.remote.configuration.type=pojo)
这个被指定了,

那么以下的也必须被设置,

我仅仅能呵呵了 。

Property Name

Data Type

Example

Description

org.apache.cxf.ws.address

(previously:osgi.remote.configuration.pojo.address)

String

{{

http://localhost:9090/greeter

}}

The address at which the service with be made available remotely. If this property is not specified, this defaults to {{

http://localhost:9000/fully/qualified/ClassName

}}.

org.apache.cxf.ws.httpservice.context

(previously:osgi.remote.configuration.pojo.httpservice.context)

String

/auction

When this property is specified, the OSGi HTTP Service is used to expose the service, rather than a dedicated Jetty HTTP Server. This property doesn't allow the specification of a port number, as this is provided by the HTTP Service. The Distributed OSGi distributions
come with Pax-Web, for which configuration information can be found here:

http://wiki.ops4j.org/display/paxweb/Configuration

, however other OSGi HTTP Service implementations are potentially configured differently.

org.apache.cxf.ws.frontend

String

jaxws

The CXF frontend which will be used to create endpoints. Defaults to 'simple' which is an Aegis-based simple frontend. Note that for JAXWS to work a javax.jws.* has to be imported into the interface and/or implementation and client bundles for annotations like
@WebService and @WebMethod be recognized

org.apache.cxf.ws.databinding

String

jaxb

Supported values are 'aegis and 'jaxb', defaults to 'aegis'. Note that for JAXB to work JAXB packages like javax.xml.bind.annotation.* have to be imported

org.apache.cxf.ws.wsdl.location

String

/wsdl/service.wsdl

WSDL location

org.apache.cxf.ws.wsdl.service.ns

String

{{

http://services.org

}}

WSDL service namespace

org.apache.cxf.ws.wsdl.service.name

String

SoapService

WSDL service name

org.apache.cxf.ws.wsdl.port.name

String

SoapServicePort

WSDL port name

org.apache.cxf.ws.in.interceptors

String, String[], List

List of CXF in interceptors

org.apache.cxf.ws.out.interceptors

String, String[], List

List of CXF out interceptors

org.apache.cxf.ws.in.fault.interceptors

String, String[], List

List of CXF in fault interceptors

org.apache.cxf.ws.out.fault.interceptors

String, String[], List

List of CXF out fault interceptors

org.apache.cxf.ws.features

String, String[], List, Object

List of CXF out features

Service Provider properties For Configuring RESTful JAXRS-based endpoints and consumers

org.apache.cxf.rs configuration type

When the service.exported.configs=org.apache.cxf.rs property is specified, the following properties may also be specified.

Property Name

Data Type

Example

Description

org.apache.cxf.rs.address

String

{{

http://localhost:9090/greeter

}}

The address at which the service with be made available remotely. If this property is not specified, this defaults to {{

http://localhost:9000/fully/qualified/ClassName

}}.

org.apache.cxf.rs.httpservice.context

String

/auction

When this property is specified, the OSGi HTTP Service which is used to expose the service, rather than a dedicated Jetty HTTP Server. By default, absolute address may look like 'http://localhost:8080/auction'

org.apache.cxf.rs.provider

Boolean

true/false

Can be used to identify a global JAXRS provider as CXF-compatible

org.apache.cxf.rs.provider.expected

Boolean

true/false

Can be used to require global providers to set an 'org.apache.cxf.rs.provider' property with a value 'true'.

org.apache.cxf.rs.provider.globalquery

Boolean

true/false

Can be used to disable queries for global providers, defaults to 'true'.

org.apache.cxf.rs.databinding

String

aegis

This property has a limited value for JAXRS services as JAXB is supported by default, the only supported value is 'aegis' and it is a shortcut for registering an Aegis provider, see below for more information on how to register custom providers for JAXRS services

org.apache.cxf.rs.wadl.location

String

/wadl/service.wadl

WADL location

org.apache.cxf.rs.provider

String, String[], List

List of JAX-RS providers

org.apache.cxf.rs.in.interceptors

String, String[], List

List of CXF in interceptors

org.apache.cxf.rs.out.interceptors

String, String[], List

List of CXF out interceptors

org.apache.cxf.rs.in.fault.interceptors

String, String[], List

List of CXF in fault interceptors

org.apache.cxf.rs.out.fault.interceptors

String, String[], List

List of CXF out fault interceptors

org.apache.cxf.rs.features

String, String[], List

List of CXF out features


这么多,怎么设。算了。用最新的吧

	Dictionary<String, String> props = new Hashtable<String, String>();

        props.put("service.exported.interfaces", "*");
props.put("service.exported.configs", "org.apache.cxf.ws");
props.put("org.apache.cxf.ws.address", "http://localhost:9000/hello_world"); registration = bundleContext.registerService(HelloWorldServiceInterfaces.class.getName(),
new HelloWorldImple(), props);

最新版的java代码是这种,

能执行,能訪问了。

我还是想吐糟一下。明明说要向下兼容,为什么要设置那么多额外的属性。

distributed OSGI demo的更多相关文章

  1. OSGI动态加载删除Service bundle

    OSGi模块化框架是很早就出来的一个插件化框架,最早Eclipse用它而出名,但这些年也没有大热虽然OSGi已经发布了版本1到版本5.现在用的最多的,也是本文讲述基于的是Equinox的OSGi实现, ...

  2. 使用DOSGi在OSGi环境下发布Web Services

    前言 Apache CXF是一个开源的服务框架项目,而Distributed OSGi子项目提供了基于OSGi远程服务规范的分布式组件实现.它使用Web Services,HTTP上的SOAP手段实现 ...

  3. Build Telemetry for Distributed Services之OpenTracing实践

    官网:https://opentracing.io/docs/best-practices/ Best Practices This page aims to illustrate common us ...

  4. 【HBase】HBase Getting Started(HBase 入门指南)

    入门指南 1. 简介 Quickstart 会让你启动和运行一个单节点单机HBase. 2. 快速启动 – 单点HBase 这部分描述单节点单机HBase的配置.一个单例拥有所有的HBase守护线程- ...

  5. 使用MapReduce实现join操作

     在关系型数据库中,要实现join操作是非常方便的,通过sql定义的join原语就可以实现.在hdfs存储的海量数据中,要实现join操作,可以通过HiveQL很方便地实现.不过HiveQL也是转化成 ...

  6. zhihu spark集群,书籍,论文

    spark集群中的节点可以只处理自身独立数据库里的数据,然后汇总吗? 修改 我将spark搭建在两台机器上,其中一台既是master又是slave,另一台是slave,两台机器上均装有独立的mongo ...

  7. Spark:大数据的电花火石!

    什么是Spark?可能你很多年前就使用过Spark,反正当年我四六级单词都是用的星火系列,没错,星火系列的洋名就是Spark. 当然这里说的Spark指的是Apache Spark,Apache Sp ...

  8. The Apache HBase™ Reference Guide

    以下内容由http://hbase.apache.org/book.html#getting_started节选并改编而来. 运行环境:hadoop-1.0.4,hbase-0.94.22,jdk1. ...

  9. clickhouse入门到实战及面试

    第一章. clickhouse入门 一.ClickHouse介绍 ClickHouse(开源)是一个面向列的数据库管理系统(DBMS),用于在线分析处理查询(OLAP). 关键词:开源.面向列.联机分 ...

随机推荐

  1. workflow engine Ruote初体验之三(条件与美元符号)

    条件 我们可以用:if和:unless公共属性来进行条件判断,或者使用if,given,once或者equals(已经过时)关键字. 使用:if属性: 1 cursor do 2 participan ...

  2. ios iPhone 如何将应用程序名称本地化

    iPhone的应用程序名称也可以本地化,可以按照以下步骤来实施: 1. 修改项目目录下的’ -info.plist’文件名 将’ -info.plist’ 修改为 Info.plist 2. 将Inf ...

  3. MFC 消息类型

    标准(窗口)消息:窗口消息一般与窗口内部运作有关,如创建窗口,绘制窗口,销毁窗口,通常,消息是从系统发到窗口,或从窗口发到系统.发送函数SendMessage()或者PostMessage().除WM ...

  4. 后台CMS日志处理记录

    自从上一次添加了极光推送之后,我的工程就像是着魔了一样,不管怎么调整,日志级别都是DEBUG. 启动一次工程会打印很多无用日志,今天决定抽时间去研究了一下,最终解决了问题,下面记录一下解决过程. 1. ...

  5. MD5算法了解(JAVA实现)

    MD5算法:尽管已经被破解,但任然广泛应用于各个领域中 如文件校验:当我们下载文件时为了保证文件的安全性,我们能够在其站点上找到相应的md5值进行校验,假设md5值不一致,也就是说文件被人动过(一般都 ...

  6. C++的标准模板库STL中实现的数据结构之顺序表vector的分析与使用

    摘要 本文主要借助对C++的标准模板库STL中实现的数据结构的学习和使用来加深对数据结构的理解.即联系数据结构的理论分析和详细的应用实现(STL),本文是系列总结的第一篇,主要针对线性表中的顺序表(动 ...

  7. beforeRouteLeave 实现vue路由拦截浏览器的需求,进行一系列操作 草稿保存等等

    场景:为了防止用户失误点错关闭按钮等等,导致没有保存已输入的信息(关键信息).用法://在路由组件中: beforeRouteLeave (to, from, next) { if(用户已经输入信息) ...

  8. html5,audio音乐播放器

    最终,做了自己原来一直想要实现的事儿.得出的结果是,有些事儿一旦開始做了,那么它就并非非常难. 如今的我,正听着自己的播放器放出的<光辉岁月>写这篇周六清晨的博文.写的不是非常好.但也请各 ...

  9. C# 字节数组拼接的速度实验(Array.copy(),Buffer.BlockCopy(),Contact())

    无聊做了如题的一个算法的优劣性能比较,由于很多人都只关心结果,那么我先贴出结果如下: 由于我的测试数据量比较小,只能得出Array.Copy()和Buffer.BlockCopy()方法性能要好于Co ...

  10. C# MVC VS WebAPI

    获取路径: MVC:Server.MapPath("/Templates/vshop/default.json") WebAPI:System.Web.Hosting.Hostin ...