protected void registerExtension ( IAggregatorExtension ext , IAggregatorExtension before ) { final String sourceMethod = "registerExtension" ; //$NON-NLS-1$ boolean isTraceLogging = log . isLoggable ( Level . FINER ) ; if ( isTraceLogging ) { log . entering ( AbstractAggregatorImpl . class . getName ( ) , sourceMethod , new Object [ ] { ext , before } ) ; } // validate type String id = ext . getExtensionPointId ( ) ; if ( IHttpTransportExtensionPoint . ID . equals ( id ) ) { if ( before != null ) { throw new IllegalArgumentException ( before . getExtensionPointId ( ) ) ; } httpTransportExtension = ext ; } else { List < IAggregatorExtension > list ; if ( IResourceFactoryExtensionPoint . ID . equals ( id ) ) { list = resourceFactoryExtensions ; } else if ( IResourceConverterExtensionPoint . ID . equals ( id ) ) { list = resourceConverterExtensions ; } else if ( IModuleBuilderExtensionPoint . ID . equals ( id ) ) { list = moduleBuilderExtensions ; } else if ( IServiceProviderExtensionPoint . ID . equals ( id ) ) { list = serviceProviderExtensions ; } else { throw new IllegalArgumentException ( id ) ; } if ( before == null ) { list . add ( ext ) ; } else { // find the extension to insert the item in front of boolean inserted = false ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( list . get ( i ) == before ) { list . add ( i , ext ) ; inserted = true ; break ; } } if ( ! inserted ) { throw new IllegalArgumentException ( ) ; } } // If this is a service provider extension then register the specified service with the // OSGi service registry if an interface name is provided. if ( IServiceProviderExtensionPoint . ID . equals ( id ) ) { String interfaceName = ext . getAttribute ( IServiceProviderExtensionPoint . SERVICE_ATTRIBUTE ) ; if ( interfaceName != null ) { try { Dictionary < String , String > props = new Hashtable < String , String > ( ) ; // Copy init-params from extension to service dictionary Set < String > attributeNames = new HashSet < String > ( ext . getAttributeNames ( ) ) ; attributeNames . removeAll ( Arrays . asList ( new String [ ] { "class" , IServiceProviderExtensionPoint . SERVICE_ATTRIBUTE } ) ) ; //$NON-NLS-1$ for ( String propName : attributeNames ) { props . put ( propName , ext . getAttribute ( propName ) ) ; } // Set name property to aggregator name props . put ( "name" , getName ( ) ) ; //$NON-NLS-1$ registrations . add ( getPlatformServices ( ) . registerService ( interfaceName , ext . getInstance ( ) , props ) ) ; } catch ( Exception e ) { if ( log . isLoggable ( Level . WARNING ) ) { log . log ( Level . WARNING , e . getMessage ( ) , e ) ; } } } } } if ( isTraceLogging ) { log . exiting ( AbstractAggregatorImpl . class . getName ( ) , sourceMethod ) ; } }
Adds the specified extension to the list of registered extensions .