Repository: incubator-brooklyn Updated Branches: refs/heads/master 512344caf -> 514541241
fix maven javac purity on JDK7 it also fix javac compiler in intellij Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d4ecbe7e Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d4ecbe7e Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d4ecbe7e Branch: refs/heads/master Commit: d4ecbe7e7190b504461645ace6c7242c57418e9b Parents: b08572f Author: Andrea Turli <[email protected]> Authored: Fri Jan 30 10:10:55 2015 +0100 Committer: Andrea Turli <[email protected]> Committed: Fri Jan 30 10:10:55 2015 +0100 ---------------------------------------------------------------------- .../io/brooklyn/camp/spi/AbstractResource.java | 63 ++++++++++---------- .../brooklyn/camp/spi/ApplicationComponent.java | 20 +++---- .../java/io/brooklyn/camp/spi/Assembly.java | 32 +++++----- .../io/brooklyn/camp/spi/AssemblyTemplate.java | 32 +++++----- .../io/brooklyn/camp/spi/PlatformComponent.java | 26 ++++---- 5 files changed, 86 insertions(+), 87 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4ecbe7e/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java index 036a8d6..9906e2b 100644 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java +++ b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AbstractResource.java @@ -18,27 +18,26 @@ */ package io.brooklyn.camp.spi; -import io.brooklyn.camp.commontypes.RepresentationSkew; - import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; -import brooklyn.util.collections.MutableMap; -import brooklyn.util.text.Identifiers; -import brooklyn.util.time.Time; - import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import brooklyn.util.collections.MutableMap; +import brooklyn.util.text.Identifiers; +import brooklyn.util.time.Time; +import io.brooklyn.camp.commontypes.RepresentationSkew; + /** Superclass of CAMP resource implementation objects. * Typically used to hold common state of implementation objects * and to populate the DTO's used by the REST API. * <p> - * These class instances are typically created using the - * static {@link #builder()} methods they contain. + * These class instances are typically created using the + * static {@link #builder()} methods they contain. * The resulting instances are typically immutable, * so where fields can change callers should use a new builder * (or update an underlying data store). @@ -50,7 +49,7 @@ import com.google.common.collect.ImmutableMap; public class AbstractResource { public static final String CAMP_TYPE = "Resource"; - + private String id = Identifiers.makeRandomId(8); private String name; private String type; @@ -59,12 +58,12 @@ public class AbstractResource { private Date created = Time.dropMilliseconds(new Date()); private List<String> tags = Collections.emptyList(); private RepresentationSkew representationSkew; - + private Map<String,Object> customAttributes = new MutableMap<String, Object>(); - + /** Use {@link #builder()} to create */ protected AbstractResource() {} - + // getters public String getId() { @@ -94,66 +93,66 @@ public class AbstractResource { public Map<String, Object> getCustomAttributes() { return ImmutableMap.copyOf(customAttributes); } - + // setters - private void setId(String id) { + void setId(String id) { this.id = id; } - private void setName(String name) { + void setName(String name) { this.name = name; } - private void setDescription(String description) { + void setDescription(String description) { this.description = description; } - private void setSourceCode(String sourceCode) { + void setSourceCode(String sourceCode) { this.sourceCode = sourceCode; } - private void setCreated(Date created) { + void setCreated(Date created) { // precision beyond seconds breaks equals check this.created = Time.dropMilliseconds(created); } - private void setTags(List<String> tags) { + void setTags(List<String> tags) { this.tags = ImmutableList.copyOf(tags); } - private void setType(String type) { + void setType(String type) { this.type = type; } - private void setRepresentationSkew(RepresentationSkew representationSkew) { + void setRepresentationSkew(RepresentationSkew representationSkew) { this.representationSkew = representationSkew; } - public void setCustomAttribute(String key, Object value) { + void setCustomAttribute(String key, Object value) { this.customAttributes.put(key, value); } - + // builder @SuppressWarnings("rawtypes") public static Builder<? extends AbstractResource,? extends Builder> builder() { return new AbstractResourceBuilder(CAMP_TYPE); } - + /** Builder creates the instance up front to avoid repetition of fields in the builder; * but prevents object leakage until build and prevents changes after build, * so effectively immutable. * <p> * Similarly setters in the class are private so those objects are also typically effectively immutable. */ public abstract static class Builder<T extends AbstractResource,U extends Builder<T,U>> { - + private boolean built = false; private String type = null; private T instance = null; - + protected Builder(String type) { this.type = type; } - + @SuppressWarnings("unchecked") protected T createResource() { return (T) new AbstractResource(); } - + protected synchronized T instance() { - if (built) + if (built) throw new IllegalStateException("Builder instance from "+this+" cannot be access after build"); if (instance==null) { instance = createResource(); @@ -165,16 +164,16 @@ public class AbstractResource { protected void initialize() { if (type!=null) type(type); } - + public synchronized T build() { T result = instance(); built = true; return result; } - + @SuppressWarnings("unchecked") protected U thisBuilder() { return (U)this; } - + public U type(String x) { instance().setType(x); return thisBuilder(); } public U id(String x) { instance().setId(x); return thisBuilder(); } public U name(String x) { instance().setName(x); return thisBuilder(); } http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4ecbe7e/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java index 2d70f9c..de1abba 100644 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java +++ b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/ApplicationComponent.java @@ -32,14 +32,14 @@ public class ApplicationComponent extends AbstractResource { public static final String CAMP_TYPE = "ApplicationComponent"; static { assert CAMP_TYPE.equals(ApplicationComponent.class.getSimpleName()); } - + /** Use {@link #builder()} to create */ protected ApplicationComponent() {} ResourceLookup<ApplicationComponent> applicationComponents; ResourceLookup<PlatformComponent> platformComponents; String externalManagementUri; - + public ResourceLookup<ApplicationComponent> getApplicationComponents() { return applicationComponents != null ? applicationComponents : new EmptyResourceLookup<ApplicationComponent>(); } @@ -47,26 +47,26 @@ public class ApplicationComponent extends AbstractResource { return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); } - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { + void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { this.applicationComponents = applicationComponents; } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { + void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { this.platformComponents = platformComponents; } - + // builder - + public static Builder<? extends ApplicationComponent> builder() { return new Builder<ApplicationComponent>(CAMP_TYPE); } - + public static class Builder<T extends ApplicationComponent> extends AbstractResource.Builder<T,Builder<T>> { - + protected Builder(String type) { super(type); } public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { instance().setApplicationComponents(x); return thisBuilder(); } public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { instance().setPlatformComponents(x); return thisBuilder(); } - + public synchronized Builder<T> add(ApplicationComponent x) { if (instance().applicationComponents==null) { instance().applicationComponents = new BasicResourceLookup<ApplicationComponent>(); @@ -77,7 +77,7 @@ public class ApplicationComponent extends AbstractResource { ((BasicResourceLookup<ApplicationComponent>)instance().applicationComponents).add(x); return thisBuilder(); } - + public synchronized Builder<T> add(PlatformComponent x) { if (instance().platformComponents==null) { instance().platformComponents = new BasicResourceLookup<PlatformComponent>(); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4ecbe7e/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java index 991f704..90511a2 100644 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java +++ b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/Assembly.java @@ -32,18 +32,18 @@ public class Assembly extends AbstractResource { public static final String CAMP_TYPE = "Assembly"; static { assert CAMP_TYPE.equals(Assembly.class.getSimpleName()); } - + /** Use {@link #builder()} to create */ protected Assembly() {} AssemblyTemplate assemblyTemplate; ResourceLookup<ApplicationComponent> applicationComponents; ResourceLookup<PlatformComponent> platformComponents; - + // TODO // "parameterDefinitionUri": URI, // "pdpUri" : URI ? - + public AssemblyTemplate getAssemblyTemplate() { return assemblyTemplate; } @@ -53,34 +53,34 @@ public class Assembly extends AbstractResource { public ResourceLookup<PlatformComponent> getPlatformComponents() { return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); } - - private void setAssemblyTemplate(AssemblyTemplate assemblyTemplate) { + + void setAssemblyTemplate(AssemblyTemplate assemblyTemplate) { this.assemblyTemplate = assemblyTemplate; } - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { + void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { this.applicationComponents = applicationComponents; } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { + void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { this.platformComponents = platformComponents; } - + // builder - + public static Builder<? extends Assembly> builder() { return new Builder<Assembly>(CAMP_TYPE); } - + public static class Builder<T extends Assembly> extends AbstractResource.Builder<T,Builder<T>> { - + protected Builder(String type) { super(type); } - + @SuppressWarnings("unchecked") protected T createResource() { return (T) new Assembly(); } - + public Builder<T> assemblyTemplate(AssemblyTemplate x) { instance().setAssemblyTemplate(x); return thisBuilder(); } public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { instance().setApplicationComponents(x); return thisBuilder(); } public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { instance().setPlatformComponents(x); return thisBuilder(); } - + public synchronized Builder<T> add(ApplicationComponent x) { if (instance().applicationComponents==null) { instance().applicationComponents = new BasicResourceLookup<ApplicationComponent>(); @@ -91,7 +91,7 @@ public class Assembly extends AbstractResource { ((BasicResourceLookup<ApplicationComponent>)instance().applicationComponents).add(x); return thisBuilder(); } - + public synchronized Builder<T> add(PlatformComponent x) { if (instance().platformComponents==null) { instance().platformComponents = new BasicResourceLookup<PlatformComponent>(); @@ -102,7 +102,7 @@ public class Assembly extends AbstractResource { ((BasicResourceLookup<PlatformComponent>)instance().platformComponents).add(x); return thisBuilder(); } - + @Override public synchronized T build() { return super.build(); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4ecbe7e/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java index c308b87..6a78a55 100644 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java +++ b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/AssemblyTemplate.java @@ -35,15 +35,15 @@ public class AssemblyTemplate extends AbstractResource { public static final String CAMP_TYPE = "AssemblyTemplate"; static { assert CAMP_TYPE.equals(AssemblyTemplate.class.getSimpleName()); } - + Class<? extends AssemblyTemplateInstantiator> instantiator; ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates; ResourceLookup<PlatformComponentTemplate> platformComponentTemplates; - + // TODO // "parameterDefinitionUri": URI, // "pdpUri" : URI ? - + /** Use {@link #builder()} to create */ protected AssemblyTemplate() {} @@ -56,30 +56,30 @@ public class AssemblyTemplate extends AbstractResource { public ResourceLookup<PlatformComponentTemplate> getPlatformComponentTemplates() { return platformComponentTemplates != null ? platformComponentTemplates : new EmptyResourceLookup<PlatformComponentTemplate>(); } - - private void setInstantiator(Class<? extends AssemblyTemplateInstantiator> instantiator) { + + void setInstantiator(Class<? extends AssemblyTemplateInstantiator> instantiator) { this.instantiator = instantiator; } - private void setApplicationComponentTemplates(ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates) { + void setApplicationComponentTemplates(ResourceLookup<ApplicationComponentTemplate> applicationComponentTemplates) { this.applicationComponentTemplates = applicationComponentTemplates; } - private void setPlatformComponentTemplates(ResourceLookup<PlatformComponentTemplate> platformComponentTemplates) { + void setPlatformComponentTemplates(ResourceLookup<PlatformComponentTemplate> platformComponentTemplates) { this.platformComponentTemplates = platformComponentTemplates; } - + // builder - + public static Builder<? extends AssemblyTemplate> builder() { return new Builder<AssemblyTemplate>(CAMP_TYPE); } - + public static class Builder<T extends AssemblyTemplate> extends AbstractResource.Builder<T,Builder<T>> { - + protected Builder(String type) { super(type); } - + @SuppressWarnings("unchecked") protected T createResource() { return (T) new AssemblyTemplate(); } - + public Builder<T> instantiator(Class<? extends AssemblyTemplateInstantiator> x) { instance().setInstantiator(x); return thisBuilder(); } public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponentTemplate> x) { instance().setApplicationComponentTemplates(x); return thisBuilder(); } public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponentTemplate> x) { instance().setPlatformComponentTemplates(x); return thisBuilder(); } @@ -87,7 +87,7 @@ public class AssemblyTemplate extends AbstractResource { /** allows callers to see the partially formed instance when needed, for example to query instantiators; * could be replaced by specific methods as and when that is preferred */ public T peek() { return instance(); } - + public synchronized Builder<T> add(ApplicationComponentTemplate x) { if (instance().applicationComponentTemplates==null) { instance().applicationComponentTemplates = new BasicResourceLookup<ApplicationComponentTemplate>(); @@ -98,7 +98,7 @@ public class AssemblyTemplate extends AbstractResource { ((BasicResourceLookup<ApplicationComponentTemplate>)instance().applicationComponentTemplates).add(x); return thisBuilder(); } - + public synchronized Builder<T> add(PlatformComponentTemplate x) { if (instance().platformComponentTemplates==null) { instance().platformComponentTemplates = new BasicResourceLookup<PlatformComponentTemplate>(); @@ -109,7 +109,7 @@ public class AssemblyTemplate extends AbstractResource { ((BasicResourceLookup<PlatformComponentTemplate>)instance().platformComponentTemplates).add(x); return thisBuilder(); } - + @Override public synchronized T build() { Preconditions.checkNotNull(instance().instantiator); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d4ecbe7e/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java ---------------------------------------------------------------------- diff --git a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java index 3e3363b..a5c343a 100644 --- a/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java +++ b/camp/camp-base/src/main/java/io/brooklyn/camp/spi/PlatformComponent.java @@ -32,14 +32,14 @@ public class PlatformComponent extends AbstractResource { public static final String CAMP_TYPE = "PlatformComponent"; static { assert CAMP_TYPE.equals(PlatformComponent.class.getSimpleName()); } - + /** Use {@link #builder()} to create */ protected PlatformComponent() {} ResourceLookup<ApplicationComponent> applicationComponents; ResourceLookup<PlatformComponent> platformComponents; String externalManagementUri; - + public ResourceLookup<ApplicationComponent> getApplicationComponents() { return applicationComponents != null ? applicationComponents : new EmptyResourceLookup<ApplicationComponent>(); } @@ -47,34 +47,34 @@ public class PlatformComponent extends AbstractResource { return platformComponents != null ? platformComponents : new EmptyResourceLookup<PlatformComponent>(); } - private void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { + void setApplicationComponents(ResourceLookup<ApplicationComponent> applicationComponents) { this.applicationComponents = applicationComponents; } - private void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { + void setPlatformComponents(ResourceLookup<PlatformComponent> platformComponents) { this.platformComponents = platformComponents; } - + public String getExternalManagementUri() { return externalManagementUri; } - private void setExternalManagementUri(String externalManagementUri) { + void setExternalManagementUri(String externalManagementUri) { this.externalManagementUri = externalManagementUri; } - + // builder - + public static Builder<? extends PlatformComponent> builder() { return new Builder<PlatformComponent>(CAMP_TYPE); } - + public static class Builder<T extends PlatformComponent> extends AbstractResource.Builder<T,Builder<T>> { - + protected Builder(String type) { super(type); } - + public Builder<T> externalManagementUri(String x) { instance().setExternalManagementUri(x); return thisBuilder(); } public Builder<T> applicationComponentTemplates(ResourceLookup<ApplicationComponent> x) { instance().setApplicationComponents(x); return thisBuilder(); } public Builder<T> platformComponentTemplates(ResourceLookup<PlatformComponent> x) { instance().setPlatformComponents(x); return thisBuilder(); } - + public synchronized Builder<T> add(ApplicationComponent x) { if (instance().applicationComponents==null) { instance().applicationComponents = new BasicResourceLookup<ApplicationComponent>(); @@ -85,7 +85,7 @@ public class PlatformComponent extends AbstractResource { ((BasicResourceLookup<ApplicationComponent>)instance().applicationComponents).add(x); return thisBuilder(); } - + public synchronized Builder<T> add(PlatformComponent x) { if (instance().platformComponents==null) { instance().platformComponents = new BasicResourceLookup<PlatformComponent>();
