blob: 4dc069ef1b37ffd23b5a13bbf4dba744d179d293 [file] [log] [blame]
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.scrplugin.helper;
20
21import java.util.LinkedHashMap;
22import java.util.Map;
23
24import org.apache.felix.scrplugin.description.ClassDescription;
25import org.apache.felix.scrplugin.description.ComponentDescription;
26import org.apache.felix.scrplugin.description.PropertyDescription;
27import org.apache.felix.scrplugin.description.ReferenceDescription;
28import org.apache.felix.scrplugin.description.ServiceDescription;
29
30
31/**
32 * A <code>ComponentContainer</code> contains all relevant information
33 * about a component:
34 * - the class descriptor
35 * - the component descriptor
36 * - the service descriptor
37 * - reference descriptors
38 * - property descriptors
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000039 */
40public class ComponentContainer {
41
Carsten Ziegeler651df212012-06-27 06:48:15 +000042 /** The class description. */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000043 private final ClassDescription classDescription;
44
Carsten Ziegeler651df212012-06-27 06:48:15 +000045 /** The component description. */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000046 private final ComponentDescription componentDescription;
47
Carsten Ziegeler651df212012-06-27 06:48:15 +000048 /** The service description (optional). */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000049 private ServiceDescription serviceDescription;
50
Carsten Ziegeler651df212012-06-27 06:48:15 +000051 /** All references. */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000052 private final Map<String, ReferenceDescription> allReferences = new LinkedHashMap<String, ReferenceDescription>();
Carsten Ziegeler651df212012-06-27 06:48:15 +000053
54 /** All properties. */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000055 private final Map<String, PropertyDescription> allProperties = new LinkedHashMap<String, PropertyDescription>();
56
Carsten Ziegeler646b8182012-08-31 07:47:57 +000057 /** Metatype container. */
58 private MetatypeContainer metatype;
Carsten Ziegelereb37dc42012-08-31 07:37:45 +000059
Carsten Ziegeler651df212012-06-27 06:48:15 +000060 /**
61 * Create a new component container
62 * @param classDescription Class description
63 * @param componentDescription Component description
64 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000065 public ComponentContainer(final ClassDescription classDescription,
66 final ComponentDescription componentDescription) {
67 this.classDescription = classDescription;
68 this.componentDescription = componentDescription;
69 }
70
Carsten Ziegeler651df212012-06-27 06:48:15 +000071 /**
72 * Get the class description
73 * @return The class description
74 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000075 public ClassDescription getClassDescription() {
76 return this.classDescription;
77 }
78
Carsten Ziegeler651df212012-06-27 06:48:15 +000079 /**
80 * Get the component description
81 * @return The component description
82 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000083 public ComponentDescription getComponentDescription() {
84 return this.componentDescription;
85 }
86
Carsten Ziegeler651df212012-06-27 06:48:15 +000087 /**
88 * Get all references.
89 * The references are put into the map by name.
90 * This map can be modified by clients.
91 * @return The map of references
92 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +000093 public Map<String, ReferenceDescription> getReferences() {
94 return this.allReferences;
95 }
96
Carsten Ziegeler283ace92012-06-27 09:51:56 +000097 /**
98 * Get all properties.
99 * The properties are put into the map by name.
100 * This map can be modified by clients.
101 * @return The map of properties
102 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +0000103 public Map<String, PropertyDescription> getProperties() {
104 return this.allProperties;
105 }
106
Carsten Ziegeler283ace92012-06-27 09:51:56 +0000107 /**
108 * Get the service description.
109 * @return The service description or <code>null</code>
110 */
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +0000111 public ServiceDescription getServiceDescription() {
112 return serviceDescription;
113 }
114
Carsten Ziegeler283ace92012-06-27 09:51:56 +0000115 /**
116 * Set the service description
117 * @param serviceDescription The new service description
118 */
119 public void setServiceDescription(final ServiceDescription serviceDescription) {
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +0000120 this.serviceDescription = serviceDescription;
121 }
Carsten Ziegeler561e4e22012-06-27 06:38:28 +0000122
123 @Override
124 public String toString() {
125 return "ComponentContainer [classDescription=" + classDescription + ", componentDescription=" + componentDescription
126 + ", serviceDescription=" + serviceDescription + ", allReferences=" + allReferences + ", allProperties="
127 + allProperties + "]";
128 }
Carsten Ziegelereb37dc42012-08-31 07:37:45 +0000129
Carsten Ziegeler646b8182012-08-31 07:47:57 +0000130 public MetatypeContainer getMetatypeContainer() {
131 return this.metatype;
Carsten Ziegelereb37dc42012-08-31 07:37:45 +0000132 }
133
Carsten Ziegeler646b8182012-08-31 07:47:57 +0000134 public void setMetatypeContainer(final MetatypeContainer ocd) {
135 this.metatype = ocd;
Carsten Ziegelereb37dc42012-08-31 07:37:45 +0000136 }
Carsten Ziegeler9a496fe2012-06-27 06:20:28 +0000137}