Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Object Teams Quick-Start"
(avoid special name base in the example) |
|||
Line 5: | Line 5: | ||
#Prerequisites: Eclipse running on a JRE 1.5 or greater | #Prerequisites: Eclipse running on a JRE 1.5 or greater | ||
− | ## ''Tip: set -Xmx512m in eclipse.ini'' | + | ## ''Tip: set'' <code>-Xmx512m</code> ''in eclipse.ini'' |
# Fire up Eclipse and add our update site | # Fire up Eclipse and add our update site | ||
#* http://www.objectteams.org/distrib/otdt-updates-1.2 -- if you are running Eclipse 3.4.x | #* http://www.objectteams.org/distrib/otdt-updates-1.2 -- if you are running Eclipse 3.4.x | ||
Line 113: | Line 113: | ||
[[Image:Object_Teams_Quick_Start_About.png]] | [[Image:Object_Teams_Quick_Start_About.png]] | ||
=What's Next?= | =What's Next?= | ||
− | Now, that you've successfully applied the fundamental concepts and mechanisms of [[OTJ|OT/J]] and [[OTEquinox|OT/Equinox]], you are ready to find out, that Object Teams is not just about replacing individual methods, but has a lot more to offer for helping you create '''architectures''', that are '''well modularized''' and '''scalable''', with exactly that balance between '''encapsulation''' and '''flexibility''' you need to develop and maintain your projects. | + | Now, that you've successfully applied the fundamental concepts and mechanisms of [[OTJ|OT/J]] and [[:Category:OTEquinox|OT/Equinox]], you are ready to find out, that Object Teams is not just about replacing individual methods, but has a lot more to offer for helping you create '''architectures''', that are '''well modularized''' and '''scalable''', with exactly that balance between '''encapsulation''' and '''flexibility''' you need to develop and maintain your projects. |
[[Category:Object Teams|*]] | [[Category:Object Teams|*]] |
Revision as of 22:45, 27 February 2010
Contents
Installation of the OTDT (development environment)
Note that existing releases are still served from www.objectteams.org until we are cleared to upload to eclipse.org
- Prerequisites: Eclipse running on a JRE 1.5 or greater
- Tip: set
-Xmx512m
in eclipse.ini
- Tip: set
- Fire up Eclipse and add our update site
- http://www.objectteams.org/distrib/otdt-updates-1.2 -- if you are running Eclipse 3.4.x
- http://www.objectteams.org/distrib/otdt-updates-1.3 -- if you are running Eclipse 3.5.x
- http://www.objectteams.org/distrib/otdt-updates-1.4 -- if you are running Eclipse 3.6.0 Mx
- Select "Object Teams Development Tooling", install it and restart
- Ensure that Java compiler compliance level is set to 1.5 or greater
- Tip: Enable "Java Type Indicator" under Preferences->General->Appearance->Label Decorations
OT/J Hello World Example
Note: throughout this site links like OTJLD §0 refer to matching paragraphs in the OT/J Language Definition.
This most simple example of an OT/J Application demonstrates how easy it is to intercept a (private!) base method and adapt its behavior in a separate role class. The example makes use of role binding (OTJLD §2, replace callin (OTJLD §4), decapsulation (OTJLD §4.6) and unanticipated team activation (OTJLD §5.5).
- Start the New Project Wizard, select "Object Teams Project" and proceed as usual
- Create a new class core.Main with the following content:
package core; public class Main { public static void main(String[] args) { sayHello(); } private static void sayHello() { System.out.println("Hello World!"); } }
- Create a run configuration of type "Java Application"
- Select
core.Main
as the main class
- Select
- Run this configuration. The console output should look like:
Hello World!
- Create a new Team class aspect.MyTeam (e.g., using the New Team wizard) with the following content:
package aspect; import base core.Main; public team class MyTeam { protected class MyRole playedBy Main { callin static void sayMore() { System.out.println("callin begins ..."); base.sayMore(); System.out.println("callin ends ..."); } sayMore <- replace sayHello; } }
- Open the previously created run configuration
- On the JRE tab, make sure that "Enable OTRE" is checked (is default for an Object Teams Project)
- On the Team Activation tab, add
aspect.MyTeam
- Run the configuration again. The console output should now look like:
callin begins ... Hello World! callin ends ...
OT/Equinox Hello World Example
This example shows a simple adaptation of an existing Eclipse plug-in using the aspect binding concept of OT/Equinox.
- Start the New Project Wizard, select "Object Teams Plug-in Project"
- Enter project name and select "Eclipse version 3.x" (matching your Eclipse version) as target platform, click "Next"
- Uncheck all of the plug-in options and choose not to create an RCP application
- Click "Finish"
- Configure the plug-in with the Plug-in Manifest Editor
- Overview tab: check "Activate this plug-in ..." and "This plug-in is a singleton"
- Dependencies tab: add
org.eclipse.ui.workbench
andorg.objectteams.otequinox
as required plug-ins - Extensions tab: add
org.objectteams.otequinox.aspectBindings
extension- For the basePlugin entry, enter the plug-in id
org.eclipse.ui.workbench
- For the team entry, enter a class name of
aspect.MyTeam
and set activation to "ALL_THREADS
" - Save
- For the basePlugin entry, enter the plug-in id
- Create a new Team class
aspect.MyTeam
(e.g., using the New Team wizard) with the following content:package aspect; import base org.eclipse.ui.internal.about.AboutItem; @SuppressWarnings("restriction") public team class MyTeam { protected class MyRole playedBy AboutItem { callin String getText() { StringBuffer sb = new StringBuffer(); sb.append("########\n"); sb.append("## Test ##\n"); sb.append("########\n"); sb.append(base.getText()); return sb.toString(); } getText <- replace getText; } }
- Create a run configuration of type "Eclipse Application"
- On the Main tab, check "Enable OT/Equinox"
- (optional) On the Plug-ins tab, switch to "plug-ins selected below only", deselect all, manually select the OT aspect plugin you created and click "Add Required Plug-ins"
- Run this configuration. In the started runtime workbench open the Help->About Eclipse SDK dialog. It should show the additional text from the callin method like this:
What's Next?
Now, that you've successfully applied the fundamental concepts and mechanisms of OT/J and OT/Equinox, you are ready to find out, that Object Teams is not just about replacing individual methods, but has a lot more to offer for helping you create architectures, that are well modularized and scalable, with exactly that balance between encapsulation and flexibility you need to develop and maintain your projects.