1 7 package org.jboss.test.security.test.opends; 8 9 import java.net.URL ; 10 import java.security.AccessController ; 11 import java.security.PrivilegedAction ; 12 13 import org.jboss.system.ServiceMBeanSupport; 14 import org.opends.server.core.DirectoryServer; 15 16 17 23 public class OpenDSService extends ServiceMBeanSupport 24 { 25 public static String objectName = "jboss.test:service=opends"; 26 27 private String newline = (String ) 28 AccessController.doPrivileged(new GetSystemPropertyAction("line.separator")); 29 30 31 35 public String printDiagnostics() 36 { 37 StringBuilder sb = new StringBuilder (); 38 sb.append("Maximum concurrent client connections allowed:"); 39 sb.append(DirectoryServer.getMaxAllowedConnections()); 40 sb.append(newline).append("# of client connections currently established:"); 41 sb.append(DirectoryServer.getCurrentConnections()); 42 return sb.toString(); 43 } 44 45 48 public void restart() 49 { 50 DirectoryServer.restart(getClass().getName(), "DS restart"); 51 } 52 53 protected void startService() throws Exception 54 { 55 super.startService(); 56 57 String confLoc = (String )AccessController.doPrivileged( 59 new GetSystemPropertyAction("jboss.server.config.url")); 60 61 65 ClassLoader tcl = Thread.currentThread().getContextClassLoader(); 66 URL ldif = tcl.getResource("opends/config/config.ldif"); 67 log.debug("config ldif="+ldif); 68 69 String [] strArr = new String [] {"--configClass", 70 "org.opends.server.config.ConfigFileHandler", 71 "--configFile", 72 ldif.getPath()}; 73 DirectoryServer.main(strArr); 75 } 76 77 protected void stopService() throws Exception 78 { 79 log.debug("Asking DS to shutdown"); 80 DirectoryServer.shutDown(getClass().getName(), "Shut down DS"); 81 } 82 83 84 91 public class GetSystemPropertyAction implements PrivilegedAction 92 { 93 private String property; 94 95 public GetSystemPropertyAction(String prop) 96 { 97 this.property = prop; 98 } 99 100 public Object run() 101 { 102 return System.getProperty(property); 103 } 104 } 105 } | Popular Tags |