brooklyn.entity.proxying.EntitySpecs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-core Show documentation
Show all versions of brooklyn-core Show documentation
Entity implementation classes, events, and other core elements
package brooklyn.entity.proxying;
import java.util.Map;
import java.util.Set;
import brooklyn.entity.Entity;
import brooklyn.entity.basic.StartableApplication;
import brooklyn.util.javalang.Reflections;
/**
* For creating {@link EntitySpec} instances.
*
* @author aled
*
* @deprecated since 0.6; use {@link EntitySpec#create(Class)} etc
*/
public class EntitySpecs {
private EntitySpecs() {}
/**
* @deprecated use {@link EntitySpec#create(Class)}
*/
public static BasicEntitySpec spec(Class type) {
return BasicEntitySpec.newInstance(type);
}
/**
* @deprecated use {@link EntitySpec#create(Class, Class)}
*/
public static BasicEntitySpec spec(Class type, Class implType) {
return BasicEntitySpec.newInstance(type, implType);
}
/**
* @deprecated use {@link EntitySpec#create(Map, Class)}
*/
public static BasicEntitySpec spec(Map,?> config, Class type) {
return EntitySpecs.spec(type).configure(config);
}
/**
* Creates a new EntitySpec for this application type. If the type is an interface, then the returned spec
* will use the normal logic of looking for {@link ImplementedBy} etc.
*
* However, if the type is a class then the that implementation will be used directly. When an entity is
* created using the EntitySpec, one will get back a proxy of type {@link StartableApplication}, but the
* proxy will also implement all the other interfaces that the given type class implements.
*
* FIXME if this *class* is deprecated where does the replacement for this live?
* perhaps we should have spec add all interfaces unless indicated otherwise, then we can just use EntitySpec.create.
*/
@SuppressWarnings("unchecked")
public static BasicEntitySpec appSpec(Class extends T> type) {
if (type.isInterface()) {
return (BasicEntitySpec) EntitySpecs.spec(type);
} else {
// is implementation
Set> additionalInterfaceClazzes = Reflections.getInterfacesIncludingClassAncestors(type);
return EntitySpecs.spec(StartableApplication.class, type)
.additionalInterfaces(additionalInterfaceClazzes);
}
}
/**
* Wraps an entity spec so its configuration can be overridden without modifying the
* original entity spec.
*
* @deprecated since 0.6.0; use {@link EntitySpec#create(EntitySpec)} - though note that
* semantics are slightly different there, the new method copies the spec so if the wrapped
* entity changes the new method will not pick up those changes;
* no plans at present to continue to support the delegation pattern (is there any need?)
*/
public static WrappingEntitySpec wrapSpec(EntitySpec extends T> spec) {
return WrappingEntitySpec.newInstance(spec);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy