/** * Constructor * * @param keyClass class of the key to be used * @param persistentClass class of the {@link Persistent} objects to be stored */ public BeanFactoryWSImpl(Class<K> keyClass, Class<T> persistentClass) { this.keyClass = keyClass; this.persistentClass = persistentClass; try { if(ReflectionUtils.hasConstructor(keyClass)) { this.keyConstructor = ReflectionUtils.getConstructor(keyClass); this.key = keyConstructor.newInstance(ReflectionUtils.EMPTY_OBJECT_ARRAY); } this.persistent = ReflectionUtils.newInstance(persistentClass); } catch (Exception ex) { throw new RuntimeException(ex); } isKeyPersistent = Persistent.class.isAssignableFrom(keyClass); }
/** * Constructs a new instance of the class using the no-arg constructor. * * @param classStr the class name of the object. * @return a new instance of the object. * @throws SecurityException if the caller's class loader is not the same as the * class loader of above class. * @throws IllegalArgumentException this will not be thrown since <code>field.get(obj)</code> passing obj is null. * since the field is a static class level variable inside the class. * @throws IllegalAccessException if the field is inaccessible due to java language access control. * @throws ClassNotFoundException class definition cannot be found for the class type. * @throws InstantiationException could not be instantiated from the given constructor. * @throws NoSuchMethodException default construct cannot by found for given class type. * @throws InvocationTargetException if the underlying constructor throws an exception. */ public static Object newInstance(String classStr) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SecurityException, IllegalArgumentException, NoSuchMethodException, InvocationTargetException { if(classStr == null) { throw new IllegalArgumentException("class cannot be null"); } Class<?> clazz = ClassLoadingUtils.loadClass(classStr); return newInstance(clazz); }
/** * Constructs a new instance of the class using the no-arg constructor. * * @param clazz the class of the object. * @param <T> class type variable. * @return a new instance of the object. * @throws SecurityException if the caller's class loader is not the same as the * class loader of above class. * @throws IllegalArgumentException this will not be thrown since <code>field.get(obj)</code> passing obj is null * since the field is a static class level variable inside the class. * @throws IllegalAccessException if the field is inaccessible due to java language access control. * @throws InstantiationException could not be instantiated from the given constructor. * @throws NoSuchMethodException default construct cannot by found for given class type. * @throws InvocationTargetException if the underlying constructor throws an exception. */ public static <T> T newInstance(Class<T> clazz) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { Constructor<T> cons = getConstructor(clazz); return cons.newInstance(EMPTY_OBJECT_ARRAY); }
/** * Constructs a new instance of the class using the no-arg constructor. * * @param classStr the class name of the object. * @return a new instance of the object. * @throws SecurityException if the caller's class loader is not the same as the * class loader of above class. * @throws IllegalArgumentException this will not be thrown since <code>field.get(obj)</code> passing obj is null. * since the field is a static class level variable inside the class. * @throws IllegalAccessException if the field is inaccessible due to java language access control. * @throws ClassNotFoundException class definition cannot be found for the class type. * @throws InstantiationException could not be instantiated from the given constructor. * @throws NoSuchMethodException default construct cannot by found for given class type. * @throws InvocationTargetException if the underlying constructor throws an exception. */ public static Object newInstance(String classStr) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SecurityException, IllegalArgumentException, NoSuchMethodException, InvocationTargetException { if(classStr == null) { throw new IllegalArgumentException("class cannot be null"); } Class<?> clazz = ClassLoadingUtils.loadClass(classStr); return newInstance(clazz); }
/** * Constructs a new instance of the class using the no-arg constructor. * * @param clazz the class of the object. * @param <T> class type variable. * @return a new instance of the object. * @throws SecurityException if the caller's class loader is not the same as the * class loader of above class. * @throws IllegalArgumentException this will not be thrown since <code>field.get(obj)</code> passing obj is null * since the field is a static class level variable inside the class. * @throws IllegalAccessException if the field is inaccessible due to java language access control. * @throws InstantiationException could not be instantiated from the given constructor. * @throws NoSuchMethodException default construct cannot by found for given class type. * @throws InvocationTargetException if the underlying constructor throws an exception. */ public static <T> T newInstance(Class<T> clazz) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException { Constructor<T> cons = getConstructor(clazz); return cons.newInstance(EMPTY_OBJECT_ARRAY); }
@Override public void readFields(DataInput in) throws IOException { byte opByte = in.readByte(); operator = Operator.values()[opByte]; int size = in.readInt(); if (size > 0) { filters = new ArrayList<>(size); try { for (int i = 0; i < size; i++) { @SuppressWarnings("unchecked") Class<? extends Filter<K, T>> cls = (Class<? extends Filter<K, T>>) Class.forName(Text.readString(in)).asSubclass(Filter.class); Filter<K, T> filter = ReflectionUtils.newInstance(cls); filter.readFields(in); filters.add(filter); } } catch (Exception e) { throw (IOException)new IOException("Failed filter init").initCause(e); } } }
/** * Constructor * * @param keyClass class of the key to be used * @param persistentClass class of the {@link Persistent} objects to be stored */ public BeanFactoryWSImpl(Class<K> keyClass, Class<T> persistentClass) { this.keyClass = keyClass; this.persistentClass = persistentClass; try { if(ReflectionUtils.hasConstructor(keyClass)) { this.keyConstructor = ReflectionUtils.getConstructor(keyClass); this.key = keyConstructor.newInstance(ReflectionUtils.EMPTY_OBJECT_ARRAY); } this.persistent = ReflectionUtils.newInstance(persistentClass); } catch (Exception ex) { throw new RuntimeException(ex); } isKeyPersistent = Persistent.class.isAssignableFrom(keyClass); }
@Override public void readFields(DataInput in) throws IOException { byte opByte = in.readByte(); operator = Operator.values()[opByte]; int size = in.readInt(); if (size > 0) { filters = new ArrayList<>(size); try { for (int i = 0; i < size; i++) { @SuppressWarnings("unchecked") Class<? extends Filter<K, T>> cls = (Class<? extends Filter<K, T>>) Class.forName(Text.readString(in)).asSubclass(Filter.class); Filter<K, T> filter = ReflectionUtils.newInstance(cls); filter.readFields(in); filters.add(filter); } } catch (Exception e) { throw (IOException)new IOException("Failed filter init").initCause(e); } } }
/** * Default constructor for this class. * * @param keyClass class of the keys * @param persistentClass class of the [{@link Persistent} objects to be stored */ public BeanFactoryImpl(Class<K> keyClass, Class<T> persistentClass) { this.keyClass = keyClass; this.persistentClass = persistentClass; try { if(ReflectionUtils.hasConstructor(keyClass)) { this.keyConstructor = ReflectionUtils.getConstructor(keyClass); this.key = keyConstructor.newInstance(ReflectionUtils.EMPTY_OBJECT_ARRAY); } this.persistent = ReflectionUtils.newInstance(persistentClass); } catch (Exception ex) { throw new RuntimeException(ex); } isKeyPersistent = Persistent.class.isAssignableFrom(keyClass); }
public MongoFilterUtil(final Configuration conf) throws GoraException { String[] factoryClassNames = conf.getStrings( MONGO_FILTER_FACTORIES_PARAMETER, MONGO_FILTERS_DEFAULT_FACTORY); for (String factoryClass : factoryClassNames) { try { FilterFactory<K, T> factory = (FilterFactory<K, T>) ReflectionUtils .newInstance(factoryClass); for (String filterClass : factory.getSupportedFilters()) { factories.put(filterClass, factory); } factory.setFilterUtil(this); } catch (Exception e) { throw new GoraException(e); } } }
/** * Default constructor for this class. * * @param keyClass class of the keys * @param persistentClass class of the [{@link Persistent} objects to be stored */ public BeanFactoryImpl(Class<K> keyClass, Class<T> persistentClass) throws GoraException { this.keyClass = keyClass; this.persistentClass = persistentClass; try { if(ReflectionUtils.hasConstructor(keyClass)) { this.keyConstructor = ReflectionUtils.getConstructor(keyClass); this.key = keyConstructor.newInstance(ReflectionUtils.EMPTY_OBJECT_ARRAY); } this.persistent = ReflectionUtils.newInstance(persistentClass); } catch (Exception ex) { throw new GoraException(ex); } isKeyPersistent = Persistent.class.isAssignableFrom(keyClass); }
public HBaseFilterUtil(Configuration conf) throws GoraException { String[] factoryClassNames = conf.getStrings("gora.hbase.filter.factories", "org.apache.gora.hbase.util.DefaultFactory"); for (String factoryClass : factoryClassNames) { try { @SuppressWarnings("unchecked") FilterFactory<K, T> factory = (FilterFactory<K, T>) ReflectionUtils.newInstance(factoryClass); for (String filterClass : factory.getSupportedFilters()) { factories.put(filterClass, factory); } factory.setHBaseFitlerUtil(this); } catch (Exception e) { throw new GoraException(e); } } }
public HBaseFilterUtil(Configuration conf) throws GoraException { String[] factoryClassNames = conf.getStrings("gora.hbase.filter.factories", "org.apache.gora.hbase.util.DefaultFactory"); for (String factoryClass : factoryClassNames) { try { @SuppressWarnings("unchecked") FilterFactory<K, T> factory = (FilterFactory<K, T>) ReflectionUtils.newInstance(factoryClass); for (String filterClass : factory.getSupportedFilters()) { factories.put(filterClass, factory); } factory.setHBaseFitlerUtil(this); } catch (Exception e) { throw new GoraException(e); } } }
setDefaultSchemaName(properties, schemaName); D dataStore = ReflectionUtils.newInstance(dataStoreClass); if ((dataStore instanceof Configurable) && conf != null) { ((Configurable)dataStore).setConf(conf);
setDefaultSchemaName(properties, schemaName); D dataStore = ReflectionUtils.newInstance(dataStoreClass); if ( auth != null) { ((WSDataStoreBase<K, Persistent>)dataStore).setConf(auth);
setDefaultSchemaName(properties, schemaName); D dataStore = ReflectionUtils.newInstance(dataStoreClass); if ( auth != null) { ((WSDataStoreBase<K, Persistent>)dataStore).setConf(auth);
setDefaultSchemaName(properties, schemaName); D dataStore = ReflectionUtils.newInstance(dataStoreClass); if ((dataStore instanceof Configurable) && conf != null) { ((Configurable)dataStore).setConf(conf);