/*
* In case the implementation providing the state is not available
* signal an error.
*/
if (implementation == null || !(implementation instanceof Implementation)) {
throw new InvalidConfiguration("Invalid state declaration, implementation can not be found "+
propertyReference.getDeclaringComponent().getName());
}
/*
* Eagerly instantiate an instance to hold the state.
*
* In case the main instance can be used to hold state we avoid
* creating additional objects.
*/
if (composite.getMainInst() != null && composite.getMainInst().getImpl().equals(implementation)) {
this.stateHolder = composite.getMainInst();
} else {
this.stateHolder = ((Implementation) implementation).createInstance(composite, null);
}
/*
* Get the property used to handle the state
*/
PropertyDefinition propertyDefinition = implementation.getDeclaration().getPropertyDefinition(propertyReference);
/*
* In case the property providing the state is not defined signal an
* error.
*/
if (propertyDefinition == null) {
throw new InvalidConfiguration("Invalid state declaration, property not defined "+ propertyReference.getIdentifier());
}
this.stateProperty = propertyDefinition.getName();
/*