1 26 27 package com.opensugar.cube; 28 29 import org.osgi.framework.BundleListener; 30 import org.osgi.framework.SynchronousBundleListener; 31 32 import java.util.Enumeration; 33 import java.util.Vector; 34 35 public class BundleListeners extends ListenerSet { 36 37 public SynchronousBundleListener[] getSynchronousBundleListeners() { 38 Enumeration enum = getAllListeners(); 39 Vector listeners = new Vector(); 40 while ( enum.hasMoreElements() ) { 41 Object listener = enum.nextElement(); 42 if ( listener instanceof SynchronousBundleListener ) { 43 listeners.addElement( listener ); 44 } 45 } 46 SynchronousBundleListener[] ret = new SynchronousBundleListener[ listeners.size() ]; 47 listeners.copyInto( ret ); 48 return ret; 49 } 50 51 public BundleListener[] getNonSynchronousBundleListeners() { 52 Enumeration enum = getAllListeners(); 53 Vector listeners = new Vector(); 54 while ( enum.hasMoreElements() ) { 55 Object listener = enum.nextElement(); 56 if ( !( listener instanceof SynchronousBundleListener ) ) { 57 listeners.addElement( listener ); 58 } 59 } 60 BundleListener[] ret = new BundleListener[ listeners.size() ]; 61 listeners.copyInto( ret ); 62 return ret; 63 } 64 65 } | Popular Tags |