public interface IJavaComponent
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 files and folders:
com.zfabrik.component.type=com.zfabrik.java java.publicReferences=<java component 1>, <java component 2>,... java.privateReferences=<java component n>, <java component n+1>,...
PUBREFS
..class
files and other resources to be added to the public types of the Java Component.PRIREFS
..class
files and other resources to be added to the private types of the Java Component.Foundation.MODE
is set to "development"..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:
.class
files and other resourcesThe following properties can be used in the component descriptor:
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
.
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
.
src.test
, bin.test
. When not running in development
mode, this setting will be ignored.
true
as the value of this component property will be ignored by the compilation mechanism (as it will be in javadoc generation).
scala
, or require special handling like apsect weaving.
This property can be omitted for pure java components, otherwise one has to define all compilers in the right order - e.g: scala, java
Modifier and Type | Interface | Description |
---|---|---|
static class |
IJavaComponent.Part |
A Java component is constructed from three different aspects, that are either publicly shared, privately used for implementation, or only available
in development mode for testing.
|
Modifier and Type | Field | Description |
---|---|---|
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 |
DEFAULT_CLASSPATH_PATTERN |
Default inclusion pattern for classpath computation of the component.
|
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 |
PRIVATE_CLASSPATH_PATTERN |
Custom inclusion pattern for classpath computation of the impl section.
|
static java.lang.String |
PRIVATE_COMPILE_ORDER |
Specific override of compile order for the implementation part of a Java component.
|
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 |
PUBLIC_CLASSPATH_PATTERN |
Custom inclusion pattern for classpath computation of the API section.
|
static java.lang.String |
PUBLIC_COMPILE_ORDER |
Specific override of compile order for the API part of a Java component.
|
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 |
TEST_CLASSPATH_PATTERN |
Custom inclusion pattern for classpath computation of the test section.
|
static java.lang.String |
TEST_COMPILE_ORDER |
Specific override of compile order for the test part of a Java component.
|
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 (see also
Foundation.MODE )
is set to "development". |
static java.lang.String |
TYPE |
Type constant for Java components.
|
Modifier and Type | Method | Description |
---|---|---|
JavaComponentClassLoader |
getPrivateLoader() |
Retrieve the private implementation's loader of this Java component.
|
JavaComponentClassLoader |
getPublicLoader() |
Retrieve the public interface's loader of this Java component.
|
static final java.lang.String TYPE
static final java.lang.String PUBREFS
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".
static final java.lang.String PUBINCS
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
.static final java.lang.String PRIREFS
Components may be specified as a comma-separated list. Component names that have no "/" will be defaulted by appending "/java".
static final java.lang.String PRIINCS
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
.static final java.lang.String TESTREFS
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
static final java.lang.String TESTINCS
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
.static final java.lang.String NOBUILD
true
as the value of this component property will be ignored by the compilation mechanism (as it will be in javadoc generation).static final java.lang.String COMPILE_ORDER
scala
code or that require additional handling by e.g. aspect weaving.
Z2 offers a compiler extension mechanism for that purpose. This property defines the order in which compilers will be applied.
This property can be omitted for pure java components in that it defaults to java
. Otherwise one has to define all compilers in the right order - e.g: scala, java
static final java.lang.String PUBLIC_COMPILE_ORDER
COMPILE_ORDER
.static final java.lang.String PRIVATE_COMPILE_ORDER
COMPILE_ORDER
.static final java.lang.String TEST_COMPILE_ORDER
COMPILE_ORDER
.static final java.lang.String DEFAULT_CLASSPATH_PATTERN
static final java.lang.String PUBLIC_CLASSPATH_PATTERN
static final java.lang.String PRIVATE_CLASSPATH_PATTERN
static final java.lang.String TEST_CLASSPATH_PATTERN
JavaComponentClassLoader getPrivateLoader()
JavaComponentClassLoader getPublicLoader()