< prev index next >

modules/graphics/src/main/java/javafx/concurrent/Service.java

Print this page

        

*** 99,120 **** * <p> * Because a Service is intended to simplify declarative use cases, subclasses * should expose as properties the input parameters to the work to be done. * For example, suppose I wanted to write a Service which read the first line * from any URL and returned it as a String. Such a Service might be defined, ! * such that it had a single property, <code>url</code>. It might be implemented * as: * <pre><code> * public static class FirstLineService extends Service&lt;String&gt; { * private StringProperty url = new SimpleStringProperty(this, "url"); * public final void setUrl(String value) { url.set(value); } * public final String getUrl() { return url.get(); } * public final StringProperty urlProperty() { return url; } * * protected Task createTask() { * final String _url = getUrl(); ! * return new Task&ltString&gt;() { * protected String call() throws Exception { * URL u = new URL(_url); * BufferedReader in = new BufferedReader( * new InputStreamReader(u.openStream())); * String result = in.readLine(); --- 99,121 ---- * <p> * Because a Service is intended to simplify declarative use cases, subclasses * should expose as properties the input parameters to the work to be done. * For example, suppose I wanted to write a Service which read the first line * from any URL and returned it as a String. Such a Service might be defined, ! * such that it had a single property, {@code url}. It might be implemented * as: + * </p> * <pre><code> * public static class FirstLineService extends Service&lt;String&gt; { * private StringProperty url = new SimpleStringProperty(this, "url"); * public final void setUrl(String value) { url.set(value); } * public final String getUrl() { return url.get(); } * public final StringProperty urlProperty() { return url; } * * protected Task createTask() { * final String _url = getUrl(); ! * return new Task&lt;String&gt;() { * protected String call() throws Exception { * URL u = new URL(_url); * BufferedReader in = new BufferedReader( * new InputStreamReader(u.openStream())); * String result = in.readLine();
*** 123,139 **** * } * }; * } * } * </code></pre> - * </p> * <p> * The Service by default uses a thread pool Executor with some unspecified * default or maximum thread pool size. This is done so that naive code * will not completely swamp the system by creating thousands of Threads. * </p> ! * @param <V> * @since JavaFX 2.0 */ public abstract class Service<V> implements Worker<V>, EventTarget { /** * Logger used in the case of some uncaught exceptions --- 124,139 ---- * } * }; * } * } * </code></pre> * <p> * The Service by default uses a thread pool Executor with some unspecified * default or maximum thread pool size. This is done so that naive code * will not completely swamp the system by creating thousands of Threads. * </p> ! * @param <V> the type of object returned by the Service. * @since JavaFX 2.0 */ public abstract class Service<V> implements Worker<V>, EventTarget { /** * Logger used in the case of some uncaught exceptions
< prev index next >