1 5 package com.tc.net.groups; 6 7 import com.tc.util.Assert; 8 import com.tc.util.runtime.Vm; 9 10 import java.io.IOException ; 11 import java.io.InputStream ; 12 import java.lang.reflect.Constructor ; 13 import java.util.logging.LogManager ; 14 15 public class GroupManagerFactory { 16 17 public static GroupManager createGroupManager() throws GroupException { 18 if (Vm.isJDK15Compliant()) { 20 return createTribesGroupManager(); 21 } else { 22 return new SingleNodeGroupManager(); 23 } 24 } 25 26 private static GroupManager createTribesGroupManager() throws GroupException { 27 initLoggerForJuli(); 28 try { 29 Class clazz = Class.forName("com.tc.net.groups.TribesGroupManager"); 30 Constructor constructor = clazz.getConstructor(new Class [0]); 31 return (GroupManager) constructor.newInstance(new Object [0]); 32 } catch (Exception e) { 33 throw new GroupException(e); 34 } 35 } 36 37 private static void initLoggerForJuli() { 38 System.setProperty("java.util.logging.config.class", LogConfig.class.getName()); 39 } 40 41 public static final class LogConfig { 42 public LogConfig() throws SecurityException , IOException { 43 InputStream in = GroupManagerFactory.class.getResourceAsStream("/com/tc/logging/juli.properties"); 44 Assert.assertNotNull(in); 45 LogManager.getLogManager().readConfiguration(in); 46 } 47 } 48 49 } 50 | Popular Tags |