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

org.apache.brooklyn.camp.spi.ApplicationComponent 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 a PCT
 * as well as fields pointing to behaviour (eg creation of PlatformComponent).
 * 

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





© 2015 - 2024 Weber Informatics LLC | Privacy Policy