com.zfabrik.components.java
Interface IJavaComponent


public interface IJavaComponent

Client interface of a Java component. I.e. any Java component provides an implementation of this interface when looked up.

A Java component is declared by using the component type com.zfabrik.java (see also IComponentDescriptor.COMPONENT_TYPE)

Java components generally serve Java type definitions to other components, for example Web applications.

One important defaulting mechanism applies to Java components: By convention, other component types that require or support an implementation, for example a Web application will use JavaComponentUtil to identify a Java component that is used to load types from. Given a project com.acme.myproject, the default Java component to look for is com.acme.myproject/java, i.e. the project name with an appended "/java". Components within the project use the private loader of that Java component by convention.

See also IComponentsRepository for a typical component repository layout.

In most cases Java components do hold Java resources, e.g. Java source files or JAR libraries. In some cases all types required are provided elsewhere, so that the project itself does not hold any Java resources. In that case a Java component does not require a folder structure but may be specified only a set of properties defining references to other Java components.

The folder structure of Java components assigns meaning to the following folders:

z.properties
The component descriptor. Typically this looks like
 com.zfabrik.component.type=com.zfabrik.java
 java.publicReferences=<java component 1>, <java component 2>,...
 java.privateReferences=<java component n>, <java component n+1>,...
 
src.api
Public type definitions that will be compiled and exposed so that they are visible by other Java components. See PUBREFS.
bin.api/lib
JAR libraries to be added to the public types of the Java Component.
bin.api/classes
Pre-compiled Java code, i.e. .class files and other resources to be added to the public types of the Java Component.
src.impl
Type definitions that will be compiled and made available for use within the project (see above) but will not be exposed to other Java components. See PRIREFS.
bin.impl/lib
JAR libraries to be added to the private types of the Java Component.
bin.impl/classes
Pre-compiled Java code, i.e. .class files and other resources to be added to the private types of the Java Component.
src.test
Type definitions that will be compiled and made available for use just like the types defined in src.impl. In contrast to src.impl, the source files in src.test will be ignored unless the runtime runs in development mode, that is the system property Foundation.MODE is set to "development".
bin.test/lib
JAR libraries to be added to the private types of the Java Component iff running in development mode.
bin.test/classes
Pre-compiled Java code, i.e. .class files and other resources to be added to the private types of the Java Component iff running in development mode.

Java components may "include" components of type com.zfabrik.files. This can be useful for libraries that cannot be shared by just re-using the classes but instead require to be used within the using component's context, e.g. to load classes by name that would not be within the library's scope. This is true for older versions of the Spring framework for example.

Files components may be included as API or impl provisioning depending on the reference used. The included source files or pre-compiled binaries are expected to comply to the following folder structure:

src
Source files that require compilation before execution.
bin/lib
JAR libraries
bin/classes
Pre-compiled Java code, i.e. .class files and other resources

The following properties can be used in the component descriptor:

java.publicReferences
Points to another java component whose types will be shared with this one (and maybe others).

Everything referenced as public reference will be visible to the public interface of the referencing component as well as to all referencing the referencing component. In other words: References are transitive. In particular, anything required to compile the public types of a Java component must be referenced via this reference property.

Components may be specified as a comma-separated list. Component names that have no "/" will be defaulted by appending "/java".

Alternatively this reference points to a com.zfabrik.files component that must have a bin folder that will be included into this java component's java resources. The files resource may also have a src folder that will be copied befor compilation into the public interface in src.api or src.

See also JavaComponentUtil.fixJavaComponentName(String)

java.privateReferences
Points to another java component whose types will be shared with this one (and maybe others) Nothing referenced as private reference will be automatically exposed to the public interface of the referencing component nor to other components. Anything needed to compile the private types of a Java component, must be referenced as a public reference, be part of the public types of that component, or be referenced via this reference property.
In other words: The private types automatically see the public types and transitively anything referenced publicly as described above. In addition, to use more types in the "private implementation section" of a Java component, types that will not be exposed to referencing components, use this reference property.

Components may be specified as a comma-separated list. Component names that have no "/" will be defaulted by appending "/java".

Alternatively this reference points to a com.zfabrik.files component that must have a bin folder that will be included into this java component's java resources. The files resource may also have a src folder that will be copied befor compilation into the public interface in src.impl or private/src.

See also JavaComponentUtil.fixJavaComponentName(String)

java.testReferences
When running in development mode, the test references add to the private references of the component. Test references are meant to satisfy the dependencies of types and other definitions defined in src.test, bin.test. When not running in development mode, this setting will be ignored.
java.nobuild
A Java component specifying true as the value of this component property will be ignored by the compilation mechanism (as it will be in javadoc generation).
java.compile.order
The compile order must be defined in java components that also contain non-java sources - e.g. scala. This property can be omitted for pure java components, otherwise one has to define all compilers in the right order - e.g: scala, java

Author:
hb

Field Summary
static java.lang.String COMPILE_ORDER
          The compile order must be defined in java components that also contain non-java sources - e.g.
static java.lang.String NOBUILD
          A Java component specifying true as the value of this component property will be ignored by the compilation mechanism (as it will be in javadoc generation).
static java.lang.String PRIINCS
          Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's private java resources.
static java.lang.String PRIREFS
          Points to another java component whose public types will be shared with this one (and maybe others) Nothing referenced as private reference will be automatically exposed to the public interface of the referencing component nor to other components.
static java.lang.String PUBINCS
          Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's public java resources.
static java.lang.String PUBREFS
          Points to another java component whose public types will be shared with this one (and maybe others).
static java.lang.String TESTINCS
          Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's test java resources.
static java.lang.String TESTREFS
          Points to another java component whose public types will be shared with this one (and maybe others) if the execution mode, as defined by the system property Foundation.MODE is set to "development".
static java.lang.String TYPE_NAME
          Type constant for Java components.
 
Method Summary
 JavaComponentClassLoader getPrivateLoader()
          Retrieve the private implementation's loader of this Java component.
 JavaComponentClassLoader getPublicLoader()
          Retrieve the public interface's loader of this Java component.
 

Field Detail

TYPE_NAME

static final java.lang.String TYPE_NAME
Type constant for Java components.

See Also:
IComponentDescriptor.COMPONENT_TYPE, Constant Field Values

PUBREFS

static final java.lang.String PUBREFS
Points to another java component whose public types will be shared with this one (and maybe others).

Everything referenced as public reference will be visible to the public interface of the referencing component as well as to all referencing the referencing component. In other words: References are transitive. In particular, anything required to compile the public types of a Java component must be referenced via this reference property.

Components may be specified as a comma-separated list. Component names that have no "/" will be defaulted by appending "/java".

See Also:
JavaComponentUtil.fixJavaComponentName(String), Constant Field Values

PUBINCS

static final java.lang.String PUBINCS
Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's public java resources. The component may also have a src (or alternatively src.api, for Java components) folder that will be copied before compilation into src.api.

See Also:
Constant Field Values

PRIREFS

static final java.lang.String PRIREFS
Points to another java component whose public types will be shared with this one (and maybe others) Nothing referenced as private reference will be automatically exposed to the public interface of the referencing component nor to other components. Anything needed to compile the private types of a Java component, must be referenced as a public reference, be part of the public types of that component, or be referenced via this reference property.
In other words: The private types automatically see the public types and transitively anything referenced publicly as described above. In addition, to use more types in the "private implementation section" of a Java component, types that will not be exposed to referencing components, use this reference property.

Components may be specified as a comma-separated list. Component names that have no "/" will be defaulted by appending "/java".

See Also:
JavaComponentUtil.fixJavaComponentName(String), Constant Field Values

PRIINCS

static final java.lang.String PRIINCS
Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's private java resources. The component may also have a src (or alternatively src.api, for Java components) folder that will be copied before compilation into src.impl.

See Also:
Constant Field Values

TESTREFS

static final java.lang.String TESTREFS
Points to another java component whose public types will be shared with this one (and maybe others) if the execution mode, as defined by the system property Foundation.MODE is set to "development". Test references extend the private references. In conjunction with the tests source folder this allows to add test code and corresponding dependencies that will be ignored by the runtime unless running in development mode.

See Also:
PRIREFS, Constant Field Values

TESTINCS

static final java.lang.String TESTINCS
Points to com.zfabrik.files or com.zfabrik.java components that must have a bin (or alternatively a bin.api, for Java components) folder that will be included into this java component's test java resources. The component may also have a src (or alternatively src.api, for Java components) folder that will be copied before compilation into src.test.

See Also:
Constant Field Values

NOBUILD

static final java.lang.String NOBUILD
A Java component specifying true as the value of this component property will be ignored by the compilation mechanism (as it will be in javadoc generation).

See Also:
Constant Field Values

COMPILE_ORDER

static final java.lang.String COMPILE_ORDER
The compile order must be defined in java components that also contain non-java sources - e.g. scala. This property can be omitted for pure java components, otherwise one has to define all compilers in the right order - e.g: scala, java

See Also:
Constant Field Values
Method Detail

getPrivateLoader

JavaComponentClassLoader getPrivateLoader()
Retrieve the private implementation's loader of this Java component. When this call completes, the Java component will have been checked and possibly compiled, if needed.


getPublicLoader

JavaComponentClassLoader getPublicLoader()
Retrieve the public interface's loader of this Java component. When this call completes, the Java component will have been checked and possibly compiled, if needed.