src/main/java/js/container/ManagedClass.java
private Class<?> loadImplementationClass(Config descriptor) throws ConfigException {
		String implementationName = descriptor.getAttribute("class");
		if (implementationName == null) {
			if (instanceType.requiresImplementation()) {
				throw new ConfigException("Managed type |%s| requires <class> attribute. See class descriptor |%s|.", instanceType, descriptor);
			}
			return null;
		}
		if (!instanceType.requiresImplementation()) {
			throw new ConfigException("Managed type |%s| forbids <class> attribute. See class descriptor |%s|.", instanceType, descriptor);
		}

		Class<?> implementationClass = Classes.forOptionalName(implementationName);
		if (implementationClass == null) {
			throw new ConfigException("Managed class implementation |%s| not found.", implementationName);
		}

		if (implementationClass.isInterface()) {
			throw new ConfigException("Managed class implementation |%s| cannot be an interface. See class descriptor |%s|.", implementationClass, descriptor);
		}
		int implementationModifiers = implementationClass.getModifiers();
		if (Modifier.isAbstract(implementationModifiers)) {
			throw new ConfigException("Managed class implementation |%s| cannot be abstract. See class descriptor |%s|.", implementationClass, descriptor);
		}
		if (Types.isKindOf(implementationClass, ManagedLifeCycle.class) && !InstanceScope.APPLICATION.equals(instanceScope)) {
			throw new ConfigException("Bad scope |%s| used with managed life cycle. See class descriptor |%s|.", instanceScope, descriptor);
		}

		return implementationClass;
	}
private Class<?> loadImplementationClass(Config descriptor) throws ConfigException {
		String implementationName = descriptor.getAttribute("class");
		if (implementationName == null) {
			if (instanceType.requiresImplementation()) {
				throw new ConfigException("Managed type |%s| requires <class> attribute. See class descriptor |%s|.", instanceType, descriptor);
			}
			return null;
		}
		if (!instanceType.requiresImplementation()) {
			throw new ConfigException("Managed type |%s| forbids <class> attribute. See class descriptor |%s|.", instanceType, descriptor);
		}

		Class<?> implementationClass = Classes.forOptionalName(implementationName);
		if (implementationClass == null) {
			throw new ConfigException("Managed class implementation |%s| not found.", implementationName);
		}

		if (implementationClass.isInterface()) {
			throw new ConfigException("Managed class implementation |%s| cannot be an interface. See class descriptor |%s|.", implementationClass, descriptor);
		}
		int implementationModifiers = implementationClass.getModifiers();
		if (Modifier.isAbstract(implementationModifiers)) {
			throw new ConfigException("Managed class implementation |%s| cannot be abstract. See class descriptor |%s|.", implementationClass, descriptor);
		}
		if (Types.isKindOf(implementationClass, ManagedLifeCycle.class) && !InstanceScope.APPLICATION.equals(instanceScope)) {
			throw new ConfigException("Bad scope |%s| used with managed life cycle. See class descriptor |%s|.", instanceScope, descriptor);
		}

		return implementationClass;
	}
private Class < ? > loadImplementationClass ( Config descriptor ) throws ConfigException { String implementationName = descriptor . getAttribute ( "class" ) ; if ( implementationName == null ) { if ( instanceType . requiresImplementation ( ) ) { throw new ConfigException ( "Managed type |%s| requires <class> attribute. See class descriptor |%s|." , instanceType , descriptor ) ; } return null ; } if ( ! instanceType . requiresImplementation ( ) ) { throw new ConfigException ( "Managed type |%s| forbids <class> attribute. See class descriptor |%s|." , instanceType , descriptor ) ; } Class < ? > implementationClass = Classes . forOptionalName ( implementationName ) ; if ( implementationClass == null ) { throw new ConfigException ( "Managed class implementation |%s| not found." , implementationName ) ; } if ( implementationClass . isInterface ( ) ) { throw new ConfigException ( "Managed class implementation |%s| cannot be an interface. See class descriptor |%s|." , implementationClass , descriptor ) ; } int implementationModifiers = implementationClass . getModifiers ( ) ; if ( Modifier . isAbstract ( implementationModifiers ) ) { throw new ConfigException ( "Managed class implementation |%s| cannot be abstract. See class descriptor |%s|." , implementationClass , descriptor ) ; } if ( Types . isKindOf ( implementationClass , ManagedLifeCycle . class ) && ! InstanceScope . APPLICATION . equals ( instanceScope ) ) { throw new ConfigException ( "Bad scope |%s| used with managed life cycle. See class descriptor |%s|." , instanceScope , descriptor ) ; } return implementationClass ; }
Load optional implementation class from class descriptor and applies insanity checks. Load implementation class from
<code>class</code> attribute from descriptor. If <code>class</code> attribute not present return null.
<p>
Beside loading implementation class this utility method performs sanity checks and throws configuration exception if:
<ul>
<li>instance type requires implementation but <code>class</code> attribute is missing,
<li>instance type does not require implementation but <code>class</code> attribute is present,
<li>class not found on run-time class path,
<li>implementation class is a Java interface,
<li>implementation class is abstract,
<li>implementation class implements managed life cycle but instance scope is not {@link InstanceScope#APPLICATION}.
</ul>

@param descriptor class descriptor.
@return loaded implementation class or null.
@throws ConfigException if sanity check fails.
Load optional implementation class from class descriptor and applies insanity checks . Load implementation class from <code > class< / code > attribute from descriptor . If <code > class< / code > attribute not present return null . <p > Beside loading implementation class this utility method performs sanity checks and throws configuration exception if : <ul > <li > instance type requires implementation but <code > class< / code > attribute is missing <li > instance type does not require implementation but <code > class< / code > attribute is present <li > class not found on run - time class path <li > implementation class is a Java interface <li > implementation class is abstract <li > implementation class implements managed life cycle but instance scope is not { @link InstanceScope#APPLICATION } . < / ul >