@Override public ExecutorService getExecutor() { if (executor != null) return executor; else return super.getExecutor(); }
@Override public ExecutorService getExecutor() { if (executor != null) return executor; else return super.getExecutor(); }
/** * Execute an arbitrary task on the executor of this resource or the first * parent that defines its own executor. If no parent defines an executor, * the thread that calls this method executes the specified task. * * @param task the task */ public void execute(Runnable task) { Executor executor = getExecutor(); // use thread from the protocol stage if (executor == null) task.run(); // use thread from the resource pool else executor.execute(task); }
/** * Execute an arbitrary task on the executor of this resource or the first * parent that defines its own executor. If no parent defines an executor, * the thread that calls this method executes the specified task. * * @param task the task */ public void execute(Runnable task) { Executor executor = getExecutor(); // use thread from the protocol stage if (executor == null) task.run(); // use thread from the resource pool else executor.execute(task); }
/** * Notifies a filtered set of CoAP clients that have established an observe * relation with this resource that the state has changed by reprocessing * their original request that has established the relation. The notification * is done by the executor of this resource or on the executor of its parent or * transitively ancestor. If no ancestor defines its own executor, the * thread that has called this method performs the notification. * * @param filter filter to select set of relations. * <code>null</code>, if all clients should be notified. * * @see #changed() */ public void changed(final ObserveRelationFilter filter) { Executor executor = getExecutor(); // use thread from the protocol stage if (executor == null) notifyObserverRelations(filter); // use thread from the resource pool else executor.execute(new Runnable() { public void run() { notifyObserverRelations(filter); }}); }
/** * Notifies a filtered set of CoAP clients that have established an observe * relation with this resource that the state has changed by reprocessing * their original request that has established the relation. The notification * is done by the executor of this resource or on the executor of its parent or * transitively ancestor. If no ancestor defines its own executor, the * thread that has called this method performs the notification. * * @param filter filter to select set of relations. * <code>null</code>, if all clients should be notified. * * @see #changed() */ public void changed(final ObserveRelationFilter filter) { Executor executor = getExecutor(); // use thread from the protocol stage if (executor == null) notifyObserverRelations(filter); // use thread from the resource pool else executor.execute(new Runnable() { public void run() { notifyObserverRelations(filter); }}); }
/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @return the CoAP client */ public CoapClient createClient() { CoapClient client = new CoapClient(); client.setExecutor(getExecutor()); List<Endpoint> endpoints = getEndpoints(); if (!endpoints.isEmpty()) client.setEndpoint(endpoints.get(0)); return client; }
/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @return the CoAP client */ public CoapClient createClient() { CoapClient client = new CoapClient(); client.setExecutor(getExecutor()); List<Endpoint> endpoints = getEndpoints(); if (!endpoints.isEmpty()) client.setEndpoint(endpoints.get(0)); return client; }