01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.net.groups;
06:
07: import com.tc.util.Assert;
08: import com.tc.util.runtime.Vm;
09:
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()
18: throws GroupException {
19: // Using reflection to avoid weird 1.4 / 1.5 project dependency issues !!
20: if (Vm.isJDK15Compliant()) {
21: return createTribesGroupManager();
22: } else {
23: return new SingleNodeGroupManager();
24: }
25: }
26:
27: private static GroupManager createTribesGroupManager()
28: throws GroupException {
29: initLoggerForJuli();
30: try {
31: Class clazz = Class
32: .forName("com.tc.net.groups.TribesGroupManager");
33: Constructor constructor = clazz
34: .getConstructor(new Class[0]);
35: return (GroupManager) constructor
36: .newInstance(new Object[0]);
37: } catch (Exception e) {
38: throw new GroupException(e);
39: }
40: }
41:
42: private static void initLoggerForJuli() {
43: System.setProperty("java.util.logging.config.class",
44: LogConfig.class.getName());
45: }
46:
47: public static final class LogConfig {
48: public LogConfig() throws SecurityException, IOException {
49: InputStream in = GroupManagerFactory.class
50: .getResourceAsStream("/com/tc/logging/juli.properties");
51: Assert.assertNotNull(in);
52: LogManager.getLogManager().readConfiguration(in);
53: }
54: }
55:
56: }
|