本文整理汇总了Java中org.osgi.framework.BundleContext.ungetService方法的典型用法代码示例。如果您正苦于以下问题:Java BundleContext.ungetService方法的具体用法?Java BundleContext.ungetService怎么用?Java BundleContext.ungetService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.BundleContext
的用法示例。
在下文中一共展示了BundleContext.ungetService方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public void stop(BundleContext context) throws Exception {
randomNumberServiceTracker.close();
if (serviceReference != null) {
context.ungetService(serviceReference);
serviceReference = null;
}
}
示例2: unsetServiceReference
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
private void unsetServiceReference(BundleContext context) {
if (serviceReference != null) {
if (context != null) {
context.ungetService(serviceReference);
}
serviceReference = null;
}
}
示例3: stop
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public void stop(BundleContext context) throws Exception {
serviceTracker.close();
if (randomNumberGeneratorServiceReference != null) {
context.ungetService(randomNumberGeneratorServiceReference);
}
if (randomStringGeneratorServiceReference != null) {
context.ungetService(randomStringGeneratorServiceReference);
}
}
示例4: log
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
protected void log ( final int level, final String message )
{
final BundleContext context = this.context;
if ( context == null )
{
return;
}
final ServiceReference<LogService> ref = context.getServiceReference ( LogService.class );
if ( ref == null )
{
return;
}
final LogService service = context.getService ( ref );
if ( service == null )
{
return;
}
try
{
service.log ( level, message );
}
finally
{
context.ungetService ( ref );
}
}
示例5: ObjectPoolTracker
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public ObjectPoolTracker ( final BundleContext context, final String poolClass ) throws InvalidSyntaxException
{
final Map<String, String> parameters = new HashMap<String, String> ();
parameters.put ( ObjectPool.OBJECT_POOL_CLASS, poolClass );
final Filter filter = FilterUtil.createAndFilter ( ObjectPool.class.getName (), parameters );
this.poolTracker = new ServiceTracker<ObjectPool<S>, ObjectPool<S>> ( context, filter, new ServiceTrackerCustomizer<ObjectPool<S>, ObjectPool<S>> () {
@Override
public void removedService ( final ServiceReference<ObjectPool<S>> reference, final ObjectPool<S> service )
{
context.ungetService ( reference );
ObjectPoolTracker.this.removePool ( service );
}
@Override
public void modifiedService ( final ServiceReference<ObjectPool<S>> reference, final ObjectPool<S> service )
{
ObjectPoolTracker.this.modifyPool ( service, reference );
}
@Override
public ObjectPool<S> addingService ( final ServiceReference<ObjectPool<S>> reference )
{
final ObjectPool<S> o = context.getService ( reference );
ObjectPoolTracker.this.addPool ( o, reference );
return o;
}
} );
}
示例6: ConnectionAnalyzerFactory
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public ConnectionAnalyzerFactory ( final ScheduledExecutorService executor, final BundleContext context )
{
this.executor = executor;
this.context = context;
this.connectionTracker = new ServiceTracker<ConnectionService, ConnectionService> ( context, ConnectionService.class, new ServiceTrackerCustomizer<ConnectionService, ConnectionService> () {
@Override
public void removedService ( final ServiceReference<ConnectionService> reference, final ConnectionService service )
{
ConnectionAnalyzerFactory.this.removeService ( service );
}
@Override
public void modifiedService ( final ServiceReference<ConnectionService> reference, final ConnectionService service )
{
}
@Override
public ConnectionService addingService ( final ServiceReference<ConnectionService> reference )
{
try
{
logger.debug ( "Found new service: {}", reference );
final ConnectionService service = context.getService ( reference );
ConnectionAnalyzerFactory.this.addService ( reference, service );
return service;
}
catch ( final Throwable e )
{
logger.warn ( "Failed to add service", e );
}
context.ungetService ( reference );
return null;
}
} );
this.connectionTracker.open ();
}
示例7: removedService
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public default void removedService(
ServiceReference<T> serviceReference,
ServiceRegistration<?> serviceRegistration) {
Bundle bundle = FrameworkUtil.getBundle(
ServiceRegistrationServiceTrackerCustomizer.class);
BundleContext bundleContext = bundle.getBundleContext();
bundleContext.ungetService(serviceReference);
serviceRegistration.unregister();
}
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:ServiceRegistrationServiceTrackerCustomizer.java
示例8: removedService
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public void removedService(ServiceReference<T> serviceReference, U u) {
Bundle bundle = FrameworkUtil.getBundle(
TransformServiceTrackerCustomizer.class);
BundleContext bundleContext = bundle.getBundleContext();
bundleContext.ungetService(serviceReference);
onRemovedService(serviceReference, u);
}
示例9: restartConfigModules
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
private void restartConfigModules(final BundleContext bundleContext, final List<Entry<String,
ModuleIdentifier>> configModules) {
if (configModules.isEmpty()) {
return;
}
ServiceReference<ConfigSubsystemFacadeFactory> configFacadeFactoryRef = bundleContext
.getServiceReference(ConfigSubsystemFacadeFactory.class);
if (configFacadeFactoryRef == null) {
LOG.debug("ConfigSubsystemFacadeFactory service reference not found");
return;
}
ConfigSubsystemFacadeFactory configFacadeFactory = bundleContext.getService(configFacadeFactoryRef);
if (configFacadeFactory == null) {
LOG.debug("ConfigSubsystemFacadeFactory service not found");
return;
}
try (ConfigSubsystemFacade configFacade = configFacadeFactory.createFacade(
"BlueprintContainerRestartService")) {
restartConfigModules(configModules, configFacade);
} catch (ParserConfigurationException | DocumentedException | ValidationException
| ConflictingVersionException e) {
LOG.error("Error restarting config modules", e);
} finally {
bundleContext.ungetService(configFacadeFactoryRef);
}
}
示例10: DaveBlockConfigurator
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public DaveBlockConfigurator ( final DaveDevice device, final BundleContext context )
{
this.device = device;
this.context = context;
final Map<String, String> parameters = new HashMap<String, String> ();
parameters.put ( "daveDevice", device.getId () );
try
{
final Filter filter = FilterUtil.createAndFilter ( BlockConfiguration.class.getName (), parameters );
this.tracker = new ServiceTracker<Object, Object> ( context, filter, new ServiceTrackerCustomizer<Object, Object> () {
@Override
public void removedService ( final ServiceReference<Object> reference, final Object service )
{
if ( service instanceof BlockConfiguration )
{
if ( DaveBlockConfigurator.this.removeBlock ( reference, (BlockConfiguration)service ) )
{
context.ungetService ( reference );
}
}
}
@Override
public void modifiedService ( final ServiceReference<Object> reference, final Object service )
{
DaveBlockConfigurator.this.modifyBlock ( reference, (BlockConfiguration)service );
}
@Override
public Object addingService ( final ServiceReference<Object> reference )
{
final Object o = DaveBlockConfigurator.this.context.getService ( reference );
try
{
DaveBlockConfigurator.this.addOrReplaceBlock ( reference, (BlockConfiguration)o );
return o;
}
catch ( final Throwable e )
{
logger.warn ( "Failed to add block", e );
return o;
}
}
} );
}
catch ( final Exception e )
{
logger.warn ( "Failed to configure", e );
}
if ( this.tracker != null )
{
this.tracker.open ();
}
}
示例11: deactivate
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Deactivate
private void deactivate(BundleContext context) {
if (this.initDone.get()) {
context.ungetService(this.dsConformanceCheckMetaTaskSR);
}
}
示例12: deactivate
import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Deactivate
public void deactivate(BundleContext bundleContext) {
bundleContext.ungetService(_serviceReference);
_serviceRegistration.unregister();
}