001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.util.transport.MulticastTransport;
020
021 import java.lang.reflect.Field;
022
023
026 public class LicenseValidationTransportUtil {
027
028 public static void stopMulticastTransportThread() {
029 try {
030 ClassLoader classLoader = PortalClassLoaderUtil.getClassLoader();
031
032 Class licenseManagerClass = classLoader.loadClass(
033 "com.liferay.portal.license.LicenseManager");
034
035 Field[] fields = licenseManagerClass.getDeclaredFields();
036
037 for (Field field : fields) {
038 Class<?> type = field.getType();
039
040 String typeName = type.getName();
041
042 if (!typeName.equals(
043 "com.liferay.util.transport.MulticastTransport")) {
044
045 continue;
046 }
047
048 field.setAccessible(true);
049
050 try {
051 Object value = field.get(null);
052
053 MulticastTransport multicastTransport =
054 (MulticastTransport)value;
055
056 if (multicastTransport != null) {
057 multicastTransport.disconnect();
058 }
059 }
060 catch (IllegalAccessException iae) {
061 iae.printStackTrace();
062 }
063 finally {
064 field.setAccessible(false);
065 }
066 }
067 }
068 catch (ClassNotFoundException cnfe) {
069 if (_log.isDebugEnabled()) {
070 _log.debug(cnfe);
071 }
072 }
073 }
074
075 private static Log _log = LogFactoryUtil.getLog(
076 LicenseValidationTransportUtil.class);
077
078 }