1 23 package com.sun.enterprise.management.support; 24 25 import java.util.Properties ; 26 27 import javax.management.ObjectName ; 28 29 import com.sun.appserv.management.util.misc.StringUtil; 30 import com.sun.appserv.management.util.misc.MapUtil; 31 32 33 import com.sun.appserv.server.LifecycleListener; 34 import com.sun.appserv.server.LifecycleEvent; 35 import static com.sun.appserv.server.LifecycleEvent.*; 36 import com.sun.appserv.server.LifecycleEventContext; 37 import com.sun.appserv.server.ServerLifecycleException; 38 39 40 42 public final class AMXLifecycleModule implements LifecycleListener 43 { 44 private final String NEWLINE; 45 46 public 47 AMXLifecycleModule() 48 { 49 NEWLINE = System.getProperty( "line.separator" ); 50 } 51 52 private void 53 init( 54 final LifecycleEventContext context, 55 final Properties props ) 56 { 57 context.log( "AMXLifecycleModule: init" ); 58 } 59 60 private void 61 startup( 62 final LifecycleEventContext context, 63 final Properties props ) 64 { 65 context.log( "AMXLifecycleModule: startup" ); 66 } 67 68 private void 69 ready( 70 final LifecycleEventContext context, 71 final Properties props ) 72 { 73 context.log( "AMXLifecycleModule: ready" ); 74 } 75 76 private void 77 shutdown( 78 final LifecycleEventContext context, 79 final Properties props ) 80 { 81 context.log( "AMXLifecycleModule: shutdown" ); 82 } 83 84 private void 85 terminate( 86 final LifecycleEventContext context, 87 final Properties props ) 88 { 89 context.log( "AMXLifecycleModule: terminate" ); 90 } 91 92 private void 93 dumpInfo( 94 final int eventType, 95 final LifecycleEventContext context, 96 final Properties props ) 97 { 98 final String msg = "AMXLifecycleModule: " + eventType + NEWLINE + 99 "InstallRoot: " + context.getInstallRoot() + NEWLINE + 100 "InstanceName: " + context.getInstanceName() + NEWLINE + 101 "CmdLineArgs: " + StringUtil.toString( " ", (Object [])context.getCmdLineArgs() ) + NEWLINE + 102 "Properties: " + NEWLINE + 103 MapUtil.toString( props, NEWLINE ) + NEWLINE; 104 105 context.log( msg ); 106 107 } 108 109 110 public void 111 handleEvent(LifecycleEvent event) 112 throws ServerLifecycleException 113 { 114 final int type = event.getEventType(); 115 116 final Properties props = (Properties )event.getData(); 117 final LifecycleEventContext context = event.getLifecycleEventContext(); 118 119 dumpInfo( type, context, props ); 120 121 if ( type == INIT_EVENT ) 122 { 123 init( context, props ); 124 } 125 else if ( type == STARTUP_EVENT ) 126 { 127 startup( context, props ); 128 } 129 else if ( type == READY_EVENT ) 130 { 131 ready( context, props ); 132 } 133 else if ( type == SHUTDOWN_EVENT ) 134 { 135 shutdown( context, props ); 136 } 137 else if ( type == TERMINATION_EVENT ) 138 { 139 terminate( context, props ); 140 } 141 else 142 { 143 throw new IllegalArgumentException ( "eventType: " + type ); 144 } 145 } 146 } 147 148 149 150 151 152 153 154 155 | Popular Tags |