All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.brooklyn.camp.spi.Assembly Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.brooklyn.camp.spi;

import org.apache.brooklyn.camp.spi.collection.BasicResourceLookup;
import org.apache.brooklyn.camp.spi.collection.ResourceLookup;
import org.apache.brooklyn.camp.spi.collection.ResourceLookup.EmptyResourceLookup;


/** Holds the metadata (name, description, etc) for an AssemblyTemplate
 * as well as fields pointing to behaviour (eg list of ACT's).
 * 

* See {@link AbstractResource} for more general information. */ 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 applicationComponents; ResourceLookup platformComponents; // TODO // "parameterDefinitionUri": URI, // "pdpUri" : URI ? public AssemblyTemplate getAssemblyTemplate() { return assemblyTemplate; } public ResourceLookup getApplicationComponents() { return applicationComponents != null ? applicationComponents : new EmptyResourceLookup(); } public ResourceLookup getPlatformComponents() { return platformComponents != null ? platformComponents : new EmptyResourceLookup(); } private void setAssemblyTemplate(AssemblyTemplate assemblyTemplate) { this.assemblyTemplate = assemblyTemplate; } private void setApplicationComponents(ResourceLookup applicationComponents) { this.applicationComponents = applicationComponents; } private void setPlatformComponents(ResourceLookup platformComponents) { this.platformComponents = platformComponents; } // builder public static Builder builder() { return new Assembly().new Builder(CAMP_TYPE); } public class Builder extends AbstractResource.Builder> { protected Builder(String type) { super(type); } public Builder assemblyTemplate(AssemblyTemplate x) { Assembly.this.setAssemblyTemplate(x); return thisBuilder(); } public Builder applicationComponentTemplates(ResourceLookup x) { Assembly.this.setApplicationComponents(x); return thisBuilder(); } public Builder platformComponentTemplates(ResourceLookup x) { Assembly.this.setPlatformComponents(x); return thisBuilder(); } public synchronized Builder add(ApplicationComponent x) { if (Assembly.this.applicationComponents==null) { Assembly.this.applicationComponents = new BasicResourceLookup(); } if (!(Assembly.this.applicationComponents instanceof BasicResourceLookup)) { throw new IllegalStateException("Cannot add to resource lookup "+Assembly.this.applicationComponents); } ((BasicResourceLookup)Assembly.this.applicationComponents).add(x); return thisBuilder(); } public synchronized Builder add(PlatformComponent x) { if (Assembly.this.platformComponents==null) { Assembly.this.platformComponents = new BasicResourceLookup(); } if (!(Assembly.this.platformComponents instanceof BasicResourceLookup)) { throw new IllegalStateException("Cannot add to resource lookup "+Assembly.this.platformComponents); } ((BasicResourceLookup)Assembly.this.platformComponents).add(x); return thisBuilder(); } @Override public synchronized T build() { return super.build(); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy