src/main/java/js/container/ManagedClass.java
private Class<?>[] loadInterfaceClasses(Config descriptor) throws ConfigException {
		List<String> interfaceNames = new ArrayList<>();

		if (!descriptor.hasChildren()) {
			if (!descriptor.hasAttribute("interface")) {
				if (instanceType.requiresInterface()) {
					throw new ConfigException("Managed type |%s| requires <interface> attribute. See class descriptor |%s|.", instanceType, descriptor);
				}
				// if interface is not required and is missing uses implementation class
				return new Class<?>[] { implementationClass };
			}
			interfaceNames.add(descriptor.getAttribute("interface"));

			if ("REMOTE".equals(descriptor.getAttribute("type"))) {
				String url = descriptor.getAttribute("url");
				if (url == null || url.isEmpty()) {
					throw new ConfigException("Managed type REMOTE requires <url> attribute. See class descriptor |%s|.", descriptor);
				}
				if (url.startsWith("${")) {
					throw new ConfigException("Remote implementation <url> property not resolved. See class descriptor |%s|.", descriptor);
				}
			}
		} else {
			for (int i = 0; i < descriptor.getChildrenCount(); ++i) {
				String interfaceName = descriptor.getChild(i).getAttribute("name");
				if (interfaceName == null) {
					throw new ConfigException("Missing <name> attribute from interface declaration. See class descriptor |%s|.", descriptor);
				}
				interfaceNames.add(interfaceName);
			}
		}

		Class<?>[] interfaceClasses = new Class<?>[interfaceNames.size()];
		for (int i = 0; i < interfaceNames.size(); ++i) {
			final String interfaceName = interfaceNames.get(i);
			final Class<?> interfaceClass = Classes.forOptionalName(interfaceName);

			if (interfaceClass == null) {
				throw new ConfigException("Managed class interface |%s| not found.", interfaceName);
			}
			if (Types.isKindOf(interfaceClass, ManagedLifeCycle.class)) {
				autoInstanceCreation = true;
			}
			if (instanceType.requiresInterface() && !interfaceClass.isInterface()) {
				throw new ConfigException("Managed type |%s| requires interface to make Java Proxy happy but got |%s|.", instanceType, interfaceClass);
			}
			if (implementationClass != null && !Types.isKindOf(implementationClass, interfaceClass)) {
				throw new ConfigException("Implementation |%s| is not a kind of interface |%s|.", implementationClass, interfaceClass);
			}

			interfaceClasses[i] = interfaceClass;
		}
		return interfaceClasses;
	}
private Class<?>[] loadInterfaceClasses(Config descriptor) throws ConfigException {
		List<String> interfaceNames = new ArrayList<>();

		if (!descriptor.hasChildren()) {
			if (!descriptor.hasAttribute("interface")) {
				if (instanceType.requiresInterface()) {
					throw new ConfigException("Managed type |%s| requires <interface> attribute. See class descriptor |%s|.", instanceType, descriptor);
				}
				// if interface is not required and is missing uses implementation class
				return new Class<?>[] { implementationClass };
			}
			interfaceNames.add(descriptor.getAttribute("interface"));

			if ("REMOTE".equals(descriptor.getAttribute("type"))) {
				String url = descriptor.getAttribute("url");
				if (url == null || url.isEmpty()) {
					throw new ConfigException("Managed type REMOTE requires <url> attribute. See class descriptor |%s|.", descriptor);
				}
				if (url.startsWith("${")) {
					throw new ConfigException("Remote implementation <url> property not resolved. See class descriptor |%s|.", descriptor);
				}
			}
		} else {
			for (int i = 0; i < descriptor.getChildrenCount(); ++i) {
				String interfaceName = descriptor.getChild(i).getAttribute("name");
				if (interfaceName == null) {
					throw new ConfigException("Missing <name> attribute from interface declaration. See class descriptor |%s|.", descriptor);
				}
				interfaceNames.add(interfaceName);
			}
		}

		Class<?>[] interfaceClasses = new Class<?>[interfaceNames.size()];
		for (int i = 0; i < interfaceNames.size(); ++i) {
			final String interfaceName = interfaceNames.get(i);
			final Class<?> interfaceClass = Classes.forOptionalName(interfaceName);

			if (interfaceClass == null) {
				throw new ConfigException("Managed class interface |%s| not found.", interfaceName);
			}
			if (Types.isKindOf(interfaceClass, ManagedLifeCycle.class)) {
				autoInstanceCreation = true;
			}
			if (instanceType.requiresInterface() && !interfaceClass.isInterface()) {
				throw new ConfigException("Managed type |%s| requires interface to make Java Proxy happy but got |%s|.", instanceType, interfaceClass);
			}
			if (implementationClass != null && !Types.isKindOf(implementationClass, interfaceClass)) {
				throw new ConfigException("Implementation |%s| is not a kind of interface |%s|.", implementationClass, interfaceClass);
			}

			interfaceClasses[i] = interfaceClass;
		}
		return interfaceClasses;
	}
private Class < ? > [ ] loadInterfaceClasses ( Config descriptor ) throws ConfigException { List < String > interfaceNames = new ArrayList <> ( ) ; if ( ! descriptor . hasChildren ( ) ) { if ( ! descriptor . hasAttribute ( "interface" ) ) { if ( instanceType . requiresInterface ( ) ) { throw new ConfigException ( "Managed type |%s| requires <interface> attribute. See class descriptor |%s|." , instanceType , descriptor ) ; } // if interface is not required and is missing uses implementation class
 return new Class < ? > [ ] { implementationClass } ; } interfaceNames . add ( descriptor . getAttribute ( "interface" ) ) ; if ( "REMOTE" . equals ( descriptor . getAttribute ( "type" ) ) ) { String url = descriptor . getAttribute ( "url" ) ; if ( url == null || url . isEmpty ( ) ) { throw new ConfigException ( "Managed type REMOTE requires <url> attribute. See class descriptor |%s|." , descriptor ) ; } if ( url . startsWith ( "${" ) ) { throw new ConfigException ( "Remote implementation <url> property not resolved. See class descriptor |%s|." , descriptor ) ; } } } else { for ( int i = 0 ; i < descriptor . getChildrenCount ( ) ; ++ i ) { String interfaceName = descriptor . getChild ( i ) . getAttribute ( "name" ) ; if ( interfaceName == null ) { throw new ConfigException ( "Missing <name> attribute from interface declaration. See class descriptor |%s|." , descriptor ) ; } interfaceNames . add ( interfaceName ) ; } } Class < ? > [ ] interfaceClasses = new Class < ? > [ interfaceNames . size ( ) ] ; for ( int i = 0 ; i < interfaceNames . size ( ) ; ++ i ) { final String interfaceName = interfaceNames . get ( i ) ; final Class < ? > interfaceClass = Classes . forOptionalName ( interfaceName ) ; if ( interfaceClass == null ) { throw new ConfigException ( "Managed class interface |%s| not found." , interfaceName ) ; } if ( Types . isKindOf ( interfaceClass , ManagedLifeCycle . class ) ) { autoInstanceCreation = true ; } if ( instanceType . requiresInterface ( ) && ! interfaceClass . isInterface ( ) ) { throw new ConfigException ( "Managed type |%s| requires interface to make Java Proxy happy but got |%s|." , instanceType , interfaceClass ) ; } if ( implementationClass != null && ! Types . isKindOf ( implementationClass , interfaceClass ) ) { throw new ConfigException ( "Implementation |%s| is not a kind of interface |%s|." , implementationClass , interfaceClass ) ; } interfaceClasses [ i ] = interfaceClass ; } return interfaceClasses ; }
Load interface classes from class descriptor. Attempt to load interface classes from <code>interface</code> attribute or
child elements. If none found returns implementation class that should be already initialized.
<p>
Perform sanity checks on loaded interface classes and throws configuration exception is:
<ul>
<li>instance type requires interface but none found,
<li><code>name</code> attribute is missing from child element,
<li>interface class not found on run-time class path,
<li>implementation class is not implemented by already configured implementation class.
</ul>
<p>
This utility method should be loaded after {@link #loadImplementationClass(Config)} otherwise behavior is not defined.

@param descriptor class descriptor.
@return interface classes array.
@throws ConfigException if sanity check fails.
Load interface classes from class descriptor . Attempt to load interface classes from <code > interface< / code > attribute or child elements . If none found returns implementation class that should be already initialized . <p > Perform sanity checks on loaded interface classes and throws configuration exception is : <ul > <li > instance type requires interface but none found <li > <code > name< / code > attribute is missing from child element <li > interface class not found on run - time class path <li > implementation class is not implemented by already configured implementation class . < / ul > <p > This utility method should be loaded after { @link #loadImplementationClass ( Config ) } otherwise behavior is not defined .