本文整理匯總了Java中org.osgi.framework.ServiceEvent.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceEvent.getType方法的具體用法?Java ServiceEvent.getType怎麽用?Java ServiceEvent.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.ServiceEvent
的用法示例。
在下文中一共展示了ServiceEvent.getType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public synchronized void serviceChanged ( final ServiceEvent event )
{
switch ( event.getType () )
{
case ServiceEvent.REGISTERED:
addReference ( event.getServiceReference () );
break;
case ServiceEvent.MODIFIED:
update ();
break;
case ServiceEvent.UNREGISTERING:
removeReference ( event.getServiceReference () );
break;
}
}
示例2: testAddServiceListenerBundleContextServiceListenerString
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Test method for
* {@link org.eclipse.gemini.blueprint.util.OsgiListenerUtils#addServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
*/
public void testAddServiceListenerBundleContextServiceListenerString() {
final List refs = new ArrayList();
ServiceListener list = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
if (ServiceEvent.REGISTERED == event.getType())
refs.add(event.getSource());
}
};
OsgiListenerUtils.addServiceListener(bundleContext, list, (String) null);
assertFalse(refs.isEmpty());
assertEquals(3, refs.size());
assertSame(ref1, refs.get(0));
assertSame(ref2, refs.get(1));
assertSame(ref3, refs.get(2));
}
示例3: testAddSingleServiceListenerBundleContextServiceListenerString
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Test method for
* {@link org.eclipse.gemini.blueprint.util.OsgiListenerUtils#addSingleServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
*/
public void testAddSingleServiceListenerBundleContextServiceListenerString() {
final List refs = new ArrayList();
ServiceListener listener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
if (ServiceEvent.REGISTERED == event.getType())
refs.add(event.getSource());
}
};
OsgiListenerUtils.addSingleServiceListener(bundleContext, listener, (String) null);
assertFalse(refs.isEmpty());
assertEquals(1, refs.size());
assertSame(ref1, refs.get(0));
}
示例4: RemoteServiceAdminCore
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public RemoteServiceAdminCore(BundleContext context, BundleContext apiContext, DistributionProvider provider) {
this.bctx = context;
this.apictx = apiContext;
this.eventProducer = new EventProducer(bctx);
this.provider = provider;
// listen for exported services being unregistered so we can close the export
this.exportedServiceListener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
if (event.getType() == ServiceEvent.UNREGISTERING) {
removeServiceExports(event.getServiceReference());
}
}
};
try {
String filter = "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=*)";
context.addServiceListener(exportedServiceListener, filter);
} catch (InvalidSyntaxException ise) {
throw new RuntimeException(ise); // can never happen
}
}
示例5: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
if (closed) {
return;
}
ServiceReference<?> sr = event.getServiceReference();
switch (event.getType()) {
case ServiceEvent.REGISTERED:
onServiceRegistration(sr);
break;
case ServiceEvent.MODIFIED:
onServiceUpdate(sr);
break;
case ServiceEvent.MODIFIED_ENDMATCH:
case ServiceEvent.UNREGISTERING:
onServiceDeparture(sr);
break;
}
}
示例6: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
if (LOG.isDebugEnabled()) {
LOG.debug("Service {} changed to {}", event, event.getType());
}
// look for blueprint container to be registered, and then we can start the CamelContext
if (event.getType() == ServiceEvent.REGISTERED
&& event.getServiceReference().isAssignableTo(bundleContext.getBundle(), "org.osgi.service.blueprint.container.BlueprintContainer")
&& bundleContext.getBundle().equals(event.getServiceReference().getBundle())) {
try {
maybeStart();
} catch (Exception e) {
LOG.error("Error occurred during starting Camel: " + this + " due " + e.getMessage(), e);
}
}
}
示例7: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Implements ServiceListener.serviceChanged().
* Prints the details of any service event from the framework.
* @param event the fired service event.
**/
public void serviceChanged(ServiceEvent event)
{
String[] objectClass = (String[])
event.getServiceReference().getProperty("objectClass");
if (event.getType() == ServiceEvent.REGISTERED)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " registered.");
}
else if (event.getType() == ServiceEvent.UNREGISTERING)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " unregistered.");
}
else if (event.getType() == ServiceEvent.MODIFIED)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " modified.");
}
}
示例8: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Receives notification that the context of the entities bundle has had a lifecycle change and
* checks it current status.
*
* @param event The {@code ServiceEvent} object.
*/
@Override
public void serviceChanged(ServiceEvent event) {
ServiceReference<?> reference = event.getServiceReference();
if (isEntities(reference.getBundle())) {
Object service = bundleContext.getService(reference);
if (service instanceof ApplicationContext) {
LOGGER.trace(
"The Entities Bundle Application Context Status: {}",
nullSafeToString(event)
);
synchronized (lock) {
contextInitialized = event.getType() != ServiceEvent.UNREGISTERING;
if (contextInitialized) {
LOGGER.info("The entities bundle context has been initialized");
} else {
LOGGER.info("The entities bundle context has been unregistered");
}
}
}
}
}
示例9: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
if (!enabled) return;
try {
if (event.getType() != ServiceEvent.REGISTERED) return;
Object service = context.getService(event.getServiceReference());
if (service == null) return;
if (!(service instanceof VaadinConfigurableResourceProviderAdmin)) return;
log.info("Admin-Service registered");
refreshAll();
} catch (Throwable t) {
t.printStackTrace(); //TODO log
}
}
示例10: testAddSingleServiceListenerBundleContextServiceListenerString
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Test method for
* {@link org.springframework.osgi.util.OsgiListenerUtils#addSingleServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
*/
public void testAddSingleServiceListenerBundleContextServiceListenerString() {
final List refs = new ArrayList();
ServiceListener listener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
if (ServiceEvent.REGISTERED == event.getType())
refs.add(event.getSource());
}
};
OsgiListenerUtils.addSingleServiceListener(bundleContext, listener, (String) null);
assertFalse(refs.isEmpty());
assertEquals(1, refs.size());
assertSame(ref1, refs.get(0));
}
示例11: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
if (event.getType() == ServiceEvent.REGISTERED) {
if (serviceReference == null) {
serviceReference = event.getServiceReference();
serviceManager = (ModulesManager) context.getService(serviceReference);
registerAddons();
}
} else if (event.getType() == ServiceEvent.UNREGISTERING) {
if (serviceReference == event.getServiceReference()) {
unregisterAddons();
context.ungetService(serviceReference);
serviceManager = null;
serviceReference = null;
}
}
}
示例12: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Handle notifications of new/removed GenericDeviceEventListeners
*
* @param event
*/
@Override
public void serviceChanged(ServiceEvent event) {
ServiceReference reference = event.getServiceReference();
GDEventListener listener = (GDEventListener) context.getService(reference);
switch (event.getType()) {
case ServiceEvent.REGISTERED:
Object filter = reference.getProperty(GENERICDEVICE_FILTER);
listeners.put(listener, getFilter(filter));
break;
case ServiceEvent.MODIFIED:
break;
case ServiceEvent.UNREGISTERING:
listeners.remove(listener);
break;
}
}
示例13: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
* Unique method of the ServiceListener interface.
*
* @param event the service event
*
*/
public void serviceChanged( final ServiceEvent event ) {
ServiceReference sr = event.getServiceReference();
switch(event.getType()) {
case ServiceEvent.REGISTERED: {
logSer = (LogService) bc.getService(sr);
registerService();
}
break;
case ServiceEvent.UNREGISTERING: {
logSer = null;
}
break;
}
}
示例14: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public void serviceChanged(ServiceEvent arg0) {
if (arg0.getType() == ServiceEvent.REGISTERED){
ServiceReference sr = arg0.getServiceReference();
String famaType = (String)sr.getProperty("famaType");
if (famaType.equals("reasoner")){
consumeReasoner(sr);
}
else if(famaType.equals("reader")){
consumeReader(sr);
}
else if (famaType.equals("writer")){
consumeWriter(sr);
}
else if (famaType.equals("selector")){
consumeSelector(sr);
}
else if (famaType.equals("transform")){
consumeTransform(sr);
}
else{
throw new IllegalArgumentException("famaType value not valid");
}
}
}
示例15: serviceChanged
import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public void serviceChanged(ServiceEvent event) {
ServiceReference sr = event.getServiceReference();
switch (event.getType()) {
case ServiceEvent.REGISTERED: {
httpHandler.setHttpService((HttpService) Activator.bc.getService(sr));
Activator.log(LogService.LOG_INFO,
"Getting instance of service: "
+ HttpService.class.getName() + "," + Constants.SERVICE_PID + "=" + (String) sr.getProperty(Constants.SERVICE_PID)
+ " from " + sr.getBundle().getSymbolicName());
}
break;
case ServiceEvent.UNREGISTERING: {
Activator.log(LogService.LOG_INFO, "Releasing service: "
+ HttpService.class.getName() + ","
+ Constants.SERVICE_PID + "="
+ (String) sr.getProperty(Constants.SERVICE_PID));
// httpService.unregister(obixServletPath);
httpHandler.setHttpService(null);
}
break;
}
}