aboutsummaryrefslogtreecommitdiff
path: root/libjava/doc/java-beans-beancontext.texi
blob: f67328600aaa2ba9f524c59b727bb388447a4707 (plain)
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
@deftypemethod BeanContextChildComponentProxy {public Component} getComponent () 
Get the @code{Component} associated with this @code{BeanContextChild}.
@end deftypemethod
@deftypemethod BeanContextChild {public void} setBeanContext (java.beans.beancontext.BeanContext@w{ }@var{parent}) @*throws PropertyVetoException
Set the parent @code{BeanContext}.
 



 This method is called from @code{BeanContext.add()} and
 should not be called directly.
 



 When this Object is being added to a new BeanContext or moved
 from an old one, a non-null value will be passed in.
 



 When this Object is being removed from the current
 @code{BeanContext}, @code{setBeanContext()} will
 receive the parameter @code{null}.
 



 When being removed from the current @code{BeanContext},
 it is the @code{BeanContextChild}'s responsibility to
 release all services it has obtained.
 



 This change should generate @code{PropertyChangeEvent}
 and @code{VetoableChangeEvent}s with the property name
 "beanContext".  If the change is vetoed, it must re-throw the
 exception and not change anything.  In this way, the parent
 @code{BeanContextChild}, who has registered himself with
 you, will have a chance to remove this child from its
 collection.
 



 If the Bean does not wish to change the parent or be removed
 from one, it may throw the @code{PropertyVetoException}.
 If you veto a @code{setBeanContext(null)} call, then you
 should try your hardest to remedy whatever problem is keeping
 you from being removed from the @code{BeanContext} so
 that you can <em>not</em> veto it the next time.
 Otherwise, nasty pathological recursion stuff could occur in
 certain situations.
 



 If you do veto the change, you must first back out any changes
 you made prior to the veto.  Best not to make any such changes
 prior to the veto in the first place.
 



 This method is called from @code{BeanContext.add()} and
 should not be called directly.
@end deftypemethod
@deftypemethod BeanContextChild {public BeanContext} getBeanContext () 
Get the parent @code{BeanContext}.
@end deftypemethod
@deftypemethod BeanContextChild {public void} addPropertyChangeListener (java.lang.String@w{ }@var{prop}, java.beans.PropertyChangeListener@w{ }@var{listener}) 
Add a listener that will be notified when a specific property changes.
@end deftypemethod
@deftypemethod BeanContextChild {public void} removePropertyChangeListener (java.lang.String@w{ }@var{prop}, java.beans.PropertyChangeListener@w{ }@var{listener}) 
Remove a listener to a certain property.
@end deftypemethod
@deftypemethod BeanContextChild {public void} addVetoableChangeListener (java.lang.String@w{ }@var{prop}, java.beans.VetoableChangeListener@w{ }@var{listener}) 
Add a listener that will be notified when a specific property
 change is requested (a PropertyVetoException may be thrown) as
 well as after the change is successfully made.
@end deftypemethod
@deftypemethod BeanContextChild {public void} removeVetoableChangeListener (java.lang.String@w{ }@var{prop}, java.beans.VetoableChangeListener@w{ }@var{listener}) 
Remove a listener to a certain property.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} setBeanContext (java.beans.beancontext.BeanContext@w{ }@var{newBeanContext}) @*throws PropertyVetoException
Set the parent @code{BeanContext}.
 



 When this Object is being added to a new BeanContext or moved
 from an old one, a non-null value will be passed in.
 



 When this Object is being removed from the current
 @code{BeanContext}, @code{setBeanContext()} will
 receive the parameter @code{null}.
 



 Order of events:
 
@itemize @bullet

   
@item

     If the new @code{BeanContext} is the same as the old
     one, nothing happens.
   

   
@item

     If the change has not been rejected or vetoed before, call
     @code{validatePendingSetBeanContext()}.  If this call
     returns @code{false}, the change is rejected and a
     @code{PropertyVetoException} is thrown.
   

   
@item

     If the change has not been rejected or vetoed before,
     @code{VetoableChangeEvent}s are fired with the name
     @code{"beanContext"}, using the
     @code{fireVetoableChange()} method.  If a veto
     occurs, reversion events are fired using the same method,
     the change is rejected, and the veto is rethrown.
   

   
@item

     @code{releaseBeanContextResources()} is called.
   

   
@item

     The change is made.
   

   
@item

     @code{PropertyChangeEvent}s are fired using the
     @code{firePropertyChange()} method.
   

   
@item

     @code{initializeBeanContextResources()} is called.
   

 
@end itemize

 


@end deftypemethod
@deftypemethod BeanContextChildSupport {public BeanContext} getBeanContext () 
Get the parent @code{BeanContext}.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public BeanContextChild} getBeanContextChildPeer () 
Get the peer (or @code{this} if there is no peer).
@end deftypemethod
@deftypemethod BeanContextChildSupport {public boolean} isDelegated () 
Determine whether there is a peer.
 This is true iff @code{getBeanContextChildPeer() == this}.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} addPropertyChangeListener (java.lang.String@w{ }@var{propertyName}, java.beans.PropertyChangeListener@w{ }@var{listener}) 
Add a listener that will be notified when a specific property changes.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} removePropertyChangeListener (java.lang.String@w{ }@var{propertyName}, java.beans.PropertyChangeListener@w{ }@var{listener}) 
Remove a listener to a certain property.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} addVetoableChangeListener (java.lang.String@w{ }@var{propertyName}, java.beans.VetoableChangeListener@w{ }@var{listener}) 
Add a listener that will be notified when a specific property
 change is requested (a PropertyVetoException may be thrown) as
 well as after the change is successfully made.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} removeVetoableChangeListener (java.lang.String@w{ }@var{propertyName}, java.beans.VetoableChangeListener@w{ }@var{listener}) 
Remove a listener to a certain property.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} firePropertyChange (java.lang.String@w{ }@var{propertyName}, java.lang.Object@w{ }@var{oldVal}, java.lang.Object@w{ }@var{newVal}) 
Fire a property change.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} fireVetoableChange (java.lang.String@w{ }@var{propertyName}, java.lang.Object@w{ }@var{oldVal}, java.lang.Object@w{ }@var{newVal}) @*throws PropertyVetoException
Fire a vetoable property change.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} serviceRevoked (java.beans.beancontext.BeanContextServiceRevokedEvent@w{ }@var{event}) 
Called by @code{BeanContextServices.revokeService()} to indicate that a service has been revoked.
 If you have a reference to such a service, it should be
 discarded and may no longer function properly.
 @code{getService()} will no longer work on the specified
 service class after this event has been fired.
 



 <EM>This method is meant to be overriden.</EM>
 @code{BeanContextChildSupport}'s implementation does
 nothing.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public void} serviceAvailable (java.beans.beancontext.BeanContextServiceAvailableEvent@w{ }@var{event}) 
Called by @code{BeanContextServices} whenever a service is made available.
 



 <EM>This method is meant to be overriden.</EM>
 @code{BeanContextChildSupport}'s implementation does
 nothing.
@end deftypemethod
@deftypemethod BeanContextChildSupport {public boolean} validatePendingSetBeanContext (java.beans.beancontext.BeanContext@w{ }@var{newBeanContext}) 
Called by @code{setBeanContext()} to determine whether the set should be rejected.
 



 <EM>This method is meant to be overriden.</EM>
 @code{BeanContextChildSupport}'s implementation simply
 returns @code{true}.
@end deftypemethod
@deftypemethod BeanContextChildSupport {protected void} releaseBeanContextResources () 
Called by @code{setBeanContext()} to release resources of a what will soon no longer be the parent.
 



 <EM>This method is meant to be overriden.</EM>
 @code{BeanContextChildSupport}'s implementation does
 nothing.
@end deftypemethod
@deftypemethod BeanContextChildSupport {protected void} initializeBeanContextResources () 
Called by @code{setBeanContext()} to grab resources when the parent has been set.
 



 <EM>This method is meant to be overriden.</EM>
 @code{BeanContextChildSupport}'s implementation does
 nothing.
@end deftypemethod
@deftypemethod BeanContextContainerProxy {public Container} getContainer () 
Get the @code{Container} associated with this @code{BeanContext}.
@end deftypemethod
@deftypemethod BeanContextEvent {public BeanContext} getBeanContext () 
Get the @code{BeanContext} that originated this event.
@end deftypemethod
@deftypemethod BeanContextEvent {public BeanContext} getPropagatedFrom () 
Get the most recent propagator of this event.
 If this value is @code{null}, you have received the event
 straight from the source.
@end deftypemethod
@deftypemethod BeanContextEvent {public boolean} isPropagated () 
Tell whether this event has been propagated.
@end deftypemethod
@deftypemethod BeanContextEvent {public void} setPropagatedFrom (java.beans.beancontext.BeanContext@w{ }@var{propagator}) 
Set the most recent propagator of this event.
@end deftypemethod
@deftypemethod BeanContext {public Object} instantiateChild (java.lang.String@w{ }@var{beanName}) @*throws IOException, ClassNotFoundException
Instantiate a Bean using this Bean's @code{ClassLoader}
 and this @code{BeanContext} as the parent.
 



 This method exists mainly so that @code{BeanContext}
 implementations can perform extra actions on Beans that are
 created within them.
@end deftypemethod
@deftypemethod BeanContext {public URL} getResource (java.lang.String@w{ }@var{resourceName}, java.beans.beancontext.BeanContextChild@w{ }@var{requestor}) 
Get a resource.  The @code{BeanContext} will typically
 call @code{ClassLoader.getResource()}, but may do it any
 way it wants to.  This allows a @code{BeanContext} to
 have its own set of resources separate from the rest of the
 system.
 



 Beans should call this method on their parent rather than the
 associated @code{ClassLoader} method.
 



 I am assuming, but am not entirely sure, that if a
 @code{BeanContext} cannot find a resource, its
 responsibility is to call the @code{getResource} method
 of its parent @code{BeanContext}.
@end deftypemethod
@deftypemethod BeanContext {public InputStream} getResourceAsStream (java.lang.String@w{ }@var{resourceName}, java.beans.beancontext.BeanContextChild@w{ }@var{requestor}) 
Get a resource as a stream.  The @code{BeanContext} will
 typically call @code{ClassLoader.getResourceAsStream()},
 but may do it any way it wants to.  This allows a
 @code{BeanContext}'s children to have their own set of
 resources separate from the rest of the system.
 



 Beans should call this method on their parent rather than the
 associated @code{ClassLoader} method.
 



 I am assuming, but am not entirely sure, that if a
 @code{BeanContext} cannot find a resource, its
 responsibility is to call the @code{getResourceAsStream}
 method of its parent @code{BeanContext}.
@end deftypemethod
@deftypemethod BeanContext {public void} addBeanContextMembershipListener (java.beans.beancontext.BeanContextMembershipListener@w{ }@var{listener}) 
Add a listener on changes to the membership of this
 @code{BeanContext} object.
@end deftypemethod
@deftypemethod BeanContext {public void} removeBeanContextMembershipListener (java.beans.beancontext.BeanContextMembershipListener@w{ }@var{listener}) 
Remove a listener on changes to the membership of this
 @code{BeanContext} object.
@end deftypemethod
@deftypemethod BeanContextMembershipEvent {public int} size () 
The number of children removed or added.
@end deftypemethod
@deftypemethod BeanContextMembershipEvent {public Iterator} iterator () 
An iterator that will step through all the children.
@end deftypemethod
@deftypemethod BeanContextMembershipEvent {public Object} toArray () 
An array of the children.
@end deftypemethod
@deftypemethod BeanContextMembershipEvent {public boolean} contains (java.lang.Object@w{ }@var{child}) 
Tell whether the @code{Object} is one of the children added or removed.
@end deftypemethod
@deftypemethod BeanContextMembershipListener {public void} childrenAdded (java.beans.beancontext.BeanContextMembershipEvent@w{ }@var{event}) 
When beans are added to a @code{BeanContext},
 this method is called to fire the event.
@end deftypemethod
@deftypemethod BeanContextMembershipListener {public void} childrenRemoved (java.beans.beancontext.BeanContextMembershipEvent@w{ }@var{event}) 
When beans are removed from a @code{BeanContext},
 this method is called to fire the event.
@end deftypemethod
@deftypemethod BeanContextProxy {public BeanContextChild} getBeanContextProxy () 
Return the @code{BeanContextChild} associated with this
 @code{Object}.
@end deftypemethod
@deftypemethod BeanContextServiceAvailableEvent {public Iterator} getCurrentServiceSelectors () 
Get the current service selectors of the service class.
 This is identical to @code{getSourceAsBeanContextServices().getCurrentServiceSelectors(getServiceClass())}
@end deftypemethod
@deftypemethod BeanContextServiceAvailableEvent {public Class} getServiceClass () 
Get the newly available service class.
@end deftypemethod
@deftypemethod BeanContextServiceAvailableEvent {public BeanContextServices} getSourceAsBeanContextServices () 
Get the @code{BeanContextServices} through which the new service is available.
@end deftypemethod
@deftypemethod BeanContextServiceProviderBeanInfo {public BeanInfo} getServicesBeanInfo () 
Get @code{BeanInfo}s for all of the service classes of this @code{BeanInfoServiceProvider}.
@end deftypemethod
@deftypemethod BeanContextServiceProvider {public Object} getService (java.beans.beancontext.BeanContextServices@w{ }@var{services}, java.lang.Object@w{ }@var{requestor}, java.lang.Class@w{ }@var{serviceClass}, java.lang.Object@w{ }@var{serviceSelector}) 
Get a service.
 Called from @code{BeanContextServices.getService().
 



 If the requested service class is not available, or if this
 @code{BeanContextServiceProvider} chooses not honor the
 request for some reason, then this method will return
 @code{null}.
 



 This method may throw unchecked exceptions, so watch out.
@end deftypemethod
@deftypemethod BeanContextServiceProvider {public void} releaseService (java.beans.beancontext.BeanContextServices@w{ }@var{services}, java.lang.Object@w{ }@var{requestor}, java.lang.Object@w{ }@var{service}) 
Release the service.
 



 Called by @code{BeanContextServices.releaseService()}.
 



 Most @code{BeanContextServiceProvider}s won't have to do
 anything here.
@end deftypemethod
@deftypemethod BeanContextServiceProvider {public Iterator} getCurrentServiceSelectors (java.beans.beancontext.BeanContextServices@w{ }@var{services}, java.lang.Class@w{ }@var{serviceClass}) 
Get a list of valid service selectors for the specified service class.
 This method is called from
 @code{BeanContextServices.getCurrentServiceSelectors()}.
 



 If the specified service class does not have a finite number of
 valid service selectors, it should return @code{null}.
 If it takes a general @code{Integer} parameter, for
 example, you may as well return @code{null} or the poor
 soul who called this method will be iterating all day.
 



 If it has no valid service selectors, it should still return an empty
 @code{Iterator}.
@end deftypemethod
@deftypemethod BeanContextServiceRevokedEvent {public Class} getServiceClass () 
Get the revoked service class.
@end deftypemethod
@deftypemethod BeanContextServiceRevokedEvent {public boolean} isServiceClass (java.lang.Class@w{ }@var{c}) 
Tell whether the revoked service class is the same as the specified class.
 Identical to @code{getServiceClass().equals(c)}.
@end deftypemethod
@deftypemethod BeanContextServiceRevokedEvent {public BeanContextServices} getSourceAsBeanContextServices () 
Get the @code{BeanContextServices} through which the service was available.
@end deftypemethod
@deftypemethod BeanContextServiceRevokedEvent {public boolean} isCurrentServiceInvalidNow () 
Tell whether current instances of the revoked service are usable or not.
 This is determined by whether the service was revoked
 immediately.
@end deftypemethod
@deftypemethod BeanContextServiceRevokedListener {public void} serviceRevoked (java.beans.beancontext.BeanContextServiceRevokedEvent@w{ }@var{event}) 
Called by @code{BeanContextServices.revokeService()} to indicate that a service has been revoked.
 If you have a reference to such a service, it should be
 discarded and may no longer function properly.
 @code{getService()} will no longer work on the specified
 service class after this event has been fired.
@end deftypemethod
@deftypemethod BeanContextServices {public boolean} addService (java.lang.Class@w{ }@var{serviceClass}, java.beans.beancontext.BeanContextServiceProvider@w{ }@var{provider}) 
Register a service to make it available to others.
 This class may refuse to add the service based on whatever
 information it can gather, including whether the service
 provider is trusted.
@end deftypemethod
@deftypemethod BeanContextServices {public void} revokeService (java.lang.Class@w{ }@var{serviceClass}, java.beans.beancontext.BeanContextServiceProvider@w{ }@var{provider}, boolean@w{ }@var{revokeNow}) 
Make it so that no one else can use this service.
 



 If @code{revokeNow} is @code{false}, the only
 effect of this method is to make all subsequent calls to
 @code{getService()} on this service class fail.
 



 If it is @code{true}, a message is also sent out to all
 listeners on the service and all references to it are released.
@end deftypemethod
@deftypemethod BeanContextServices {public void} releaseService (java.beans.beancontext.BeanContextChild@w{ }@var{requestorChild}, java.lang.Object@w{ }@var{requestor}, java.lang.Object@w{ }@var{service}) 
Release your copy of this service.
 



 If all copies of the service's class have been relinquished by
 the requestor, the @code{BeanContextServiceRevokedListener}
 previously registered by @code{getService()} will be
 unregistered.
@end deftypemethod
@deftypemethod BeanContextServices {public Object} getService (java.beans.beancontext.BeanContextChild@w{ }@var{requestorChild}, java.lang.Object@w{ }@var{requestor}, java.lang.Class@w{ }@var{serviceClass}, java.lang.Object@w{ }@var{serviceSelector}, java.beans.beancontext.BeanContextServiceRevokedListener@w{ }@var{listener}) 
Get a service from this @code{BeanContextServices}.
 



 The specified listener will be registered to receive a
 revocation notice for the specified serviceClass.  One
 notification per service class per requestor object will be
 sent.
 



 The listener will be unregistered when all services that were
 obtained by that requestor for that service class are released.
 



 If the requested service class is not available, or if this
 @code{BeanContextServices} object chooses not honor the
 request because the service class has been revoked or for some
 other reason, then this method will return @code{null}.
 



 This method may throw unchecked exceptions, so watch out.
@end deftypemethod
@deftypemethod BeanContextServices {public Iterator} getCurrentServiceClasses () 
Get a list of all service classes supported.
 



 This method must synchronize on
 @code{BeanContext.globalHierarchyLock}.
@end deftypemethod
@deftypemethod BeanContextServices {public Iterator} getCurrentServiceSelectors (java.lang.Class@w{ }@var{serviceClass}) 
Get a list of valid service selectors for the specified service class.
 



 If the specified service class does not have a finite number of
 valid service selectors, it should return @code{null}.
 If it takes a general @code{Integer} parameter, for
 example, you may as well return @code{null} or the poor
 soul who called this method will be iterating all day.
 



 If it has no valid service selectors, it should still return an empty
 @code{Iterator}.
@end deftypemethod
@deftypemethod BeanContextServices {public boolean} hasService (java.lang.Class@w{ }@var{serviceClass}) 
Tell whether the specified service class is available.
 Iff getService() could return a non-null value for the
 specified service, this method will return @code{true}.
@end deftypemethod
@deftypemethod BeanContextServices {public void} addBeanContextServicesListener (java.beans.beancontext.BeanContextServicesListener@w{ }@var{listener}) 
Add a listener on all adds and removes of services.
@end deftypemethod
@deftypemethod BeanContextServices {public void} removeBeanContextServicesListener (java.beans.beancontext.BeanContextServicesListener@w{ }@var{listener}) 
Remove a listener on all adds and removes of services.
@end deftypemethod
@deftypemethod BeanContextServicesListener {public void} serviceAvailable (java.beans.beancontext.BeanContextServiceAvailableEvent@w{ }@var{event}) 
Called by @code{BeanContextServices} whenever a service is made available.
@end deftypemethod