Javolution 6.0.0 java
javolution.osgi.internal.ServiceTrackerImpl< C > Class Template Reference
Collaboration diagram for javolution.osgi.internal.ServiceTrackerImpl< C >:
[legend]

Public Member Functions

 ServiceTrackerImpl (Class< C > type, Class<? extends C > defaultImplClass)
 
void activate (BundleContext bc)
 
void deactivate (BundleContext bc)
 
Object[] getServices ()
 

Private Attributes

volatile ServiceTracker< C, C > tracker
 
final Class< C > type
 
final Class<? extends C > defaultImplClass
 
defaultImpl
 

Detailed Description

Bridge to service tracker (does not trigger class loading exception if running outside OSGi).

Definition at line 18 of file ServiceTrackerImpl.java.

Constructor & Destructor Documentation

◆ ServiceTrackerImpl()

javolution.osgi.internal.ServiceTrackerImpl< C >.ServiceTrackerImpl ( Class< C >  type,
Class<? extends C >  defaultImplClass 
)

Creates a context tracker for the specified context type.

Definition at line 26 of file ServiceTrackerImpl.java.

26  {
28  this.type = type;
29  }

Member Function Documentation

◆ activate()

void javolution.osgi.internal.ServiceTrackerImpl< C >.activate ( BundleContext  bc)

Activates OSGi tracking.

Definition at line 32 of file ServiceTrackerImpl.java.

32  {
33  ServiceTracker<C, C> trk = new ServiceTracker<C, C>(bc, type, null);
34  trk.open();
35  tracker = trk;
36  }

Referenced by javolution.osgi.internal.JavolutionActivator.start().

Here is the caller graph for this function:

◆ deactivate()

void javolution.osgi.internal.ServiceTrackerImpl< C >.deactivate ( BundleContext  bc)

Deactivates OSGi tracking.

Definition at line 39 of file ServiceTrackerImpl.java.

39  {
40  tracker.close();
41  tracker = null;
42  }

Referenced by javolution.osgi.internal.JavolutionActivator.stop().

Here is the caller graph for this function:

◆ getServices()

Object [] javolution.osgi.internal.ServiceTrackerImpl< C >.getServices ( )

Returns the published services or the default implementation if none.

Definition at line 45 of file ServiceTrackerImpl.java.

45  {
46  ServiceTracker<C, C> trk = tracker;
47  if (trk != null) {
48  Object[] services = trk.getServices();
49  if (services != null) return services;
50  }
51  synchronized (this) {
52  if (defaultImpl == null) {
53  try {
54  defaultImpl = defaultImplClass.newInstance();
55  } catch (Throwable error) {
56  throw new RuntimeException(error);
57  }
58  }
59  }
60  return new Object[] { defaultImpl };
61  }

Referenced by javolution.osgi.internal.OSGiServices.getLogServices().

Here is the caller graph for this function:

Member Data Documentation

◆ defaultImpl

◆ defaultImplClass

◆ tracker

◆ type


The documentation for this class was generated from the following file:
javolution.osgi.internal.ServiceTrackerImpl.defaultImplClass
final Class<? extends C > defaultImplClass
Definition: ServiceTrackerImpl.java:22
javolution.osgi.internal.ServiceTrackerImpl.defaultImpl
C defaultImpl
Definition: ServiceTrackerImpl.java:23
javolution.osgi.internal.ServiceTrackerImpl.tracker
volatile ServiceTracker< C, C > tracker
Definition: ServiceTrackerImpl.java:20
javolution.osgi.internal.ServiceTrackerImpl.type
final Class< C > type
Definition: ServiceTrackerImpl.java:21