org.osgi.util.tracker.BundleTrackerCustomizer Java Examples

The following examples show how to use org.osgi.util.tracker.BundleTrackerCustomizer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OsgiMessageInterpolator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public OsgiMessageInterpolator ( final BundleContext context )
{
    this.tracker = new BundleTracker<> ( context, Bundle.ACTIVE | Bundle.RESOLVED, new BundleTrackerCustomizer<Resolver> () {

        @Override
        public Resolver addingBundle ( final Bundle bundle, final BundleEvent event )
        {
            if ( bundle.getResource ( "META-INF/ValidationMessages.properties" ) != null )
            {
                return new Resolver ( bundle );
            }
            return null;
        }

        @Override
        public void modifiedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
        {
        }

        @Override
        public void removedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
        {
            resolver.dispose ();
        }
    } );
    this.tracker.open ();
}