protected void initContextVersionService()
{
final Element element = context( Element.class );
final PropertyDef property = context( PropertyDef.class );
final VersionCompatibilityTarget versionCompatibilityTargetAnnotation;
if( property != null )
{
versionCompatibilityTargetAnnotation = property.getAnnotation( VersionCompatibilityTarget.class );
}
else
{
versionCompatibilityTargetAnnotation = element.type().getAnnotation( VersionCompatibilityTarget.class );
}
Function versionFunction = null;
try
{
versionFunction = ExpressionLanguageParser.parse( versionCompatibilityTargetAnnotation.version() );
}
catch( Exception e )
{
Sapphire.service( LoggingService.class ).log( e );
}
if( versionFunction == null )
{
versionFunction = Literal.NULL;
this.versionedFunctionResult = versionFunction.evaluate( new FunctionContext() );
}
else
{
versionFunction = FailSafeFunction.create( versionFunction, Literal.create( Version.class ), null );
this.versionFunctionResult = versionFunction.evaluate( new ModelElementFunctionContext( element ) );
this.versionFunctionResult.attach
(
new Listener()
{
@Override
public void handle( final Event event )
{
refresh();
}
}
);
}
Function versionedFunction = null;
try
{
versionedFunction = ExpressionLanguageParser.parse( versionCompatibilityTargetAnnotation.versioned() );
}
catch( Exception e )
{
Sapphire.service( LoggingService.class ).log( e );
}