스프링 DM은 새 버전의 스프링을 지원하지 않지만 Eclipse Gemini Blueprint은 지원하지 않습니다. Spring 3.1.x 이상 및 Blueprint를 사용할 수 있다면 Spring 프로필이 작동 할 수 있습니다. 이를 수행하는 한 가지 방법은 ApplicationContext
Environment
활성 프로필을 적합하게 구성하는 OsgiApplicationContextCreator
을 직접 구현하여 extend the Blueprint Extender bundle입니다. 당신은 청사진 확장 번들에 부착 된 조각 번들이 점을 넣을 필요가
public class MyOsgiApplicationContextCreator extends BlueprintContainerCreator {
@Override
public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(
BundleContext bundleContext) throws Exception {
DelegatedExecutionOsgiBundleApplicationContext applicationContext = super
.createApplicationContext(bundleContext);
if (null == applicationContext) {
// non-spring/blueprint bundles will not build an ApplicationContext
return null;
}
// determine environment profile here...
applicationContext.getEnvironment().setActiveProfiles("myProfile");
return applicationContext;
}
}
예를 들어, 다음 사용자 정의 BlueprintContainerCreator
구현을 고려한다.
META-INF/MANIFEST.MF, META-INF/spring/extender/extender.xml (xml 파일의 이름은 다음과 같이 3 개의 파일로 묶음을 만들어야합니다. xml 확장자이지만 META-INF/spring/extender 폴더에 있어야 함) 및 OsgiApplicationContextCreator
구현. MANIFEST.MF 파일은 OSGi 매니페스트 헤더 Fragment-Host org.eclipse.gemini.blueprint.extender
을 포함해야합니다. 당신은 받는다는 - 번들 플러그인을 사용하는 경우, 플러그인 구성은 다음과 같이 보일 것입니다 :
...
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.5</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Fragment-Host>org.eclipse.gemini.blueprint.extender</Fragment-Host>
<Export-Package>your.package,!*</Export-Package>
<Import-Package>org.osgi.framework,org.springframework.core.env,!*</Import-Package>
</instructions>
</configuration>
</plugin>
...
귀하의 extender.xml 파일 applicationContextCreator
의 이름으로 정의 OsgiApplicationContextCreator
빈을 정의해야합니다. 파일은 다음과 같을 수 있습니다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<util:properties id="extenderProperties">
<prop key="shutdown.wait.time">30000</prop>
</util:properties>
<bean id="applicationContextCreator" class="your.package.MyOsgiApplicationContextCreator"/>
</beans>
그런 다음 사용자 환경에 번들을 배포하십시오. Blueprint 번들과 관련하여이 조각 번들이 설치된 순서에 따라 Blueprint OSGi 번들 (또는 서버)을 다시 시작해야 할 수도 있습니다.