Java Code Examples for org.apache.commons.lang3.reflect.ConstructorUtils#invokeConstructor()

The following examples show how to use org.apache.commons.lang3.reflect.ConstructorUtils#invokeConstructor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GobblinConstructorUtils.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new instance of the <code>cls</code> based on a set of arguments. The method will search for a
 * constructor accepting the first k arguments in <code>args</code> for every k from args.length to 0, and will
 * invoke the first constructor found.
 *
 * For example, {@link #invokeLongestConstructor}(cls, myString, myInt) will first attempt to create an object with
 * of class <code>cls</code> with constructor <init>(String, int), if it fails it will attempt <init>(String), and
 * finally <init>().
 *
 * @param cls the class to instantiate.
 * @param args the arguments to use for instantiation.
 * @throws ReflectiveOperationException
 */
public static <T> T invokeLongestConstructor(Class<T> cls, Object... args) throws ReflectiveOperationException {

  Class<?>[] parameterTypes = new Class[args.length];
  for (int i = 0; i < args.length; i++) {
    parameterTypes[i] = args[i].getClass();
  }

  for (int i = args.length; i >= 0; i--) {
    if (ConstructorUtils.getMatchingAccessibleConstructor(cls, Arrays.copyOfRange(parameterTypes, 0, i)) != null) {
      log.debug(
          String.format("Found accessible constructor for class %s with parameter types %s.", cls,
              Arrays.toString(Arrays.copyOfRange(parameterTypes, 0, i))));
      return ConstructorUtils.invokeConstructor(cls, Arrays.copyOfRange(args, 0, i));
    }
  }
  throw new NoSuchMethodException(String.format("No accessible constructor for class %s with parameters a subset of %s.",
      cls, Arrays.toString(parameterTypes)));
}
 
Example 2
Source File: GobblinConstructorUtils.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method on top of {@link ConstructorUtils#invokeConstructor(Class, Object[])} that returns a new
 * instance of the <code>cls</code> based on a constructor priority order. Each {@link List} in the
 * <code>constructorArgs</code> array contains the arguments for a constructor of <code>cls</code>. The first
 * constructor whose signature matches the argument types will be invoked.
 *
 * @param cls the class to be instantiated
 * @param constructorArgs An array of constructor argument list. Order defines the priority of a constructor.
 * @return
 *
 * @throws NoSuchMethodException if no constructor matched was found
 */
@SafeVarargs
public static <T> T invokeFirstConstructor(Class<T> cls, List<Object>... constructorArgs)
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

  for (List<Object> args : constructorArgs) {

    Class<?>[] parameterTypes = new Class[args.size()];
    for (int i = 0; i < args.size(); i++) {
      parameterTypes[i] = args.get(i).getClass();
    }

    if (ConstructorUtils.getMatchingAccessibleConstructor(cls, parameterTypes) != null) {
      return ConstructorUtils.invokeConstructor(cls, args.toArray(new Object[args.size()]));
    }
  }
  throw new NoSuchMethodException("No accessible constructor found");
}
 
Example 3
Source File: DefaultAuditSinkFactory.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new {@link AuditSink} using the alias or cannonical classname specified at {@value #AUDIT_SINK_CLASS_NAME_KEY} in the <code>config</code>
 * The {@link AuditSink} class MUST have an accessible constructor <code>abc(Config config, TableMetadata tableMetadata)</code>
 * <br>
 * If {@value #AUDIT_SINK_CLASS_NAME_KEY} is not set in <code>config</code>, a default {@link #DEFAULT_AUDIT_SINK_CLASS} is used
 *
 * @param config job configs
 * @param auditRuntimeMetadata runtime table metadata
 *
 * @return a new instance of {@link AuditSink}
 */
public AuditSink create(Config config, ValueAuditRuntimeMetadata auditRuntimeMetadata) {

  String sinkClassName = DEFAULT_AUDIT_SINK_CLASS;
  if (config.hasPath(AUDIT_SINK_CLASS_NAME_KEY)) {
    sinkClassName = config.getString(AUDIT_SINK_CLASS_NAME_KEY);
  }
  log.info("Using audit sink class name/alias " + sinkClassName);

  try {
    return (AuditSink)ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve(
        sinkClassName)), config, auditRuntimeMetadata);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example 4
Source File: HiveRegister.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
protected HiveRegistrationUnitComparator<?> getPartitionComparator(HivePartition existingPartition,
    HivePartition newPartition) {
  try {
    Class<?> clazz =
        Class.forName(this.props.getProp(HIVE_PARTITION_COMPARATOR_TYPE, DEFAULT_HIVE_PARTITION_COMPARATOR_TYPE));
    return (HiveRegistrationUnitComparator<?>) ConstructorUtils
        .invokeConstructor(clazz, existingPartition, newPartition);
  } catch (ReflectiveOperationException e) {
    log.error("Unable to instantiate Hive partition comparator", e);
    throw Throwables.propagate(e);
  }
}
 
Example 5
Source File: SimpleKafkaSpecProducer.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private AsyncDataWriter<byte[]> getKafkaProducer() {
  if (null == _kafkaProducer) {
    try {
      Class<?> kafkaProducerClass = (Class<?>) Class.forName(_kafkaProducerClassName);
      _kafkaProducer = (AsyncDataWriter<byte[]>) ConstructorUtils.invokeConstructor(kafkaProducerClass,
          ConfigUtils.configToProperties(_config));
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
      log.error("Failed to instantiate Kafka consumer from class " + _kafkaProducerClassName, e);
      throw new RuntimeException("Failed to instantiate Kafka consumer", e);
    }
  }
  return _kafkaProducer;
}
 
Example 6
Source File: HiveLock.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public HiveLock(Properties properties) throws IOException {
  this.properties = properties;
  try {
    locks = (HiveLockFactory) ConstructorUtils.invokeConstructor(
        Class.forName(properties.getProperty(HIVE_LOCK_TYPE, HIVE_LOCK_TYPE_DEFAULT)), properties);
  } catch (Exception e) {
    throw new IOException(e);
  }
}
 
Example 7
Source File: HighLevelConsumer.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
protected GobblinKafkaConsumerClient createConsumerClient(Config config) {
  String kafkaConsumerClientClass = config.getString(CONSUMER_CLIENT_FACTORY_CLASS_KEY);

  try {
    Class clientFactoryClass = Class.forName(kafkaConsumerClientClass);
    final GobblinKafkaConsumerClient.GobblinKafkaConsumerClientFactory factory =
        (GobblinKafkaConsumerClient.GobblinKafkaConsumerClientFactory)
            ConstructorUtils.invokeConstructor(clientFactoryClass);

    return factory.create(config);
  } catch (ReflectiveOperationException e) {
    throw new RuntimeException("Failed to instantiate Kafka consumer client " + kafkaConsumerClientClass, e);
  }
}
 
Example 8
Source File: DefaultRowSelectionPolicyFactory.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link RowSelectionPolicy} using the alias or cannonical classname specified at {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} in the <code>config</code>
 * The {@link RowSelectionPolicy} class MUST have an accessible constructor <code>abc(Config config, TableMetadata tableMetadata, ColumnProjectionPolicy columnProjectionPolicy)</code>
 * <b>Note : must have the key {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} set in <code>config</code> to create the {@link RowSelectionPolicy}</b>
 *
 * @param config job configs, must have the key {@value #ROW_SELECTION_POLICY_CLASS_NAME_KEY} set to create the {@link RowSelectionPolicy}
 * @param tableMetadata runtime table metadata
 * @param columnProjectionPolicy used by the {@link ValueAuditGenerator}
 *
 * @return a new instance of {@link RowSelectionPolicy}
 */
public RowSelectionPolicy create(Config config, ValueAuditRuntimeMetadata.TableMetadata tableMetadata, ColumnProjectionPolicy columnProjectionPolicy) {

  Preconditions.checkArgument(config.hasPath(ROW_SELECTION_POLICY_CLASS_NAME_KEY));

  log.info("Using row selection class name/alias " + config.getString(ROW_SELECTION_POLICY_CLASS_NAME_KEY));

  try {
    return (RowSelectionPolicy)ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve(
            config.getString(ROW_SELECTION_POLICY_CLASS_NAME_KEY))), config, tableMetadata, columnProjectionPolicy);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example 9
Source File: KafkaDeserializerExtractor.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@link Deserializer}, using the value of {@link #KAFKA_DESERIALIZER_TYPE}.
 */
private static Deserializer<?> getDeserializer(Properties props, Optional<Deserializers> deserializerType) throws ReflectiveOperationException {

  Deserializer<?> deserializer;
  if (deserializerType.isPresent()) {
    deserializer = ConstructorUtils.invokeConstructor(deserializerType.get().getDeserializerClass());
  } else {
    deserializer = Deserializer.class
        .cast(ConstructorUtils.invokeConstructor(Class.forName(props.getProperty(KAFKA_DESERIALIZER_TYPE))));
  }
  deserializer.configure(PropertiesUtils.propsToStringKeyMap(props), false);
  return deserializer;
}
 
Example 10
Source File: PageFragment.java    From adf-selenium with Apache License 2.0 5 votes vote down vote up
protected <P extends PageFragment> P navigatedTo(Class<? extends P> cls) {
    try {
        return ConstructorUtils.invokeConstructor(cls, region);
    } catch (Exception e) {
        throw new WebDriverException(e.getCause() != null ? e.getCause() : e);
    }
}
 
Example 11
Source File: Page.java    From adf-selenium with Apache License 2.0 5 votes vote down vote up
protected <D extends WindowDialog> D openedDialog(Class<? extends D> cls) {
    try {
        return ConstructorUtils.invokeConstructor(cls, driver, DialogManager.getInstance().getCurrentDialog());
    } catch (Exception e) {
        throw new WebDriverException(e.getCause() != null ? e.getCause() : e);
    }
}
 
Example 12
Source File: Orchestrator.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public Orchestrator(Config config, Optional<TopologyCatalog> topologyCatalog, Optional<DagManager> dagManager, Optional<Logger> log,
    boolean instrumentationEnabled) {
  _log = log.isPresent() ? log.get() : LoggerFactory.getLogger(getClass());
  this.aliasResolver = new ClassAliasResolver<>(SpecCompiler.class);
  this.topologyCatalog = topologyCatalog;
  this.dagManager = dagManager;
  try {
    String specCompilerClassName = ServiceConfigKeys.DEFAULT_GOBBLIN_SERVICE_FLOWCOMPILER_CLASS;
    if (config.hasPath(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWCOMPILER_CLASS_KEY)) {
      specCompilerClassName = config.getString(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWCOMPILER_CLASS_KEY);
    }
    _log.info("Using specCompiler class name/alias " + specCompilerClassName);

    this.specCompiler = (SpecCompiler) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve(
        specCompilerClassName)), config);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }

  //At this point, the TopologySpecMap is initialized by the SpecCompiler. Pass the TopologySpecMap to the DagManager.
  if (this.dagManager.isPresent()) {
    this.dagManager.get().setTopologySpecMap(getSpecCompiler().getTopologySpecMap());
  }

  if (instrumentationEnabled) {
    this.metricContext = Instrumented.getMetricContext(ConfigUtils.configToState(config), this.specCompiler.getClass());
    this.flowOrchestrationSuccessFulMeter = Optional.of(this.metricContext.meter(ServiceMetricNames.FLOW_ORCHESTRATION_SUCCESSFUL_METER));
    this.flowOrchestrationFailedMeter = Optional.of(this.metricContext.meter(ServiceMetricNames.FLOW_ORCHESTRATION_FAILED_METER));
    this.flowOrchestrationTimer = Optional.of(this.metricContext.timer(ServiceMetricNames.FLOW_ORCHESTRATION_TIMER));
    this.eventSubmitter = Optional.of(new EventSubmitter.Builder(this.metricContext, "org.apache.gobblin.service").build());
  } else {
    this.metricContext = null;
    this.flowOrchestrationSuccessFulMeter = Optional.absent();
    this.flowOrchestrationFailedMeter = Optional.absent();
    this.flowOrchestrationTimer = Optional.absent();
    this.eventSubmitter = Optional.absent();
  }
}
 
Example 13
Source File: ActorFactoryBean.java    From akka-java-springfactory with MIT License 5 votes vote down vote up
@Override
public Actor create() throws Exception {
	Actor actor = (Actor) ConstructorUtils.invokeConstructor(clazz, args);
	if(actor != null) {
		ctx.getAutowireCapableBeanFactory().autowireBean(actor);
	}
	return actor;
}
 
Example 14
Source File: ReflectionUtils.java    From async-gamequery-lib with MIT License 5 votes vote down vote up
public static <T> T createInstance(Class<T> classOf) {
    try {
        return ConstructorUtils.invokeConstructor(classOf);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
        log.debug("Error on createInstance()", e);
    }
    return null;
}
 
Example 15
Source File: ReflectionUtil.java    From j360-dubbo-app-all with Apache License 2.0 5 votes vote down vote up
/**
 * 调用构造函数.
 */
public static <T> T invokeConstructor(final Class<T> cls, Object... args) {
	try {
		return ConstructorUtils.invokeConstructor(cls, args);
	} catch (Exception e) {
		throw ExceptionUtil.uncheckedAndWrap(e);
	}
}
 
Example 16
Source File: TopologyCatalog.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public TopologyCatalog(Config config, Optional<Logger> log, Optional<MetricContext> parentMetricContext,
    boolean instrumentationEnabled) {
  this.log = log.isPresent() ? log.get() : LoggerFactory.getLogger(getClass());
  this.listeners = new SpecCatalogListenersList(log);
  if (instrumentationEnabled) {
    MetricContext realParentCtx =
        parentMetricContext.or(Instrumented.getMetricContext(new org.apache.gobblin.configuration.State(), getClass()));
    this.metricContext = realParentCtx.childBuilder(TopologyCatalog.class.getSimpleName()).build();
    this.metrics = new SpecCatalog.StandardMetrics(this, Optional.of(config));
    this.addListener(this.metrics);
  }
  else {
    this.metricContext = null;
    this.metrics = null;
  }

  this.aliasResolver = new ClassAliasResolver<>(SpecStore.class);
  try {
    Config newConfig = config;
    if (config.hasPath(ConfigurationKeys.TOPOLOGYSPEC_STORE_DIR_KEY)) {
      newConfig = config.withValue(FSSpecStore.SPECSTORE_FS_DIR_KEY,
          config.getValue(ConfigurationKeys.TOPOLOGYSPEC_STORE_DIR_KEY));
    }
    String specStoreClassName = ConfigUtils.getString(config, ConfigurationKeys.TOPOLOGYSPEC_STORE_CLASS_KEY,
        DEFAULT_TOPOLOGYSPEC_STORE_CLASS);
    this.log.info("Using SpecStore class name/alias " + specStoreClassName);
    String specSerDeClassName = ConfigUtils.getString(config, ConfigurationKeys.TOPOLOGYSPEC_SERDE_CLASS_KEY,
        DEFAULT_TOPOLOGYSPEC_SERDE_CLASS);
    this.log.info("Using SpecSerDe class name/alias " + specSerDeClassName);

    SpecSerDe specSerDe = (SpecSerDe) ConstructorUtils.invokeConstructor(Class.forName(
        new ClassAliasResolver<>(SpecSerDe.class).resolve(specSerDeClassName)));
    this.specStore = (SpecStore) ConstructorUtils.invokeConstructor(Class.forName(this.aliasResolver.resolve(
        specStoreClassName)), newConfig, specSerDe);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
Example 17
Source File: GobblinYarnAppLauncher.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private AbstractYarnAppSecurityManager buildSecurityManager() throws IOException {
  Path tokenFilePath = new Path(this.fs.getHomeDirectory(), this.applicationName + Path.SEPARATOR +
      GobblinYarnConfigurationKeys.TOKEN_FILE_NAME);

  ClassAliasResolver<AbstractYarnAppSecurityManager> aliasResolver = new ClassAliasResolver<>(
      AbstractYarnAppSecurityManager.class);
  try {
   return (AbstractYarnAppSecurityManager)ConstructorUtils.invokeConstructor(Class.forName(aliasResolver.resolve(
        ConfigUtils.getString(config, GobblinYarnConfigurationKeys.SECURITY_MANAGER_CLASS, GobblinYarnConfigurationKeys.DEFAULT_SECURITY_MANAGER_CLASS))), this.config, this.helixManager, this.fs,
        tokenFilePath);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new IOException(e);
  }
}
 
Example 18
Source File: ConfigBasedTopologySpecFactory.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<TopologySpec> getTopologies() {

  if (!_config.hasPath(ServiceConfigKeys.TOPOLOGY_FACTORY_TOPOLOGY_NAMES_KEY)) {
    return Collections.EMPTY_LIST;
  }
  Collection<TopologySpec> topologySpecs = Lists.newArrayList();
  Collection<String> topologyNames = SPLIT_BY_COMMA.splitToList(
      _config.getString(ServiceConfigKeys.TOPOLOGY_FACTORY_TOPOLOGY_NAMES_KEY));

  for (String topologyName : topologyNames) {
    Preconditions.checkArgument(_config.hasPath(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + topologyName),
        "Config does not contain Topology Factory descriptor for Topology " + topologyName);
    Config topologyConfig = _config.getConfig(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + topologyName);
    String description = ConfigUtils.getString(topologyConfig, ServiceConfigKeys.TOPOLOGYSPEC_DESCRIPTION_KEY, "NA");
    String version = ConfigUtils.getString(topologyConfig, ServiceConfigKeys.TOPOLOGYSPEC_VERSION_KEY, "-1");

    String specExecutorClass = ServiceConfigKeys.DEFAULT_SPEC_EXECUTOR;
    if (topologyConfig.hasPath(ServiceConfigKeys.SPEC_EXECUTOR_KEY)) {
      specExecutorClass = topologyConfig.getString(ServiceConfigKeys.SPEC_EXECUTOR_KEY);
    }
    SpecExecutor specExecutor;
    try {
      _log.info("Using SpecProducer class name/alias " + specExecutorClass);
      specExecutor = (SpecExecutor) ConstructorUtils
          .invokeConstructor(Class.forName(_aliasResolver
              .resolve(specExecutorClass)), topologyConfig);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
        | ClassNotFoundException e) {
      if (e.getCause() != null) {
        throw new RuntimeException(e.getCause());
      } else {
        throw new RuntimeException(e);
      }
    }

    TopologySpec.Builder topologySpecBuilder = TopologySpec
        .builder(topologyConfig.getString(ServiceConfigKeys.TOPOLOGYSPEC_URI_KEY))
        .withConfig(topologyConfig)
        .withDescription(description)
        .withVersion(version)
        .withSpecExecutor(specExecutor);
    topologySpecs.add(topologySpecBuilder.build());
  }

  return topologySpecs;
}
 
Example 19
Source File: GobblinConstructorUtils.java    From incubator-gobblin with Apache License 2.0 3 votes vote down vote up
/**
 * Utility method to create an instance of <code>clsName</code> using the constructor matching the arguments, <code>args</code>
 *
 * @param superType of <code>clsName</code>. The new instance is cast to superType
 * @param clsName complete cannonical name of the class to be instantiated
 * @param args constructor args to be used
 *
 * @throws IllegalArgumentException if there was an issue creating the instance due to
 * {@link NoSuchMethodException}, {@link InvocationTargetException},{@link InstantiationException},
 *  {@link ClassNotFoundException}
 *
 * @return A new instance of <code>clsName</code>
 */
@SuppressWarnings("unchecked")
public static <T> T invokeConstructor(final Class<T> superType, final String clsName, Object... args) {

  try {
    return (T) ConstructorUtils.invokeConstructor(Class.forName(clsName), args);
  } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
      | ClassNotFoundException e) {
    throw new IllegalArgumentException(e);
  }
}
 
Example 20
Source File: ConstructorUtil.java    From feilong-core with Apache License 2.0 3 votes vote down vote up
/**
 * 返回指定类型 <code>klass</code>,指定参数 <code>parameterValues</code> 和指定参数类型 <code>parameterTypes</code>的构造函数示例.
 * 
 * <h3>说明:</h3>
 * <blockquote>
 * <ol>
 * <li>定位并调用一个构造函数。构造函数的签名必须与赋值兼容的参数类型相匹配。</li>
 * <li>和 {@link #newInstance(Class, Object...)}的区别, 在于 如果一个类有些重载的构造函数,并且参数类型相似, 此时使用这个方法可以精准定位到需要的构造函数</li>
 * </ol>
 * </blockquote>
 * 
 * <h3>示例:</h3>
 * 
 * <blockquote>
 * 
 * <pre class="code">
 * User user = ConstructorUtil.newInstance(User.class,null,null)
 * </pre>
 * 
 * 调用无参的构造函数,返回User对象,你还可以:
 * 
 * <pre class="code">
 * 
 * User user1 = ConstructorUtil.newInstance(User.class, toArray(100L), toArray(Long.class));
 * </pre>
 * 
 * 返回 id 是100的user对象构造函数
 * </blockquote>
 *
 * @param <T>
 *            the generic type
 * @param klass
 *            the class to be constructed, not {@code null}
 * @param parameterValues
 *            the array of arguments, {@code null} treated as empty
 * @param parameterTypes
 *            the array of parameter types, {@code null} treated as empty
 * @return 如果 <code>klass</code> 是null,抛出 {@link NullPointerException}<br>
 *         有任何异常(比如 NoSuchMethodException 找不到相关参数的构造函数),将抛出 {@link ReflectException}
 * @see org.apache.commons.lang3.reflect.ConstructorUtils#invokeConstructor(Class, Object[], Class[])
 * @see "org.springframework.beans.BeanUtils.instantiateClass(Constructor<T>, Object...)"
 */
public static <T> T newInstance(Class<T> klass,Object[] parameterValues,Class<?>[] parameterTypes){
    Validate.notNull(klass, "klass can't be null!");

    //---------------------------------------------------------------
    try{
        return ConstructorUtils.invokeConstructor(klass, parameterValues, parameterTypes);
    }catch (Exception e){
        String pattern = "invokeConstructor exception,class:[{}].args:[{}],parameterTypes:[{}]";
        String message = Slf4jUtil.format(pattern, klass, parameterValues, parameterTypes);
        throw new ReflectException(message, e);
    }
}