src/main/java/js/container/Container.java
private static void pojoStaticInitialization(Config config) throws ConfigException {
		Config pojoClassesSection = config.getChild("pojo-classes");
		if (pojoClassesSection == null) {
			return;
		}

		for (Config pojoClassElement : pojoClassesSection.getChildren()) {
			String pojoClassName = pojoClassElement.getAttribute("class");
			if (pojoClassName == null) {
				throw new ConfigException("Invalid POJO class element. Missing <class> attribute.");
			}
			Config configSection = config.getChild(pojoClassElement.getName());
			Class<?> pojoClass = Classes.forOptionalName(pojoClassName);
			if (pojoClass == null) {
				throw new ConfigException("Missing configured POJO class |%s|.", pojoClassName);
			}
			if (configSection == null) {
				continue;
			}

			for (Config staticElement : configSection.findChildren("static-field")) {
				String fieldName = staticElement.getAttribute("name");
				if (fieldName == null) {
					throw new ConfigException("Missing <name> attribute from static field initialization |%s|.", configSection);
				}
				if (!staticElement.hasAttribute("value")) {
					throw new ConfigException("Missing <value> attribute from static field initialization |%s|.", configSection);
				}

				Field staticField = Classes.getOptionalField(pojoClass, fieldName);
				if (staticField == null) {
					throw new ConfigException("Missing POJO static field |%s#%s|.", pojoClassName, fieldName);
				}
				int modifiers = staticField.getModifiers();
				if (!Modifier.isStatic(modifiers)) {
					throw new ConfigException("Attempt to execute POJO |%s| static initialization on instance field |%s|.", pojoClassName, fieldName);
				}

				Object value = staticElement.getAttribute("value", staticField.getType());
				log.debug("Intialize static field |%s#%s| |%s|", pojoClassName, fieldName, value);
				Classes.setFieldValue(null, staticField, value);
			}
		}
	}
private static void pojoStaticInitialization(Config config) throws ConfigException {
		Config pojoClassesSection = config.getChild("pojo-classes");
		if (pojoClassesSection == null) {
			return;
		}

		for (Config pojoClassElement : pojoClassesSection.getChildren()) {
			String pojoClassName = pojoClassElement.getAttribute("class");
			if (pojoClassName == null) {
				throw new ConfigException("Invalid POJO class element. Missing <class> attribute.");
			}
			Config configSection = config.getChild(pojoClassElement.getName());
			Class<?> pojoClass = Classes.forOptionalName(pojoClassName);
			if (pojoClass == null) {
				throw new ConfigException("Missing configured POJO class |%s|.", pojoClassName);
			}
			if (configSection == null) {
				continue;
			}

			for (Config staticElement : configSection.findChildren("static-field")) {
				String fieldName = staticElement.getAttribute("name");
				if (fieldName == null) {
					throw new ConfigException("Missing <name> attribute from static field initialization |%s|.", configSection);
				}
				if (!staticElement.hasAttribute("value")) {
					throw new ConfigException("Missing <value> attribute from static field initialization |%s|.", configSection);
				}

				Field staticField = Classes.getOptionalField(pojoClass, fieldName);
				if (staticField == null) {
					throw new ConfigException("Missing POJO static field |%s#%s|.", pojoClassName, fieldName);
				}
				int modifiers = staticField.getModifiers();
				if (!Modifier.isStatic(modifiers)) {
					throw new ConfigException("Attempt to execute POJO |%s| static initialization on instance field |%s|.", pojoClassName, fieldName);
				}

				Object value = staticElement.getAttribute("value", staticField.getType());
				log.debug("Intialize static field |%s#%s| |%s|", pojoClassName, fieldName, value);
				Classes.setFieldValue(null, staticField, value);
			}
		}
	}
private static void pojoStaticInitialization ( Config config ) throws ConfigException { Config pojoClassesSection = config . getChild ( "pojo-classes" ) ; if ( pojoClassesSection == null ) { return ; } for ( Config pojoClassElement : pojoClassesSection . getChildren ( ) ) { String pojoClassName = pojoClassElement . getAttribute ( "class" ) ; if ( pojoClassName == null ) { throw new ConfigException ( "Invalid POJO class element. Missing <class> attribute." ) ; } Config configSection = config . getChild ( pojoClassElement . getName ( ) ) ; Class < ? > pojoClass = Classes . forOptionalName ( pojoClassName ) ; if ( pojoClass == null ) { throw new ConfigException ( "Missing configured POJO class |%s|." , pojoClassName ) ; } if ( configSection == null ) { continue ; } for ( Config staticElement : configSection . findChildren ( "static-field" ) ) { String fieldName = staticElement . getAttribute ( "name" ) ; if ( fieldName == null ) { throw new ConfigException ( "Missing <name> attribute from static field initialization |%s|." , configSection ) ; } if ( ! staticElement . hasAttribute ( "value" ) ) { throw new ConfigException ( "Missing <value> attribute from static field initialization |%s|." , configSection ) ; } Field staticField = Classes . getOptionalField ( pojoClass , fieldName ) ; if ( staticField == null ) { throw new ConfigException ( "Missing POJO static field |%s#%s|." , pojoClassName , fieldName ) ; } int modifiers = staticField . getModifiers ( ) ; if ( ! Modifier . isStatic ( modifiers ) ) { throw new ConfigException ( "Attempt to execute POJO |%s| static initialization on instance field |%s|." , pojoClassName , fieldName ) ; } Object value = staticElement . getAttribute ( "value" , staticField . getType ( ) ) ; log . debug ( "Intialize static field |%s#%s| |%s|" , pojoClassName , fieldName , value ) ; Classes . setFieldValue ( null , staticField , value ) ; } } }
Plain Java objects static initialization. Inject static fields value into arbitrary Java classes. Note that this
mechanism is not related to managed classes; it acts on regular Java classes and only on static fields.
<p>
Here is a sample configuration for Java objects static injection. There is <code>pojo-classes</code> section that list
all involved classes, with aliases. For every Java class alias there is a section with the same name that has
<code>static</code> name / value elements related by name to class static fields.

<pre>
&lt;pojo-classes&gt;
&lt;email-reader class="com.mobile.EmailReader" /&gt;
&lt;/pojo-classes&gt;
...
&lt;email-reader&gt;
&lt;static-field name="USER_NAME" value="johndoe" /&gt;
&lt;static-field name="PASSWORD" value="secret" /&gt;
&lt;/email-reader&gt;
</pre>
<p>
Static values from above configuration sample are injected into class static fields with the same name. String value from
configuration object is converted to field type.

<pre>
public class EmailReader {
private static String USER_NAME;
private static String PASSWORD;
...
}
</pre>

This initializer has side effects: it loads configured Java classes at container startup.

@param config configuration object.
@throws ConfigException if configuration object is not valid or class or field not found.
@throws ConverterException if there is no converter registered for a specific field type.
Plain Java objects static initialization . Inject static fields value into arbitrary Java classes . Note that this mechanism is not related to managed classes ; it acts on regular Java classes and only on static fields . <p > Here is a sample configuration for Java objects static injection . There is <code > pojo - classes< / code > section that list all involved classes with aliases . For every Java class alias there is a section with the same name that has <code > static< / code > name / value elements related by name to class static fields .