|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package com.cloud.utils.component; |
| 19 | + |
| 20 | +import java.util.List; |
| 21 | + |
| 22 | +import com.cloud.utils.Pair; |
| 23 | + |
| 24 | + |
| 25 | +/** |
| 26 | + * CloudStack uses Adapters to implement different capabilities. |
| 27 | + * There are different Adapters such as NetworkGuru, NetworkElement, |
| 28 | + * HypervisorGuru, DeploymentPlanner, etc. However, Adapters only |
| 29 | + * defines what CloudStack needs from the implementation. What about |
| 30 | + * what the Adapter itself needs, such as configurations and administrative |
| 31 | + * operations, and what if one implementation can |
| 32 | + * implement two different Adapters? |
| 33 | + * |
| 34 | + * Plugin is a CloudStack container for Adapters. It rolls the following |
| 35 | + * capabilities into the one package for CloudStack to load at runtime. |
| 36 | + * - REST API commands supported by the Plugin. |
| 37 | + * - Components needed by the Plugin. |
| 38 | + * - Adapters implemented by the Plugin. |
| 39 | + * - Database operations |
| 40 | + * |
| 41 | + */ |
| 42 | +public interface Plugin extends PluggableService { |
| 43 | + |
| 44 | + /** |
| 45 | + * Retrieves the component libraries needed by this Plugin. |
| 46 | + * ComponentLocator put these components and add them to the startup |
| 47 | + * and shutdown processes of CloudStack. This is only needed if the |
| 48 | + * Plugin uses ComponentLocator to inject what it needs. If the |
| 49 | + * Plugin uses other mechanisms, then it can return null here. |
| 50 | + * |
| 51 | + * @return a component library that contains the components this Plugin |
| 52 | + * contains and needs. |
| 53 | + */ |
| 54 | + ComponentLibrary getComponentLibrary(); |
| 55 | + |
| 56 | + /** |
| 57 | + * Retrieves the list of Adapters and the interface they implement. It |
| 58 | + * can be an empty list if the Plugin does not implement any. |
| 59 | + * |
| 60 | + * @return list of pairs where the first is the interface and the second |
| 61 | + * is the adapter. |
| 62 | + */ |
| 63 | + List<Pair<Class<?>, Class<? extends Adapter>>> getAdapterImplementations(); |
| 64 | +} |
0 commit comments