com.ibm.wsspi.runtime.component
Class WsComponentImpl

java.lang.Object
  extended by com.ibm.wsspi.runtime.component.WsComponentImpl
All Implemented Interfaces:
WsComponent
Direct Known Subclasses:
WsContainer

public class WsComponentImpl
extends java.lang.Object
implements WsComponent

WsComponentImpl provides a default implementation of the WsComponent interface. Lifecycle methods are no-ops. Additionally, various convenience methods are provided.


Field Summary
protected  java.lang.String name
          Deprecated. This field will be private in a future release. It is protected for legacy reasons.
protected  java.lang.String state
          Deprecated. This field will be private in a future release. It is protected for legacy reasons.
 
Fields inherited from interface com.ibm.wsspi.runtime.component.WsComponent
DESTROYED, DESTROYING, ERROR, INITIALIZED, INITIALIZING, STARTED, STARTING, STATE, STOPPED, STOPPING
 
Constructor Summary
protected WsComponentImpl()
          The default constructor for a WsComponentImpl.
 
Method Summary
static void _setStartupThreadPool(com.ibm.ws.util.ThreadPool threadPool)
          NOTE: This method is not part of the official SPI and should not be invoked by general code.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener propertyChangeListener)
          Adds a property change listener to this component.
protected  void deregisterMBean(java.lang.Object obj)
          Deregisters the MBean associated with the given object.
protected  void deregisterMBean(java.lang.String id)
          Deregisters the MBean associated with the given ID.
protected  void deregisterMBeanViaQuery(java.lang.String query)
          Deregisters all MBeans identified by the given query string.
 void destroy()
          A lifecycle event.
protected  java.lang.String expandVariable(java.lang.String string)
          Expands all variables in the given string per the variable map service established for this runtime context.
protected  void firePropertyChange(java.beans.PropertyChangeEvent evt)
          Broadcast a PropertyChangeEvent to all listeners.
protected  java.lang.String getConfigId(java.lang.Object object)
          Gets the administrative configuration ID associated with the given object.
 java.lang.String getName()
          Returns the name of this component.
protected  java.beans.PropertyChangeSupport getPropertyChangeSupport()
          Provides access to the PropertyChangeSupport object.
 java.lang.String getState()
          Returns the current state of the component.
 void inhibitAsynchBehavior()
          NOTE: This method is not part of the official SPI and should not be invoked by general code.
 void initialize(java.lang.Object config)
          A lifecycle event invoked when the component is being initialized.
protected  void join()
          Blocks until all (accountable) tasks dispatched by runAsynchronousInitializer have completed.
protected  java.util.Set lookupMBeans(java.lang.String name)
          Looks up MBeans via the given query string.
protected  void registerMBean(java.lang.String type, com.ibm.websphere.management.RuntimeCollaborator collab, java.lang.String name, java.lang.String id, java.util.Properties props)
          Registers an MBean.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener propertyChangeListener)
          Removes a property change listener from this component.
protected  void runAsynchronousInitializer(AsynchronousInitializer initializer)
          Equivalent to runAsynchronousInitializer(initializer,true).
protected  void runAsynchronousInitializer(AsynchronousInitializer initializer, boolean joinFlag)
          Requests that the initializer be run on another thread.
static void setGlobalAsynchBehaviorInhibited(boolean b)
          NOTE: This method is not part of the official SPI and should not be invoked by general code.
protected  void setName(java.lang.String name)
          Sets the name of this component.
protected  void setState(java.lang.String newState)
          Updates the state of the component.
 void start()
          A lifecycle event indicating that the component should start.
 void stop()
          A lifecycle event indicating that the component should stop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Deprecated. This field will be private in a future release. It is protected for legacy reasons.

state

protected java.lang.String state
Deprecated. This field will be private in a future release. It is protected for legacy reasons.
Constructor Detail

WsComponentImpl

protected WsComponentImpl()
The default constructor for a WsComponentImpl.

Method Detail

initialize

public void initialize(java.lang.Object config)
                throws ComponentDisabledException,
                       ConfigurationWarning,
                       ConfigurationError
Description copied from interface: WsComponent
A lifecycle event invoked when the component is being initialized.

Specified by:
initialize in interface WsComponent
Parameters:
config - The configuration data for the component. The value may be null or some other object if no configuration data is present. Note that this argument may be removed.
Throws:
ComponentDisabledException - Thrown if the component considers itself to be disabled. No further lifecycle methods will be called by the framework.
ConfigurationWarning - Thrown if the component has encountered some non-fatal configuration problem. Server startup will generally continue.
ConfigurationError - The component has severe configuration problem and cannot allow the server startup to proceed. Note that this exception will halt server startup.
See Also:
WsComponent.initialize(Object)

destroy

public void destroy()
Description copied from interface: WsComponent
A lifecycle event. Invoked when the component is being destroyed. Final cleanup of resources should be done at this point. Components should not rely on the existence of other components during this phase, since they may have already been destroyed.

Specified by:
destroy in interface WsComponent
See Also:
WsComponent.destroy()

start

public void start()
           throws RuntimeError,
                  RuntimeWarning
Description copied from interface: WsComponent
A lifecycle event indicating that the component should start. It may be assumed that the components initialize() method has already been invoked.

Specified by:
start in interface WsComponent
Throws:
RuntimeError
RuntimeWarning
See Also:
WsComponent.start()

stop

public void stop()
Description copied from interface: WsComponent
A lifecycle event indicating that the component should stop.

Specified by:
stop in interface WsComponent
See Also:
WsComponent.stop()

_setStartupThreadPool

public static void _setStartupThreadPool(com.ibm.ws.util.ThreadPool threadPool)
NOTE: This method is not part of the official SPI and should not be invoked by general code.


setGlobalAsynchBehaviorInhibited

public static void setGlobalAsynchBehaviorInhibited(boolean b)
NOTE: This method is not part of the official SPI and should not be invoked by general code.


inhibitAsynchBehavior

public void inhibitAsynchBehavior()
NOTE: This method is not part of the official SPI and should not be invoked by general code.


runAsynchronousInitializer

protected final void runAsynchronousInitializer(AsynchronousInitializer initializer)
                                         throws WsRuntimeFwException
Equivalent to runAsynchronousInitializer(initializer,true).

Throws:
WsRuntimeFwException
See Also:
runAsynchronousInitializer(AsynchronousInitializer, boolean)

runAsynchronousInitializer

protected final void runAsynchronousInitializer(AsynchronousInitializer initializer,
                                                boolean joinFlag)
                                         throws WsRuntimeFwException
Requests that the initializer be run on another thread. The work is optionally accounted for in subsequent join() method calls. Note that this call is a hint, not a promise to dispatch the work onto another thread; it is possible that multi-threaded behavior is inhibited and therefore code may not assume true parallelism.

Parameters:
AsynchronousInitializer - initializer is the work to be done.
boolean - joinFlag indicates whether the work is to be accounted for in a join call.
Throws:
WsRuntimeFwException
See Also:
join()

join

protected final void join()
                   throws ConfigurationWarning,
                          ConfigurationError,
                          ComponentDisabledException,
                          RuntimeWarning,
                          RuntimeError
Blocks until all (accountable) tasks dispatched by runAsynchronousInitializer have completed. The highest priority exception from all such threads will be thrown.

Throws:
ConfigurationWarning
ConfigurationError
ComponentDisabledException
RuntimeWarning
RuntimeError
See Also:
runAsynchronousInitializer(AsynchronousInitializer, boolean)

getName

public java.lang.String getName()
Returns the name of this component.

Specified by:
getName in interface WsComponent

setName

protected void setName(java.lang.String name)
Sets the name of this component.

Parameters:
name -

getState

public java.lang.String getState()
Returns the current state of the component.

Specified by:
getState in interface WsComponent

setState

protected void setState(java.lang.String newState)
                 throws RuntimeError,
                        RuntimeWarning,
                        ConfigurationError,
                        ConfigurationWarning
Updates the state of the component. This method is intended to be invoked by the runtime framework and is not necessarily intended for general use.

Parameters:
newState -
Throws:
RuntimeError
RuntimeWarning
ConfigurationError
ConfigurationWarning

getPropertyChangeSupport

protected java.beans.PropertyChangeSupport getPropertyChangeSupport()
Provides access to the PropertyChangeSupport object.

Returns:

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener propertyChangeListener)
Adds a property change listener to this component.

Parameters:
propertyName -
propertyChangeListener -
See Also:
PropertyChangeListener

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener propertyChangeListener)
Removes a property change listener from this component.

Parameters:
propertyName -
propertyChangeListener -
See Also:
PropertyChangeListener

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent evt)
Broadcast a PropertyChangeEvent to all listeners.


expandVariable

protected java.lang.String expandVariable(java.lang.String string)
                                   throws java.lang.IllegalArgumentException
Expands all variables in the given string per the variable map service established for this runtime context. This is a convenience method for accessing the VariableMap service.

Parameters:
string - The string to be expanded.
Returns:
String The expanded string.
Throws:
java.lang.IllegalArgumentException
See Also:
com.ibm.ws.util.service.VariableMap#expand(java.lang.String)

getConfigId

protected java.lang.String getConfigId(java.lang.Object object)
Gets the administrative configuration ID associated with the given object. This is a convenience method and is equivalent to AdminServiceFactory.getMBeanFactory().getConfigId(obj)

Returns:
the confguration ID associated with the given object (or null if the Admin Service is not available).

registerMBean

protected void registerMBean(java.lang.String type,
                             com.ibm.websphere.management.RuntimeCollaborator collab,
                             java.lang.String name,
                             java.lang.String id,
                             java.util.Properties props)
Registers an MBean. This is a convenience function and is equivalent to:

AdminServiceFactory.getMBeanFactory.activateMBean(type,collab,id,null,props);

Parameters:
type - Specifies the MBean type.
collab - Specifies the collaborator object to be used as the MBean implementation.
name - The name of the MBean.
id - The ID of the MBean
props -

deregisterMBean

protected void deregisterMBean(java.lang.String id)
Deregisters the MBean associated with the given ID.

Parameters:
id - The ID of the MBean being deregistered.

deregisterMBean

protected void deregisterMBean(java.lang.Object obj)
Deregisters the MBean associated with the given object. This is equivalent to deregisterMBean(getConfigId(obj))


deregisterMBeanViaQuery

protected void deregisterMBeanViaQuery(java.lang.String query)
Deregisters all MBeans identified by the given query string.


lookupMBeans

protected java.util.Set lookupMBeans(java.lang.String name)
Looks up MBeans via the given query string.

Example:lookupMBeans("WebSphere:j2eeType=J2EEServer,*");

Parameters:
name - The query string.
Returns:
Set The set of MBeans meeting the query or possibly null.