private <T extends Entity> Class<? extends T> getImplementedBy(EntitySpec<T> spec) { if (spec.getImplementation() != null) { return spec.getImplementation(); } else { return entityTypeRegistry.getImplementedBy(spec.getType()); } } }
/** * Creates a new {@link EntitySpec} instance with the given config, for an entity of the given type. * * This is primarily for groovy code; equivalent to {@code EntitySpec.create(type).configure(config)}. * * @param config The spec's configuration (see {@link EntitySpec#configure(Map)}). * @param type An {@link Entity} interface */ public static <T extends Entity> EntitySpec<T> create(Map<?,?> config, Class<T> type) { return EntitySpec.create(type).configure(config); }
/** * The most basic implementation of an application possible. * Used (internally) for the default type of application to be built. * * @author aled */ @ImplementedBy(BasicApplicationImpl.class) public interface BasicApplication extends StartableApplication { }
protected EntitySpec<?> buildSpec(Class<?> specType) { @SuppressWarnings("unchecked") Class<Entity> specClass = (Class<Entity>)specType; return EntitySpec.create(specClass); }
@Override public Object call() { return entities[1].getConfig(TestEntity.CONF_OBJECT); }}).get(); Assert.assertNotNull(object);
@Override protected Set<ConfigKey<?>> getKeysAtContainer(Entity container) { return container.getEntityType().getConfigKeys(); }
private Maybe<Effector<?>> getEffector(String name) { return entity.getEntityType().getEffectorByName(name); }
@ImplementedBy(FeedExceptionEntityImpl.class) public static interface FeedExceptionEntity extends Entity { ConfigKey<ThrowingPoller> POLLER = ConfigKeys.newConfigKey(ThrowingPoller.class, "poller"); AttributeSensor<Boolean> FLAG = Sensors.newBooleanSensor("flag"); void startThrowingPollExceptions(); void stopThrowingPollExceptions(); }
@Override public Void call() throws Exception { EntitySpec<?> obj = EntitySpec.create(TestEntity.class); assertSerializeAndDeserialize(obj); return null; }})); }
@Override public Object call() throws Exception { return testEntity.getConfig(TestEntity.CONF_MAP_PLAIN); } }).build()).get();
@ImplementedBy(MySubEntityImpl.class) public interface MySubEntity extends MyBaseEntity, MyInterface { public static final ConfigKey<String> SUPER_KEY_1 = ConfigKeys.newConfigKeyWithDefault(MyBaseEntity.SUPER_KEY_1, "overridden superKey1 default"); public static final ConfigKey<String> SUB_KEY_2 = ConfigKeys.newStringConfigKey("subKey2", "subKey2 key", "subKey2 default"); }
@ImplementedBy(MyAnnotatedEntityImpl.class) public interface MyAnnotatedEntity extends Entity { static MethodEffector<String> EFF_WITH_NEW_ANNOTATION = new MethodEffector<String>(MyAnnotatedEntity.class, "effWithNewAnnotation"); @org.apache.brooklyn.core.annotation.Effector(description="my effector description") public String effWithNewAnnotation( @EffectorParam(name="param1", defaultValue="my default val", description="my param description") String param1); @org.apache.brooklyn.core.annotation.Effector(description="my effector description") public String effWithAnnotationButNoConstant( @EffectorParam(name="param1", defaultValue="my default val", description="my param description") String param1); }
@ImplementedBy(EntityChecksIsRebindingImpl.class) public static interface EntityChecksIsRebinding extends TestEntity { boolean isRebindingValWhenRebinding(); boolean isRebinding(); }
@ImplementedBy(MyEntityImpl.class) public interface MyEntity extends Entity { int getConfigureCount(); int getConfigureDuringConstructionCount(); }
@ImplementedBy(DoNothingSoftwareProcessImpl.class) public interface DoNothingSoftwareProcess extends SoftwareProcess { public static final ConfigKey<Boolean> SKIP_ON_BOX_BASE_DIR_RESOLUTION = ConfigKeys.newConfigKeyWithDefault( BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true); }