The Component Framework uses XML declarations of contracts, implementations and instances. Related documents are the concept and cookbook of the component framework.
The <COMPONENTS>
tag is the body tag for component definitions.
The XML declaration, encoding and namespace are added automatically when creating a new component definition.
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://www.intershop.de/component/2010"/>
scope
This attribute is optional.
The attribute scope defines a default scope to instantiate contained instances. Currently available are app and global.
<components scope="global|app" />
Note
If no scope is defined within the instance definition, the component framework applies the default value global
.
Contracts define the API for a component.
Defining contracts is as "simple" as writing JAVA interfaces. Thereby, it is possible to split the interfaces to requirement interfaces and provided interfaces. For example, usually getter and setter are put together in one interface to configure the instance.
You can remove these types of methods from the provided interface.
Note
The provided interface should declare what the instance is doing. It should not declare what is needed to fulfill this functionality.
The <CONTRACT>
tag allows to define a component contract.
Note
Currently, only JAVA interfaces are supported.
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://www.intershop.de/component/2010"> <contract name="[name]" class="[classname]"/> </components>
name
This attribute is required.
class
This attribute is required.
The <IMPLEMENTATION>
tag allows to define an implementation of a contract.
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://www.intershop.de/component/2010"> <implementation name="[name]" implements="[contract-name]" factory="[factory-name]" class="[class-name]" start="nameOfStartMethod" stop="nameOfStopMethod"> <!-- multiple implements can be listed --> <implements contract="[contract-name]" /> <requires name="[property-name]" contract="[contract-name]" cardinality="[1..1|0..1|1..n|0..n]" /> </implementation> </components>
name
This attribute is required.
factory
This attribute is optional.
JavaBeanFactory
)implements
This attribute is required.
class
This attribute is optional when using a factory which already have the class
attribute. When using the JavaBeanFactory
the attribute is required.
start
This attribute is optional.
stop
This attribute is optional.
The <REQUIRES>
tag allows to define the requirements of the implementation.
The <REQUIRES>
tag is a child element of the <IMPLEMENTATION>
tag. For a syntax example see syntax of <IMPLEMENTATION>.
name
This tag is required.
contract
This tag is required.
cardinality
This tag is optional (default: 1..1).
The <IMPLEMENTS>
tag allows to define the names of additional implemented contracts (extension to the attribute implements of <IMPLEMENTATION>
tag).
The <IMPLEMENTS>
tag is a child element of the <IMPLEMENTATION>
tag. For a syntax example see syntax of <IMPLEMENTATION>.
contract
This attribute is required.
The <INSTANCE>
tag allows to define a component configuration for a component instance.
<?xml version="1.0" encoding="UTF-8"?> <components xmlns="http://www.intershop.de/component/2010"> <!-- an instance for an implementation without requirements --> <instance name="[name]" with="[implementation-name]" /> <!-- an instance for an implementation with directly fulfilled requirements --> <instance name="[name]" with="[implementation-name]"> <!-- fulfill the requirement with a constant --> <fulfill requirement="[property-name]" value="[constant]"/> <!-- fulfill the requirement with another instance --> <fulfill requirement="[property-name]" with="[instance-name]" /> </instance> <!-- outside of instance tag --> <fulfill requirement="[property-name]" of="[instance-name]" with="[instance-name]" /> <fulfill requirement="[property-name]" of="[instance-name]" value="[constant]" /> <!-- instance inside of fulfill tag --> <instance name="[name]" with="[implementation-name]"> <!-- with attribute of fulfill tag is implicit - filled with inner instance element(s) --> <fulfill requirement="[property-name]"> <!-- name of instance is optional - anonymous instances are allowed here --> <instance with="[implementation-name] requirement="[property-name]" with="[instance-name]" /> </instance> <!-- recursive declaration of instances and fulfillment --> <instance with="[implementation-name]"> <fulfill requirement="[property-name]"> <instance with="[implementation-name]" /> </fulfill> </instance> </fulfill> </instance> <!-- replace an instance with a new one, the old is available via the name - value of delegate attribute --> <replace name="[name]" with="[implementation-name]" delegate="[renamed-instance-name]"> <fulfill requirement="[delegate-property-name]" with="[renamed-instance-name]" /> <!-- other fulfill tags ... --> </replace> </components>
name
This attribute is optional.
Note
If you use <INSTANCE>
tag as a child element of <COMPONENTS>
tag, the name
attribute is required for wiring.
It is recommended to use anonymous instances if you do not need the instance twice for wiring.
with
This attribute is required.
scope
This attribute is optional.
The attribute scope defines the context in which an instance is created. So it is possible to create different instances for different applications.
<instance name="[aName]" with="[anImplementation]" scope="global|app" />
Note
If no scope
is defined within the instance definition, the component framework applies the value set in the components
tag. If the components
tag does not have a scope the default value is global
.
global
A single instance of the implementation is created. The instance is available from all applications.
app
The framework creates an instance of the implementation for each application. An instance is created exclusively for the current application and cannot be accessed by any other application.
The <FULFILL>
tag allows to define the wiring or simple configuration of the component instance.
The <FULFILL>
tag can be used both as a child element of <INSTANCE>
tag and outside as a child element of the <COMPONENTS>
tag.
For syntax examples see syntax of <INSTANCE>
.
requirement
This attribute is required.
of
One attribute out of with
, of
or value
is mandatory.
with
One attribute out of with
, of
or value
is mandatory.
value
One attribute out of with
, of
or value
is mandatory.
The <REPLACE>
tag allows to define replacement of an existing instance.
For a syntax example see Syntax of <INSTANCE>
.
name
This attribute is required.
<INSTANCE>
tag)with
This attribute is required.
<INSTANCE>
tag)delegate
This attribute is required.