- 浏览: 545002 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (251)
- UML/RUP/软件工程 (0)
- DDD:领域驱动设计 (1)
- IaaS/Paas/SaaS (1)
- Hadoop/YARN (10)
- PBDP项目 (2)
- OSGi-基础 (7)
- OSGi-Aries (2)
- OSGi-SpringDM (32)
- Oracle/MySQL/SS (8)
- Felix/Equinox/Bnd (14)
- Virgo Server/Gemini (7)
- Weblogic/JBoss/Tomcat (10)
- ActiveMQ (14)
- Camel (1)
- Spring Roo/Eclipse (7)
- Java/JSP/JSF (10)
- Maven (19)
- ESB-Mule (1)
- ESB-ServiceMix (18)
- SOA/SCA/SDO (12)
- WebService/RESTful (17)
- JS/jQuery/ExtJS (4)
- Spring/JPA/MVC (15)
- SpringSecurity (5)
- BPM/jBPM (3)
- Hudson/SVN/CI (0)
- LinuxOS/虚拟化 (25)
- Office/OpenOffice (1)
- 项目管理 (5)
- POI/jFreeChart (1)
最新评论
-
panamera:
请问JMS Transport 发布的webservice 是 ...
CXF 提供的Service Transport-JMS Transpor -
jianyi296:
where is attachment.
CXF WebService Dynamic Client -
hj01kkk:
您好,我用jdbc-user-service为什么每次验证时都 ...
SpringSecurity笔记3-Authenticating Users:Authenticaton Strategy -
wufenglin1231:
你好,我在实现Mapping exceptions to re ...
RESTful 异常处理 -
xchd:
[echo] Project: common
[echo ...
Hive安装配置学习笔记
1. Configuration for registering services:The tag:service
(1)BEAN REFERENCE
Spring DM also supports the use of an anonymous bean(inner bean) within the service tag, as
shown in the following:
<osgi:service id="testService" interface="com.manning.sdmia.springdm.service.TestService">
<bean class="com.manning.sdmia.springdm.service.impl.TestServiceImpl"/>
</osgi:service>
其中,bean:TestServiceImpl无Id,不能在Spring配置文件中其他地方使用。
(2) SERVICE INTERFACE SUPPORT
Because OSGi allows you to register services under several identifiers, Spring DM also provides
an inner interfaces tag that accepts a list of values, as shown in the following:
<osgi:service id="testService" ref="testServiceBean">
<osgi:interfaces>
<value>
com.manning.sdmia.springdm.service.TestService
</value>
<value>(...)</value>
</osgi:interfaces>
</osgi:service>
In addition to this explicit configuration of interfaces, Spring DM provides a mechanism to detect
values used for the interface attribute and interfaces tag. This mechanism is configured through
the auto-export attribute and provides alternative strategies to autodetect interfaces when the
interface attribute and interfaces tag are not specified, as described follow:
■ disabled:Default strategy where you need to explicitly specify values of the interface
attribute and interfaces tag;
■ interfaces:Strategy using all the interfaces implemented by the service;
■ class-hierarchy:Strategy using the class and all parent classes of the service;
■ all-classes:Corresponds to both the interfaces and class-hierarchy strategies。
示例:
<osgi:service id="testService" ref="testServiceBean" auto-export="interfaces"/>
(3) SERVICE PROPERTY SUPPORT,使用service-properties标签:
<osgi:service id="testService" ref="testServiceBean"
interface="com.manning.sdmia.springdm.service.TestService">
<osgi:service-properties>
<entry key="creationDate" value="2009-12-12"/>
(...)
</osgi:service-properties>
</osgi:service>
(4)MANAGING THE CLASSLOADING CONTEXT
If TCCL specified in the service registration configuration , Spring DM makes it possible during the
service call to see all the classes of the bundle that registers the service,When exporting a bean
as an OSGi service, Spring DM allows you to specify which classes are reachable from this
service based on the TCCL managed by Spring DM. At this level, either no classes, or classes
present in the bundle that registers service, will be reachable.This behavior can be configured
using the context-class-loader attribute of the service tag. For example:
<osgi:service id="testService" ref="testServiceBean"
interface="com.manning.sdmia.springdm.service.TestService"
context-class-loader="service-provider"/>
Context classloading strategies for the context-class-loader attribute:
■ unmanaged:This is the default strategy, where no context classloader management is done.
■ service-provider:This strategy allows the service implementation, during the service call, to
see all the classes of the bundle that registered the service.
(5)SERVICE-RANKING SUPPORT
Spring DM allows you to specify a rank for a service through the service tag’s ranking attribute.
This attribute is optional and its default value is 0. The following snippet shows how to use this
attribute:
<osgi:service id="testService" ref="testServiceBean"
interface="com.manning.sdmia.springdm.service.TestService" ranking="5"
/>
OSGi’s ranking feature is used when you’re trying to obtain a service reference and there’s more
than one service match. In this situation, the service with the highest ranking will match. The
ranking of services is also used by Spring DM as a tiebreaker in its shutdown algorithm.
(6)BUNDLE SCOPE
SpringDM提供了一个Bean Scope:bundle,而OSGi 规范也规定了一个借口:ServiceFactory,用于针对特定
的服务请求创建每个Bundle的服务实例;SpringDM实现这种机制没有使用OSGi规范中ServiceFactory接口,
而是使用bundle Scpoe来实现.
The configuration of the service factory feature using bundle scope must be done on the bean (in
the bean tag) in order to export the bean as a service. It is not done on the service exporter (the
service tag of the osgi namespace). The following snippet shows this:
<osgi:service id="testService" ref="testServiceBean"
interface="com.manning.sdmia.springdm.service.TestService"/>
<bean id=" testServiceBean" scope="bundle"
class="com.manning.sdmia.springdm.service.impl.TestServiceImpl">
(...)
</bean>
2. Configuration for referencing services(using a single service.)
(1)SERVICE INTERFACE SUPPORT
<osgi:reference id="testService">
<osgi:interfaces>
<value>
com.manning.sdmia.springdm.service.TestService
</value>
<value>(...)</value>
</osgi:interfaces>
</osgi:reference>
(2)SERVICE AVAILABILITY IN REFERENCING
The availability attribute of the reference tag allows you to configure whether or not service is
optional, and it accepts the values listed follow:
Values for the availability attribute:
■ optional:This value specifies that the service is optional and doesn’t need to be available all
the time.
■ mandatory:This is the default value, which specifies that the service is mandatory for the
component to function correctly. The service must always be present for the component’s
execution.
注意:Before Spring DM version 2, the availability attribute was named cardinality . In that
context, the value 0..1 was the equivalent of the optional value, and 1.. was the equivalent
of mandatory.
Setting the value for the availability attribute specifies how Spring DM should behave during
service matching and, more particularly, when the service can’t be immediately resolved.
Different behaviors of Spring DM depending on service availability :
■ On Spring container startup
Availability:mandatory
Description:The container waits until the service is available before completing its startup.
If the service isn’t available after the specified timeout, the container throws a
ServiceUnavailableException exception and the container isn’t started.
Availability:optional
Description:The container starts even if the referenced service isn’t available.
■ Spring container started
Availability:mandatory
Description:On a service call, if the service isn’t available, the container waits until the service
becomes available to execute the call. If the service isn’t available after the specified timeout,
the container throws a ServiceUnavailableException exception.
Availability:mandatory
Description:It behaves in the same way as on Spring container startup.
示例:
<osgi:reference id="testService" interface="com.manning.sdmia.springdm.service.TestService"
availability="optional"
/>
<osgi:reference id="testService" interface="com.manning.sdmia.springdm.service.TestService"
timeout="1000" depends-on="anotherBean"/>
(3)CLASSLOADER MANAGEMENT
As with service exporting, Spring DM provides support to automatically manage the TCCL when
calling a referenced service. Spring DM allows a service call invocation to see all the classes of
the calling bundle, or of the bundle that registered the service, through the setting of the TCCL.
When referencing an OSGi service, Spring DM allows you to specify which classes are reachable
from this service by setting the context classloader. At this level, either no classes, or classes
present in the bundle that either registers or calls the service, will be reachable.
The class visibility can be configured using the context-class-loader attribute of the service tag.
<osgi:reference id="testService" interface="com.manning.sdmia.springdm.service.TestService"
context-class-loader="service-provider"
/>
Context classloading strategies for the context-class-loader attribute :
■ Strategy:client
Description:This default strategy allows the implementation to see all the classes of the calling
component during the service call.
■ Strategy: service-provider
Description:This strategy allows the service implementation to see all the classes of the bundle
that registered the service during its call.
■ Strategy:unmanaged
Description:This strategy performs no context classloader management.
注意:Classloader management for services can be configured both when registering and
referencing services. Spring DM will always override the reference setting if the service setting
is configured.
(4)SERVICE SELECTION
Spring DM allows you to specify fine-grained selection of services at the level of the reference
element. Two attributes are available:
■ filter: can be used as an expression
to select a subset of services to be matched.
■ bean-name: allows you to select the service with the bean-name property set.
For this to work,
the service must have been registered using Spring DM or a tool that also uses the bean-name
property.
The following snippet shows how to select the service corresponding to the TestService interface
and having a creationDate attribute with the value 2009-12-12:
<osgi:reference id="testService" interface="com.manning.sdmia.springdm.service.TestService"
filter="(creationDate='2009-12-12')"/>.
发表评论
-
SpringDM笔记31-Testing with OSGi and SpringDM
2011-11-22 10:27 12461. 创建一个SpringDM测试类 SpringD ... -
SpringDM笔记30-OSGi中使用SSL/STL
2011-11-21 11:55 1319SSL:Secure Sockets Layer ... -
SpringDM笔记29-Require-Bundle与Import-Package的区别
2011-11-21 10:31 2238具体可参考:http://www.osgi.org/bl ... -
SpringDM笔记28-OSGi Bundle Activities with Spring-DM
2011-11-17 10:19 1159OSGi框架中也支持搞层次的模块交互:bundles.例如 ... -
SpringDM笔记28-Spring And OSGi:Layers of Integration
2011-11-15 11:00 11761. Application Design:Service和B ... -
SpringDM笔记27-Extending The Stand Extender and Configure
2011-09-02 09:38 8691. -
SpringDM笔记25-Using AJAX frameworks with Spring DM:GWT
2011-09-01 08:53 12011. Using Spring DM with AJAX fr ... -
SpringDM笔记24-Using action-based web frameworks with Spring DM:SpringMVC
2011-08-30 09:33 1479■ Action-based web frameworks ... -
SpringDM笔记23-Using the open EntityManager in view pattern实现延迟加载
2011-08-30 09:27 15671. The open EntityManager in vi ... -
SpringDM笔记22-Transactions Support With SpringDM
2011-08-29 21:24 12111. Spring’s transactional suppo ... -
SpringDM笔记21-Using ORM within OSGi with Spring DM
2011-08-25 10:31 2096Version 1.Object/relational ma ... -
SpringDM笔记20-Using JDBC within OSGi with Spring DM
2011-08-25 09:08 1776The public API for interact ... -
SpringDM笔记19-SpringDM如何处理OSGi应用的动态行为
2011-08-24 08:51 1143ServiceTracker 1. Dealing ... -
SpringDM笔记18-Designing OSGi Enterprise Applications
2011-08-22 11:08 11221. Organizing OSGi components ... -
SpringDM笔记17-Handling Collections of OSGi Services
2011-08-20 09:12 15421.Configuring collections:the l ... -
SpringDM笔记16-处理OSGi服务的动态性:事件
2011-08-19 09:51 17801. Service registration and unr ... -
SpringDM笔记14-The thread context classloader 及在OSGi中的运用
2011-08-18 10:40 22481. Using the thread context cla ... -
SpringDM笔记13-OSGi服务注册与引用
2011-08-18 09:28 34501. Combining OSGi services and ... -
SpringDM笔记12-Spring DM’s web Extender运行机制
2011-08-17 11:04 2088SpringDM把一个WAR作为一个Bundle, 其实 ... -
SpringDM笔记11-Hard dependencies on the OSGi environment
2011-08-17 10:50 1414Any bean in a Spring DM app ...
相关推荐
NULL 博文链接:https://springsfeng.iteye.com/blog/1149243
NULL 博文链接:https://springsfeng.iteye.com/blog/1148907
NULL 博文链接:https://springsfeng.iteye.com/blog/1152012
NULL 博文链接:https://springsfeng.iteye.com/blog/1271565
NULL 博文链接:https://springsfeng.iteye.com/blog/1259203
黑马程序员-SpringCloud-学习笔记-03-Eureka注册中心
Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新最新
spring-DM 分布式 spring-DM 分布式 spring-DM 分布式 spring-DM 分布式
黑马程序员-SpringCloud-学习笔记01-认识微服务
spring-dm-referencespring-dm-referencespring-dm-referencespring-dm-referencespring-dm-referencespring-dm-reference
SSH笔记-通过property-placeholder使用外部属性文件的demo
spring-webmvc-struts.jar对Struts和Spring整合时需要用到的包
spring源码缺失jar。spring-cglib-repack-3.2.5.jar,spring-objenesis-repack-2.6.jar
Spring笔记_2017-07-131
Spring笔记_2017-07-141
Spring笔记_2017-07-121
Spring.NET学习笔记 - 刘冬.NET - 博客园
SPRING 笔记SPRING 笔记SPRING 笔记
NULL 博文链接:https://coolszy.iteye.com/blog/520913
spring-boot spring-security-oauth2 完整demo,可以使用微信的方式来获取token和查看资源,注意看代码中的备注