BEA Systems, Inc.

Type-Safe Access to BEA WebLogic Server 9.0 MBeans (Deprecated)


weblogic.management.utils
Class GenericBeanListener

java.lang.Object
  extended byweblogic.management.utils.GenericBeanListener
All Implemented Interfaces:
weblogic.descriptor.BeanUpdateListener, EventListener

public class GenericBeanListener
extends Object
implements weblogic.descriptor.BeanUpdateListener

This class should be used to translate getters on the descriptor beans to setters on managed objects. Setters/getters can be automatically hooked up whenever whenever they are of the form: 1. The getter for the property must be of the form: public get(); // or public boolean is(); // if the type of property is boolean 2. The setter for the property must be of the form: public void set() throws BeanUpdateFailedException; For example, if you have a property named Foo of type int, the descriptor bean would have to have: public int getFoo() and the managed object would have to have: public void setFoo(int newValue) throws BeanUpdateFailedException; Note that the BeanUpdateFailedException is optional. Use this if you want your setter to have a checked exception. Any exception thrown from the setter will cause the activate() call to fail, although all setters will be called in any case. The property to be set must be marked @dynamic true in the descriptor bean. If it is not marked @dynamic true in the descriptor bean, the setter will NOT be called on a dynamic change of the bean. However, the setter will still be called when GenericBeanListener.initialize() is called. Hence, it is useful to put all properties you want initialized and dynamically updated into the same table. Only the ones that are dynamic will be "set" by the GenericBeanListener on an update. 3. You can have an optional method starting with "val" followed by the property name, which throws BeanUpdateRejectedException. This method will be called during the prepare phase of the update, and allows the user to vote on whether or not the update should succeed. The form of the validator must be of the form: public void val() throws BeanUpdateRejectedException; For example, if you have a property named Foo of type int, the validator for that property would look like this: public void valFoo(int newValue) throws BeanUpdateRejectedException; The generic bean processor will get the changed property from the DescriptorBean passed in the consructor and call the setter of the same property on the managed object during the activate phase of the bean update event. The types for each item in the bean must be specified in the incoming hashMap that has as its key the name of the property and as its value the class of the type of property that should be used. Another ability of the GenericBeanListener is the ability to handle simple add and remove operations, but these are slightly more complex operations. For each property in the add/remove hash the following API must be present: void startAdd() throws BeanUpdateRejectedException void finishAdd(, boolean) throws BeanUpdateFailedException void startRemove() throws BeanUpdateRejectedException void finishRemove(, boolean) throws BeanUpdateFailedException So for example if you had a property named Foo of type FooBean you would need the following API in the managed object: void startAddFoo(FooBean toAdd) throws BeanUpdateRejectedException void finishAddFoo(FooBean toAdd, boolean isActivate) throws BeanUpdateFailedException void startRemoveFoo(FooBean toRemove) throws BeanUpdateRejectedException void finishRemoveFoo(FooBean toRemove, boolean isActivate) throws BeanUpdateFailedException The boolean in the finishAdd/finishRemove calls determine whether the addition should go ahead (activated - true) or not (rollback - false). Also note that in the remove case the toRemove object passed in both the start and finish are from the original bean tree. In the addition case the toAdd object passed in the start call is from the proposed tree, while the toAdd object passed in the finish call (assuming isActivate is true) is from the new merged tree, and hence can have subsequent BeanUpdateListeners registered on them. The user can always use the getCurrentEvent() API to get the current bean event being handled. Furthermore, a customizer can be added to the GenericBeanListener which allows the caller to get callbacks when events in the lifecycle of the update occur. The generic bean listener also has a facility for initializing your managed object, which will call all the defined setters on the managed object from values gotten from the descriptor bean.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe, Object paramManagedObject, Map paramPropertyMap)
           
GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe, Object paramManagedObject, Map paramPropertyMap, boolean paramRegister)
           
GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe, Object paramManagedObject, Map paramPropertyMap, Map paramAdditionMap)
           
GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe, Object paramManagedObject, Map paramPropertyMap, Map paramAdditionMap, boolean paramRegister)
          Most general constructor for the generic bean listener Note the hash maps have propertyName as the key and the class of the type of property as the value.
 
Method Summary
 void activateUpdate(weblogic.descriptor.BeanUpdateEvent event)
          Called when a descriptor update that includes an update to the source bean.
 void close()
          This should be called whenever a bean no longer wishes to be notified of updates
 weblogic.descriptor.BeanUpdateEvent getCurrentEvent()
          Sometimes it is useful to be able to get access to the complete current event.
 void initialize()
          This method runs down the entire list of getters/setters and invokes all of them.
 void initialize(boolean setAll)
          This method runs down the entire list of getters/setters and invokes all of them.
 void open()
          This will cause this generic bean listener to start listening for update events on its associated descriptor bean
 void prepareUpdate(weblogic.descriptor.BeanUpdateEvent event)
          Called when a proposed update includes an update to the source bean.
 void rollbackUpdate(weblogic.descriptor.BeanUpdateEvent event)
          Called when a prepared descriptor update that include changes to source is being rolled back.
 void setCustomizer(BeanListenerCustomizer paramCustomizer)
          Sets the customizer for this generic bean listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericBeanListener

public GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe,
                           Object paramManagedObject,
                           Map paramPropertyMap)

GenericBeanListener

public GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe,
                           Object paramManagedObject,
                           Map paramPropertyMap,
                           boolean paramRegister)

GenericBeanListener

public GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe,
                           Object paramManagedObject,
                           Map paramPropertyMap,
                           Map paramAdditionMap)

GenericBeanListener

public GenericBeanListener(weblogic.descriptor.DescriptorBean paramListenToMe,
                           Object paramManagedObject,
                           Map paramPropertyMap,
                           Map paramAdditionMap,
                           boolean paramRegister)
Most general constructor for the generic bean listener Note the hash maps have propertyName as the key and the class of the type of property as the value. For example, if I had a property named Foo of type int, the following would be put into the hashmap: map.put("Foo", int.class);

Throws:
AssertionError - if the getters or setters corresponding to the maps passed in cannot be found on the bean or on the managed object
Method Detail

activateUpdate

public void activateUpdate(weblogic.descriptor.BeanUpdateEvent event)
                    throws weblogic.descriptor.BeanUpdateFailedException
Called when a descriptor update that includes an update to the source bean.

Specified by:
activateUpdate in interface weblogic.descriptor.BeanUpdateListener
Parameters:
event - - a description of the changes to the target bean
Throws:
weblogic.descriptor.BeanUpdateFailedException

close

public void close()
This should be called whenever a bean no longer wishes to be notified of updates


getCurrentEvent

public weblogic.descriptor.BeanUpdateEvent getCurrentEvent()
Sometimes it is useful to be able to get access to the complete current event. This will return the currentEvent being processes, or null if no event is currently underway


initialize

public void initialize()
                throws ManagementException
This method runs down the entire list of getters/setters and invokes all of them. It is meant to be run once at initialization time in order to get all of the values from the Bean into the managed object. This method will call all the defined setters, regardless of whether or not they were set on the descriptor bean

Throws:
ManagementException - if some error occurs with any one of the gets or sets

initialize

public void initialize(boolean setAll)
                throws ManagementException
This method runs down the entire list of getters/setters and invokes all of them. It is meant to be run once at initialization time in order to get all of the values from the Bean into the managed object

Parameters:
setAll - If true all the setters will be called even if the attribute was not explicitly set. If false, only those attributes that were explicitly set on the descriptor bean will have their setters called.
Throws:
ManagementException - if some error occurs with any one of the gets or sets

open

public void open()
This will cause this generic bean listener to start listening for update events on its associated descriptor bean


prepareUpdate

public void prepareUpdate(weblogic.descriptor.BeanUpdateEvent event)
                   throws weblogic.descriptor.BeanUpdateRejectedException
Called when a proposed update includes an update to the source bean. The implementation should examine the proposed update and either accept it (by returning) or reject it (by throwing a BeanUpdateRejectedException). If the listener rejects the update, the entire descriptor update will be aborted.

Specified by:
prepareUpdate in interface weblogic.descriptor.BeanUpdateListener
Parameters:
event - - description of proposed update to bean
Throws:
weblogic.descriptor.BeanUpdateRejectedException - to reject the update.

rollbackUpdate

public void rollbackUpdate(weblogic.descriptor.BeanUpdateEvent event)
Called when a prepared descriptor update that include changes to source is being rolled back.

Specified by:
rollbackUpdate in interface weblogic.descriptor.BeanUpdateListener
Parameters:
event - - a description of the proposed changes to the target bean that are being rolled back.

setCustomizer

public void setCustomizer(BeanListenerCustomizer paramCustomizer)
Sets the customizer for this generic bean listener. The customizer allows for callbacks when interesting events in the life of an update occur.

Parameters:
paramCustomizer - The customizer to use for this generic bean listener

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs90
Copyright 2005 BEA Systems Inc.