AppserverIo\Appserver\Core\Api\AbstractService::newInstance PHP Method

newInstance() public method

(non-PHPdoc)
See also: AppserverIo\Appserver\Core\InitialContext::newInstance()
public newInstance ( string $className, array $args = [] ) : object
$className string The fully qualified class name to return the instance for
$args array Arguments to pass to the constructor of the instance
return object The instance itself
    public function newInstance($className, array $args = array())
    {
        return $this->getInitialContext()->newInstance($className, $args);
    }

Usage Example

 /**
  * Test the new instance method.
  *
  * @return null
  */
 public function testNewInstance()
 {
     $className = 'AppserverIo\\Appserver\\Core\\Api\\Mock\\MockService';
     $instance = $this->service->newInstance($className, array($this->service->getInitialContext()));
     $this->assertInstanceOf($className, $instance);
 }