brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [5/7] git commit: Fix formatting
Date Fri, 13 Jun 2014 16:45:18 GMT
Fix formatting


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/92a08bce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/92a08bce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/92a08bce

Branch: refs/heads/master
Commit: 92a08bced01335c86fc80f78bafef5cb6808a3f2
Parents: a9fa54e
Author: Andrew Donald Kennedy <grkvlt@apache.org>
Authored: Thu Jun 12 20:06:20 2014 +0100
Committer: Andrew Donald Kennedy <grkvlt@apache.org>
Committed: Thu Jun 12 20:06:20 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/basic/AbstractGroup.java    |  2 +-
 .../entity/basic/AbstractGroupImpl.java         | 36 ++++++++++----------
 .../brooklyn/entity/basic/DelegateEntity.java   | 18 ++++++++--
 .../entity/basic/DelegateEntityImpl.java        | 28 ++++++++-------
 4 files changed, 51 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/92a08bce/core/src/main/java/brooklyn/entity/basic/AbstractGroup.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractGroup.java b/core/src/main/java/brooklyn/entity/basic/AbstractGroup.java
index 000393b..bf55e86 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractGroup.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractGroup.java
@@ -29,7 +29,7 @@ public interface AbstractGroup extends Entity, Group, Changeable {
             new TypeToken<Collection<Entity>>() { }, "group.members", "Members
of the group");
 
     ConfigKey<Boolean> MEMBER_DELEGATE_CHILDREN = ConfigKeys.newBooleanConfigKey(
-    		"group.members.delegate", "Add delegate child entities for members of the group", Boolean.FALSE);
+            "group.members.delegate", "Add delegate child entities for members of the group",
Boolean.FALSE);
 
     void setMembers(Collection<Entity> m);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/92a08bce/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java b/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
index 5bab83b..77960a5 100644
--- a/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/AbstractGroupImpl.java
@@ -86,13 +86,13 @@ public abstract class AbstractGroupImpl extends AbstractEntity implements
Abstra
                 setAttribute(GROUP_MEMBERS, getMembers());
 
                 if (Boolean.TRUE.equals(getConfig(MEMBER_DELEGATE_CHILDREN))) {
-	                Optional<Entity> result = Iterables.tryFind(getChildren(), Predicates.equalTo(member));
-	                if (!result.isPresent()) {
-		                DelegateEntity child = addChild(EntitySpec.create(DelegateEntity.class)
-		                		.configure(DelegateEntity.DELEGATE_ENTITY, member)
-		                		.displayName(String.format("(%s)", member.getDisplayName())));
-		                Entities.manage(child);
-	                }
+                    Optional<Entity> result = Iterables.tryFind(getChildren(), Predicates.equalTo(member));
+                    if (!result.isPresent()) {
+                        DelegateEntity child = addChild(EntitySpec.create(DelegateEntity.class)
+                                .configure(DelegateEntity.DELEGATE_ENTITY, member)
+                                .displayName(String.format("(%s)", member.getDisplayName())));
+                        Entities.manage(child);
+                    }
                 }
 
                 getManagementSupport().getEntityChangeListener().onMembersChanged();
@@ -115,17 +115,17 @@ public abstract class AbstractGroupImpl extends AbstractEntity implements
Abstra
                 setAttribute(GROUP_MEMBERS, getMembers());
 
                 if (Boolean.TRUE.equals(getConfig(MEMBER_DELEGATE_CHILDREN))) {
-	                Optional<Entity> result = Iterables.tryFind(getChildren(), new Predicate<Entity>()
{
-						@Override
-						public boolean apply(Entity input) {
-							return input.getConfig(DelegateEntity.DELEGATE_ENTITY).equals(member);
-						}      	
-	                });
-	                if (result.isPresent()) {
-	                	Entity child = result.get();
-	                	removeChild(child);
-	                	Entities.unmanage(child);
-	                }
+                    Optional<Entity> result = Iterables.tryFind(getChildren(), new
Predicate<Entity>() {
+                        @Override
+                        public boolean apply(Entity input) {
+                            return input.getConfig(DelegateEntity.DELEGATE_ENTITY).equals(member);
+                        }
+                    });
+                    if (result.isPresent()) {
+                        Entity child = result.get();
+                        removeChild(child);
+                        Entities.unmanage(child);
+                       }
                 }
 
                 getManagementSupport().getEntityChangeListener().onMembersChanged();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/92a08bce/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java b/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
index c38d8c1..df3d6bf 100644
--- a/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
+++ b/core/src/main/java/brooklyn/entity/basic/DelegateEntity.java
@@ -1,5 +1,9 @@
 package brooklyn.entity.basic;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.annotation.Nullable;
+
 import com.google.common.base.Function;
 
 import brooklyn.config.render.RendererHints;
@@ -20,8 +24,10 @@ public interface DelegateEntity extends Entity {
 
     AttributeSensor<String> DELEGATE_ENTITY_LINK = Sensors.newStringSensor("webapp.url",
"The delegate entity link");
 
+    /** Hints for rendering the delegate entity as a link in the Brooklyn console UI. */
     public static class EntityUrl {
- 
+
+        private static final AtomicBoolean initialized = new AtomicBoolean(false);
         private static final Function<Object, String> entityUrlFunction = new Function<Object,
String>() {
             @Override
             public String apply(Object input) {
@@ -37,10 +43,18 @@ public interface DelegateEntity extends Entity {
 
         public static Function<Object, String> entityUrl() { return entityUrlFunction;
}
 
-        static {
+        /** Setup renderer hints. */
+        @SuppressWarnings("rawtypes")
+        public static void init() {
+            if (initialized.getAndSet(true)) return;
+
             RendererHints.register(DELEGATE_ENTITY, new RendererHints.NamedActionWithUrl("Open",
entityUrl()));
             RendererHints.register(DELEGATE_ENTITY_LINK, new RendererHints.NamedActionWithUrl("Open"));
         }
+
+        static {
+            init();
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/92a08bce/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java b/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
index 25e165e..5d7ca20 100644
--- a/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
+++ b/core/src/main/java/brooklyn/entity/basic/DelegateEntityImpl.java
@@ -7,20 +7,24 @@ import com.google.common.base.Preconditions;
 
 public class DelegateEntityImpl extends AbstractEntity implements DelegateEntity {
 
+    static {
+        EntityUrl.init();
+    }
+
     @Override
     public void init() {
-    	Entity delegate = getConfig(DELEGATE_ENTITY);
-    	Preconditions.checkNotNull(delegate, "delegate");
-
-    	// Propagate all sensors from the delegate entity
-    	addEnricher(Enrichers.builder()
-    			.propagatingAll()
-    			.from(delegate)
-    			.build());
-
-    	// Publish the entity as an attribute for linking
-    	setAttribute(DELEGATE_ENTITY, delegate);
-    	setAttribute(DELEGATE_ENTITY_LINK, EntityUrl.entityUrl().apply(delegate));
+        Entity delegate = getConfig(DELEGATE_ENTITY);
+        Preconditions.checkNotNull(delegate, "delegate");
+
+        // Propagate all sensors from the delegate entity
+        addEnricher(Enrichers.builder()
+                .propagatingAll()
+                .from(delegate)
+                .build());
+
+        // Publish the entity as an attribute for linking
+        setAttribute(DELEGATE_ENTITY, delegate);
+        setAttribute(DELEGATE_ENTITY_LINK, EntityUrl.entityUrl().apply(delegate));
     }
 }
 


Mime
View raw message