src/main/java/js/container/Container.java
@Override
	public void config(Config config) throws ConfigException {
		log.trace("config(Config)");

		// normalized class descriptors with overrides resolves; should preserve order from external files

		// it is legal for application descriptor to override already defined class descriptor
		// for example user defined ro.gnotis.Fax2MailApp overrides library declared js.core.App
		// <app interface='js.core.App' class='ro.gnotis.Fax2MailApp' />

		// when found an overridden class descriptor replace it with most recent version
		// only class descriptors with single interface can be overridden

		List<Config> classDescriptors = new ArrayList<>();

		for (Config descriptorsSection : config.findChildren("managed-classes", "web-sockets")) {
			CLASS_DESCRIPTORS: for (Config classDescriptor : descriptorsSection.getChildren()) {
				if (!classDescriptor.hasChildren()) {
					if (!classDescriptor.hasAttribute("interface")) {
						classDescriptor.setAttribute("interface", classDescriptor.getAttribute("class"));
					}
					String interfaceClass = classDescriptor.getAttribute("interface");
					for (int i = 0; i < classDescriptors.size(); ++i) {
						if (classDescriptors.get(i).hasAttribute("interface", interfaceClass)) {
							log.debug("Override class descriptor for interface |%s|.", interfaceClass);
							classDescriptors.set(i, classDescriptor);
							continue CLASS_DESCRIPTORS;
						}
					}
				}
				classDescriptors.add(classDescriptor);
			}
		}

		// second step is to actually populate the classes pool from normalized class descriptors list

		for (Config classDescriptor : classDescriptors) {
			// create managed class, a single one per class descriptor, even if there are multiple interfaces
			// if multiple interfaces register the same managed class multiple times, once per interface
			// this way, no mater which interface is used to retrieve the instance it uses in the end the same managed class
			ManagedClass managedClass = new ManagedClass(this, classDescriptor);
			log.debug("Register managed class |%s|.", managedClass);
			for (Class<?> interfaceClass : managedClass.getInterfaceClasses()) {
				classesPool.put(interfaceClass, managedClass);
			}

			for (ClassProcessor classProcessor : classProcessors) {
				classProcessor.postProcessClass(managedClass);
			}
		}

		convertersInitialization(config);
		pojoStaticInitialization(config);

		// special handling for this container instance accessed via application context
		// need to ensure this container instance is reused and not to create a new one
		ManagedClassSPI appContext = classesPool.get(AppContext.class);
		// application context can be null on tests
		// also on tests application context interface can be implemented by mock class not in container hierarchy
		if (appContext != null && Types.isKindOf(appContext.getImplementationClass(), ContainerSPI.class)) {
			log.debug("Persist container instance on application scope.");
			scopeFactories.get(InstanceScope.APPLICATION).persistInstance(new InstanceKey(appContext.getKey()), this);
		}
	}
@Override
	public void config(Config config) throws ConfigException {
		log.trace("config(Config)");

		// normalized class descriptors with overrides resolves; should preserve order from external files

		// it is legal for application descriptor to override already defined class descriptor
		// for example user defined ro.gnotis.Fax2MailApp overrides library declared js.core.App
		// <app interface='js.core.App' class='ro.gnotis.Fax2MailApp' />

		// when found an overridden class descriptor replace it with most recent version
		// only class descriptors with single interface can be overridden

		List<Config> classDescriptors = new ArrayList<>();

		for (Config descriptorsSection : config.findChildren("managed-classes", "web-sockets")) {
			CLASS_DESCRIPTORS: for (Config classDescriptor : descriptorsSection.getChildren()) {
				if (!classDescriptor.hasChildren()) {
					if (!classDescriptor.hasAttribute("interface")) {
						classDescriptor.setAttribute("interface", classDescriptor.getAttribute("class"));
					}
					String interfaceClass = classDescriptor.getAttribute("interface");
					for (int i = 0; i < classDescriptors.size(); ++i) {
						if (classDescriptors.get(i).hasAttribute("interface", interfaceClass)) {
							log.debug("Override class descriptor for interface |%s|.", interfaceClass);
							classDescriptors.set(i, classDescriptor);
							continue CLASS_DESCRIPTORS;
						}
					}
				}
				classDescriptors.add(classDescriptor);
			}
		}

		// second step is to actually populate the classes pool from normalized class descriptors list

		for (Config classDescriptor : classDescriptors) {
			// create managed class, a single one per class descriptor, even if there are multiple interfaces
			// if multiple interfaces register the same managed class multiple times, once per interface
			// this way, no mater which interface is used to retrieve the instance it uses in the end the same managed class
			ManagedClass managedClass = new ManagedClass(this, classDescriptor);
			log.debug("Register managed class |%s|.", managedClass);
			for (Class<?> interfaceClass : managedClass.getInterfaceClasses()) {
				classesPool.put(interfaceClass, managedClass);
			}

			for (ClassProcessor classProcessor : classProcessors) {
				classProcessor.postProcessClass(managedClass);
			}
		}

		convertersInitialization(config);
		pojoStaticInitialization(config);

		// special handling for this container instance accessed via application context
		// need to ensure this container instance is reused and not to create a new one
		ManagedClassSPI appContext = classesPool.get(AppContext.class);
		// application context can be null on tests
		// also on tests application context interface can be implemented by mock class not in container hierarchy
		if (appContext != null && Types.isKindOf(appContext.getImplementationClass(), ContainerSPI.class)) {
			log.debug("Persist container instance on application scope.");
			scopeFactories.get(InstanceScope.APPLICATION).persistInstance(new InstanceKey(appContext.getKey()), this);
		}
	}
@ Override public void config ( Config config ) throws ConfigException { log . trace ( "config(Config)" ) ; // normalized class descriptors with overrides resolves; should preserve order from external files
 // it is legal for application descriptor to override already defined class descriptor
 // for example user defined ro.gnotis.Fax2MailApp overrides library declared js.core.App
 // <app interface='js.core.App' class='ro.gnotis.Fax2MailApp' />
 // when found an overridden class descriptor replace it with most recent version
 // only class descriptors with single interface can be overridden
 List < Config > classDescriptors = new ArrayList <> ( ) ; for ( Config descriptorsSection : config . findChildren ( "managed-classes" , "web-sockets" ) ) { CLASS_DESCRIPTORS : for ( Config classDescriptor : descriptorsSection . getChildren ( ) ) { if ( ! classDescriptor . hasChildren ( ) ) { if ( ! classDescriptor . hasAttribute ( "interface" ) ) { classDescriptor . setAttribute ( "interface" , classDescriptor . getAttribute ( "class" ) ) ; } String interfaceClass = classDescriptor . getAttribute ( "interface" ) ; for ( int i = 0 ; i < classDescriptors . size ( ) ; ++ i ) { if ( classDescriptors . get ( i ) . hasAttribute ( "interface" , interfaceClass ) ) { log . debug ( "Override class descriptor for interface |%s|." , interfaceClass ) ; classDescriptors . set ( i , classDescriptor ) ; continue CLASS_DESCRIPTORS ; } } } classDescriptors . add ( classDescriptor ) ; } } // second step is to actually populate the classes pool from normalized class descriptors list
 for ( Config classDescriptor : classDescriptors ) { // create managed class, a single one per class descriptor, even if there are multiple interfaces
 // if multiple interfaces register the same managed class multiple times, once per interface
 // this way, no mater which interface is used to retrieve the instance it uses in the end the same managed class
 ManagedClass managedClass = new ManagedClass ( this , classDescriptor ) ; log . debug ( "Register managed class |%s|." , managedClass ) ; for ( Class < ? > interfaceClass : managedClass . getInterfaceClasses ( ) ) { classesPool . put ( interfaceClass , managedClass ) ; } for ( ClassProcessor classProcessor : classProcessors ) { classProcessor . postProcessClass ( managedClass ) ; } } convertersInitialization ( config ) ; pojoStaticInitialization ( config ) ; // special handling for this container instance accessed via application context
 // need to ensure this container instance is reused and not to create a new one
 ManagedClassSPI appContext = classesPool . get ( AppContext . class ) ; // application context can be null on tests
 // also on tests application context interface can be implemented by mock class not in container hierarchy
 if ( appContext != null && Types . isKindOf ( appContext . getImplementationClass ( ) , ContainerSPI . class ) ) { log . debug ( "Persist container instance on application scope." ) ; scopeFactories . get ( InstanceScope . APPLICATION ) . persistInstance ( new InstanceKey ( appContext . getKey ( ) ) , this ) ; } }
Create all managed instances registered to this container via external application descriptor. See
<a href="#descriptors">Descriptors</a> for details about application and class descriptors.

@param config container configuration object.
@throws ConfigException if container configuration fails.
@throws BugError for insane condition that prevent managed classes initialization.
Create all managed instances registered to this container via external application descriptor . See <a href = #descriptors > Descriptors< / a > for details about application and class descriptors .