当前位置: 首页>>代码示例>>Java>>正文


Java OsgiBundleXmlApplicationContext类代码示例

本文整理汇总了Java中org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext的典型用法代码示例。如果您正苦于以下问题:Java OsgiBundleXmlApplicationContext类的具体用法?Java OsgiBundleXmlApplicationContext怎么用?Java OsgiBundleXmlApplicationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OsgiBundleXmlApplicationContext类属于org.springframework.osgi.context.support包,在下文中一共展示了OsgiBundleXmlApplicationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。