1 4 package com.tc.net.core; 5 6 import com.tc.exception.TCInternalError; 7 import com.tc.util.runtime.IOFlavor; 8 9 import java.lang.reflect.Constructor ; 10 11 16 public class TCCommFactory { 17 18 private static TCCommFactoryIF factory; 19 20 static { 21 22 Class clazz; 23 try { 24 if (IOFlavor.isNioAvailable()) { 25 clazz = Class.forName("com.tc.net.core.TCCommFactoryJDK14"); 26 } else { 27 clazz = Class.forName("com.tc.net.core.TCCommFactoryJDK13"); 28 } 29 30 Constructor cstr = clazz.getDeclaredConstructor(new Class [] {}); 31 factory = (TCCommFactoryIF) cstr.newInstance(new Object [] {}); 32 } catch (Exception e) { 33 throw new TCInternalError(e); 34 } 35 } 36 37 43 public TCComm getInstance(boolean start) { 44 TCComm rv = factory.getInstance(); 45 46 if (start) { 47 rv.start(); 48 } 49 50 return rv; 51 } 52 53 59 public TCComm getInstance() { 60 return getInstance(true); 61 } 62 } | Popular Tags |