本文整理汇总了Java中org.osgi.service.blueprint.container.BlueprintContainer类的典型用法代码示例。如果您正苦于以下问题:Java BlueprintContainer类的具体用法?Java BlueprintContainer怎么用?Java BlueprintContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlueprintContainer类属于org.osgi.service.blueprint.container包,在下文中一共展示了BlueprintContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
@Override
public void process(ComponentDefinitionRegistry cdr) {
BlueprintContainer container = getComponent(cdr, "blueprintContainer");
Bundle bundle = getComponent(cdr, "blueprintBundle");
cdr.registerComponentDefinition(createServiceRef(JPA_COORDINATOR, Coordinator.class));
Set<String> components = new HashSet<String>(cdr.getComponentDefinitionNames());
for (String component : components) {
ComponentMetadata compDef = cdr.getComponentDefinition(component);
if (compDef instanceof MutableBeanMetadata && !((MutableBeanMetadata)compDef).isProcessor()) {
// Normal bean def
handleComponent((MutableBeanMetadata)compDef, bundle, cdr, container);
} else if(compDef instanceof MutableServiceMetadata) {
// Bean inlined into service def
MutableServiceMetadata sMeta = (MutableServiceMetadata)compDef;
Target target = sMeta.getServiceComponent();
if (target instanceof MutableBeanMetadata) {
handleComponent((MutableBeanMetadata)target, bundle, cdr, container);
}
}
}
}
示例2: testThreadSafePreCall
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
@Test
public void testThreadSafePreCall() throws InterruptedException {
BlueprintContainer container = new BlueprintContainerStub();
interceptor = new JpaInterceptor(container, "coordinator", "em");
Thread t1 = new Thread(this);
Thread t2 = new Thread(this);
t1.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
t2.start();
synchronized (result) {
result.wait();
}
Assert.assertTrue(result.get());
}
示例3: lookupBlueprintCamelContext
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
/**
* Lookup all the {@link BlueprintCamelContext} in the {@link BlueprintContainer}.
*
* @param container the blueprint container, must be provided
* @return a set with the ids of the {@link BlueprintCamelContext}, never <tt>null</tt>, but can be empty set.
*/
public static Set<String> lookupBlueprintCamelContext(BlueprintContainer container) {
Set<String> ids = new LinkedHashSet<String>();
for (Object id : container.getComponentIds()) {
ComponentMetadata meta = container.getComponentMetadata(id.toString());
// must be extended meta, to see if its the blueprint camel context
if (meta instanceof ExtendedBeanMetadata) {
Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
if (clazz != null && BlueprintCamelContext.class.isAssignableFrom(clazz)) {
// okay we found a BlueprintCamelContext
ids.add(meta.getId());
}
}
}
return ids;
}
示例4: testProperties
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
@Test
public void testProperties() throws Exception {
Bundle camelCore = getBundleBySymbolicName("org.apache.camel.camel-core");
Bundle test = getBundleBySymbolicName(getClass().getSimpleName());
camelCore.stop();
test.stop();
Thread.sleep(500);
test.start();
try {
getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + getClass().getSimpleName() + ")", 500);
fail("Expected a timeout");
} catch (RuntimeException e) {
// Expected timeout
}
camelCore.start();
CamelBlueprintHelper.waitForBlueprintContainer(null, test.getBundleContext(), getClass().getSimpleName(), BlueprintEvent.CREATED, null);
getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + getClass().getSimpleName() + ")", 500);
}
示例5: getBeanFactory
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
@Override
public BeanFactory getBeanFactory( Bundle bundle ) {
try {
BundleContext bundleContext = bundle.getBundleContext();
Collection<ServiceReference<BlueprintContainer>> serviceReferences = bundleContext
.getServiceReferences( BlueprintContainer.class,
"(osgi.blueprint.container.symbolicname=" + bundle.getSymbolicName() + ")" );
if ( serviceReferences.size() == 0 ) {
return null;
}
ServiceReference<BlueprintContainer> reference = serviceReferences.iterator().next();
BlueprintContainer service = bundleContext.getService( reference );
return new BeanFactoryBlueprintImpl( service );
} catch ( InvalidSyntaxException e ) {
logger.error( "Error finding blueprint container", e );
return null;
}
}
示例6: BGPClusterSingletonService
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
BGPClusterSingletonService(
@Nonnull final ClusterSingletonServiceProvider provider,
@Nonnull final BGPTableTypeRegistryConsumer tableTypeRegistry,
@Nonnull final BlueprintContainer container,
@Nonnull final BundleContext bundleContext,
@Nonnull final InstanceIdentifier<Bgp> bgpIid) {
this.tableTypeRegistry = tableTypeRegistry;
this.container = container;
this.bundleContext = bundleContext;
this.bgpIid = bgpIid;
final String ribInstanceName = getRibInstanceName(bgpIid);
this.serviceGroupIdentifier = ServiceGroupIdentifier.create(ribInstanceName + "-service-group");
LOG.info("BGPClusterSingletonService {} registered", this.serviceGroupIdentifier.getValue());
ClusterSingletonServiceRegistrationHelper
.registerSingletonService(provider, this);
}
示例7: BgpDeployerImpl
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public BgpDeployerImpl(final String networkInstanceName, final ClusterSingletonServiceProvider provider,
final BlueprintContainer container,
final BundleContext bundleContext, final DataBroker dataBroker,
final BGPTableTypeRegistryConsumer mappingService) {
this.dataBroker = requireNonNull(dataBroker);
this.provider = requireNonNull(provider);
this.networkInstanceName = requireNonNull(networkInstanceName);
this.container = requireNonNull(container);
this.bundleContext = requireNonNull(bundleContext);
this.tableTypeRegistry = requireNonNull(mappingService);
this.networkInstanceIId = InstanceIdentifier.create(NetworkInstances.class)
.child(NetworkInstance.class, new NetworkInstanceKey(networkInstanceName));
Futures.addCallback(initializeNetworkInstance(dataBroker, this.networkInstanceIId), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.debug("Network Instance {} initialized successfully.", networkInstanceName);
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Failed to initialize Network Instance {}.", networkInstanceName, t);
}
}, MoreExecutors.directExecutor());
}
示例8: registerService
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
private void registerService(ApplicationContext applicationContext) {
final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>();
Bundle bundle = bundleContext.getBundle();
String symName = bundle.getSymbolicName();
serviceProperties.put(Constants.BUNDLE_SYMBOLICNAME, symName);
serviceProperties.put(BLUEPRINT_SYMNAME, symName);
Version version = OsgiBundleUtils.getBundleVersion(bundle);
serviceProperties.put(Constants.BUNDLE_VERSION, version);
serviceProperties.put(BLUEPRINT_VERSION, version);
log.info("Publishing BlueprintContainer as OSGi service with properties " + serviceProperties);
// export just the interface
final String[] serviceNames = new String[] { BlueprintContainer.class.getName() };
if (log.isDebugEnabled())
log.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames));
AccessControlContext acc = SecurityUtils.getAccFrom(applicationContext);
// publish service
if (System.getSecurityManager() != null) {
registration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() {
public ServiceRegistration run() {
return bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
}
}, acc);
} else {
registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
}
}
示例9: setUp
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
protected void setUp() throws Exception {
bundleContext = new MockBundleContext();
context = new GenericApplicationContext();
context.setClassLoader(getClass().getClassLoader());
context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
}
});
reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
context.refresh();
BlueprintContainer = new SpringBlueprintContainer(context);
}
示例10: testDependsOnTest
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public void testDependsOnTest() throws Exception {
try {
System.out.println(BlueprintContainer.getComponentInstance("dependsOnComponent"));
fail("expected validation exception");
} catch (NoSuchComponentException nsce) {
}
}
示例11: shutdownAllContainers
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
private void shutdownAllContainers() {
shuttingDown = true;
restartService.close();
// Close all CSS modules first.
ConfigSystemService configSystem = getOSGiService(ConfigSystemService.class);
if (configSystem != null) {
configSystem.closeAllConfigModules();
}
LOG.info("Shutting down all blueprint containers...");
Collection<Bundle> containerBundles = new HashSet<>(Arrays.asList(bundleContext.getBundles()));
while (!containerBundles.isEmpty()) {
// For each iteration of getBundlesToDestroy, as containers are destroyed, other containers become
// eligible to be destroyed. We loop until we've destroyed them all.
for (Bundle bundle : getBundlesToDestroy(containerBundles)) {
containerBundles.remove(bundle);
BlueprintContainer container = blueprintExtenderService.getContainer(bundle);
if (container != null) {
blueprintExtenderService.destroyContainer(bundle, container);
}
}
}
LOG.info("Shutdown of blueprint containers complete");
}
示例12: lookupByType
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public static <T> Map<String, T> lookupByType(BlueprintContainer blueprintContainer, Class<T> type, boolean includeNonSingletons) {
Bundle bundle = (Bundle) blueprintContainer.getComponentInstance("blueprintBundle");
Map<String, T> objects = new LinkedHashMap<String, T>();
Set<String> ids = blueprintContainer.getComponentIds();
for (String id : ids) {
try {
ComponentMetadata metadata = blueprintContainer.getComponentMetadata(id);
Class<?> cl = null;
if (metadata instanceof BeanMetadata) {
BeanMetadata beanMetadata = (BeanMetadata)metadata;
// should we skip the bean if its prototype and we are only looking for singletons?
if (!includeNonSingletons) {
String scope = beanMetadata.getScope();
if (BeanMetadata.SCOPE_PROTOTYPE.equals(scope)) {
continue;
}
}
cl = bundle.loadClass(beanMetadata.getClassName());
} else if (metadata instanceof ReferenceMetadata) {
ReferenceMetadata referenceMetadata = (ReferenceMetadata)metadata;
cl = bundle.loadClass(referenceMetadata.getInterface());
}
if (cl != null && type.isAssignableFrom(cl)) {
Object o = blueprintContainer.getComponentInstance(metadata.getId());
objects.put(metadata.getId(), type.cast(o));
}
} catch (Throwable t) {
// ignore
}
}
return objects;
}
示例13: BlueprintCamelContext
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public BlueprintCamelContext(BundleContext bundleContext, BlueprintContainer blueprintContainer) {
this.bundleContext = bundleContext;
this.blueprintContainer = blueprintContainer;
// inject common osgi
OsgiCamelContextHelper.osgiUpdate(this, bundleContext);
// and these are blueprint specific
setComponentResolver(new BlueprintComponentResolver(bundleContext));
setLanguageResolver(new BlueprintLanguageResolver(bundleContext));
setDataFormatResolver(new BlueprintDataFormatResolver(bundleContext));
setApplicationContextClassLoader(new BundleDelegatingClassLoader(bundleContext.getBundle()));
// must use classloader of the namespace handler
setModelJAXBContextFactory(new BlueprintModelJAXBContextFactory(CamelNamespaceHandler.class.getClassLoader()));
}
示例14: PCEPTopologyDeployerImpl
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public PCEPTopologyDeployerImpl(final BlueprintContainer container,
final DataBroker dataBroker, final InstructionSchedulerFactory instructionSchedulerFactory) {
this.container = requireNonNull(container);
this.dataBroker = requireNonNull(dataBroker);
this.instructionSchedulerFactory = requireNonNull(instructionSchedulerFactory);
this.networTopology = InstanceIdentifier.builder(NetworkTopology.class).build();
}
示例15: LoginPagelet
import org.osgi.service.blueprint.container.BlueprintContainer; //导入依赖的package包/类
public LoginPagelet(
BlueprintContainer blueprintContainer,
GuiFactoryTracker guiFactoryTracker) {
super(blueprintContainer);
this.guiFactoryTracker = Validate.notNull(guiFactoryTracker);
}