Creates a new bean.
@return a new bean.
@throws InstantiationException if anything goes wrong.
556870
protected T createNewBean() throws InstantiationException {
        try {
            return beanClass.getConstructor().newInstance();
        } catch (final InstantiationException |
                 IllegalAccessException |
                 IllegalArgumentException |
                 InvocationTargetException |
                 NoSuchMethodException |
                 SecurityException e) {
            // fold it all into one type of exception
            throw new InstantiationException(e.getMessage());
        }
    }
214582
@Override
    public Mp newInstance() throws DempsyException {
        try {
            return newMp.get();
        } catch(final RuntimeException rte) {
            throw new DempsyException(rte, true);
        }
    }
384563
public Object create(String name, Object... args)
    throws ClassNotFoundException,
           NoSuchMethodException,
           IllegalAccessException,
           InstantiationException,
           InvocationTargetException
    {
        try {
            return super.create(name, args);
        } catch (NoSuchMethodException x) {
            Class<?> type = Class.forName(name);
            Object singleton = _singleton.get(name);

            if (singleton != null) {
                return singleton;
            } else {
                Object[] burnedin = _arguments.get(type);
                if (burnedin != null) {
                    Object[] nargs = new Object[burnedin.length + args.length];
                    System.arraycopy(burnedin, 0, nargs, 0, burnedin.length);
                    System.arraycopy(args, 0, nargs, burnedin.length, args.length);
                    return Beans.create(type, nargs);
                } else {
                    throw x;
                }
            }
        }
    }
1341619
protected Expression instantiate(Object oldInstance, Encoder out)
    {
        if (! (oldInstance instanceof EventAdaptor))
            return super.instantiate(oldInstance, out);

        //
        // An implementation instance is actually constructed at decode time by calling
        // ControlBean.ensureControl on the parent bean.  This will create a new impl
        // instance and run the impl initializer on it.
        //
        return new Expression(oldInstance, oldInstance.getClass(), "new", 
                              new Object[] { ((EventAdaptor)oldInstance).getClient() });
    }
1297168
public static SOAPElementFactory newInstance() throws SOAPException {
        try {
            return new SOAPElementFactory(SOAPFactory.newInstance());
        } catch (Exception ex) {
            throw new SOAPException(
                "Unable to create SOAP Element Factory: " + ex.getMessage());
        }
    }
250673
public function newInstance()
    {
        if (!$this->instantiator instanceof InstantiatorInterface) {
            $this->instantiator = new Instantiator();
        }

        return $this->instantiator->instantiate($this->name);
    }
791578
@SuppressWarnings("all")
	protected Object newInstance(String className) {
		log.debug("Loading class: {}", className);
		Object instance = null;
		Class<?> clazz = null;
		if ("".equals(className) || className == null)
			return instance;
		try {
			// check for special DS class aliases
			if (className.length() == 3) {
				className = classAliases.get(className);
			}
			if (className.startsWith("flex.")) {
				// Use Red5 compatibility class instead
				className = "org.red5.compatibility." + className;
				log.debug("Modified classname: {}", className);
			}
			if (!classAllowed(className)) {
				log.error("Class creation is not allowed {}", className);
			} else {
				clazz = Thread.currentThread().getContextClassLoader()
						.loadClass(className);
				instance = clazz.newInstance();
			}
		} catch (InstantiationException iex) {
			try {
				// check for default ctor
				clazz.getConstructor(null);
				log.error("Error loading class: {}", className);
			} catch (NoSuchMethodException nse) {
				log.error(
						"Error loading class: {}; this can be resolved by adding a default constructor to your class",
						className);
			}
			log.debug("Exception was: {}", iex);
		} catch (Exception ex) {
			log.error("Error loading class: {}", className);
			log.debug("Exception was: {}", ex);
		}
		return instance;
	}
637029
public static Object newInstance(String name) {
        try {
            return forName(name).newInstance();
        } catch (InstantiationException e) {
            throw new IllegalStateException(e.getMessage(), e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
782806
public ControlBeanContext instantiate(ControlBean controlBean) {
        if(!(controlBean instanceof org.apache.beehive.controls.runtime.bean.ControlBean))
            throw new IllegalArgumentException("The ControlBean of type \"" +
                controlBean.getClass().getName() +
                "\" is unsupported.  The ControlBean must extend " +
                org.apache.beehive.controls.runtime.bean.ControlBean.class.getName());

        /*
        The provided ControlBean is a "api.bean.ControlBean"; this factory implementation only creates
        ControlBeanContext implementations for "runtime.bean.ControlBean" types.  Ensuare that this is
        of that type.
         */
        org.apache.beehive.controls.runtime.bean.ControlBean runtimeControlBean =
            (org.apache.beehive.controls.runtime.bean.ControlBean)controlBean;

        /*
        Create a simple new ControlBeanContext.
        */
        return new org.apache.beehive.controls.runtime.bean.ControlBeanContext(runtimeControlBean);
    }
525724
public static BeanMap create(Class srcClass) {
        BeanMappingObject describeConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(srcClass, Map.class,
                                                                                                  true);

        BeanMappingObject populateConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(Map.class, srcClass,
                                                                                                  true);
        return new BeanMap(describeConfig, populateConfig);
    }
1001604
@SuppressWarnings("unchecked")
  public static <T> T newInstance(Class<T> theClass, Configuration conf,
      boolean supportJobConf) {
    T result;
    try {
      Constructor<T> meth = (Constructor<T>) CONSTRUCTOR_CACHE.get(theClass);
      if (meth == null) {
        meth = theClass.getDeclaredConstructor(EMPTY_ARRAY);
        meth.setAccessible(true);
        CONSTRUCTOR_CACHE.put(theClass, meth);
      }
      result = meth.newInstance();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    setConf(result, conf, supportJobConf);
    return result;
  }
301454
public static DocumentBuilderFactory newInstance(String factoryClassName,
            ClassLoader classLoader) {
        if (factoryClassName == null) {
            throw new FactoryConfigurationError("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            return (DocumentBuilderFactory) type.newInstance();
        } catch (ClassNotFoundException e) {
            throw new FactoryConfigurationError(e);
        } catch (InstantiationException e) {
            throw new FactoryConfigurationError(e);
        } catch (IllegalAccessException e) {
            throw new FactoryConfigurationError(e);
        }
    }
932811
public Scan<Beans<T>> getOrCreateScan()
   {
      List<Node> nodeList = childNode.get("scan");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new ScanImpl<Beans<T>>(this, "scan", childNode, nodeList.get(0));
      }
      return createScan();
   }
1168731
public Constructor<?> getEnterpriseBeanClassConstructor() {
        Constructor<?> constructor = ivEnterpriseBeanClassConstructor;
        if (constructor == null) {
            constructor = ivEnterpriseBeanFactory.getConstructor();
        }
        return constructor;
    }
952370
@SuppressWarnings("unchecked")
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (clazz.isInstance(bean)) {
            register((V) bean);
        }
        
        return bean;
    }
389350
public T newInstance(Object... args)
    {
        try
        {
            return type.cast(factoryMethod.invoke(null, args));
        }
        catch (IllegalAccessException e)
        {
            throw ExceptionImposter.imposterize( e );
        }
        catch (InvocationTargetException e)
        {
            throw ExceptionImposter.imposterize( e.getCause() );
        }
    }
129144
public static function newInstance($name)
    {
        $bean       = \Mix\Core\Bean::config($name);
        $class      = $bean['class'];
        $properties = $bean['properties'] ?? [];
        return new $class($properties);
    }