@Deactivate protected void deactivate(ComponentContext ctx){ if(chainTracker != null){ chainTracker.close(); chainTracker = null; } }
public Chain getDefaultChain(){ return chainTracker.getDefault(); } public boolean isDefault(String name){
/** * Creates a new {@link ChainsTracker} for the parsed {@link BundleContext} * and chain names. * Examples: * <code><pre> * //Track all active chains with a customiser * new ChainsTracker(context,null,customiser); * * //Track all chains with the names and use the customiser * //to react on changes * new ChainsTracker(context,chainNames,customiser); * </pre></code> * @param context the bundle context used to track chains * @param chainNames the names of the chains to track. Parse <code>null</code> * or an {@link Collections#emptySet()} to track all chains * @param customizer the {@link ServiceTrackerCustomizer} used with this tracker. */ public ChainsTracker(BundleContext context, Set<String> chainNames, ServiceTrackerCustomizer customizer){ if(context == null){ throw new IllegalArgumentException("The parsed BundleContext MUST NOT be NULL!"); } initChainTracker(context,chainNames,customizer); } /**
@Activate public void activate(ComponentContext ctx) { final BundleContext bc = ctx.getBundleContext(); chainTracker = new ChainsTracker(ctx.getBundleContext(), Collections.<String>emptySet(), new ServiceTrackerCustomizer() { chainTracker.open();
@Override public Chain getDefault() { Chain chain = getChain(DEFAULT_CHAIN_NAME); if(chain == null){ chain = (Chain)nameTracker.getService(); } return chain; } /**
@Override public Chain getChain(String name){ ServiceReference ref = getReference(name); return ref == null ? null : (Chain)nameTracker.getService(ref); } /*
@Activate public void activate(ComponentContext ctx) { final BundleContext bc = ctx.getBundleContext(); chainTracker = new ChainsTracker(ctx.getBundleContext(), Collections.<String>emptySet(), new ServiceTrackerCustomizer() { chainTracker.open();
@Override public Chain getDefault() { Chain chain = getChain(DEFAULT_CHAIN_NAME); if(chain == null){ chain = (Chain)nameTracker.getService(); } return chain; } /**
@Override public Chain getChain(String name){ ServiceReference ref = getReference(name); return ref == null ? null : (Chain)nameTracker.getService(ref); } /*
public Chain getDefaultChain(){ return chainTracker.getDefault(); } public boolean isDefault(String name){
/** * Creates a new {@link ChainsTracker} for the parsed {@link BundleContext} * and chain names. * Examples: * <code><pre> * //Track all active chains with a customiser * new ChainsTracker(context,null,customiser); * * //Track all chains with the names and use the customiser * //to react on changes * new ChainsTracker(context,chainNames,customiser); * </pre></code> * @param context the bundle context used to track chains * @param chainNames the names of the chains to track. Parse <code>null</code> * or an {@link Collections#emptySet()} to track all chains * @param customizer the {@link ServiceTrackerCustomizer} used with this tracker. */ public ChainsTracker(BundleContext context, Set<String> chainNames, ServiceTrackerCustomizer customizer){ if(context == null){ throw new IllegalArgumentException("The parsed BundleContext MUST NOT be NULL!"); } initChainTracker(context,chainNames,customizer); } /**
@Deactivate protected void deactivate(ComponentContext ctx){ if(chainTracker != null){ chainTracker.close(); chainTracker = null; } }
public boolean isDefault(String name){ return chainTracker.getDefault().getName().equals(name); }
/** * Creates a new {@link ChainsTracker} for the parsed {@link BundleContext} * and chain names. * Examples: * <code><pre> * //Track all active chains * new ChainsTracker(context); * * //Track only the chain with the name "dbpediaLinking" * new ChainsTracker(context,"dbpediaLinking"); * </pre></code> * @param context The bundle context used to track chains * @param chainNames the name of the chains to track. If empty * all chains are tracked. */ public ChainsTracker(BundleContext context, String...chainNames){ if(context == null){ throw new IllegalArgumentException("The parsed BundleContext MUST NOT be NULL!"); } final Set<String> names; if(chainNames == null){ names = Collections.emptySet(); } else { names = new HashSet<String>(Arrays.asList(chainNames)); } initChainTracker(context,names,null); } /**
public boolean isDefault(String name){ return chainTracker.getDefault().getName().equals(name); }
/** * Creates a new {@link ChainsTracker} for the parsed {@link BundleContext} * and chain names. * Examples: * <code><pre> * //Track all active chains * new ChainsTracker(context); * * //Track only the chain with the name "dbpediaLinking" * new ChainsTracker(context,"dbpediaLinking"); * </pre></code> * @param context The bundle context used to track chains * @param chainNames the name of the chains to track. If empty * all chains are tracked. */ public ChainsTracker(BundleContext context, String...chainNames){ if(context == null){ throw new IllegalArgumentException("The parsed BundleContext MUST NOT be NULL!"); } final Set<String> names; if(chainNames == null){ names = Collections.emptySet(); } else { names = new HashSet<String>(Arrays.asList(chainNames)); } initChainTracker(context,names,null); } /**
@GET @Produces(value={JSON_LD, APPLICATION_JSON,N3,N_TRIPLE,RDF_JSON,RDF_XML,TURTLE,X_TURTLE}) public Response getEngines(@Context HttpHeaders headers){ String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); Graph graph = new SimpleGraph(); addActiveChains(getActiveChains(), chainTracker.getDefault(),graph,rootUrl); ResponseBuilder res = Response.ok(graph); //addCORSOrigin(servletContext,res, headers); return res.build(); }
@GET @Produces(value={JSON_LD, APPLICATION_JSON,N3,N_TRIPLE,RDF_JSON,RDF_XML,TURTLE,X_TURTLE}) public Response getEngines(@Context HttpHeaders headers){ String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); Graph graph = new SimpleGraph(); addActiveChains(getActiveChains(), chainTracker.getDefault(),graph,rootUrl); ResponseBuilder res = Response.ok(graph); //addCORSOrigin(servletContext,res, headers); return res.build(); }