Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1e0729be09b87a4775ba74f3c4b0f026983a3ee6 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.ecf">
<annotation>
      <appInfo>
         <meta.schema plugin="org.eclipse.ecf" id="containerFactory" name="ECF Container Factory"/>
      </appInfo>
      <documentation>
         This extension allows plugins to register themselves as &apos;providers&apos; of ECF containers.  Once registered via this extension point, plugins can then provide there own implementations of  IContainer in response to client request of the ECF container factory (&lt;b&gt;org.eclipse.ecf.core.ContainerFactory&lt;/b&gt;).
&lt;p&gt;Plugins using this extension point can define a new implementation of any desired communications protocol, and expose that protocol as an instance of an &lt;b&gt;IContainer&lt;/b&gt;.  When client requests are made to ECF ContainerFactory to create &lt;b&gt;IContainer&lt;/b&gt; instances, those requests will be re-directed to the given IContainer implementer.
      </documentation>
   </annotation>

   <element name="extension">
      <complexType>
         <sequence>
            <element ref="containerFactory" minOccurs="1" maxOccurs="unbounded"/>
         </sequence>
         <attribute name="point" type="string" use="required">
            <annotation>
               <documentation>
                  
               </documentation>
            </annotation>
         </attribute>
         <attribute name="id" type="string">
            <annotation>
               <documentation>
                  
               </documentation>
            </annotation>
         </attribute>
         <attribute name="name" type="string">
            <annotation>
               <documentation>
                  
               </documentation>
            </annotation>
         </attribute>
      </complexType>
   </element>

   <element name="containerFactory">
      <annotation>
         <documentation>
            The container factory extension point.  Can optionally contain a list of &apos;defaultargument&apos; elements that describe the arguments (and provide default values) to be passed to provider implementation
         </documentation>
      </annotation>
      <complexType>
         <attribute name="class" type="string" use="required">
            <annotation>
               <documentation>
                  The fully qualified name of the class implementing the &lt;b&gt;org.eclipse.ecf.core.provider.IContainerInstantiator&lt;/b&gt; interface.
               </documentation>
               <appInfo>
                  <meta.attribute kind="java" basedOn="org.eclipse.ecf.core.provider.IContainerInstantiator"/>
               </appInfo>
            </annotation>
         </attribute>
         <attribute name="name" type="string">
            <annotation>
               <documentation>
                  An optional name for the extension.  If no name is explicitly provided by the extension, the containerFactory class name is used as the name.  Note that this name must &lt;b&gt;not&lt;/b&gt; conflict with any other name in the ECF SharedFactory in order to be successfully registered in the container factory.  Care should therefore be taken in selection of a name such that it does not conflict with other pre-existing names for this factory implementations
               </documentation>
            </annotation>
         </attribute>
         <attribute name="description" type="string">
            <annotation>
               <documentation>
                  A description of the container factory suitable for presentation in a user interface.
               </documentation>
            </annotation>
         </attribute>
         <attribute name="server" type="boolean">
            <annotation>
               <documentation>
                  Flag to indicate whether the factory is for creating servers.  Default is false.
               </documentation>
            </annotation>
         </attribute>
         <attribute name="hidden" type="boolean">
            <annotation>
               <documentation>
                  Flag for whether the given container factory should be hidden in the user interface.  Default is false.
               </documentation>
            </annotation>
         </attribute>
      </complexType>
   </element>

   <annotation>
      <appInfo>
         <meta.section type="since"/>
      </appInfo>
      <documentation>
         0.0.1
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="examples"/>
      </appInfo>
      <documentation>
         Here&apos;s an extension that associates a class org.eclipse.ecf.test.FooContainerFactory with name &apos;foo&apos; in the ECF &lt;b&gt;ContainerFactory&lt;/b&gt;:

&lt;pre&gt;
&lt;extension point=&quot;org.eclipse.ecf.containerFactory&quot;&gt;
    &lt;containerFactory name=&quot;foo&quot; class=&quot;org.eclipse.ecf.test.FooInstantiator&quot; description=&quot;My container factory&quot;/&gt;
&lt;/extension&gt;
&lt;/pre&gt;

Here is some example code to implement this class:

&lt;pre&gt;
package org.eclipse.ecf.test;

import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.ContainerInstantiationException;
import org.eclipse.ecf.core.provider.IContainerInstantiator;

public class FooInstantiator implements IContainerInstantiator {

    public FooInstantiator() {
        super();
    }
    public IContainer createInstance(ContainerTypeDescription description, Class[] argTypes, Object[] args)
            throws ContainerInstantiationException {
        // Create/return instance of FooContainer
        // Note that FooContainer class must
        // implement IContainer
        return new FooContainer();
    }
}
&lt;/pre&gt;

In this example, the given class implements the &lt;b&gt;IContainerInstantiator&lt;/b&gt;.createInstance method by creating and returning a new instance of FooInstantiator, a class also defined in the extension plugin.  As noted in the code, this class must implement &lt;b&gt;IContainer&lt;/b&gt;, so that it can successfully be returned from createInstance.

&lt;h3&gt;Example Usage of Container by Clients&lt;/h3&gt;

Clients that wish to use the &apos;foo&apos; container implementation can do so simply by making the following call to create an &lt;b&gt;IContainer&lt;/b&gt;:

&lt;pre&gt;
IContainer newContainer = ContainerFactory.getDefault().createContainer(&apos;foo&apos;); 
// Further use of newContainer instance here

&lt;/pre&gt;
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="apiInfo"/>
      </appInfo>
      <documentation>
         The API for this extension point is provided by the &lt;b&gt;org.eclipse.ecf.core.ContainerFactory.getDefault()&lt;/b&gt; methods.  Specifically, the &apos;createContainer&apos; methods are to be used by clients.  The functionality provided by the extension point mechanism can be used at runtime via the &lt;b&gt;ContainerFactory.getDefault().addDescription(ContainerTypeDescription)&lt;/b&gt; method.  Here is the IContainerFactory interface
contract:

&lt;pre&gt;
/**
 * Container factory contract {@link ContainerFactory} for default
 * implementation.
 */
public interface IContainerFactory {
 /**
  * Add a ContainerTypeDescription to the set of known ContainerDescriptions.
  * 
  * @param description
  *            the ContainerTypeDescription to add to this factory. Must not
  *            be null.
  * @return ContainerTypeDescription the old description of the same name,
  *         null if none found
  */
 public ContainerTypeDescription addDescription(ContainerTypeDescription description);

 /**
  * Get a collection of the ContainerDescriptions currently known to this
  * factory. This allows clients to query the factory to determine what if
  * any other ContainerDescriptions are currently registered with the
  * factory, and if so, what they are.
  * 
  * @return List of ContainerTypeDescription instances
  */
 public List /* ContainerTypeDescription */ getDescriptions();

 /**
  * Check to see if a given named description is already contained by this
  * factory
  * 
  * @param description
  *            the ContainerTypeDescription to look for
  * @return true if description is already known to factory, false otherwise
  */
 public boolean containsDescription(ContainerTypeDescription description);

 /**
  * Get the known ContainerTypeDescription given it&apos;s name.
  * 
  * @param name
  *            the name to use as key to find ContainerTypeDescription
  * @return ContainerTypeDescription found. Null if not found.
  */
 public ContainerTypeDescription getDescriptionByName(String name);

 /**
  * Make IContainer instance. Given a ContainerTypeDescription object, a
  * String [] of argument types, and an Object [] of parameters, this method
  * will
  * &lt;p&gt;
  * &lt;ul&gt;
  * &lt;li&gt;lookup the known ContainerDescriptions to find one of matching name&lt;/li&gt;
  * &lt;li&gt;if found, will retrieve or create an IContainerInstantiator for that
  * description&lt;/li&gt;
  * &lt;li&gt;Call the IContainerInstantiator.createInstance method to return an
  * instance of IContainer&lt;/li&gt;
  * &lt;/ul&gt;
  * 
  * @param description
  *            the ContainerTypeDescription to use to create the instance
  * @param parameters
  *            an Object [] of parameters passed to the createInstance method
  *            of the IContainerInstantiator
  * @return a valid instance of IContainer
  * @throws ContainerCreateException
  */
 public IContainer createContainer(ContainerTypeDescription description,
   Object[] parameters) throws ContainerCreateException;

 /**
  * Make IContainer instance. Given a ContainerTypeDescription name, this
  * method will
  * &lt;p&gt;
  * &lt;ul&gt;
  * &lt;li&gt;lookup the known ContainerDescriptions to find one of matching name&lt;/li&gt;
  * &lt;li&gt;if found, will retrieve or create an IContainerInstantiator for that
  * description&lt;/li&gt;
  * &lt;li&gt;Call the IContainerInstantiator.createInstance method to return an
  * instance of IContainer&lt;/li&gt;
  * &lt;/ul&gt;
  * 
  * @param descriptionName
  *            the ContainerTypeDescription name to lookup
  * @return a valid instance of IContainer
  * @throws ContainerCreateException
  */
 public IContainer createContainer(String descriptionName)
   throws ContainerCreateException;

 /**
  * Make IContainer instance. Given a ContainerTypeDescription name, this
  * method will
  * &lt;p&gt;
  * &lt;ul&gt;
  * &lt;li&gt;lookup the known ContainerDescriptions to find one of matching name&lt;/li&gt;
  * &lt;li&gt;if found, will retrieve or create an IContainerInstantiator for that
  * description&lt;/li&gt;
  * &lt;li&gt;Call the IContainerInstantiator.createInstance method to return an
  * instance of IContainer&lt;/li&gt;
  * &lt;/ul&gt;
  * 
  * @param descriptionName
  *            the ContainerTypeDescription name to lookup
  * @param parameters
  *            the Object [] of parameters passed to the
  *            IContainerInstantiator.createInstance method
  * @return a valid instance of IContainer
  * @throws ContainerCreateException
  */
 public IContainer createContainer(String descriptionName, Object[] parameters)
   throws ContainerCreateException;

 /**
  * Remove given description from set known to this factory.
  * 
  * @param description
  *            the ContainerTypeDescription to remove
  * @return the removed ContainerTypeDescription, null if nothing removed
  */
 public ContainerTypeDescription removeDescription(
   ContainerTypeDescription description);
}
&lt;/pre&gt;
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="implementation"/>
      </appInfo>
      <documentation>
         The supplied implementations of this extension point are:

org.eclipse.ecf.provider.generic.GenericContainerInstantiator
      </documentation>
   </annotation>

   <annotation>
      <appInfo>
         <meta.section type="copyright"/>
      </appInfo>
      <documentation>
         Copyright (c) 2004 Composent, Inc. and others.
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:  Composent, Inc. - initial API and implementation
      </documentation>
   </annotation>

</schema>

Back to the top