/** * Switch to the OrientDb classloader before lookups on ServiceRegistry for * implementation of the given Class. Useful under OSGI and generally under * applications where jars are loaded by another class loader * * @param clazz * the class to lookup foor * @return an Iterator on the class implementation */ public static synchronized <T extends Object> Iterator<T> lookupProviderWithOrientClassLoader(Class<T> clazz) { return lookupProviderWithOrientClassLoader(clazz,OClassLoaderHelper.class.getClassLoader()); }
/** * Switch to the OrientDb classloader before lookups on ServiceRegistry for implementation of the given Class. Useful under OSGI * and generally under applications where jars are loaded by another class loader * * @param clazz * the class to lookup foor * @return an Iterator on the class implementation */ public static synchronized <T extends Object> Iterator<T> lookupProviderWithOrientClassLoader(Class<T> clazz) { return lookupProviderWithOrientClassLoader(clazz, OClassLoaderHelper.class.getClassLoader()); }
public static Iterator<OSQLMethodFactory> getMethodFactories() { if (METHOD_FACTORIES == null) { synchronized (INSTANCE) { if (METHOD_FACTORIES == null) { final Iterator<OSQLMethodFactory> ite = lookupProviderWithOrientClassLoader(OSQLMethodFactory.class, orientClassLoader); final List<OSQLMethodFactory> factories = new ArrayList<OSQLMethodFactory>(); while (ite.hasNext()) { factories.add(ite.next()); } METHOD_FACTORIES = Collections.unmodifiableList(factories); } } } return METHOD_FACTORIES.iterator(); }
/** * Cache a set of all factories. we do not use the service loader directly since it is not concurrent. * * @return Set<OIndexFactory> */ private static synchronized Set<OIndexFactory> getFactories() { if (FACTORIES == null) { final Iterator<OIndexFactory> ite = lookupProviderWithOrientClassLoader(OIndexFactory.class, orientClassLoader); final Set<OIndexFactory> factories = new HashSet<>(); while (ite.hasNext()) { factories.add(ite.next()); } factories.addAll(DYNAMIC_FACTORIES); FACTORIES = Collections.unmodifiableSet(factories); } return FACTORIES; }
/** * @return Iterator of all function factories */ public static Iterator<OCollateFactory> getCollateFactories() { if (COLLATE_FACTORIES == null) { synchronized (INSTANCE) { if (COLLATE_FACTORIES == null) { final Iterator<OCollateFactory> ite = lookupProviderWithOrientClassLoader(OCollateFactory.class, orientClassLoader); final List<OCollateFactory> factories = new ArrayList<OCollateFactory>(); while (ite.hasNext()) { factories.add(ite.next()); } COLLATE_FACTORIES = Collections.unmodifiableList(factories); } } } return COLLATE_FACTORIES.iterator(); }
/** * @return Iterator of all function factories */ public static Iterator<OSQLFunctionFactory> getFunctionFactories() { if (FUNCTION_FACTORIES == null) { synchronized (INSTANCE) { if (FUNCTION_FACTORIES == null) { final Iterator<OSQLFunctionFactory> ite = lookupProviderWithOrientClassLoader(OSQLFunctionFactory.class, orientClassLoader); final List<OSQLFunctionFactory> factories = new ArrayList<OSQLFunctionFactory>(); while (ite.hasNext()) { factories.add(ite.next()); } FUNCTION_FACTORIES = Collections.unmodifiableList(factories); } } } return FUNCTION_FACTORIES.iterator(); }
/** * @return Iterator of all operator factories */ public static Iterator<OQueryOperatorFactory> getOperatorFactories() { if (OPERATOR_FACTORIES == null) { synchronized (INSTANCE) { if (OPERATOR_FACTORIES == null) { final Iterator<OQueryOperatorFactory> ite = lookupProviderWithOrientClassLoader(OQueryOperatorFactory.class, orientClassLoader); final List<OQueryOperatorFactory> factories = new ArrayList<OQueryOperatorFactory>(); while (ite.hasNext()) { factories.add(ite.next()); } OPERATOR_FACTORIES = Collections.unmodifiableList(factories); } } } return OPERATOR_FACTORIES.iterator(); }
public OWorkloadFactory() { register(new OCRUDWorkload()); final ClassLoader orientClassLoader = OWorkloadFactory.class.getClassLoader(); final Iterator<OWorkload> ite = lookupProviderWithOrientClassLoader(OWorkload.class, orientClassLoader); while (ite.hasNext()) { final OWorkload strategy = ite.next(); register(strategy); } }
/** * @return Iterator of all command factories */ public static Iterator<OCommandExecutorSQLFactory> getCommandFactories() { if (EXECUTOR_FACTORIES == null) { synchronized (INSTANCE) { if (EXECUTOR_FACTORIES == null) { final Iterator<OCommandExecutorSQLFactory> ite = lookupProviderWithOrientClassLoader(OCommandExecutorSQLFactory.class, orientClassLoader); final List<OCommandExecutorSQLFactory> factories = new ArrayList<OCommandExecutorSQLFactory>(); while (ite.hasNext()) { try { factories.add(ite.next()); } catch (Exception e) { OLogManager.instance().warn(null, "Cannot load OCommandExecutorSQLFactory instance from service registry", e); } } EXECUTOR_FACTORIES = Collections.unmodifiableList(factories); } } } return EXECUTOR_FACTORIES.iterator(); }
private void registerStrategy() { final Iterator<OClusterSelectionStrategy> ite = lookupProviderWithOrientClassLoader(OClusterSelectionStrategy.class, orientClassLoader); while (ite.hasNext()) { OClusterSelectionStrategy strategy = ite.next(); Class clz = strategy.getClass(); try { Method method = clz.getMethod("getName"); if (method != null) { String key = (String) method.invoke(clz.newInstance()); register(key, clz); } else OLogManager.instance().error(this, "getName() funciton missing", null); } catch (Exception ex) { OLogManager.instance().error(this, "failed to register class - " + clz.getName(), ex); } } }
/** * Shutdown whole OrientDB ecosystem. Usually is called during JVM shutdown by JVM shutdown handler. During shutdown all handlers * which were registered by the call of {@link #addShutdownHandler(OShutdownHandler)} are called together with pre-registered * system shoutdown handlers according to their priority. * * @see OShutdownWorkersHandler * @see */ private void registerEngines() { ClassLoader classLoader = Orient.class.getClassLoader(); Iterator<OEngine> engines = OClassLoaderHelper.lookupProviderWithOrientClassLoader(OEngine.class, classLoader); OEngine engine = null; while (engines.hasNext()) { try { engine = engines.next(); registerEngine(engine); } catch (IllegalArgumentException e) { if (engine != null) OLogManager.instance().debug(this, "Failed to replace engine " + engine.getName(), e); } } }
Iterator<OScriptExecutorRegister> customExecutors = lookupProviderWithOrientClassLoader(OScriptExecutorRegister.class);