KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > core > TCConnectionManagerFactory


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.core;
5
6 import com.tc.exception.TCRuntimeException;
7 import com.tc.util.runtime.IOFlavor;
8
9 import java.lang.reflect.Constructor JavaDoc;
10
11 /**
12  * Factory class for creating ConnectionManger instances
13  *
14  * @author teck
15  */

16 public class TCConnectionManagerFactory {
17
18   private static TCConnectionManagerFactoryIF factory;
19
20   static {
21     Class JavaDoc clazz;
22     try {
23       if (IOFlavor.isNioAvailable()) {
24         clazz = Class.forName("com.tc.net.core.TCConnectionManagerJDK14Factory");
25       } else {
26         clazz = Class.forName("com.tc.net.core.TCConnectionManagerJDK13Factory");
27       }
28
29       Constructor JavaDoc cstr = clazz.getDeclaredConstructor(new Class JavaDoc[] {});
30       factory = (TCConnectionManagerFactoryIF) cstr.newInstance(new Object JavaDoc[] {});
31     } catch (Throwable JavaDoc t) {
32       throw new TCRuntimeException(t);
33     }
34   }
35
36   public TCConnectionManager getInstance() {
37     return factory.getInstance(null);
38   }
39
40   public TCConnectionManager getInstance(TCComm comm) {
41     return factory.getInstance(comm);
42   }
43 }
Popular Tags