3737import org .apache .brooklyn .camp .brooklyn .spi .creation .BrooklynYamlTypeInstantiator ;
3838import org .apache .brooklyn .camp .brooklyn .spi .creation .EntitySpecConfiguration ;
3939import org .apache .brooklyn .camp .brooklyn .spi .dsl .BrooklynDslDeferredSupplier ;
40+ import org .apache .brooklyn .camp .brooklyn .spi .dsl .DslAccessible ;
4041import org .apache .brooklyn .camp .brooklyn .spi .dsl .methods .DslComponent .Scope ;
4142import org .apache .brooklyn .config .ConfigKey ;
4243import org .apache .brooklyn .core .config .ConfigKeys ;
@@ -83,37 +84,48 @@ public class BrooklynDslCommon {
8384
8485 // Access specific entities
8586
87+ @ DslAccessible
8688 public static DslComponent self () {
8789 return new DslComponent (Scope .THIS );
8890 }
91+ @ DslAccessible
8992 public static DslComponent entity (Object id ) {
9093 return DslComponent .newInstance (Scope .GLOBAL , id );
9194 }
95+ @ DslAccessible
9296 public static DslComponent parent () {
9397 return new DslComponent (Scope .PARENT );
9498 }
99+ @ DslAccessible
95100 public static DslComponent child (Object id ) {
96101 return DslComponent .newInstance (Scope .CHILD , id );
97102 }
103+ @ DslAccessible
98104 public static DslComponent sibling (Object id ) {
99105 return DslComponent .newInstance (Scope .SIBLING , id );
100106 }
107+ @ DslAccessible
101108 public static DslComponent descendant (Object id ) {
102109 return DslComponent .newInstance (Scope .DESCENDANT , id );
103110 }
111+ @ DslAccessible
104112 public static DslComponent ancestor (Object id ) {
105113 return DslComponent .newInstance (Scope .ANCESTOR , id );
106114 }
115+ @ DslAccessible
107116 public static DslComponent root () {
108117 return new DslComponent (Scope .ROOT );
109118 }
119+ @ DslAccessible
110120 public static DslComponent scopeRoot () {
111121 return new DslComponent (Scope .SCOPE_ROOT );
112122 }
113123 // prefer the syntax above to the below now, but not deprecating the below
124+ @ DslAccessible
114125 public static DslComponent component (String id ) {
115126 return component ("global" , id );
116127 }
128+ @ DslAccessible
117129 public static DslComponent component (String scope , String id ) {
118130 if (!DslComponent .Scope .isValid (scope )) {
119131 throw new IllegalArgumentException (scope + " is not a valid scope" );
@@ -123,10 +135,12 @@ public static DslComponent component(String scope, String id) {
123135
124136 // Access things on entities
125137
138+ @ DslAccessible
126139 public static BrooklynDslDeferredSupplier <?> config (String keyName ) {
127140 return new DslComponent (Scope .THIS , "" ).config (keyName );
128141 }
129142
143+ @ DslAccessible
130144 public static BrooklynDslDeferredSupplier <?> config (BrooklynObjectInternal obj , String keyName ) {
131145 return new DslBrooklynObjectConfigSupplier (obj , keyName );
132146 }
@@ -194,22 +208,26 @@ public String toString() {
194208 }
195209 }
196210
211+ @ DslAccessible
197212 public static BrooklynDslDeferredSupplier <?> attributeWhenReady (String sensorName ) {
198213 return new DslComponent (Scope .THIS , "" ).attributeWhenReady (sensorName );
199214 }
200215
216+ @ DslAccessible
201217 public static BrooklynDslDeferredSupplier <?> entityId () {
202218 return new DslComponent (Scope .THIS , "" ).entityId ();
203219 }
204220
205221 /** Returns a {@link Sensor}, looking up the sensor on the context if available and using that,
206222 * or else defining an untyped (Object) sensor */
223+ @ DslAccessible
207224 public static BrooklynDslDeferredSupplier <Sensor <?>> sensor (Object sensorName ) {
208225 return new DslComponent (Scope .THIS , "" ).sensor (sensorName );
209226 }
210227
211228 /** Returns a {@link Sensor} declared on the type (e.g. entity class) declared in the first argument. */
212229 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
230+ @ DslAccessible
213231 public static Sensor <?> sensor (String clazzName , String sensorName ) {
214232 try {
215233 // TODO Should use catalog's classloader, rather than ClassLoaderUtils; how to get that? Should we return a future?!
@@ -238,6 +256,7 @@ public static Sensor<?> sensor(String clazzName, String sensorName) {
238256
239257 // Build complex things
240258
259+ @ DslAccessible
241260 public static EntitySpecConfiguration entitySpec (Map <String , Object > arguments ) {
242261 return new EntitySpecConfiguration (arguments );
243262 }
@@ -249,6 +268,7 @@ public static EntitySpecConfiguration entitySpec(Map<String, Object> arguments)
249268 * bundles).
250269 */
251270 @ SuppressWarnings ("unchecked" )
271+ @ DslAccessible
252272 public static Object object (Map <String , Object > arguments ) {
253273 ConfigBag config = ConfigBag .newInstance (arguments );
254274 String typeName = BrooklynYamlTypeInstantiator .InstantiatorFromKey .extractTypeName ("object" , config ).orNull ();
@@ -285,6 +305,7 @@ public static Object object(Map<String, Object> arguments) {
285305 // String manipulation
286306
287307 /** Return the expression as a literal string without any further parsing. */
308+ @ DslAccessible
288309 public static Object literal (Object expression ) {
289310 return expression ;
290311 }
@@ -293,6 +314,7 @@ public static Object literal(Object expression) {
293314 * Returns a formatted string or a {@link BrooklynDslDeferredSupplier} if the arguments
294315 * are not yet fully resolved.
295316 */
317+ @ DslAccessible
296318 public static Object formatString (final String pattern , final Object ...args ) {
297319 if (resolved (args )) {
298320 // if all args are resolved, apply the format string now
@@ -302,6 +324,7 @@ public static Object formatString(final String pattern, final Object...args) {
302324 }
303325 }
304326
327+ @ DslAccessible
305328 public static Object regexReplacement (final Object source , final Object pattern , final Object replacement ) {
306329 if (resolved (Arrays .asList (source , pattern , replacement ))) {
307330 return (new Functions .RegexReplacer (String .valueOf (pattern ), String .valueOf (replacement ))).apply (String .valueOf (source ));
@@ -642,6 +665,7 @@ public String toString() {
642665 * The name of the appropriate {@link ExternalConfigSupplier} is captured, along with the key of
643666 * the desired config value.
644667 */
668+ @ DslAccessible
645669 public static DslExternal external (final String providerName , final String key ) {
646670 return new DslExternal (providerName , key );
647671 }
@@ -698,6 +722,7 @@ public String toString() {
698722 }
699723
700724 public static class Functions {
725+ @ DslAccessible
701726 public static Object regexReplacement (final Object pattern , final Object replacement ) {
702727 if (resolved (pattern , replacement )) {
703728 return new org .apache .brooklyn .util .text .StringFunctions .RegexReplacer (String .valueOf (pattern ), String .valueOf (replacement ));
@@ -788,6 +813,7 @@ private EntityInternal entity() {
788813 }
789814 }
790815
816+ @ DslAccessible
791817 public static Object wrap (Entity entity ) {
792818 return DslComponent .newInstance (Scope .GLOBAL , new EntitySupplier (entity .getId ()));
793819 }
0 commit comments