001
014
015 package com.liferay.portal.kernel.nio.intraband.welder;
016
017 import com.liferay.portal.kernel.nio.intraband.welder.fifo.FIFOUtil;
018 import com.liferay.portal.kernel.nio.intraband.welder.fifo.FIFOWelder;
019 import com.liferay.portal.kernel.nio.intraband.welder.socket.SocketWelder;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.OSDetector;
022 import com.liferay.portal.kernel.util.PropsKeys;
023 import com.liferay.portal.kernel.util.Validator;
024
025
028 public class WelderFactoryUtil {
029
030 public static Welder createWelder() {
031 Class<? extends Welder> welderClass = getWelderClass();
032
033 try {
034 return welderClass.newInstance();
035 }
036 catch (Exception e) {
037 throw new RuntimeException(
038 "Unable to create Welder instance for class " + welderClass, e);
039 }
040 }
041
042 public static Class<? extends Welder> getWelderClass() {
043 if (Validator.isNotNull(_INTRABAND_WELDER_IMPL)) {
044 try {
045 return (Class<? extends Welder>)Class.forName(
046 _INTRABAND_WELDER_IMPL);
047 }
048 catch (ClassNotFoundException cnfe) {
049 throw new RuntimeException(
050 "Unable to load class with name " + _INTRABAND_WELDER_IMPL,
051 cnfe);
052 }
053 }
054 else {
055 if (!OSDetector.isWindows() && FIFOUtil.isFIFOSupported()) {
056 return FIFOWelder.class;
057 }
058 else {
059 return SocketWelder.class;
060 }
061 }
062 }
063
064 private static final String _INTRABAND_WELDER_IMPL = GetterUtil.getString(
065 System.getProperty(PropsKeys.INTRABAND_WELDER_IMPL));
066
067 }