Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e6bd7f5ff3d764fdc73925d59c774a82e64deb8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.ds.model;

import java.util.*;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentInstance;

/**
 * 
 * Component Description with properties
 * 
 * Component Configuration – A component configuration represents a component
 * description parameterized by component properties.
 * 
 * @version $Revision: 1.1 $
 */
public class ComponentConfiguration {

	private ComponentDescription cd;
	private Hashtable properties;
	private ServiceRegistration serviceRegistration;

	/**
	 * List of {@link org.eclipse.equinox.ds.resolver.Reference Reference} objects
	 */
	private List references;

	/**
	 * List of {@link ComponentInstance} objects
	 */
	private List instances;

	/**
	 * List of names (Strings) of Component Configurations we should not cause to
	 * activate during the activation of this Component Configuration.  This is
	 * populated by the {@link org.eclipse.equinox.ds.resolver.Resolver Resolver}
	 * and used by {@link org.eclipse.equinox.ds.instance.BuildDispose BuildDispose}.
	 */
	protected List delayActivateComponentConfigurationNames;

	/**
	 * Flag to indicate that this Component Configuration registers 
	 * the {@link org.osgi.service.component.ComponentFactory} 
	 * service.  
	 * 
	 * (A Service Component that has the "factory" attribute will have
	 * one Component Configuration that registers 
	 * {@link org.osgi.service.component.ComponentFactory} and then a Component
	 * Configuration for every factory instance that registers a different service
	 * or none at all).
	 */
	protected boolean componentFactory;

	/**
	 * Create a new Component Configuration for this Service Component with
	 * it's own Reference objects, and properties.
	 * 
	 * @param cd the Service Component
	 * 
	 * @param references a List of 
	 *        {@link org.eclipse.equinox.ds.resolver.Reference Reference}
	 *        objects
	 *        
	 * @param properties Properties associated with this Component Configuration
	 * 
	 * @param componentFactory "Component Factory" flag - see 
	 *        {@link ComponentConfiguration#componentFactory}
	 */
	public ComponentConfiguration(ComponentDescription cd, List references, Hashtable properties, boolean componentFactory) {

		this.cd = cd;
		this.references = references;
		this.properties = properties;

		delayActivateComponentConfigurationNames = new ArrayList();
		instances = new ArrayList();

		this.componentFactory = componentFactory;
	}

	/**
	 * Get the properties of this Component Configuration
	 */
	public Hashtable getProperties() {
		return properties;
	}

	public ComponentDescription getComponentDescription() {
		return cd;
	}

	/**
	 * Add a new Component Configuration name we should beware of activating to
	 * prevent a cycle.
	 * 
	 * @see ComponentConfiguration#delayActivateComponentConfigurationNames
	 */
	public void setDelayActivateComponentConfigurationName(String componentConfigurationName) {
		if (!delayActivateComponentConfigurationNames.contains(componentConfigurationName))
			delayActivateComponentConfigurationNames.add(componentConfigurationName);
	}

	public ServiceRegistration getServiceRegistration() {
		return serviceRegistration;
	}

	public void setServiceRegistration(ServiceRegistration serviceRegistration) {
		this.serviceRegistration = serviceRegistration;
	}

	public List getDelayActivateComponentConfigurationNames() {
		return delayActivateComponentConfigurationNames;
	}

	public void clearDelayActivateComponentConfigurationNames() {
		delayActivateComponentConfigurationNames.clear();
	}

	public List getReferences() {
		return references;
	}

	public void addInstance(ComponentInstance instance) {
		instances.add(instance);
	}

	public List getInstances() {
		return instances;
	}

	public void removeInstance(Object object) {
		instances.remove(object);
	}

	public void removeAllInstances() {
		instances.clear();
	}

	public boolean isComponentFactory() {
		return componentFactory;
	}
}

Back to the top