Now that we have an Eclipse project with the right dependencies, we'll create a simple transactional application.
In the File menu, select
New -> Package. Name the
new package quickstart
, and then click the
Finish button.
In the Package Explorer, right-click on the new
quickstart
package and select New ->
Class. Set the class name to
QuickStartObject
. This will be our ActiveSpaces® Transactions
managed type. Click the Finish button.
Now edit QuickStartObject.java
in the edit
pane. We will add an @Managed
annotation to the
class, and define a package-private String field named
message
. The class should look like the
following:
package quickstart; import com.kabira.platform.annotation.Managed; @Managed public class QuickStartObject { String message; }
As a Managed type, any instance of this object we create will be stored in ActiveSpaces® Transactions shared memory.
Now we'll create another public class with a
main()
method. As before, right-click on the
quickstart
package and select New ->
Class. Set the class name to Main, and let Eclipse generate
the method stub for us:
Replace the empty main() method body with some transactional code. We'll create and update an instance of the Managed QuickStartObject class we defined:
package quickstart; import com.kabira.platform.Transaction; public class Main { public static void main(String[] args) { new Transaction() { @Override public void run() throws Rollback { String message = "Welcome to ActiveSpaces® Transactions !"; System.out.println(message); QuickStartObject quickStartObject = new QuickStartObject(); quickStartObject.message = message; } }.execute(); } }
Take a moment to check for any source errors identified by Eclipse. Under the File menu, select Save all.