static OrientDBInternal distributed(String directoryPath, OrientDBConfig configuration) { OrientDBInternal factory; try { String className = "com.orientechnologies.orient.core.db.OrientDBDistributed"; ClassLoader loader; if (configuration != null) { loader = configuration.getClassLoader(); } else { loader = OrientDBInternal.class.getClassLoader(); } Class<?> kass = loader.loadClass(className); Constructor<?> constructor = kass.getConstructor(String.class, OrientDBConfig.class, Orient.class); factory = (OrientDBInternal) constructor.newInstance(directoryPath, configuration, Orient.instance()); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException e) { throw OException.wrapException(new ODatabaseException("OrientDB distributed API missing"), e); } catch (InvocationTargetException e) { //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw OException.wrapException(new ODatabaseException("Error creating OrientDB remote factory"), e.getTargetException()); } return factory; }
/** * Create a new remote factory * * @param hosts array of hosts * @param configuration configuration for the specific factory for the list of option {@see OGlobalConfiguration}. * * @return a new remote databases factory */ static OrientDBInternal remote(String[] hosts, OrientDBConfig configuration) { OrientDBInternal factory; try { String className = "com.orientechnologies.orient.core.db.OrientDBRemote"; ClassLoader loader; if (configuration != null) { loader = configuration.getClassLoader(); } else { loader = OrientDBInternal.class.getClassLoader(); } Class<?> kass = loader.loadClass(className); Constructor<?> constructor = kass.getConstructor(String[].class, OrientDBConfig.class, Orient.class); factory = (OrientDBInternal) constructor.newInstance(hosts, configuration, Orient.instance()); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException e) { throw OException.wrapException(new ODatabaseException("OrientDB client API missing"), e); } catch (InvocationTargetException e) { //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw OException.wrapException(new ODatabaseException("Error creating OrientDB remote factory"), e.getTargetException()); } return factory; }