Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012-2013 EclipseSource and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Holger Staudacher - initial API and implementation, ongoing development Dirk Lecluse - added tracking of Provider classes Frank Appel - specified Filter to exclude resources from publishing /
package com.eclipsesource.jaxrs.publisher.internal;
import static com.eclipsesource.jaxrs.publisher.ServiceProperties.PUBLISH;
import  org.osgi.framework.BundleContext;
import  org.osgi.framework.Filter;
import  org.osgi.framework.ServiceReference;
import  org.osgi.util.tracker.ServiceTracker;
public class ResourceTracker extends ServiceTracker<ObjectObject> {
  
  static final String ANY_SERVICE_FILTER = "(&(objectClass=*)(!(" +  + "=false)))";
  
  private final BundleContext context;
  private final JAXRSConnector connector;
  
  public ResourceTracker( BundleContext context, Filter filterJAXRSConnector connector ) {
    supercontextfilternull );
    this. = context;
    this. = connector;
  }
  
  public Object addingService( ServiceReference<Objectreference ) {
    Object service = .getService( reference );
    return delegateAddServicereferenceservice );
  }
  private Object delegateAddService( ServiceReference<ObjectreferenceObject service ) {
    Object result;
    ifisResourceservice ) ) {
      result = .addResourcereference );
    } else {
      result = super.addingService( reference );
    }
    return result;
  }
  public void removedService( ServiceReference<ObjectreferenceObject service ) {
    ifisResourceservice ) ) {
      .removeResourceservice );
    }
    .ungetService( reference );
  }
  
  public void modifiedService( ServiceReference<ObjectreferenceObject service ) {
    ifisResourceservice ) ) {
      .removeResourceservice );
      delegateAddServicereferenceservice );
    }
  }
  private boolean isResourceObject service ) {
    return service != null && ( hasRegisterableAnnotationservice ) || service instanceof Feature );
  }
  private boolean hasRegisterableAnnotationObject service ) {
    boolean result = isRegisterableAnnotationPresentservice.getClass() );
    if( !result ) {
      Class<?>[] interfaces = service.getClass().getInterfaces();
      forClass<?> type : interfaces ) {
        result = result || isRegisterableAnnotationPresenttype );
      }
    }
    return result;
  }
  private boolean isRegisterableAnnotationPresentClass<?> type ) {
    return type.isAnnotationPresentPath.class ) || type.isAnnotationPresentProvider.class );
  }
  
New to GrepCode? Check out our FAQ X