本文整理汇总了Java中org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext类的典型用法代码示例。如果您正苦于以下问题:Java OsgiBundleXmlApplicationContext类的具体用法?Java OsgiBundleXmlApplicationContext怎么用?Java OsgiBundleXmlApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OsgiBundleXmlApplicationContext类属于org.springframework.osgi.context.support包,在下文中一共展示了OsgiBundleXmlApplicationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initApplicationContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
protected void initApplicationContext() throws Exception {
OsgiBundleXmlApplicationContext ac = new OsgiBundleXmlApplicationContext();
try {
ac.setBundleContext(bundleContext());
ac.setPublishContextAsService(false);
String[] springConfigFiles = getSpringConfigFiles();
if (springConfigFiles != null && springConfigFiles.length > 0) {
ac.setConfigLocations(springConfigFiles);
}
// ac.refresh();
ac.normalRefresh();
ac.start();
} catch (Exception e) {
ac.close();
throw e;
}
this.applicationContext = ac;
}
开发者ID:DDTH,项目名称:osgi-bundle-frontapi,代码行数:19,代码来源:AbstractSpringActivator.java
示例2: createApplicationContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(BundleContext bundleContext)
throws Exception {
Bundle bundle = bundleContext.getBundle();
ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle, configurationScanner);
if (log.isTraceEnabled())
log.trace("Created configuration " + config + " for bundle "
+ OsgiStringUtils.nullSafeNameAndSymName(bundle));
// it's not a spring bundle, ignore it
if (!config.isSpringPoweredBundle()) {
return null;
}
log.info("Discovered configurations " + ObjectUtils.nullSafeToString(config.getConfigurationLocations())
+ " in bundle [" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]");
DelegatedExecutionOsgiBundleApplicationContext sdoac = new OsgiBundleXmlApplicationContext(
config.getConfigurationLocations());
sdoac.setBundleContext(bundleContext);
sdoac.setPublishContextAsService(config.isPublishContextAsService());
return sdoac;
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:24,代码来源:DefaultOsgiApplicationContextCreator.java
示例3: getHeaderLocations
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
/**
* Returns the location headers (if any) specified by the Spring-Context
* header (if available). The returned Strings can be sent to a
* {@link org.springframework.core.io.ResourceLoader} for loading the
* configurations.
*
* @param headers bundle headers
* @return array of locations specified (if any)
*/
public static String[] getHeaderLocations(Dictionary headers) {
String header = getSpringContextHeader(headers);
String[] ctxEntries;
if (StringUtils.hasText(header) && !(';' == header.charAt(0))) {
// get the config locations
String locations = StringUtils.tokenizeToStringArray(header, DIRECTIVE_SEPARATOR)[0];
// parse it into individual token
ctxEntries = StringUtils.tokenizeToStringArray(locations, CONTEXT_LOCATION_SEPARATOR);
// replace * with a 'digestable' location
for (int i = 0; i < ctxEntries.length; i++) {
if (CONFIG_WILDCARD.equals(ctxEntries[i]))
ctxEntries[i] = OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION;
}
}
else {
ctxEntries = new String[0];
}
return ctxEntries;
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:32,代码来源:ConfigUtils.java
示例4: testAppContextClassHierarchy
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void testAppContextClassHierarchy() {
Class[] clazz = ClassUtils.getClassHierarchy(OsgiBundleXmlApplicationContext.class,
ClassUtils.INCLUDE_ALL_CLASSES);
Class[] expected = new Class[] { OsgiBundleXmlApplicationContext.class,
AbstractDelegatedExecutionApplicationContext.class, DelegatedExecutionOsgiBundleApplicationContext.class,
ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class, ApplicationContext.class,
Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
HierarchicalBeanFactory.class, MessageSource.class, ApplicationEventPublisher.class,
ResourcePatternResolver.class, BeanFactory.class, ResourceLoader.class, AutoCloseable.class,
AbstractOsgiBundleApplicationContext.class, AbstractRefreshableApplicationContext.class,
AbstractApplicationContext.class, DisposableBean.class, DefaultResourceLoader.class };
String msg = "Class: ";
for (int i=0;i<clazz.length;i++) {
msg += clazz[i].getSimpleName() + " ";
}
assertTrue(msg, compareArrays(expected, clazz));
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:19,代码来源:ClassUtilsTest.java
示例5: RealtimeRuleEngineContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
private RealtimeRuleEngineContext() {
LOG.info("Starting a stateless Rule Engine");
try {
String[] configLocations = {"classpath:applicationContext_Realtime.RuleEngine.xml"};
OsgiBundleXmlApplicationContext osgiAppContext = new OsgiBundleXmlApplicationContext(configLocations);
osgiAppContext.setClassLoader(osgiAppContext.getClassLoader());
osgiAppContext.setBundleContext(Activator.getBundleContext());
osgiAppContext.refresh();
context = osgiAppContext;
} catch (Exception e) {
LOG.error("Failed to create spring context", e);
this.destroyContext();
throw new RuntimeException(e);
}
}
开发者ID:CodeGerm,项目名称:Pathogen,代码行数:16,代码来源:RealtimeRuleEngineContext.java
示例6: destroyContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void destroyContext() {
if ( context != null ) {
((OsgiBundleXmlApplicationContext) context).close();
}
LOG.info("Spring context closed");
}
开发者ID:CodeGerm,项目名称:Pathogen,代码行数:11,代码来源:RealtimeRuleEngineContext.java
示例7: run
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void run() {
if (applicationContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) applicationContext).close();
}
if (applicationContext instanceof OsgiBundleXmlApplicationContext){
try {
((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
} catch (BundleException e) {
LOG.info("Error stopping OSGi bundle " + e, e);
}
}
}
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:14,代码来源:SpringOsgiContextHook.java
示例8: testXmlOsgiContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void testXmlOsgiContext() throws Exception {
OsgiBundleXmlApplicationContext context = new OsgiBundleXmlApplicationContext(
new String[] { "/org/springframework/osgi/iandt/context/no-op-context.xml" });
context.setBundleContext(bundleContext);
context.refresh();
checkedPublishedOSGiService(2);
context.close();
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:10,代码来源:PublishedInterfacesTest.java
示例9: onSetUp
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
protected void onSetUp() throws Exception {
DICT.put("foo", "bar");
DICT.put("white", "horse");
// Set up the bundle storage dirctory
System.setProperty("com.gatespace.bundle.cm.store", CONFIG_DIR);
System.setProperty("felix.cm.dir", CONFIG_DIR);
initializeDirectory(CONFIG_DIR);
prepareConfiguration();
String[] locations = new String[] { "org/springframework/osgi/iandt/propertyplaceholder/placeholder.xml" };
ctx = new OsgiBundleXmlApplicationContext(locations);
ctx.setBundleContext(bundleContext);
ctx.refresh();
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:15,代码来源:PropertyPlaceholderTest.java
示例10: loadAppContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
private ConfigurableOsgiBundleApplicationContext loadAppContext() {
OsgiBundleXmlApplicationContext appContext = new OsgiBundleXmlApplicationContext(
new String[] { "/org/springframework/osgi/iandt/importer/importer-ordering.xml" });
appContext.setBundleContext(bundleContext);
appContext.refresh();
return appContext;
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:8,代码来源:ServiceComparatorTest.java
示例11: getNestedContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
private ConfigurableApplicationContext getNestedContext() throws Exception {
OsgiBundleXmlApplicationContext ctx = new OsgiBundleXmlApplicationContext(
new String[] { "org/springframework/osgi/iandt/nonosgicl/context.xml" });
ctx.setBundleContext(bundleContext);
ctx.refresh();
return ctx;
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:9,代码来源:NonOSGiLoaderProxyTest.java
示例12: testSetServletContextWOBundleContextWithParent
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void testSetServletContextWOBundleContextWithParent() throws Exception {
servletContext = new MockServletContext();
BundleContext bc = new MockBundleContext();
ConfigurableOsgiBundleApplicationContext parent = new OsgiBundleXmlApplicationContext();
parent.setBundleContext(bc);
context.setParent(parent);
context.setServletContext(servletContext);
assertSame(servletContext, context.getServletContext());
assertSame(bc, parent.getBundleContext());
assertSame(bc, context.getBundleContext());
assertSame(parent, context.getParent());
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:13,代码来源:OsgiBundleXmlWebApplicationContextTest.java
示例13: getDMCoreBundle
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public static Bundle getDMCoreBundle(BundleContext ctx) {
ServiceReference ref = ctx.getServiceReference(PackageAdmin.class.getName());
if (ref != null) {
Object service = ctx.getService(ref);
if (service instanceof PackageAdmin) {
PackageAdmin pa = (PackageAdmin) service;
if (pa != null) {
return pa.getBundle(OsgiBundleXmlApplicationContext.class);
}
}
}
return null;
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:14,代码来源:BundleUtils.java
示例14: tstConfigLocationsInMetaInfWithWildcardHeader
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void tstConfigLocationsInMetaInfWithWildcardHeader() throws Exception {
Dictionary headers = new Hashtable();
headers.put("Spring-Context", "*;wait-for-dependencies:=false");
EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
String[] configFiles = config.getConfigurationLocations();
assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
assertEquals("1 config files", 1, configFiles.length);
assertEquals(OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION, configFiles[0]);
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:13,代码来源:ApplicationContextConfigurationTest.java
示例15: tstEmptyConfigLocationsInMetaInf
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
public void tstEmptyConfigLocationsInMetaInf() throws Exception {
System.out.println("tsst");
Dictionary headers = new Hashtable();
headers.put("Spring-Context", ";wait-for-dependencies:=false");
EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
aBundle.setEntryReturnOnNextCallToGetEntry(new URL(META_INF_SPRING_CONTENT[0]));
ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
String[] configFiles = config.getConfigurationLocations();
assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
assertEquals("1 config files", 1, configFiles.length);
assertEquals(OsgiBundleXmlApplicationContext.DEFAULT_CONFIG_LOCATION, configFiles[0]);
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:14,代码来源:ApplicationContextConfigurationTest.java
示例16: createApplicationContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
@Override
protected OsgiBundleXmlApplicationContext createApplicationContext() {
return getOsgiSpringContext(new ReleaseIdImpl("dummyGroup", "dummyArtifact", "dummyVersion"),
DroolsOnBodyCamelKarafIntegrationTest.class.getResource("/org/drools/karaf/itest/camel-context.xml"));
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:6,代码来源:DroolsOnBodyCamelKarafIntegrationTest.java
示例17: createApplicationContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
@Override
protected OsgiBundleXmlApplicationContext createApplicationContext() {
return getOsgiSpringContext(new ReleaseIdImpl("dummyGroup", "dummyArtifact", "dummyVersion"),
DroolsOnCommandCamelKarafIntegrationTest.class.getResource("/org/drools/karaf/itest/camel-context.xml"));
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:6,代码来源:DroolsOnCommandCamelKarafIntegrationTest.java
示例18: createAppCtx
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
private void createAppCtx() {
appCtx = new OsgiBundleXmlApplicationContext(
new String[] { "/org/springframework/osgi/iandt/syntheticEvents/importers.xml" });
appCtx.setBundleContext(bundleContext);
appCtx.refresh();
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:7,代码来源:ServiceListenerSyntheticEvents.java
示例19: WarListenerConfiguration
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
/**
* Constructs a new <code>WarListenerConfiguration</code> instance.
* Locates the extender configuration, creates an application context which
* will returned the extender items.
*
* @param bundleContext extender OSGi bundle context
*/
public WarListenerConfiguration(BundleContext bundleContext) {
Bundle bundle = bundleContext.getBundle();
Properties properties = new Properties(createDefaultProperties());
Enumeration enm = bundle.findEntries(EXTENDER_CFG_LOCATION, XML_PATTERN, false);
if (enm == null) {
log.info("No custom extender configuration detected; using defaults...");
warScanner = createDefaultWarScanner();
warDeployer = createDefaultWarDeployer(bundleContext);
contextPathStrategy = createDefaultContextPathStrategy();
}
else {
String[] configs = copyEnumerationToList(enm);
log.info("Detected extender custom configurations at " + ObjectUtils.nullSafeToString(configs));
// create OSGi specific XML context
ConfigurableOsgiBundleApplicationContext context = new OsgiBundleXmlApplicationContext(configs);
context.setBundleContext(bundleContext);
context.refresh();
synchronized (lock) {
extenderConfiguration = context;
}
warScanner = context.containsBean(WAR_SCANNER_NAME) ? (WarScanner) context.getBean(WAR_SCANNER_NAME,
WarScanner.class) : createDefaultWarScanner();
warDeployer = context.containsBean(WAR_DEPLOYER_NAME) ? (WarDeployer) context.getBean(WAR_DEPLOYER_NAME,
WarDeployer.class) : createDefaultWarDeployer(bundleContext);
contextPathStrategy = context.containsBean(CONTEXT_PATH_STRATEGY_NAME) ? (ContextPathStrategy) context.getBean(
CONTEXT_PATH_STRATEGY_NAME, ContextPathStrategy.class)
: createDefaultContextPathStrategy();
// extender properties using the defaults as backup
if (context.containsBean(PROPERTIES_NAME)) {
Properties customProperties = (Properties) context.getBean(PROPERTIES_NAME, Properties.class);
Enumeration propertyKey = customProperties.propertyNames();
while (propertyKey.hasMoreElements()) {
String property = (String) propertyKey.nextElement();
properties.setProperty(property, customProperties.getProperty(property));
}
}
}
undeployWarsAtShutdown = getUndeployWarsAtShutdown(properties);
}
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:56,代码来源:WarListenerConfiguration.java
示例20: createApplicationContext
import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; //导入依赖的package包/类
protected abstract OsgiBundleXmlApplicationContext createApplicationContext();
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:2,代码来源:OSGiIntegrationSpringTestSupport.java
注:本文中的org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论