@Test public void testLookupMessagingClientFactoryRegistryService_noReference() { BundleContext bundleCtx = Mockito.mock( BundleContext.class ); OsgiHelper osgiHelper = Mockito.mock( OsgiHelper.class ); Mockito.when( osgiHelper.findBundleContext()).thenReturn( bundleCtx ); MessagingClientFactoryRegistry registry = ReconfigurableClient.lookupMessagingClientFactoryRegistryService( osgiHelper ); Assert.assertNull( registry ); }
public static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ) { MessagingClientFactoryRegistry result = null; final Logger logger = Logger.getLogger( ReconfigurableClient.class.getName()); BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { logger.info( "The messaging registry is used in an OSGi environment." ); final ServiceReference<MessagingClientFactoryRegistry> reference = bundleCtx.getServiceReference( MessagingClientFactoryRegistry.class ); if( reference != null ) { logger.fine( "The service reference was found." ); result = bundleCtx.getService( reference ); } } else { logger.info( "The messaging registry is NOT used in an OSGi environment." ); } return result; }
ReconfigurableClient implements IClient, MessagingClientFactoryListener { public static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ) { MessagingClientFactoryRegistry result = null; final Logger logger = Logger.getLogger( ReconfigurableClient.class.getName()); BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { logger.info( "The messaging registry is used in an OSGi environment." ); final ServiceReference<MessagingClientFactoryRegistry> reference = bundleCtx.getServiceReference( MessagingClientFactoryRegistry.class ); if( reference != null ) { logger.fine( "The service reference was found." ); result = bundleCtx.getService( reference ); } } else { logger.info( "The messaging registry is NOT used in an OSGi environment." ); } return result; } }
ReconfigurableClient implements IClient, MessagingClientFactoryListener { public static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ) { MessagingClientFactoryRegistry result = null; final Logger logger = Logger.getLogger( ReconfigurableClient.class.getName()); BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { logger.info( "The messaging registry is used in an OSGi environment." ); final ServiceReference<MessagingClientFactoryRegistry> reference = bundleCtx.getServiceReference( MessagingClientFactoryRegistry.class ); if( reference != null ) { logger.fine( "The service reference was found." ); result = bundleCtx.getService( reference ); } } else { logger.info( "The messaging registry is NOT used in an OSGi environment." ); } return result; } protected  ReconfigurableClient(); }
ReconfigurableClient implements IClient, MessagingClientFactoryListener { public static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ) { MessagingClientFactoryRegistry result = null; final Logger logger = Logger.getLogger( ReconfigurableClient.class.getName()); BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { logger.info( "The messaging registry is used in an OSGi environment." ); final ServiceReference<MessagingClientFactoryRegistry> reference = bundleCtx.getServiceReference( MessagingClientFactoryRegistry.class ); if( reference != null ) { logger.fine( "The service reference was found." ); result = bundleCtx.getService( reference ); } } else { logger.info( "The messaging registry is NOT used in an OSGi environment." ); } return result; } protected  ReconfigurableClient(); @Override void setDomain( String domain ); @Override String getDomain(); synchronized MessagingClientFactoryRegistry getRegistry(); synchronized void setRegistry( MessagingClientFactoryRegistry registry ); static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ); @Override synchronized String getMessagingType(); void switchMessagingType( String factoryName ); @Override void addMessagingClientFactory( final IMessagingClientFactory factory ); @Override void removeMessagingClientFactory( IMessagingClientFactory factory ); @Override Map<String,String> getConfiguration(); abstract RecipientKind getOwnerKind(); void associateMessageProcessor( AbstractMessageProcessor<T> messageProcessor ); AbstractMessageProcessor<T> getMessageProcessor(); synchronized boolean hasValidClient(); IMessagingClient getMessagingClient(); }
ReconfigurableClient implements IClient, MessagingClientFactoryListener { public static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ) { MessagingClientFactoryRegistry result = null; final Logger logger = Logger.getLogger( ReconfigurableClient.class.getName()); BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { logger.info( "The messaging registry is used in an OSGi environment." ); final ServiceReference<MessagingClientFactoryRegistry> reference = bundleCtx.getServiceReference( MessagingClientFactoryRegistry.class ); if( reference != null ) { logger.fine( "The service reference was found." ); result = bundleCtx.getService( reference ); } } else { logger.info( "The messaging registry is NOT used in an OSGi environment." ); } return result; } protected  ReconfigurableClient(); @Override void setDomain( String domain ); @Override String getDomain(); synchronized MessagingClientFactoryRegistry getRegistry(); synchronized void setRegistry( MessagingClientFactoryRegistry registry ); static MessagingClientFactoryRegistry lookupMessagingClientFactoryRegistryService( OsgiHelper osgiHelper ); @Override synchronized String getMessagingType(); void switchMessagingType( String factoryName ); @Override void addMessagingClientFactory( final IMessagingClientFactory factory ); @Override void removeMessagingClientFactory( IMessagingClientFactory factory ); @Override Map<String,String> getConfiguration(); abstract RecipientKind getOwnerKind(); void associateMessageProcessor( AbstractMessageProcessor<T> messageProcessor ); AbstractMessageProcessor<T> getMessageProcessor(); synchronized boolean hasValidClient(); IMessagingClient getMessagingClient();  }