/[debian]/libspin-java/branches/upstream/current/src/site/xdoc/acknowledgement.xml
ViewVC logotype

Contents of /libspin-java/branches/upstream/current/src/site/xdoc/acknowledgement.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 680 - (show annotations)
Sun Apr 1 14:25:01 2007 UTC (14 years, 4 months ago) by gregoa
File MIME type: text/xml
File size: 5300 byte(s)
[svn-upgrade] Integrating new upstream version, libspin-java (1.5)
1 <document>
2 <properties>
3 <author email="sven@users.sourceforge.net">Sven Meier</author>
4 <title>Spin your Swing</title>
5 </properties>
6 <body>
7 <section name="Acknowledgment">
8 <subsection name="Foxtrot">
9 <p>
10 The <em>Spin</em> project is influenced by the <a class="external" href="http://foxtrot.sourceforge.net">Foxtrot</a> project. Foxtrot is the inventor of the <b>Synchronous Model</b> (<em>Spin</em> has adopted this technique) but uses an API that is similar to <code>SwingWorker</code>. It offers a subset of <em>Spin</em>s features - it lacks transparent exception handling and offers no solution for asynchronous callbacks:
11 </p>
12
13 <!--
14 public void actionPerformed(ActionEvent e)
15 {
16 label.setText("...");
17 String text = (String)Worker.post(new Job()
18 {
19 public Object run()
20 {
21 return bean.getValue();
22 }
23 });
24 label.setText(text);
25 }
26 -->
27 <div class="java">
28 <h3 class="java">GUI.java</h3>
29 <code class="java"><span class="java4">public </span><span class="java9">void </span><span class="java10">actionPerformed</span><span class="java8">(</span><span class="java10">ActionEvent e</span><span class="java8">)<br />
30 {<br />
31 &#xA0; </span><span class="java10">label.setText</span><span class="java8">(</span><span class="java5">&#34;...&#34;</span><span class="java8">)</span><span class="java10">;<br />
32 &#xA0; String text = </span><span class="java8">(</span><span class="java10">String</span><span class="java8">)</span><span class="java10">Worker.post</span><span class="java8">(</span><span class="java4">new </span><span class="java10">Job</span><span class="java8">()<br />
33 &#xA0; {<br />
34 &#xA0;&#xA0;&#xA0; </span><span class="java4">public </span><span class="java10">Object run</span><span class="java8">()<br />
35 &#xA0;&#xA0;&#xA0; {<br />
36 &#xA0;&#xA0;&#xA0;&#xA0;&#xA0; </span><span class="java4">return </span><span class="java10">bean.getValue</span><span class="java8">()</span><span class="java10">;<br />
37 &#xA0;&#xA0;&#xA0; </span><span class="java8">}<br />
38 &#xA0; })</span><span class="java10">;<br />
39 &#xA0; label.setText</span><span class="java8">(</span><span class="java10">text</span><span class="java8">)</span><span class="java10">;<br />
40 </span><span class="java8">}</span></code></div>
41
42 <p>
43 The following code shows how Foxtrot can be 'simulated' with <em>Spin</em> (if you insist on restricting yourself to only one generic interface named <code>Job</code> or what-ever-you-like):
44 </p>
45
46 <!--
47 public void actionPerformed(ActionEvent e)
48 {
49 label.setText("...");
50 String text = ((Job)Spin.off(new Job()
51 {
52 public String run()
53 {
54 return bean.getValue();
55 }
56 })).run();
57 label.setText(text);
58 }
59 -->
60 <div class="java">
61 <h3 class="java">GUI.java</h3>
62 <code class="java"><span class="java4">public </span><span class="java9">void </span><span class="java10">actionPerformed</span><span class="java8">(</span><span class="java10">ActionEvent e</span><span class="java8">)<br />
63 {<br />
64 &#xA0; </span><span class="java10">label.setText</span><span class="java8">(</span><span class="java5">&#34;...&#34;</span><span class="java8">)</span><span class="java10">;<br />
65 &#xA0; String text = </span><span class="java8">((</span><span class="java10">Job</span><span class="java8">)</span><span class="java10">Spin.off</span><span class="java8">(</span><span class="java4">new </span><span class="java10">Job</span><span class="java8">()<br />
66 &#xA0; {<br />
67 &#xA0;&#xA0;&#xA0; </span><span class="java4">public </span><span class="java10">String run</span><span class="java8">()<br />
68 &#xA0;&#xA0;&#xA0; {<br />
69 &#xA0;&#xA0;&#xA0;&#xA0;&#xA0; </span><span class="java4">return </span><span class="java10">bean.getValue</span><span class="java8">()</span><span class="java10">;<br />
70 &#xA0;&#xA0;&#xA0; </span><span class="java8">}<br />
71 &#xA0; }))</span><span class="java10">.run</span><span class="java8">()</span><span class="java10">;<br />
72 &#xA0; label.setText</span><span class="java8">(</span><span class="java10">text</span><span class="java8">)</span><span class="java10">;<br />
73 </span><span class="java8">}</span></code></div>
74
75 </subsection>
76
77 <subsection name="CGLib">
78 <p>
79 Starting with release 1.4 Spin isn't any longer restricted on using JDK virtual proxies. The creation of proxies is now encapsulated in the interface <a href="./apidocs/spin/ProxyFactory.html">ProxyFactory</a>.
80 </p>
81 <p>
82 <em>Spin</em> contains a <a class="external" href="http://cglib.sourceforge.net">CGLib</a> specific implementation <a href="./apidocs/spin/CGLibProxyFactory.html">CGLibProxyFactory</a> that offers the following benefits:
83 </p>
84 <ul>
85 <li>improved performance on interception of method invocations</li>
86 <li>no need to to use interfaces for your beans as required by JDK proxies</li>
87 </ul>
88 <p>
89 For this you just have to change the default factory of proxies:
90 </p>
91 <blockquote>
92 <code>Spin.setDefaultProxyFactory(new CGLibProxyFactory());</code>
93 </blockquote>
94 </subsection>
95 </section>
96 </body>
97 </document>

  ViewVC Help
Powered by ViewVC 1.1.26