/*
(non-Javadoc)

@see
com.impetus.kundera.loader.GenericClientFactory#instantiateClient(java
.lang.String)
167010
@Override
    protected Client<?> instantiateClient(String persistenceUnit)
    {
        return new DSClient(this, persistenceUnit, externalProperties, kunderaMetadata, reader, timestampGenerator);
    }
756192
public static Object instantiate(String type, ClassLoader classLoader) {
        try {
            return ClassUtils.forName(type, classLoader)
                .flatMap(InstantiationUtils::tryInstantiate)
                .orElseThrow(() -> new InstantiationException("No class found for name: " + type));
        } catch (Throwable e) {
            throw new InstantiationException("Could not instantiate type [" + type + "]: " + e.getMessage(), e);
        }
    }
1342280
public static Object loadInstance(Class clazz) throws ClassException {
	try {
	    return clazz.newInstance();
	}
	catch (InstantiationException e) {
	    throw new ClassException("the specified class object [" + clazz.getName() + "()] cannot be instantiated");
	}
	catch (IllegalAccessException e) {
	    throw new ClassException("can't load class because the currently executing method does not have access to the definition of the specified class");
	}
    }
678185
@Override
    public void populateClientProperties(Client client, Map<String, Object> properties)
    {
        this.clientProperties = properties;
    }
515051
@SuppressWarnings("unchecked")
	private T createInstance(final String className, final Object... arguments) {
		try {
			Class<?> implementation = Class.forName(className, false, classLoader);
			if (service.isAssignableFrom(implementation)) {
				return (T) implementation.getDeclaredConstructor(argumentTypes).newInstance(arguments);
			} else {
				InternalLogger.log(Level.ERROR, "Class '" + className + "' does not implement servcie interface '" + service + "'");
			}
		} catch (ClassNotFoundException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' not found");
		} catch (NoSuchMethodException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' has no matching constructor");
		} catch (InstantiationException ex) {
			InternalLogger.log(Level.ERROR, "Service implementation '" + className + "' is not instantiable");
		} catch (IllegalAccessException ex) {
			InternalLogger.log(Level.ERROR, "Constructor of service implementation '" + className + "' is not accessible");
		} catch (IllegalArgumentException ex) {
			InternalLogger.log(Level.ERROR, "Illegal arguments for constructor of service implementation '" + className + "'");
		} catch (InvocationTargetException ex) {
			InternalLogger.log(Level.ERROR, ex.getTargetException(), "Failed creating service implementation '" + className + "'");
		}

		return null;
	}
747853
private static <T> T instantiate(Class<T> pojoClass) throws InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException {
        try {
            Constructor<T> constructor = pojoClass.getDeclaredConstructor();
            constructor.setAccessible(true);
            return constructor.newInstance();
        } catch (NoSuchMethodException e) {
            Function<Class<?>,Object> fn = unsafeInstantiator.get();
            if (fn == null) {
                throw new HecateException(e, "Unable to instantiate object of type %s (no-arg constructor missing).", pojoClass.getCanonicalName());
            }
            return (T) fn.apply(pojoClass);
        }
    }
1229994
@Override
    protected T createInstance() throws Exception {
        for (final String beanName : this.delegateBeanNames) {
            try {
                final T bean;
                if (this.type == null) {
                    bean = (T) this.getBeanFactory().getBean(beanName);
                } else {
                    bean = this.getBeanFactory().getBean(beanName, this.type);
                }

                if (this.logger.isInfoEnabled()) {
                    this.logger.info("Loaded bean for name " + beanName);
                }

                return bean;
            } catch (final Exception e) {
                final String msg =
                        "Failed to load bean '"
                                + beanName
                                + "' from ApplicationContext"
                                + (this.type != null ? " expecting type: " + this.type : "")
                                + ". Will try to load the next bean in the list instead. Error message from the attempt to load this bean ('"
                                + beanName
                                + "'): ";

                if (this.logger.isDebugEnabled()) {
                    this.logger.debug(msg, e);
                } else if (this.logger.isInfoEnabled()) {
                    this.logger.info(
                            msg + " " + e.getMessage() + " (enable debug for stack trace)");
                }
            }
        }

        throw new BeanCreationException(
                "None of the configured bean names could be loaded. BeanNames: "
                        + this.delegateBeanNames);
    }
1098234
public C createObject(String className, Class clazz) throws ClassNotFoundException {
        return createObject(className, clazz, /* no dynamic init */ null);
    }
1083688
@Override
	public <K extends TServiceClient> K getClient(String serviceName, Class<K> clazz) {
		if (thriftConnection != null) {
			return thriftConnection.getClient(serviceName, clazz);
		}
		throw new IllegalStateException("连接代理类没有绑定的原始连接信息");
	}
486901
private void createInstance() throws InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "createInstance");

        ManagedObjectFactory<?> ejbManagedObjectFactory = home.beanMetaData.ivEnterpriseBeanFactory;
        if (ejbManagedObjectFactory != null) {
            createInstanceUsingMOF(ejbManagedObjectFactory);
        } else {
            createInstanceUsingConstructor();
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "createInstance");
    }
1186632
JmsSessionImpl instantiateSession(boolean transacted, int acknowledgeMode, SICoreConnection coreConnection, JmsJcaSession jcaSession) throws JMSException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "instantiateSession", new Object[]{transacted, acknowledgeMode, coreConnection, jcaSession});
    JmsQueueSessionImpl jmsQueueSession = new JmsQueueSessionImpl(transacted, acknowledgeMode, coreConnection, this, jcaSession);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "instantiateSession",  jmsQueueSession);
    return jmsQueueSession;
  }
424249
public SoapClientActionBuilder client(String soapClient) {
		SoapClientActionBuilder clientAction = new SoapClientActionBuilder(action, soapClient)
				.withApplicationContext(applicationContext);
		return clientAction;
	}
1246616
public static SematextClient newInstance(String token) {
    if (token == null) {
      throw new IllegalArgumentException("Token should be defined.");
    }
    return newInstance(new ClientProperties(token, null, null));
  }
1130845
@Override
    protected Client instantiateClient(String persistenceUnit)
    {
        return new RethinkDBClient(kunderaMetadata, indexManager, reader, externalProperties, persistenceUnit,
                this.connection, this.clientMetadata);
    }
879241
public Client getClient(int clientId) throws Exception {
        Client client = null;

        PreparedStatement statement = null;
        ResultSet results = null;
        try (Connection sqlConnection = sqlService.getConnection()) {
            String queryString = "SELECT * FROM " + Constants.DB_TABLE_CLIENT +
                " WHERE " + Constants.GENERIC_ID + " = ?";

            statement = sqlConnection.prepareStatement(queryString);
            statement.setInt(1, clientId);

            results = statement.executeQuery();
            if (results.next()) {
                client = this.getClientFromResultSet(results);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            try {
                if (results != null) {
                    results.close();
                }
            } catch (Exception e) {
            }
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }

        return client;
    }
276802
JmsConnectionImpl instantiateConnection(JmsJcaConnection jcaConnection, Map _passThruProps) throws JMSException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "instantiateConnection", jcaConnection);
    JmsQueueConnectionImpl jmsQueueConnection = new JmsQueueConnectionImpl(jcaConnection, isManaged(), _passThruProps);
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "instantiateConnection",  jmsQueueConnection);
    return jmsQueueConnection;
  }
18508
protected final HylaFAXClientConnectionFactory createHylaFAXClientConnectionFactory(String className)
    {
        //create new instance
        HylaFAXClientConnectionFactory factory=(HylaFAXClientConnectionFactory)ReflectionHelper.createInstance(className);
            
        //initialize
        factory.initialize(this);
        
        return factory;
    }