The Spin project is influenced by the Foxtrot project. Foxtrot is the inventor of the Synchronous Model (Spin has adopted this technique) but uses an API that is similar to SwingWorker
. It offers a subset of Spins features - it lacks transparent exception handling and offers no solution for asynchronous callbacks:
public void actionPerformed(ActionEvent e)
{
label.setText("...");
String text = (String)Worker.post(new Job()
{
public Object run()
{
return bean.getValue();
}
});
label.setText(text);
}
The following code shows how Foxtrot can be 'simulated' with Spin (if you insist on restricting yourself to only one generic interface named Job
or what-ever-you-like):
public void actionPerformed(ActionEvent e)
{
label.setText("...");
String text = ((Job)Spin.off(new Job()
{
public String run()
{
return bean.getValue();
}
})).run();
label.setText(text);
}
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 ProxyFactory.
Spin contains a CGLib specific implementation CGLibProxyFactory that offers the following benefits:
Spin.setDefaultProxyFactory(new CGLibProxyFactory());