private void invokeMethod(String methodName, Registration registration) { try { Method method = getMethod(methodName); method.invoke(m_target, registration.getProvider(m_serviceInterface), registration.getProperties()); } catch (Throwable e) { throw new UndeclaredThrowableException(e, "Unexexpected exception invoking method " + methodName); } finally { } }
@Override public void registrationAdded(final Registration onmsRegistration) { final Map<String, String> onmsProperties = onmsRegistration.getProperties() == null ? Collections.<String,String>emptyMap() : onmsRegistration.getProperties(); if (OSGI_SOURCE.equals(onmsProperties.get(REGISTRATION_SOURCE))) return; final Class<?>[] providerInterfaces = onmsRegistration.getProvidedInterfaces(); final String[] serviceClasses = new String[providerInterfaces.length]; for(int i = 0; i < providerInterfaces.length; i++) { serviceClasses[i] = providerInterfaces[i].getName(); } final Dictionary<String,String> props = new Hashtable<String,String>(); for(final Entry<String, String> entry : onmsProperties.entrySet()) { props.put(entry.getKey(), entry.getValue()); } props.put(REGISTRATION_SOURCE, ONMS_SOURCE); final BundleContext bundleContext = m_bundleContext.get(); if (bundleContext != null) { ServiceRegistration<?> osgiRegistration = bundleContext.registerService(serviceClasses, onmsRegistration.getProvider(), props); m_onmsRegistration2osgiRegistrationMap.put(onmsRegistration, osgiRegistration); } }
private void invokeMethod(String methodName, Registration registration) { try { Method method = getMethod(methodName); method.invoke(m_target, registration.getProvider(m_serviceInterface), registration.getProperties()); } catch (Throwable e) { throw new UndeclaredThrowableException(e, "Unexexpected exception invoking method " + methodName); } finally { } }
@Override public void registrationAdded(final Registration onmsRegistration) { final Map<String, String> onmsProperties = onmsRegistration.getProperties() == null ? Collections.<String,String>emptyMap() : onmsRegistration.getProperties(); if (OSGI_SOURCE.equals(onmsProperties.get(REGISTRATION_SOURCE))) return; final Class<?>[] providerInterfaces = onmsRegistration.getProvidedInterfaces(); final String[] serviceClasses = new String[providerInterfaces.length]; for(int i = 0; i < providerInterfaces.length; i++) { serviceClasses[i] = providerInterfaces[i].getName(); } final Dictionary<String,String> props = new Hashtable<String,String>(); for(final Entry<String, String> entry : onmsProperties.entrySet()) { props.put(entry.getKey(), entry.getValue()); } props.put(REGISTRATION_SOURCE, ONMS_SOURCE); final BundleContext bundleContext = m_bundleContext.get(); if (bundleContext != null) { ServiceRegistration<?> osgiRegistration = bundleContext.registerService(serviceClasses, onmsRegistration.getProvider(), props); m_onmsRegistration2osgiRegistrationMap.put(onmsRegistration, osgiRegistration); } }
/** {@inheritDoc} */ @Override public void providerRegistered(Registration registration, T provider) { if (m_filter != null && !m_filter.match(registration.getProperties())) { // this object doesn't match the filter so skip it return; } m_providerRegistrations.add(provider); for(RegistrationListener<T> listener : m_listeners) { listener.providerRegistered(registration, provider); } }
/** {@inheritDoc} */ @Override public void providerRegistered(Registration registration, T provider) { if (m_filter != null && !m_filter.match(registration.getProperties())) { // this object doesn't match the filter so skip it return; } m_providerRegistrations.add(provider); for(RegistrationListener<T> listener : m_listeners) { listener.providerRegistered(registration, provider); } }
@Test @DirtiesContext public void testServiceProperties() { assertNotNull(m_bigRegistration); assertNotNull(m_bigRegistration.getProperties()); assertEquals("big", m_bigRegistration.getProperties().get("size")); assertNotNull(m_smallRegistration); assertNotNull(m_smallRegistration.getProperties()); assertEquals("small", m_smallRegistration.getProperties().get("size")); }