public interface BrooklynTypePlanTransformer extends ManagementContextInjectable
To add a new plan transformation scheme, simply create an implementation and declare it
as a java service (cf ServiceLoader
).
Implementations may wish to extend AbstractTypePlanTransformer
which simplifies the process.
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
create(RegisteredType type,
RegisteredTypeLoadingContext context)
Creates a new instance of the indicated type, or throws if not supported;
this method is used by the
BrooklynTypeRegistry when it creates instances,
so implementations must respect the BrooklynTypeRegistry.RegisteredTypeKind semantics and the RegisteredTypeLoadingContext
(or return null / throw). |
java.util.List<RegisteredType> |
createFromTypeDefinition(java.lang.String formatCode,
java.lang.Object catalogData) |
java.lang.String |
getFormatCode() |
java.lang.String |
getFormatDescription() |
java.lang.String |
getFormatName() |
double |
scoreForType(RegisteredType type,
RegisteredTypeLoadingContext context)
Determines how appropriate is this transformer for the
RegisteredType.getPlan() of the type. |
double |
scoreForTypeDefinition(java.lang.String formatCode,
java.lang.Object catalogData) |
setManagementContext
java.lang.String getFormatCode()
java.lang.String getFormatName()
java.lang.String getFormatDescription()
double scoreForType(@Nonnull RegisteredType type, @Nonnull RegisteredTypeLoadingContext context)
RegisteredType.getPlan()
of the type.
The framework guarantees arguments are nonnull, and that the RegisteredType.getPlan()
is also not-null.
However many fields on the RegisteredType
may be null,
including RegisteredType.getId()
for an ad hoc creation
(eg if invoked from BrooklynTypeRegistry.createBeanFromPlan(String, Object, RegisteredTypeLoadingContext, Class)
)@Nullable java.lang.Object create(@Nonnull RegisteredType type, @Nonnull RegisteredTypeLoadingContext context)
BrooklynTypeRegistry
when it creates instances,
so implementations must respect the BrooklynTypeRegistry.RegisteredTypeKind
semantics and the RegisteredTypeLoadingContext
(or return null / throw).
The framework guarantees this will only be invoked when scoreForType(RegisteredType, RegisteredTypeLoadingContext)
has returned a positive value, and the same constraints on the inputs as for that method apply.
Implementations should either return null or throw UnsupportedTypePlanException
if they cannot instantiate the given RegisteredType.getPlan()
.
@Beta double scoreForTypeDefinition(java.lang.String formatCode, java.lang.Object catalogData)
@Beta java.util.List<RegisteredType> createFromTypeDefinition(java.lang.String formatCode, java.lang.Object catalogData)