dedecms.com
The Spring extender recognizes a bundle as "Spring-powered"andwill create an associated application context when the bundleisstarted if one or both of the following conditions is true: 内容来自dedecms
如果满足以下两个条件,Springextender会通过一个bundle的具有"Spring-powered"的验证,当这个bundle启动时会为其创建一个相关联的applicationcontext:
The bundle classpath contains a folder META-INF/spring with oneormore files in that folder with a ".xml" extension.
本文来自织梦
这个bundle的classpath包含一个目录META-INF/spring,这个目录中有一个或多个扩展名为".xml"的文件。 本文来自织梦
META-INF/MANIFEST.MF contains a manifestheaderSpring-Context.
这个bundle中的META-INF/MANIFEST.MF文件包含一个名为Spring-Context的header。
dedecms.com
In addition, if the optional SpringExtender-Version headerisdeclared in the bundle manifest, then the extender willonlyrecognize bundles where the specified version constraintsaresatisfied by the version of the extender bundle(Bundle-Version).The value of the SpringExtender-Version headermust follow thesyntax for a version range as specified in section3.2.5 of theOSGi Service Platform Core Specification.
copyright dedecms
另外,如果bundle的manifest声明了可选header-SpringExtender-Version,那么extender将仅仅认可与之版本相符的指定版本约束的bundle(bundle的Bundle-Version)。SpringExtender-Version的值必须遵循OSGi规范3.2.5节中指定的版本范围。
In the absence of the Spring-Context header the extenderexpectsevery ".xml" file in the META-INF/spring folder to be avalidSpring configuration file, and all directives (see below) takeontheir default values.
在缺少Spring-Context的情况下,springextender仍然认为所有META-INF/spring中".xml"的文件都是spring的配置文件,所有的header都是默认值。 织梦内容管理系统
An application context is constructed from this set of files.Asuggested practice is to split the applicationcontextconfiguration into at least two files, named byconventionmodulename-context.xml and modulename-osgi-context.xml.Themodulename-context.xml file contains regular beandefinitionsindependent of any knowledge of OSGi.Themodulename-osgi-context.xml file contains the bean definitionsforimporting and exporting OSGi services. It may (but is notrequiredto) use the Spring Dynamic Modules OSGi schema as thetop-levelnamespace instead of the Spring "beans" namespace. 内容来自dedecms
applicationcontext就是根据这些文件(META-INF/spring中".xml"的文件)构造的。一个推荐的做法是将applicationcontext配置文件至少分割成2个文件,习惯上命名为[模块名-context.xml]和[模块名-osgi-context.xml]。modulename-context.xml文件包含了不依赖与OSGi相关的bean的定义(可以理解为普通bean定义)。modulename-osgi-context.xml文件则定义那些引入或输出OSGi服务的bean。这可能需要使用SpringDynamicModules的OSGischema做为顶级命名空间,取代spring的"bean"命名空间,但这不是必须的。 织梦内容管理系统
以下是 Spring-Context的和配置,主要意思如下:
dedecms.com
1.如果在Spring-Context指定了配置文件,那么extender将忽略META-INF/spring中的配置文件,除非明确指定。 织梦好,好织梦
2.可以用通配符,例如Spring-Context: osgi-*;
3.create-asynchronously=false(默认值是true),使用同步方式创建该bundle的applicationcontext。有一点需要注意,同步创建applicationcontext的过程是在OSGi的事件线程中进行的,它将阻塞这个线程的事件发送,直到完成applicationcontext的初始化。如果这个过程中发生了错误,那么将出现一个FrameworkEvent.ERROR,但是bundle的状态仍然还是ACTIVE。
copyright dedecms
复制地址和好友共享







