@Override public void remoteAdminEvent(RemoteServiceAdminEvent event) { if (event.getType() == RemoteServiceAdminEvent.IMPORT_UNREGISTRATION) { unImport(event.getImportReference()); } }
/** * Map a Remote Service Admin Event to an EventAdmin event according to OSGi Enterprise R5 122.7.1. * * @param event the Remote Service Admin event * @return the Event Admin event */ private Event createEventAdminEvent(RemoteServiceAdminEvent event, EndpointDescription description, Throwable exception) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("bundle", getBundleContext().getBundle()); properties.put("bundle.id", getBundleContext().getBundle().getBundleId()); properties.put("bundle.symbolicname", getBundleContext().getBundle().getSymbolicName()); properties.put("bundle.version", getBundleContext().getBundle().getVersion()); properties.put("bundle.signer", new String[] {}); // TODO impl properties.put("event", event); properties.put("timestamp", System.currentTimeMillis()); putIfValueNotNull(properties, "cause", exception); if (description != null) { putIfValueNotNull(properties, "endpoint.service.id", description.getServiceId()); putIfValueNotNull(properties, "endpoint.framework.uuid", description.getFrameworkUUID()); putIfValueNotNull(properties, "endpoint.id", description.getId()); putIfValueNotNull(properties, "endpoint.imported.configs", description.getConfigurationTypes()); } return new Event(getEventTopic(event.getType()), properties); }
public void emitEvent(int type, Bundle source, ImportReference importRef, Throwable exception) { RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, source, importRef, exception); // FIXME why are we casting here? EndpointDescription desc = null; if (importRef instanceof ImportedEndpointImpl) { desc = ((ImportedEndpointImpl) importRef).getImportedEndpoint(true); } else { desc = importRef.getImportedEndpoint(); } if (!m_listeners.isEmpty()) { emitRemoteServiceAdminEvent(event, desc); } if (!m_admins.isEmpty()) { emitEventAdminEvent(createEventAdminEvent(event, desc, exception)); } }
public void emitEvent(int type, Bundle source, ExportReference exportRef, Throwable exception) { RemoteServiceAdminEvent event = new RemoteServiceAdminEvent(type, source, exportRef, exception); // FIXME why are we casting here? EndpointDescription desc = null; if (exportRef instanceof ExportedEndpointImpl) { desc = ((ExportedEndpointImpl) exportRef).getExportedEndpoint(true); } else { desc = exportRef.getExportedEndpoint(); } if (!m_listeners.isEmpty()) { emitRemoteServiceAdminEvent(event, desc); } else { logDebug("No RSA listeners"); } if (!m_admins.isEmpty()) { emitEventAdminEvent(createEventAdminEvent(event, desc, exception)); } else { logDebug("No EventAdmins"); } }