001
014
015 package com.liferay.portal.osgi;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019
020 import org.osgi.framework.Bundle;
021 import org.osgi.framework.BundleEvent;
022
023
026 public class BundleListener implements org.osgi.framework.BundleListener {
027
028 public void bundleChanged(BundleEvent bundleEvent) {
029 try {
030 int type = bundleEvent.getType();
031
032 Bundle bundle = bundleEvent.getBundle();
033
034 Log log = LogFactoryUtil.getLog(bundle.getSymbolicName());
035
036 if (!log.isInfoEnabled()) {
037 return;
038 }
039
040 if (type == BundleEvent.INSTALLED) {
041 log.info("[INSTALLED]");
042 }
043 else if (type == BundleEvent.LAZY_ACTIVATION) {
044 log.info("[LAZY_ACTIVATION]");
045 }
046 else if (type == BundleEvent.RESOLVED) {
047 log.info("[RESOLVED]");
048 }
049 else if (type == BundleEvent.STARTED) {
050 log.info("[STARTED]");
051 }
052 else if (type == BundleEvent.STARTING) {
053 log.info("[STARTING]");
054 }
055 else if (type == BundleEvent.STOPPED) {
056 log.info("[STOPPED]");
057 }
058 else if (type == BundleEvent.STOPPING) {
059 log.info("[STOPPING]");
060 }
061 else if (type == BundleEvent.UNINSTALLED) {
062 log.info("[UNINSTALLED]");
063 }
064 else if (type == BundleEvent.UNRESOLVED) {
065 log.info("[UNRESOLVED]");
066 }
067 else if (type == BundleEvent.UPDATED) {
068 log.info("[UPDATED]");
069 }
070 }
071 catch (Exception e) {
072 _log.error(e, e);
073 }
074 }
075
076 private static Log _log = LogFactoryUtil.getLog(BundleListener.class);
077
078 }