1 23 24 28 package com.sun.enterprise.management.support; 29 30 31 import javax.management.ObjectName ; 32 33 import com.sun.appserv.management.util.misc.StringUtil; 34 import com.sun.appserv.management.util.jmx.JMXUtil; 35 36 38 public final class WebModuleSupport 39 { 40 private WebModuleSupport() {} 41 42 45 public static final String VIRTUAL_SERVER_PREFIX = "//"; 46 47 50 public static final String VIRTUAL_SERVER_DELIM = "/"; 51 52 public static boolean 53 isLegalVirtualServerName( final String candidate ) 54 { 55 return (! candidate.startsWith( VIRTUAL_SERVER_PREFIX ) ) && 56 ( candidate.indexOf( VIRTUAL_SERVER_DELIM ) < 0 ); 57 } 58 59 public static String 60 formCompositeName( 61 final String virtualServerName, 62 final String webModuleName ) 63 { 64 return VIRTUAL_SERVER_PREFIX + virtualServerName + VIRTUAL_SERVER_DELIM + webModuleName; 65 } 66 67 68 73 public static String 74 extractVirtualServerName( final String compositeName ) 75 { 76 if ( ! compositeName.startsWith( VIRTUAL_SERVER_PREFIX ) ) 77 { 78 throw new IllegalArgumentException ( compositeName ); 79 } 80 81 final String temp = 82 StringUtil.stripPrefix( compositeName, VIRTUAL_SERVER_PREFIX ); 83 final int delimIdx = temp.indexOf( VIRTUAL_SERVER_DELIM ); 84 if ( delimIdx < 0 ) 85 { 86 throw new IllegalArgumentException ( compositeName ); 87 } 88 89 final String virtualServerName = temp.substring( 0, delimIdx ); 90 91 return virtualServerName; 92 } 93 94 99 public static String 100 extractWebModuleName( final String compositeName ) 101 { 102 final String virtualServerName = extractVirtualServerName( compositeName ); 103 104 final String prefix = 105 VIRTUAL_SERVER_PREFIX + virtualServerName + VIRTUAL_SERVER_DELIM; 106 107 String name = compositeName.substring( prefix.length(), compositeName.length() ); 108 if ( name.length() == 0 ) 109 { 110 name = virtualServerName + ".default"; 111 } 112 113 return name; 114 } 115 116 public static String 117 getWebModuleName( final ObjectName oldObjectName ) 118 { 119 final String webModule = oldObjectName.getKeyProperty( "web-module" ); 120 final String standaloneWebModule = oldObjectName.getKeyProperty( "standalone-web-module" ); 121 122 String webModuleName = null; 123 if ( standaloneWebModule != null ) 124 { 125 webModuleName = extractWebModuleName( standaloneWebModule ); 126 } 127 else if ( webModule != null ) 128 { 129 webModuleName = extractWebModuleName( webModule ); 130 } 131 else 132 { 133 throw new IllegalArgumentException ( JMXUtil.toString( oldObjectName ) ); 134 } 135 136 return( webModuleName ); 137 } 138 139 140 public static final String JWS_APP_CLIENTS_WEB_MODULE_NAME = "//server/__JWSappclients"; 141 142 143 public static final String JWS_APP_CLIENTS_WEB_MODULE_MONITOR_NAME = "//server/sys"; 144 145 } 147 148 | Popular Tags |