1 23 24 29 30 package com.sun.cli.jmx.cmd; 31 32 import java.lang.reflect.Method ; 33 34 public final class CmdFactoryIniter 35 { 36 final CmdFactory mFactory; 37 38 public 39 CmdFactoryIniter( CmdFactory factory) 40 throws Exception  41 { 42 mFactory = factory; 43 } 44 45 public 46 CmdFactoryIniter( CmdFactory factory, final Class [] cmds ) 47 throws Exception  48 { 49 mFactory = factory; 50 init( cmds ); 51 } 52 53 54 public void 55 addMappings( Class theClass ) 56 throws Exception  57 { 58 final String [] names = CmdBase.getCmdNames( theClass ); 59 60 for( int i = 0; i < names.length; ++i ) 61 { 62 mFactory.addCmdMapping( names[ i ], theClass ); 63 } 64 } 65 66 public void 67 removeMappings( Class theClass ) 68 throws Exception  69 { 70 final String [] names = CmdBase.getCmdNames( theClass ); 71 72 for( int i = 0; i < names.length; ++i ) 73 { 74 mFactory.removeCmdMapping( names[ i ] ); 75 } 76 } 77 78 private void 79 init( final Class [] cmds ) 80 throws Exception  81 { 82 for( int i = 0; i < cmds.length; ++i ) 83 { 84 addMappings( cmds[ i ] ); 85 } 86 } 87 } 88 89 | Popular Tags |