larryi 02/03/14 03:33:31 Modified: proposals/PasswordPrompter/WEB-INF/classes/org/apache/tomcat/modules/config PasswordPrompter.java Log: Update to handle context local interceptors. Include the context name in the prompt for context local interceptors. Revision Changes Path 1.3 +36 -12 jakarta-tomcat/proposals/PasswordPrompter/WEB-INF/classes/org/apache/tomcat/modules/config/PasswordPrompter.java Index: PasswordPrompter.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/proposals/PasswordPrompter/WEB-INF/classes/org/apache/tomcat/modules/config/PasswordPrompter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PasswordPrompter.java 12 Mar 2002 04:08:30 -0000 1.2 +++ PasswordPrompter.java 14 Mar 2002 11:33:31 -0000 1.3 @@ -102,7 +102,7 @@ * * @author Larry Isaacs * @author Christopher Cain - * @version $Revision: 1.2 $ $Date: 2002/03/12 04:08:30 $ + * @version $Revision: 1.3 $ $Date: 2002/03/14 11:33:31 $ */ public class PasswordPrompter extends BaseInterceptor { @@ -172,6 +172,19 @@ return MOD_VERSION; } + /** + * Perform the prompts if appropriate for any of the + * specified interceptors. + */ + public void doPrompts( Object[] modules, Context ctx ) { + for ( int idx = 0; idx < prompts.size(); idx++ ) { + UserPrompt p = + (UserPrompt)prompts.elementAt(idx); + // perform this prompt for any applicable modules in the array + p.prompt( modules, ctx, delay, scroll ); + } + } + // -------------------------------------------------------------- Callbacks /** @@ -211,7 +224,7 @@ // if time to prompt if ( cm.getState() != ContextManager.STATE_CONFIG ) { - BaseInterceptor[] modules; + Object[] modules; // if adding ourselves (i.e. the first call ) if ( i == this ) { @@ -225,18 +238,25 @@ // check all previously added modules modules = - cm.getContainer().getInterceptors( Container.H_engineInit ); + cm.getContainer().getInterceptors(); + // do prompts on these modules + doPrompts( modules, ctx ); + + // check local context modules + Enumeration enum = cm.getContexts(); + while (enum.hasMoreElements()) { + ctx = (Context)enum.nextElement(); + modules = ctx.getContainer().getHooks().getModules(); + if ( modules.length > 0 ) + doPrompts( modules, ctx ); + } } else { // check just the module being added modules = new BaseInterceptor[] { i }; + // do prompts on this module + doPrompts( modules, ctx ); } - for ( int idx = 0; idx < prompts.size(); idx++ ) { - UserPrompt p = - (UserPrompt)prompts.elementAt(idx); - // perform this prompt for any applicable modules in the array - p.prompt( modules, delay, scroll ); - } } } @@ -329,12 +349,12 @@ * methods succeed, the prompt is displayed and the response is * set on the module using the "set" method. */ - public void prompt( BaseInterceptor [] modules, int delay, int scroll ) { + public void prompt( Object [] modules, Context ctx, int delay, int scroll ) { if ( !valid ) return; for ( int i = 0; i < modules.length; i++ ) { - BaseInterceptor module = modules[i]; + BaseInterceptor module = (BaseInterceptor)modules[i]; if ( !moduleClass.isInstance( module ) ) { continue; } @@ -365,7 +385,11 @@ // go ahead with the prompting String response = null; try { - response = Prompter.promptForInput( prompt, scroll ); + String temp = prompt; + if ( ctx != null ) { + temp = "Context " + ctx.getName() + "\n" + prompt; + } + response = Prompter.promptForInput( temp, scroll ); setMethod.invokeSet( module, response ); } catch (IOException ioe) { logger.log( "IO problem with command line: " + ioe.toString() );
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>