Github user neykov commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/1017#discussion_r44635434
--- Diff:
core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypes.java ---
@@ -66,180 +94,131 @@ public static RegisteredType of(CatalogItem<?, ?>
item) {
type.deprecated = item.isDeprecated();
// TODO
- // javaType, specType, registeredTypeName ...
- // tags ?
+ // probably not: javaType, specType, registeredTypeName ...
+ // maybe: tags ?
return type;
}
- /** Visitor adapter which can be used to ensure all kinds are
supported */
- public static abstract class RegisteredTypeKindVisitor<T> {
- public T visit(RegisteredType type) {
- if (type==null) throw new NullPointerException("Registered
type must not be null");
- if (type instanceof RegisteredSpecType) {
- return visitSpec((RegisteredSpecType)type);
- }
- // others go here
- throw new IllegalStateException("Unexpected registered type:
"+type.getClass());
- }
-
- protected abstract T visitSpec(RegisteredSpecType type);
-
- // TODO beans, others
+ /** Preferred mechanism for defining a bean {@link RegisteredType} */
+ public static RegisteredType bean(String symbolicName, String version,
TypeImplementationPlan plan, @Nullable Class<?> superType) {
+ return addSuperType(new
BasicRegisteredType(RegisteredTypeKind.BEAN, symbolicName, version, plan),
superType);
}
- public static RegisteredTypeKind getKindOf(RegisteredType type) {
- return new RegisteredTypeKindVisitor<RegisteredTypeKind>() {
- @Override protected RegisteredTypeKind
visitSpec(RegisteredSpecType type) { return RegisteredTypeKind.SPEC; }
- }.visit(type);
+ public static RegisteredType spec(String symbolicName, String version,
TypeImplementationPlan plan, @Nullable Class<?> superType) {
+ return addSuperType(new
BasicRegisteredType(RegisteredTypeKind.SPEC, symbolicName, version, plan),
superType);
}
-
- public abstract static class AbstractRegisteredType implements
RegisteredType {
- final String symbolicName;
- final String version;
+ /** returns the {@link Class} object corresponding to the given java
type name,
+ * using the cache on the type and the loader defined on the type
+ * @param mgmt */
+ @Beta
+ // TODO should this be on the AbstractTypePlanTransformer ?
+ public static Class<?> loadActualJavaType(String javaTypeName,
ManagementContext mgmt, RegisteredType type, RegisteredTypeLoadingContext
context) throws Exception {
--- End diff --
Looks like `throws Exception` is not needed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---