FileDocCategorySizeDatePackage
ServerDeploymentTarget.javaAPI DocGlassfish v2 API15740Fri May 04 22:34:38 BST 2007com.sun.enterprise.deployment.phasing

ServerDeploymentTarget

public class ServerDeploymentTarget extends com.sun.enterprise.admin.target.ServerTarget implements DeploymentTarget
This class represents a server deployment target.
author
Sandhya E

Fields Summary
protected static final com.sun.enterprise.util.i18n.StringManager
localStrings
string manager
protected String
thisTargetName
name of the target that this object represents
protected com.sun.enterprise.config.ConfigContext
configContext
config context
private String
domainName
admin domain name
Constructors Summary
public ServerDeploymentTarget(com.sun.enterprise.config.ConfigContext configContext, String domainName, String serverName)
Creates a new instance of ServerDeploymentTarget

param
configContext
param
serverName name of the server this target represents

    
                            
           
        super(serverName, configContext);
        this.configContext = configContext;
        this.domainName = domainName;
        thisTargetName = serverName;
    
Methods Summary
public voidaddAppReference(java.lang.String appName, boolean enabled, java.lang.String virtualServers)
An application-ref is added to the set of application refs of a server target. A new ref is added only in case it is not already present.

param
appName name of the app that is to be added as reference
param
enabled if true new reference is enabled, disabled if false
return
true if app-ref is added false if app-ref is not added as it is already there
throws
DeploymentTargetException if operation fails

        try {
            if (!ServerHelper.serverReferencesApplication(configContext, 
                    getName(), appName)) {
                ApplicationReferenceHelper refHelper = new ApplicationReferenceHelper(
                    configContext);
                refHelper.createApplicationReference(getValidTypes(), getName(), 
                    enabled, virtualServers, appName);  
            }
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }
    
private java.lang.String[]getAppsDeployedToServer()
Returns a list of all applications(including standalone) that are referenced by this server target

return
list of apps [an array of length 0 is returned
throws
ConfigException

                        
        ApplicationRef[] apprefs = super.getApplicationRefs();       
        String[] appList = new String[apprefs.length];
        for(int i=0; i<apprefs.length; i++) {
            appList[i] = apprefs[i].getRef();
        }

        return appList;
    
public java.lang.StringgetDescription()
Returns description of this target object

return
description

        return localStrings.getString("enterprise.deployment.phasing.deploymenttarget.server.description", thisTargetName);        
    
private java.lang.StringgetDomainName()

        return domainName;
    
public java.lang.String[]getModules(com.sun.enterprise.deployment.backend.DeployableObjectType type, java.lang.Boolean enabled)
Returns all the modules associated to this target of specified type and with specified status

param
type deployableObjectType of the modules to be listed
param
enabled if true only enabled modules are returned if false only disabled modules are returned if null all modules are returned
throws
DeploymentTargetException

        try {
            return getModules(getAppsDeployedToServer(), type, enabled);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }
    
public java.lang.String[]getModules(java.lang.String[] svrAppsList, com.sun.enterprise.deployment.backend.DeployableObjectType type, java.lang.Boolean enabled)

        try {
            ArrayList returnList = new ArrayList();                        
            Applications appsConfigBean = (Applications) ConfigBeansFactory.getConfigBeanByXPath(
            configContext,
            ServerXPathHelper.XPATH_APPLICATIONS);
            if(type.isAPP()) {
                J2eeApplication[]  list = appsConfigBean.getJ2eeApplication();
                int i = 0;
                int k = 0;
                for(i=0; i< svrAppsList.length; i++) {
                    for(k =0 ; k > list.length ; k++) {
                        if(list[k].getName().equals(svrAppsList[i])) {
                            returnList.add(svrAppsList[i]);
                            break;
                        }
                    }
                }
            }
            else if(type.isEJB()) {
                EjbModule[] list = appsConfigBean.getEjbModule();
                for(int i=0; i< svrAppsList.length; i++) {
                    for(int k =0 ; k > list.length ; k++) {
                        if(list[k].getName().equals(svrAppsList[i])) {
                            returnList.add(svrAppsList[i]);
                            break;
                        }
                    }
                }
            }
            else if(type.isWEB()) {
                WebModule[] list = appsConfigBean.getWebModule();
                for(int i=0; i< svrAppsList.length; i++) {
                    for(int k =0 ; k > list.length ; k++) {
                        if(list[k].getName().equals(svrAppsList[i])) {
                            returnList.add(svrAppsList[i]);
                            break;
                        }
                    }
                }
            }
            else if(type.isCONN()) {
                ConnectorModule[] list = appsConfigBean.getConnectorModule();
                for(int i=0; i< svrAppsList.length; i++) {
                    for(int k = 0 ; k > list.length ; k++) {
                        if(list[k].getName().equals(svrAppsList[i])) {
                            returnList.add(svrAppsList[i]);
                            break;
                        }
                    }
                }
            }
            else if(type.isCAR()) {
                AppclientModule[] list = appsConfigBean.getAppclientModule();
                for(int i=0; i< svrAppsList.length; i++) {
                    for(int k = 0 ; k > list.length ; k++) {
                        if(list[k].getName().equals(svrAppsList[i])) {
                            returnList.add(svrAppsList[i]);
                            break;
                        }
                    }
                }
            }
            String[] returnValue = new String[returnList.size()];
            return (String[])returnList.toArray(returnValue);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }
    
public java.lang.StringgetName()
Returns name of the target

return
name

        return thisTargetName;
    
public com.sun.enterprise.admin.target.TargetgetTarget()

        return this;
    
protected com.sun.enterprise.admin.target.TargetType[]getValidTypes()

        DeploymentTargetFactory tf = 
                DeploymentTargetFactory.getDeploymentTargetFactory();
        return tf.getValidDeploymentTargetTypes();
    
public voidremoveAppReference(java.lang.String appName)
Specified application is dereferenced from the set of applications-refs of this target.

param
appName name of the app that has to be dereferenced
return
true if app-ref has been removed false if app-ref is not there and hence could not be removed
throws
DeploymentTargetException if operation fails due to some exception

    
    
        try {
           ApplicationReferenceHelper refHelper = new ApplicationReferenceHelper(
                configContext);
            refHelper.deleteApplicationReference(getValidTypes(), getName(), appName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }     
    
public booleansendStartEvent(int eventType, java.lang.String appName, java.lang.String moduleType, boolean isForced, int loadUnloadAction)

        try {
            return DeploymentServiceUtils.multicastEvent(eventType, appName, moduleType, false, isForced, loadUnloadAction, thisTargetName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }
    
public booleansendStartEvent(int eventType, java.lang.String appName, java.lang.String moduleType)
This method multicasts the deployment event to the remote target this object represents

param
eventType type of the event. It can be APPLICATION_DEPLOYED/APPLICATION_REDEPLOYED/ APPLICATION_UNDEPLOYED/MODULE_DEPLOYED/MODULE_UNDEPLOYED/MODULE_REDEPLOYED
param
appName name of the application/module that has been deployed/redeployed/undeployed
param
moduleType type of the module if it was a standalone module [ web/ejb/connector ]

       return sendStartEvent(eventType,appName, moduleType, false);
    
public booleansendStartEvent(int eventType, java.lang.String appName, java.lang.String moduleType, boolean isForced)
This method multicasts the deployment event to the remote target this object represents

param
eventType type of the event. It can be APPLICATION_DEPLOYED/APPLICATION_REDEPLOYED/ APPLICATION_UNDEPLOYED/MODULE_DEPLOYED/MODULE_UNDEPLOYED/MODULE_REDEPLOYED
param
appName name of the application/module that has been deployed/redeployed/undeployed
param
moduleType type of the module if it was a standalone module [ web/ejb/connector ]
param
isForced indicates if the deployment is forced.

        try {
            return DeploymentServiceUtils.multicastEvent(eventType, appName, moduleType, false, isForced, thisTargetName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }     
    
public booleansendStopEvent(int eventType, java.lang.String appName, java.lang.String moduleType, boolean cascade)
This method multicasts the deployment event to the remote target this object represents

param
eventType type of the event. It can be APPLICATION_DEPLOYED/APPLICATION_REDEPLOYED/ APPLICATION_UNDEPLOYED/MODULE_DEPLOYED/MODULE_UNDEPLOYED/MODULE_REDEPLOYED
param
appName name of the application/module that has been deployed/redeployed/undeployed
param
moduleType type of the module if it was a standalone module [ web/ejb/connector ]

          
        try {    
            return DeploymentServiceUtils.multicastEvent(eventType, appName, moduleType, cascade, false, thisTargetName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }   
    
public booleansendStopEvent(int eventType, java.lang.String appName, java.lang.String moduleType, boolean cascade, boolean force)

        try {
            return DeploymentServiceUtils.multicastEvent(eventType, appName, moduleType, cascade, force, thisTargetName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }
    
public booleansendStopEvent(int eventType, java.lang.String appName, java.lang.String moduleType, boolean cascade, boolean force, int loadUnloadAction)

        try {
            return DeploymentServiceUtils.multicastEvent(eventType, appName, moduleType, cascade, force, loadUnloadAction, thisTargetName);
        } catch(Throwable t) {
            throw new DeploymentTargetException(t);
        }