Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Object Teams Quick-Start"

(Installation of the OTDT (development environment))
 
(15 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
=Installation of the OTDT (development environment)=
 
=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  
+
#Prerequisites:  Eclipse running on a JRE 1.7 or greater
## ''Tip: set'' <code>-Xmx512m</code> ''in eclipse.ini''  
+
# Fire up Eclipse, and select Install New Software
# Fire up Eclipse and add our update site
+
#* The OTDT is hosted in the common Eclipse repository (Indigo, Juno, Kepler ...), so
#* http://www.objectteams.org/distrib/otdt-updates-1.2 -- if you are running Eclipse 3.4.x
+
#*# select the '''Mars - <nowiki>http://download.eclipse.org/releases/mars</nowiki>''' site (or similar ...)
#* http://www.objectteams.org/distrib/otdt-updates-1.3 -- if you are running Eclipse 3.5.x  
+
#*# find Object Teams in the '''Programming Languages''' category.
#* http://www.objectteams.org/distrib/otdt-updates-1.4 -- if you are running Eclipse 3.6.0 Mx
+
<!--
 +
#: ''Old releases are still served from www.objectteams.org'':
 +
#:* http://www.objectteams.org/distrib/otdt-updates-1.4 -- for Eclipse 3.6.0 M6
 +
#:* http://www.objectteams.org/distrib/otdt-updates-1.3 -- for Eclipse 3.5.x  
 +
#:* http://www.objectteams.org/distrib/otdt-updates-1.2 -- for Eclipse 3.4.x
 +
-->
 
# Select "''Object Teams Development Tooling''", install it and restart  
 
# Select "''Object Teams Development Tooling''", install it and restart  
## Ensure that Java compiler compliance level is set to 1.5 or greater  
+
## Ensure that Java compiler compliance level is set to 1.7 or greater  
 
## ''Tip: Enable "Java Type Indicator" under Preferences->General->Appearance->Label Decorations''
 
## ''Tip: Enable "Java Type Indicator" under Preferences->General->Appearance->Label Decorations''
  
Line 17: Line 21:
 
''Note: throughout this site links like {{otjld|0|}} refer to matching paragraphs in the OT/J Language Definition''.
 
''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}}).
+
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}}).
 
   
 
   
 
<ol>
 
<ol>
<li>Start the New Project Wizard, select "''Object Teams Project''" and proceed as usual</li>
+
<li>Start the New Project Wizard, select "''[[Image:Newprj_wiz.gif]] Object Teams Project''" and proceed as usual</li>
 
<li>Create a new class core.Main with the following content:
 
<li>Create a new class core.Main with the following content:
 
<source lang="otj">package core;
 
<source lang="otj">package core;
Line 36: Line 40:
 
</ol></li>
 
</ol></li>
 
<li>Run this configuration. The console output should look like:<pre>Hello World!</pre></li>
 
<li>Run this configuration. The console output should look like:<pre>Hello World!</pre></li>
<li>Create a new '''Team''' class aspect.MyTeam (e.g., using the New Team wizard) with the following content:  
+
<li>Create a new '''Team''' class aspect.MyTeam (e.g., using the New [[Image:OTNewteam_obj.gif]] Team wizard) with the following content:  
 
<source lang="otj">
 
<source lang="otj">
 
package aspect;
 
package aspect;
Line 62: Line 66:
 
callin ends ...</pre></li>
 
callin ends ...</pre></li>
 
</ol>
 
</ol>
 +
 
=OT/Equinox Hello World Example=
 
=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.  
 
This example shows a simple adaptation of an existing Eclipse plug-in using the aspect binding concept of OT/Equinox.  
 
<ol>
 
<ol>
<li>Start the New Project Wizard, select "''Object Teams Plug-in Project''"  
+
<li>Start the New Project Wizard, select "''[[Image:Newotpprj obj.gif]] Object Teams Plug-in Project''"  
 
<ol>
 
<ol>
 
   <li>Enter project name and select "''Eclipse version 3.x''" (matching your Eclipse version) as target platform, click "Next" </li>
 
   <li>Enter project name and select "''Eclipse version 3.x''" (matching your Eclipse version) as target platform, click "Next" </li>
   <li>Uncheck all of the plug-in options and choose not to create an RCP application</li>
+
   <li>On the '''Content''' wizard page uncheck all options and choose not to create an RCP application.</li>
   <li>Click "Finish" </li>
+
  <li>On the '''Templates''' wizard page uncheck creation from a template.</li>
 +
   <li>Click "Finish".</li>
 
</ol>
 
</ol>
 
<li>Configure the plug-in with the Plug-in Manifest Editor  
 
<li>Configure the plug-in with the Plug-in Manifest Editor  
 
<ol>
 
<ol>
 
   <li>'''Overview''' tab: check "''Activate this plug-in ...''" and "''This plug-in is a singleton''" </li>
 
   <li>'''Overview''' tab: check "''Activate this plug-in ...''" and "''This plug-in is a singleton''" </li>
   <li>'''Dependencies''' tab: add <code>org.eclipse.ui.workbench</code> and <code>org.objectteams.otequinox</code> as required plug-ins </li>
+
   <li>'''Dependencies''' tab: add <code>org.eclipse.ui.workbench</code> and <code>org.eclipse.objectteams.otequinox</code> as required plug-ins </li>
   <li>'''Extensions''' tab: add <code>org.objectteams.otequinox.aspectBindings</code> extension
+
   <li>'''Extensions''' tab: add a [[Image:OTCalloutbinding_obj.gif]] <code>org.eclipse.objectteams.otequinox.aspectBindings</code> extension
 
   <ol>
 
   <ol>
     <li>For the '''basePlugin''' entry, enter the plug-in id <code>org.eclipse.ui.workbench</code></li>
+
     <li>For the [[Image:Plugin_obj.gif]] '''basePlugin''' entry, enter the plug-in id <code>org.eclipse.ui.workbench</code></li>
     <li>For the '''team''' entry, enter a class name of <code>aspect.MyTeam</code> and set activation to "<code>ALL_THREADS</code>"</li>
+
     <li>For the [[Image:Team_obj.gif]] '''team''' entry, enter a class name of <code>aspect.MyTeam</code> and set '''activation''' to "<code>ALL_THREADS</code>"</li>
 
     <li>Save </li>
 
     <li>Save </li>
 
   </ol></li>
 
   </ol></li>
Line 112: Line 118:
  
 
[[Image:Object_Teams_Quick_Start_About.png]]
 
[[Image:Object_Teams_Quick_Start_About.png]]
 +
 +
 +
[[Image:OTCalloutbinding_obj.gif]]  By the way: should you like to build your OT/Equinox projects using '''Maven/Tycho''', please have a look at [[Media:OTEquiTycho.zip]], which is a mavenized version of the above example.
 +
 
=What's Next?=
 
=What's Next?=
 
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.
 
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.
 +
 +
[[Image:OTCalloutbinding_obj.gif]] [[:Category:Object Teams|Overview of Object Teams pages in the wiki]]
  
 
[[Category:Object Teams|*]]
 
[[Category:Object Teams|*]]

Latest revision as of 08:50, 26 June 2015

Idea.png
This step-by-step Quick-Start guide should get you started with Object Teams in less than 15 minutes.


Installation of the OTDT (development environment)

  1. Prerequisites: Eclipse running on a JRE 1.7 or greater
  2. Fire up Eclipse, and select Install New Software
    • The OTDT is hosted in the common Eclipse repository (Indigo, Juno, Kepler ...), so
      1. select the Mars - http://download.eclipse.org/releases/mars site (or similar ...)
      2. find Object Teams in the Programming Languages category.
  3. Select "Object Teams Development Tooling", install it and restart
    1. Ensure that Java compiler compliance level is set to 1.7 or greater
    2. 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).

  1. Start the New Project Wizard, select "Newprj wiz.gif Object Teams Project" and proceed as usual
  2. 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!");
        }
    }
  3. Create a run configuration of type "Java Application"
    1. Select core.Main as the main class
  4. Run this configuration. The console output should look like:
    Hello World!
  5. Create a new Team class aspect.MyTeam (e.g., using the New OTNewteam obj.gif 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;
        }
    }
  6. Open the previously created run configuration
    1. On the JRE tab, make sure that "Enable OTRE" is checked (is default for an Object Teams Project)
    2. On the Team Activation tab, add aspect.MyTeam
  7. 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.

  1. Start the New Project Wizard, select "Newotpprj obj.gif Object Teams Plug-in Project"
    1. Enter project name and select "Eclipse version 3.x" (matching your Eclipse version) as target platform, click "Next"
    2. On the Content wizard page uncheck all options and choose not to create an RCP application.
    3. On the Templates wizard page uncheck creation from a template.
    4. Click "Finish".
  2. Configure the plug-in with the Plug-in Manifest Editor
    1. Overview tab: check "Activate this plug-in ..." and "This plug-in is a singleton"
    2. Dependencies tab: add org.eclipse.ui.workbench and org.eclipse.objectteams.otequinox as required plug-ins
    3. Extensions tab: add a OTCalloutbinding obj.gif org.eclipse.objectteams.otequinox.aspectBindings extension
      1. For the Plugin obj.gif basePlugin entry, enter the plug-in id org.eclipse.ui.workbench
      2. For the Team obj.gif team entry, enter a class name of aspect.MyTeam and set activation to "ALL_THREADS"
      3. Save
  3. 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;
        }
    }
  4. Create a run configuration of type "Eclipse Application"
    1. On the Main tab, check "Enable OT/Equinox"
    2. (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"
  5. 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:

Object Teams Quick Start About.png


OTCalloutbinding obj.gif By the way: should you like to build your OT/Equinox projects using Maven/Tycho, please have a look at Media:OTEquiTycho.zip, which is a mavenized version of the above example.

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.

OTCalloutbinding obj.gif Overview of Object Teams pages in the wiki

Back to the top