@ExpressionBean
public static class SampleTimestampService {
public Instant getTimestamp() {
return new Instant();
}
}
@Retention(value=RUNTIME) public @interface ExpressionBean
Marker annotation for Spring beans that can be used in backend expression evaluation.
By default, Spring beans cannot be referenced in backend expressions. This annotation can be used to mark bean implementations that should be usable from a backend expression. For example, declare a sample date service class:
@ExpressionBean
public static class SampleTimestampService {
public Instant getTimestamp() {
return new Instant();
}
}
Then declare a corresponding Spring bean:
<bean id="timestampService" class="com.acme.date.SampleTimestampService"/>
The bean methods can then be used in a backend expression by referencing the bean ID (in this case treating the getter as a property):
#{timestampService.timestamp}
Enabling bean methods for invocation using expressions may have security implications. You should ensure that data and operations performed are protected by suitable security checks.
Copyright © 2010 - 2018 edorasware ag. All Rights Reserved.