Java Code Examples for org.osgi.framework.ServiceEvent#MODIFIED_ENDMATCH
The following examples show how to use
org.osgi.framework.ServiceEvent#MODIFIED_ENDMATCH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReferenceListener.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * */ void serviceEvent(ServiceReference<?> s, ServiceEvent se) { Filter f = getTargetFilter(); boolean match = f == null || f.match(s); if (match && ReferenceDescription.SCOPE_PROTOTYPE_REQUIRED.equals(ref.getScope())) { match = Constants.SCOPE_PROTOTYPE.equals(s.getProperty(Constants.SERVICE_SCOPE)); } int type = se.getType(); if (!match) { if (type != ServiceEvent.UNREGISTERING && serviceRefs.contains(s)) { type = ServiceEvent.MODIFIED_ENDMATCH; } else { return; } } serviceChanged(new RefServiceEvent(type, s, se)); }
Example 2
Source File: ConnectionInformationList.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected synchronized void handleServiceChanged ( final ServiceEvent event ) { switch ( event.getType () ) { case ServiceEvent.UNREGISTERING: case ServiceEvent.MODIFIED_ENDMATCH: removeService ( event.getServiceReference () ); break; case ServiceEvent.REGISTERED: addService ( event.getServiceReference () ); break; } }
Example 3
Source File: ServiceTracker.java From concierge with Eclipse Public License 1.0 | 5 votes |
/** * {@code ServiceListener} method for the {@code ServiceTracker} class. * This method must NOT be synchronized to avoid deadlock potential. * * @param event {@code ServiceEvent} object from the framework. */ final public void serviceChanged(final ServiceEvent event) { /* * Check if we had a delayed call (which could happen when we * close). */ if (closed) { return; } @SuppressWarnings("unchecked") final ServiceReference<S> reference = (ServiceReference<S>) event.getServiceReference(); if (DEBUG) { System.out.println("ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference); } switch (event.getType()) { case ServiceEvent.REGISTERED : case ServiceEvent.MODIFIED : track(reference, event); /* * If the customizer throws an unchecked exception, it is * safe to let it propagate */ break; case ServiceEvent.MODIFIED_ENDMATCH : case ServiceEvent.UNREGISTERING : untrack(reference, event); /* * If the customizer throws an unchecked exception, it is * safe to let it propagate */ break; } }
Example 4
Source File: ServiceTracker.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * {@code ServiceListener} method for the {@code ServiceTracker} class. * This method must NOT be synchronized to avoid deadlock potential. * * @param event {@code ServiceEvent} object from the framework. */ final public void serviceChanged(final ServiceEvent event) { /* * Check if we had a delayed call (which could happen when we * close). */ if (closed) { return; } @SuppressWarnings("unchecked") final ServiceReference<S> reference = (ServiceReference<S>) event.getServiceReference(); if (DEBUG) { System.out.println("ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference); } switch (event.getType()) { case ServiceEvent.REGISTERED : case ServiceEvent.MODIFIED : track(reference, event); /* * If the customizer throws an unchecked exception, it is * safe to let it propagate */ break; case ServiceEvent.MODIFIED_ENDMATCH : case ServiceEvent.UNREGISTERING : untrack(reference, event); /* * If the customizer throws an unchecked exception, it is * safe to let it propagate */ break; } }
Example 5
Source File: Repositories.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void serviceChanged(ServiceEvent event) { @SuppressWarnings("unchecked") RepositoryInfo ri = new RepositoryInfo((ServiceReference<Repository>) event.getServiceReference()); synchronized (this) { switch (event.getType()) { case ServiceEvent.REGISTERED: repos.put(ri, ri); break; case ServiceEvent.MODIFIED: for (Iterator<RepositoryInfo> i = repos.keySet().iterator(); i.hasNext();) { RepositoryInfo old = i.next(); if (old.getId() == ri.getId()) { i.remove(); repos.put(ri, ri); } } break; case ServiceEvent.MODIFIED_ENDMATCH: case ServiceEvent.UNREGISTERING: repos.remove(ri); break; } changeCount++; } for (RepositoryListener rl : listeners) { switch (event.getType()) { case ServiceEvent.REGISTERED: rl.addedRepo(ri); repos.put(ri, ri); break; case ServiceEvent.MODIFIED: rl.modifiedRepo(ri); break; case ServiceEvent.MODIFIED_ENDMATCH: case ServiceEvent.UNREGISTERING: rl.removedRepo(ri); break; } } }
Example 6
Source File: ReferenceListener.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void serviceChanged(RefServiceEvent se) { ref.comp.scr.postponeCheckin(); try { do { boolean wasSelected = false; int op; synchronized (serviceRefs) { if (sEventQueue.isEmpty()) { if (se == null) { return; } } else { if (se != null) { sEventQueue.addLast(se); } se = sEventQueue.removeFirst(); } switch (se.type) { case ServiceEvent.MODIFIED: case ServiceEvent.REGISTERED: op = serviceRefs.add(se.sr) ? ADD_OP : UPDATE_OP; break; case ServiceEvent.MODIFIED_ENDMATCH: case ServiceEvent.UNREGISTERING: serviceRefs.remove(se.sr); if (selectedServiceRef == se.sr) { wasSelected = true; } unbinding.add(se.sr); op = DELETE_OP; break; default: // To keep compiler happy throw new RuntimeException("Internal error"); } } switch (op) { case ADD_OP: if (!ref.refAvailable()) { refAdded(se); } break; case DELETE_OP: boolean deleted = false; if (!ref.refUnavailable()) { if (ref.isMultiple() || wasSelected) { refDeleted(se); deleted = true; } } synchronized (serviceRefs) { unbinding.remove(se.sr); if (deleted) { setSelected(null); } } break; case UPDATE_OP: refUpdated(se); break; } se = null; } while (!sEventQueue.isEmpty()); } finally { ref.comp.scr.postponeCheckout(); } }
Example 7
Source File: ContentHandlerWrapper.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
ContentHandlerWrapper(FrameworkContext framework, String mimetype) { this.framework = framework; this.mimetype = mimetype; filter = "(&" + "(" + Constants.OBJECTCLASS + "=" + ContentHandler.class.getName() + ")" + "(" + URLConstants.URL_CONTENT_MIMETYPE + "=" + mimetype + ")" + ")"; final ServiceListener serviceListener = new ServiceListener() { public void serviceChanged(ServiceEvent evt) { @SuppressWarnings("unchecked") final ServiceReference<ContentHandler> ref = (ServiceReference<ContentHandler>) evt.getServiceReference(); switch (evt.getType()) { case ServiceEvent.MODIFIED: // fall through case ServiceEvent.REGISTERED: if (best == null) { updateBest(); return ; } if (compare(best, ref) > 0) { best = ref; } break; case ServiceEvent.MODIFIED_ENDMATCH: // fall through case ServiceEvent.UNREGISTERING: if (best.equals(ref)) { best = null; } } } }; try { framework.systemBundle.bundleContext.addServiceListener(serviceListener, filter); } catch (final Exception e) { throw new IllegalArgumentException("Could not register service listener for content handler: " + e); } if (framework.debug.url) { framework.debug.println("created wrapper for " + mimetype + ", filter=" + filter); } }