001/*
002 * (C) Copyright 2006-2017 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 */
019package org.nuxeo.runtime.model;
020
021import java.io.Serializable;
022import java.net.URL;
023import java.util.Map;
024import java.util.Set;
025
026import org.nuxeo.runtime.Version;
027
028/**
029 * The component registration info.
030 * <p>
031 * A registration info object is keeping all the information needed to deploy a component, like the component
032 * implementation, properties, dependencies and also the defined extension points and contributed extensions.
033 * <p>
034 * When a component is activated the registration info is creating a component instance using the current runtime
035 * context.
036 *
037 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
038 */
039public interface RegistrationInfo extends Serializable {
040
041    int UNREGISTERED = 0;
042
043    int REGISTERED = 1;
044
045    /**
046     * Component dependencies are resolved
047     */
048    int RESOLVED = 2;
049
050    /**
051     * Before component activation
052     */
053    int ACTIVATING = 3;
054
055    int DEACTIVATING = 4;
056
057    /**
058     * Component activation successful
059     */
060    int ACTIVATED = 5;
061
062    /**
063     * Notification of applicationStarted fails
064     *
065     * @since 7.4
066     */
067    int START_FAILURE = 6;
068
069    /**
070     * Component was started
071     *
072     * @since 9.2
073     */
074    int STARTED = 7;
075
076    /**
077     * The component is being started
078     */
079    int STARTING = 8;
080
081    /**
082     * The component is being stopped
083     */
084    int STOPPING = 9;
085
086    /**
087     * Gets the component version.
088     */
089    Version getVersion();
090
091    /**
092     * Get the owner bundle symbolic name of that component. If null the default owner is used.
093     */
094    String getBundle();
095
096    /**
097     * Gets any comments on this component.
098     */
099    String getDocumentation();
100
101    /**
102     * Gets the runtime context that created this registration info.
103     *
104     * @return the runtime context
105     */
106    RuntimeContext getContext();
107
108    /**
109     * Gets the component properties.
110     *
111     * @return the component properties
112     */
113    Map<String, Property> getProperties();
114
115    /**
116     * Gets the list of aliases.
117     *
118     * @return the aliases
119     */
120    Set<ComponentName> getAliases();
121
122    /**
123     * Gets the list of the required components.
124     *
125     * @return the required components
126     */
127    Set<ComponentName> getRequiredComponents();
128
129    /**
130     * Gets the defined extension points.
131     *
132     * @return the defined extension points
133     */
134    ExtensionPoint[] getExtensionPoints();
135
136    /**
137     * Gets the extensions contributed by this component.
138     *
139     * @return the contributed extensions
140     */
141    Extension[] getExtensions();
142
143    /**
144     * Gets the name of the component.
145     *
146     * @return the component name
147     */
148    ComponentName getName();
149
150    /**
151     * Whether this component is disabled. For now this is used only for persistent components.
152     */
153    boolean isDisabled();
154
155    /**
156     * Gets the component instance or null if the component was not yet activated.
157     *
158     * @return the component instance
159     */
160    ComponentInstance getComponent();
161
162    /**
163     * Gets the component state.
164     *
165     * @return the component state
166     */
167    int getState();
168
169    /**
170     * Gets the component manager.
171     *
172     * @return the component manager
173     */
174    ComponentManager getManager();
175
176    /**
177     * Checks whether this component is activated.
178     *
179     * @return true if the component is activated, false otherwise
180     */
181    boolean isActivated();
182
183    /**
184     * Checks whether this component is resolved (i&dot;e&dot; all its dependencies are satisfied).
185     *
186     * @return true if the component is resolved, false otherwise
187     */
188    boolean isResolved();
189
190    /**
191     * Checks whether this component is started
192     *
193     * @since 9.2
194     */
195    boolean isStarted();
196
197    /**
198     * Gets the list of provided services or null if no service is provided.
199     *
200     * @return an array containing the service class names or null if no service are provided
201     */
202    String[] getProvidedServiceNames();
203
204    /**
205     * Whether or not this registration is persisted by the user (not part of a real bundle).
206     *
207     * @return true if persisted, false otherwise
208     */
209    boolean isPersistent();
210
211    /**
212     * Set the persistent flag on this registration
213     */
214    void setPersistent(boolean isPersistent);
215
216    /**
217     * Give the class name for the component implementation if this is a java component
218     *
219     * @return class name
220     */
221    String getImplementation();
222
223    /**
224     * Retrieve the URL of the XML file used to declare the component
225     *
226     * @return the XML file URL
227     */
228    URL getXmlFileUrl();
229
230    /**
231     * The id of the content source used to create the registration (usually a StreamRef id)
232     *
233     * @since 9.2
234     */
235    String getSourceId();
236
237    /**
238     * The component notification order for {@link ComponentManager#start()}.
239     *
240     * @return the order, 1000 by default
241     * @since 5.6
242     */
243    int getApplicationStartedOrder();
244
245}