FileDocCategorySizeDatePackage
ReconfigHelper.javaAPI DocGlassfish v2 API5304Fri May 04 22:33:46 BST 2007com.sun.enterprise.admin.server.core.channel

ReconfigHelper

public class ReconfigHelper extends Object
ReconfigHelper executes reconfig command in a sub-process, which triggers refresh within web container.

Fields Summary
private static boolean
reconfigEnabled
private static Class
j2eeRunnerClass
private static Method
reconfigMethod
private static final String
J2EE_RUNNER_CLASS
private static final String
RECONFIG_METHOD
private static final String
RECONFIG_ERROR
Constructors Summary
Methods Summary
static voidenableWebCoreReconfig()


        
              
        findReconfigMethod();
        if (reconfigMethod != null) {
            reconfigEnabled = true;
        }
    
private static voidfindReconfigMethod()

        j2eeRunnerClass = Class.forName(J2EE_RUNNER_CLASS);
        reconfigMethod = j2eeRunnerClass.getMethod(RECONFIG_METHOD, (Class[])null);
    
private static java.lang.String[]getReconfigCommand(java.lang.String instance)

        String pfx = AdminChannel.instanceRoot + File.separator + instance
                + File.separator;
        if (OS.isUnix()) {
            return new String[]{pfx + "reconfig"};
        } else if (OS.isWindows()) {
            return new String[]{pfx + "reconfig.bat"};
        } else {
            return null;
        }
    
private static intreconfig(java.lang.String instanceName)

        int retval = 0;
        String[] cmd = getReconfigCommand(instanceName);
        if (cmd != null) {
            ProcessExecutor pe = new ProcessExecutor(cmd);
            try {
                pe.execute();
            } catch (ExecException ee) {
                AdminChannel.debug(ee);
                retval = 1;
            }
        }
        return retval;
    
public static voidsendReconfigMessage(java.lang.String instanceName)
Send reconfigure message to specified instance

/*
        int ret = reconfig(instanceName);
        if (ret != 0) {
            AdminChannel.warn(RECONFIG_ERROR);
        }
*/
        if (reconfigEnabled) {
            try {
                reconfigMethod.invoke( null, (Object[])null);
            } catch (IllegalAccessException access) {
                AdminChannel.warn(RECONFIG_ERROR);
                AdminChannel.debug(access);
            } catch (IllegalArgumentException arg) {
                AdminChannel.warn(RECONFIG_ERROR);
                AdminChannel.debug(arg);
            } catch (InvocationTargetException ite) {
                AdminChannel.warn(RECONFIG_ERROR);
                AdminChannel.debug(ite.getTargetException());
                AdminChannel.debug(ite);
            }
        }