FileDocCategorySizeDatePackage
SunConfigBean.javaAPI DocGlassfish v2 API10207Fri May 04 22:34:30 BST 2007com.sun.enterprise.deployapi.config

SunConfigBean

public abstract class SunConfigBean extends Object implements javax.enterprise.deploy.model.XpathListener, javax.enterprise.deploy.spi.DConfigBean
Superclass for all the ConfigBeans. ConfigBeans are organized with a parent-child relationship. The parent defines xPaths and their mapping to child beans and return this mapping from the getXPathToBeanMapping method. Each bean is associated with a DOL descriptor (virtual field for this class) accessible through the getDescriptor() call.
author
Jerome Dochez

Fields Summary
private SunConfigBean
parent
protected javax.enterprise.deploy.model.DDBean
ddBean
protected PropertyChangeSupport
propertyChange
protected static final com.sun.enterprise.util.LocalStringManagerImpl
localStrings
Constructors Summary
Methods Summary
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener)
Register a property listener for this bean.

param
pcl PropertyChangeListener to add

    
public static java.lang.StringextractTextFromXML(java.lang.String key, java.lang.String xmlFragment)
Convenience method extract node value from the passed xml fragment.

param
key the xml tag name
param
xml fragment to extract the tag value
return
the xml tag value

       // should we use a parser... seems heavy, we'll see if string parsing is enough
        
       // pass opening tag
       String openingTag = "<" + key + ">";
       xmlFragment = xmlFragment.substring(xmlFragment.indexOf(openingTag)+openingTag.length());
       return xmlFragment.substring(0, xmlFragment.indexOf("</" + key + ">"));       
    
public voidfireXpathEvent(javax.enterprise.deploy.model.XpathEvent xpe)
Notification of change from the standard DDBean

param
the change event

        if (getParent()!=null) {
            getParent().fireXpathEvent(xpe);
            return;
        }        
    
public javax.enterprise.deploy.spi.DConfigBeangetDConfigBean(javax.enterprise.deploy.model.DDBean bean)
Return the JavaBean containing the server-specific deployment configuration information based upon the XML data provided by the DDBean.

return
The DConfigBean to display the server-specific properties for the standard bean.
param
bean The DDBean containing the XML data to be evaluated.
throws
ConfigurationException reports errors in generating a configuration bean. This DDBean is considered undeployable to this server until this exception is resolved. A suitably descriptive message is required so the user can diagnose the error.

    
                                                                                                                                                                 
        
                 
                   
        Map mapping = getXPathToBeanMapping();
        if (mapping==null) {
            return null;
        }
        if (mapping.containsKey(bean.getXpath())) {
            Class c = (Class) mapping.get(bean.getXpath());
            try {
                Object o = c.newInstance();
                if (o instanceof SunConfigBean) {
                    SunConfigBean child = (SunConfigBean) o;
                    child.setParent(this);
                    child.setDDBean(bean);
                    return child;
                } 
            } catch(Exception e) {
                e.printStackTrace();
                throw new ConfigurationException(e.getMessage());
            }
            
        } 
        return null;
    
protected javax.enterprise.deploy.spi.DConfigBeanRootgetDConfigBeanRoot()

return
the ConfigBeanRoot for this config bean

        if (parent!=null) {
            return parent.getDConfigBeanRoot();
        } 
        return null;
    
public javax.enterprise.deploy.model.DDBeangetDDBean()
Return the JavaBean containing the deployment descriptor XML text associated with this DConfigBean.

return
The bean class containing the XML text for this DConfigBean.

        return ddBean;
    
public abstract java.lang.ObjectgetDescriptor()

return
the associated DOL Descriptor for this config beans

public com.sun.enterprise.deployapi.config.SunConfigBeangetParent()

        return parent;
    
protected abstract java.util.MapgetXPathToBeanMapping()

return
the mapping from xpaths to child config beans where the map keys are the xpaths and the values are the class object for the child config beans

public java.lang.String[]getXpaths()
Return a list of XPaths designating the deployment descriptor information this DConfigBean requires. A given server vendor will need to specify some server-specific information. Each String returned by this method is an XPath describing a certain portion of the standard deployment descriptor for which there is corresponding server-specific configuration.

return
a list of XPath Strings representing XML data to be retrieved or 'null' if there are none.

        Map mapping = getXPathToBeanMapping();
        if (mapping==null) {
            return null;
        }
        
        Set keys = mapping.keySet();        
        String[] xPaths = new String[keys.size()];
        int i=0;
        for (Iterator itr=keys.iterator(); itr.hasNext();) {
            String s = (String) itr.next();
            xPaths[i++]=s;
        }
        return xPaths;
    
public voidnotifyDDChange(javax.enterprise.deploy.model.XpathEvent xpathEvent)
A notification that the DDBean provided in the event has changed and this bean or its child beans need to reevaluate themselves.

param
event an event containing a reference to the DDBean which has changed.

    
protected abstract voidprocess()
evaluate a standard bean

public voidremoveDConfigBean(javax.enterprise.deploy.spi.DConfigBean dConfigBean)
Remove a child DConfigBean from this bean.

param
bean The child DConfigBean to be removed.
throws
BeanNotFoundException the bean provided is not in the child list of this bean.

    
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener propertyChangeListener)
Unregister a property listener for this bean.

param
pcl Listener to remove.

    
protected voidsetDDBean(javax.enterprise.deploy.model.DDBean ddBean)
we are being set a new DDBean, we need to reevaluate ourself.

param
DDBean is the new standard DDBean container

        this.ddBean = ddBean;
        process();
    
protected voidsetParent(com.sun.enterprise.deployapi.config.SunConfigBean parent)

        this.parent = parent;
    
public java.lang.StringtoString()

return
a meaningful string about myself

        String s = "DConfigBean";
        s = s + "\nDConfigBeanRoot = " + getDConfigBeanRoot();
        s = s + "\nParent = " + parent;
        s = s + "\nXPath = " + ddBean.getXpath();
        return s;