@Override public Iterable<AdminCommand.Provider> getAllProviders() { return Service.load( AdminCommand.Provider.class ); } };
private static <T> void putAllInstancesToMap( Iterable<T> services, Map<String,T> servicesMap ) { for ( T instance : filterExceptions( services ) ) { if ( null != instance ) { servicesMap.put( instance.getClass().getName(), instance ); } } } }
/** * Load all implementations of a Service. * * @param <T> the type of the Service * @param type the type of the Service to load * @return all registered implementations of the Service */ public static <T> Iterable<T> load( Class<T> type ) { Iterable<T> loader; if ( null != (loader = java6Loader( type )) ) { return loader; } return Collections.emptyList(); }
/** * Load the Service implementation with the specified key. This method will return null if requested service not * found. * * @param type the type of the Service to load * @param key the key that identifies the desired implementation * @param <T> the type of the Service to load * @return requested service */ public static <T extends Service> T loadSilently( Class<T> type, String key ) { for ( T service : load( type ) ) { if ( service.matches( key ) ) { return service; } } return null; }
/** * Load the Service implementation with the specified key. This method should never return null. * * @param <T> the type of the Service * @param type the type of the Service to load * @param key the key that identifies the desired implementation * @return the matching Service implementation * @throws NoSuchElementException if no service could be loaded with the given key. */ public static <T extends Service> T load( Class<T> type, String key ) { T service = loadSilently( type, key ); if ( service == null ) { throw new NoSuchElementException( String.format( "Could not find any implementation of %s with a key=\"%s\"", type.getName(), key ) ); } return service; }
/** * Load the Service implementation with the specified key. This method will return null if requested service not * found. * * @param type the type of the Service to load * @param key the key that identifies the desired implementation * @param <T> the type of the Service to load * @return requested service */ public static <T extends Service> T loadSilently( Class<T> type, String key ) { for ( T service : load( type ) ) { if ( service.matches( key ) ) { return service; } } return null; }
@Nullable private static RecordFormats loadRecordFormat( String recordFormat ) { if ( StringUtils.isNotEmpty( recordFormat ) ) { if ( Standard.LATEST_NAME.equals( recordFormat ) ) { return Standard.LATEST_RECORD_FORMATS; } for ( RecordFormats knownFormat : KNOWN_FORMATS ) { if ( recordFormat.equals( knownFormat.name() ) ) { return knownFormat; } } RecordFormats.Factory formatFactory = Service.loadSilently( RecordFormats.Factory.class, recordFormat ); if ( formatFactory != null ) { return formatFactory.newInstance(); } } return null; }
@Override public AdminCommand.Provider findProvider( String name ) { return Service.load( AdminCommand.Provider.class, name ); }
/** * Load the Service implementation with the specified key. This method should never return null. * * @param <T> the type of the Service * @param type the type of the Service to load * @param key the key that identifies the desired implementation * @return the matching Service implementation * @throws NoSuchElementException if no service could be loaded with the given key. */ public static <T extends Service> T load( Class<T> type, String key ) { T service = loadSilently( type, key ); if ( service == null ) { throw new NoSuchElementException( String.format( "Could not find any implementation of %s with a key=\"%s\"", type.getName(), key ) ); } return service; }
private static <T> void putAllInstancesToMap( Iterable<T> services, Map<String,T> servicesMap ) { for ( T instance : filterExceptions( services ) ) { if ( null != instance ) { servicesMap.put( instance.getClass().getName(), instance ); } } } }
/** * Load all implementations of a Service. * * @param <T> the type of the Service * @param type the type of the Service to load * @return all registered implementations of the Service */ public static <T> Iterable<T> load( Class<T> type ) { Iterable<T> loader; if ( null != (loader = java6Loader( type )) ) { return loader; } return Collections.emptyList(); }
public ExtensionInitializer( NeoServer neoServer ) { this.neoServer = neoServer; lifecycles = Service.load( PluginLifecycle.class ); }
@Nullable private static RecordFormats loadRecordFormat( String recordFormat ) { if ( StringUtils.isNotEmpty( recordFormat ) ) { if ( Standard.LATEST_NAME.equals( recordFormat ) ) { return Standard.LATEST_RECORD_FORMATS; } for ( RecordFormats knownFormat : KNOWN_FORMATS ) { if ( recordFormat.equals( knownFormat.name() ) ) { return knownFormat; } } RecordFormats.Factory formatFactory = Service.loadSilently( RecordFormats.Factory.class, recordFormat ); if ( formatFactory != null ) { return formatFactory.newInstance(); } } return null; }
private static Iterable loadKernelExtension() { return Service.load( KernelExtensionFactory.class ); } }
/** * Load the {@link CheckPointThresholdPolicy} by the given name. * * @throws NoSuchElementException if the policy was not found. */ public static CheckPointThresholdPolicy loadPolicy( String policyName ) throws NoSuchElementException { return Service.load( CheckPointThresholdPolicy.class, policyName ); }
static Iterable<ServerPlugin> load() { return Service.load( ServerPlugin.class ); }
public RepresentationFormatRepository( AbstractNeoServer injectorProvider ) { this.injectorProvider = injectorProvider; this.formats = new HashMap<>(); for ( RepresentationFormat format : Service.load( RepresentationFormat.class ) ) { formats.put( format.mediaType, format ); } }
public static BatchImporterFactory withHighestPriority() { Iterable<BatchImporterFactory> candidates = Service.load( BatchImporterFactory.class ); BatchImporterFactory highestPrioritized = null; for ( BatchImporterFactory candidate : candidates ) { if ( highestPrioritized == null || candidate.priority > highestPrioritized.priority ) { highestPrioritized = candidate; } } if ( highestPrioritized == null ) { throw new NoSuchElementException( "No batch importers found" ); } return highestPrioritized; } }
public GraphDatabaseFactoryState() { settingsClasses = new CopyOnWriteArrayList<>(); settingsClasses.add( GraphDatabaseSettings.class ); kernelExtensions = new CopyOnWriteArrayList<>(); for ( KernelExtensionFactory<?> factory : Service.load( KernelExtensionFactory.class ) ) { kernelExtensions.add( factory ); } urlAccessRules = new ConcurrentHashMap<>(); }
/** * This is deprecated. Use {@link TestGraphDatabaseFactory} instead */ @Deprecated public ImpermanentGraphDatabase( File storeDir, Map<String, String> params ) { this( storeDir, params, Iterables.cast( Service.load( KernelExtensionFactory.class ) ) ); }