Getting Started with Wonder
                     Kieran Kelleher               WOWODC 2010 Montreal
                     Green Island Consulting LLC
                     SmartleadsUSA LLC
                     SmartMix Technologies LLC




Friday, September 3, 2010
Getting Started with Wonder
                            •   Get you started using Wonder

                                •   Wonder installation and upgrade - Binaries and Source

                                •   Create a Wonder Application

                                •   Convert existing non-Wonder to a Wonder Application

                            •   Review a few useful features of Wonder

                                •   ERXProperties, Properties files usage, ERXEC usage

                                •   ERPrototypes and Overriding prototypes


Friday, September 3, 2010
What Is It?
                            •      World’s largest Open Source WebObjects project

                            •      Umbrella Project for

                                 •       Patches and Bug Fixes to WebObjects

                                 •       Very Useful Extensions to Standard WebObjects Functionality

                                 •       Reusable WOComponents

                                 •       Powerful Reusable Frameworks

                                 •       Example Applications
  * Some verbiage reproduced from Jonathon “Wolf” Rentzsch’s 2002 CAWUG Presentation



Friday, September 3, 2010
Brief History Snippet
                            •   A long long time ago in a galaxy far far away...

                                •   dotcom: “eResource” (“ER*”), then became NetStruxr

                                •   WOnder is acronym for

                                    •   WebObjects Nodes for Distributing E-Resources

                                •   NetStruxr closed

                                    •   SourceForge project named WONDER was created (~2002)



Friday, September 3, 2010
What’s in It

         GoogleChart           ERChronic       ... and much more!   (db *)PlugIn     ERModernLook



            ERTaggable         ERCaptcha          ERProfiling        ERIndexing     ERModernDefaultSkin



        ERAttachment         ExcelGenerator    ERPDFGeneration        ERRest         ERModernD.T.W.



                 Ajax       JavaWOExtensions       WOOgnl           WOJRebel         ERNeutralLook



         ERExtensions            ERJars          ERPrototypes       ERJavaMail       ERDirectToWeb



Friday, September 3, 2010
Why Should You Use It?
                            •   Bug fixes to standard WebObjects frameworks

                            •   Even Apple uses Wonder (Branch 2_0_0?)

                            •   Improved and Replaced Functionality

                            •   Extended and Additional Functionality

                            •   The source code has an educational benefit

                            •   Why reinvent and debug the wheel?



Friday, September 3, 2010
How Do You Get It?

        “Semi-Pro” Way*                                                      “Pro” Way*




                            Binaries                                                      Source



 * Terms coined by David Holt on wonder-disc mailing list on May 12, 2010

Friday, September 3, 2010
Binary Frameworks Initial Installation
   $ mkdir WonderBinaries54


   $ cd WonderBinaries54


   $ curl -O http://webobjects.mdimension.com/hudson/job/Wonder54/lastSuccessfulBuild/artifact/dist/Wonder-Frameworks.tar.gz


   $ tar -xzvf Wonder-Frameworks.tar.gz


   $ sudo cp -Rvf *.framework /Library/Frameworks




         For WebObjects 5.3, replace “54” above with “53”
Friday, September 3, 2010
Binary Frameworks Upgrade Installation
   $ cd WonderBinaries54


   $ for FRAMEWORK in `echo *.framework`; do sudo rm -r /Library/Frameworks/${FRAMEWORK}; done


   $ rm -r *


   $ curl -O http://webobjects.mdimension.com/hudson/job/Wonder54/lastSuccessfulBuild/artifact/dist/Wonder-Frameworks.tar.gz


   $ tar -xzvf Wonder-Frameworks.tar.gz


   $ sudo cp -Rvf *.framework /Library/Frameworks




         For WebObjects 5.3, replace “54” above with “53”
Friday, September 3, 2010
Source Frameworks Initial Installation
   $ svn co http://wonder.svn.sourceforge.net/svnroot/wonder/trunk/Wonder --revision <ARG> WonderSource



   $ cd WonderSource



   $ ant -Dwonder.patch=54 frameworks; sudo ant -Dwonder.patch=54 frameworks.install     [WO 5.4]



                            OR



   $ ant frameworks; sudo ant frameworks.install      [WO 5.3]




         <ARG> = HEAD to get latest version. Type svn --help checkout for more.
Friday, September 3, 2010
Source Frameworks Upgrade Installation
   $ cd ~/Roots/



   $ for FRAMEWORK in `echo *.framework`; do sudo rm -r /Library/Frameworks/${FRAMEWORK}; done



   $ cd /path/to/WonderSource



   $ svn update --force --accept theirs-full --revision <ARG>



   $ ant -Dwonder.patch=54 clean; ant -Dwonder.patch=54 frameworks; sudo ant -Dwonder.patch=54 frameworks.install   [WO 5.4]



                        OR



   $ ant clean; ant frameworks; sudo ant frameworks.install         [WO 5.3]




Friday, September 3, 2010
Working with Wonder Source

                            •   Some Advantages of working with Source over Binaries:

                                •   Learn much about WebObjects and EOF (and java dev styles?)

                                •   Easily browse and search the source

                                •   Work with a specific svn version (teams, quality control)

                                •   Discover the Hidden Treasures (Don’t miss Chuck Hill later)

                            •   Note ERXExtensions classpath file contents for 5.3 vs 5.4 .....


Friday, September 3, 2010
Demo


                            •   Linking Wonder Source projects to your Workspace

                            •   Creating a Wonder app

                            •   What is different between a Wonder app and a Standard app




Friday, September 3, 2010
Integrating Wonder into Your
                                     Existing Application
                            •   Add Frameworks

                            •   Adjust Application, Session and DirectAction superclasses

                            •   Use ERXGenericRecord instead of EOGenericRecord

                            •   Configure Wonder-specific Properties

                                •   copy/paste from a new temp Wonder app as a starting point



Friday, September 3, 2010
Integrating Wonder into an
                                     Existing Application


                            •   DEMO




Friday, September 3, 2010
Configuring Wonder’s Features
                            •   Wonder is configured, more or less, using Properties files.

                                •   Check comments and contents of each framework’s
                                    Properties file

                            •   Where to find Documentation

                                •   Java API

                                •   Framework “Documentation” directory

                                •   http://wiki.objectstyle.org/confluence/display/WONDER/Home

                                •   Examine Source code

Friday, September 3, 2010
Select Features

                            •   ERXProperties

                            •   EOModel Connection Dictionary using Properties

                            •   ERXEC usage

                            •   ERPrototypes

                            •   Over-riding Prototypes via ERXModel and ERXModelGroup



Friday, September 3, 2010
ERXProperties

                            •   A variety of ways to organize Properties

                            •   ERXProperties replaces and extends deprecated NSProperties

                                •   many convenient utility methods including property coercion

                            •   log4j configured via Properties

                            •   Understanding how ERXProperties works can facilitate better
                                team organization, app administration and general happiness :-)



Friday, September 3, 2010
The Standard WebObjects Way

 Override

                            Properties                    Framework Resources
                             Properties
                              Properties


                            Properties                    Application Resources


                            WebObjects.properties         [user.home] dir


                        -DpropertyName=propertyValue      Command Line arguments
                        -DpropertyName=”property Value”




Friday, September 3, 2010
Properties: The Wonder Way
          Properties
           Properties
            Properties
          Properties.<username>
                                              Framework Resources                                                          Override
           Properties.<username>
            Properties.<username>

          Properties                          Application Resources
          WebObjects.properties               [user.home] dir

          ( file1, file2, file3 )                [er.extensions.ERXProperties.OptionalConfigurationFiles]
                                                 (absolute filepaths AND/OR application Resource filenames)
          Properties OR                       [er.extensions.ERXProperties.machinePropertiesPath]
          /<appName>/Properties                  (absolute filepath, default “/etc/WebObjects”)

          Properties.dev                       [er.extensions.ERXProperties.devPropertiesName]
                                                  (file extension, App Resource, default “dev”)
          Properties.<username>                Application Resources
          -DpropertyName=propertyValue         Command Line arguments
          -DpropertyName=”property Value”


          @see er.extensions.foundation.ERXProperties.pathsForUserAndBundleProperties(boolean)
          Note: [propertyname] denotes a system property (so properties are determining the loading of more properties!)
Friday, September 3, 2010
Examples of Properties fiddling...
   ## We always want to use @@ as the delimiter and NOT a single @
   er.extensions.ERXSimpleTemplateParser.useOldDelimiter=false

   app.directActionPassword=passw0rd
   er.extensions.ERXJUnitPassword = @@app.directActionPassword@@
   er.extensions.ERXLog4JPassword = @@app.directActionPassword@@
   er.extensions.ERXGCPassword = @@app.directActionPassword@@
   er.extensions.ERXDirectAction.ChangeSystemPropertyPassword = @@app.directActionPassword@@

   app.smtpserver=192.168.3.142
   WOSMTPHost=@@app.smtpserver@@
   log4j.appender.myMail.SMTPHost=@@app.smtpserver@@


                                                                                               Automatically generated into Resources by build




   ## Optional properties to load
   er.extensions.ERXProperties.OptionalConfigurationFiles=deploy.properties

   log4j.appender.A2.file=/var/log/webobjects_apps/@@build.app.bundle.name@@-@@WOPort@@.log

   log4j.appender.myMail.Subject=Log4jError (@@build.app.bundle.name@@ @@host@@ @@WOPort@@)




Friday, September 3, 2010
Common Dev/Deploy Properties Strategy




Friday, September 3, 2010
EOModel Connection Dictionary
       WebObjects Way




Friday, September 3, 2010
EOModel Connection Dictionary
     Wonder Way - Properties File:
                            # For individual eomodels
                            model.URL = jdbc:mysql://hostname/firstdatabase
                            model.DBUser = firstuser
                            model.DBPassword = firstpassword
                            model.DBDriver =
                            model.DBPlugin =



                            # Global, or default where model entry not specified
                            dbConnectURLGLOBAL = jdbc:mysql://hostname/nextdatabase
                            dbConnectUserGLOBAL = nextuser
                            dbConnectPasswordGLOBAL = nextpassword
                            dbConnectDriverGLOBAL =
                            dbConnectPluginGLOBAL =



     Wonder Way - WOMonitor Launch Arguments:
                            -Dmodel.URL=”jdbc:mysql://localhost/database?useUnicode=true&characterEncoding=UTF-8”
                            -Dmodel.DBUser=firstuser
                            -Dmodel.DBPassword=firstpassword




Friday, September 3, 2010
ERXEC
                            •   EOEditingContext subclass
                                •   EOEditingContext ec = ERXEC.newEditingContext();


                            •   supports automatic lock/unlock in R-R cycle
                                •   er.extensions.ERXEC.safeLocking=true


                                •   enabled by default for new Wonder projects

                            •   Calls ERXEnterpriseObject state transition will*/did* methods

                                •   Implemented by ERXGenericRecord


Friday, September 3, 2010
ERXEC Auto Lock/Unlock

                            •   Implicitly supported in Request-Response threads
                                •   ERXApplication._endRequest()    ... which calls ...

                                    •   ERXEC.unlockAllContextsForCurrentThread();


                            •   Background threads are your responsibility!

                                •   Here is how to do it ...




Friday, September 3, 2010
Runnable lock handling
   public class MyTask implements Runnable {

   	       public void run() {
   	       	    ERXApplication._startRequest();
   	       	    try {
   	       	    	     performTask();
   	       	    } finally {
   	       	    	     ERXApplication._endRequest();
   	       	    }
   	       }
   	
   	       private void performTask() {
   	       	    EOEditingContext ec = ERXEC.newEditingContext();

   	       	      ec.lock();
   	       	      try {

   	       	      	         // Do some EOF stuff with the ec.

   	       	      } catch (Exception e) {
   	       	      	    // handle exception
   	       	      } finally {
   	       	      	    ec.unlock();
   	       	      }
   	       }
   }

Friday, September 3, 2010
Callable lock handling
   public class MyTask implements Callable<MyResultClass> {

   	       public MyResultClass call() {
   	       	    ERXApplication._startRequest();
   	       	    try {
   	       	    	     return performTask();
   	       	    } finally {
   	       	    	     ERXApplication._endRequest();
   	       	    }
   	       }
   	
   	       private MyResultClass performTask() {
   	       	    EOEditingContext ec = ERXEC.newEditingContext();
   	       	    ec.lock();
   	       	    try {
   	       	    	     // Do some EOF stuff with the ec.

   	       	      } catch (Exception e) {
   	       	      	    // handle exception
   	       	      } finally {
   	       	      	    ec.unlock();
   	       	      }
   	       	      return myResult;
   	       }
   }


Friday, September 3, 2010
Passing Objects to a Thread
   	       public WOActionResults shuffleStudioAction() {
   	       	   Studio studio = selectedStudio();
   	       	
   	       	   EOGlobalID studioGid = (EOGlobalID) ERXEOControlUtilities.convertEOtoGID(studio);
   	       	
   	       	   ProcessStudioTask task = new ProcessStudioTask(studioGid);
   	       	
   	       	   MyExecutorServices.executorService().execute(task);
   	       	
   	       	   return null;
   	       }




Friday, September 3, 2010
Thread Hydrates EO
   public class ProcessStudioTask extends ERXRunnable {
   	
   	    private final EOGlobalID _studioGlobalID;

   	       public ProcessStudioTask(EOGlobalID studioGlobalID) {
   	       	    _studioGlobalID = studioGlobalID;
   	       }
   	
   	       @Override
   	       public void _run() {
   	       	    EOEditingContext ec = ERXEC.newEditingContext();
   	       	    ec.lock();
   	       	    try {
   	
   	       	      	         Studio studio = (Studio) ERXEOControlUtilities.convertGIDtoEO(ec, _studioGlobalID);

   	       	      } catch (Exception e) {
   	       	      	    // Handle error
   	       	      } finally {
   	       	      	    ec.unlock();
   	       	      }
   	       }

   }




Friday, September 3, 2010
ERPrototypes



                            •   DEMO




Friday, September 3, 2010
Overriding Prototypes
                       •      ERXModel and ERXModelGroup

                       •      Allow “over-riding” of prototypes based on prototype entity naming
                              conventions

                       •      Feature configured in system Properties:


                            er.extensions.ERXModelGroup.modelClassName = com.webobjects.eoaccess.ERXModel
                            er.extensions.ERXModel.useExtendedPrototypes = true
                            er.extensions.ERXModelGroup.flattenPrototypes = false




Friday, September 3, 2010
Prototypes Over-ride Order
                       •    From lowest to highest priority:

                            •   EOPrototypes

                            •   EO<adaptorName>Prototypes (Wonder has ‘Memory’ and ‘REST’ adaptor protypes)

                            •   EOJDBC<pluginName>Prototypes (Wonder database prototype names)

                            •   EOCustomPrototypes

                            •   EO<adaptorName>CustomPrototypes

                            •   EOJDBC<pluginName>CustomPrototypes

                            •   EO<modelName>Prototypes

                            •   EO<adaptorName><modelName>Prototypes

                            •   EOJDBC<pluginName><modelName>Prototypes



Friday, September 3, 2010
Override Prototypes



                            •   DEMO




Friday, September 3, 2010
Resources
                            •   http://wiki.objectstyle.org/confluence/display/WONDER/Home

                            •   http://projectwonder.blogspot.com/

                            •   http://webobjects.mdimension.com/hudson/

                                •   JavaDoc and Binaries

                                •   “Wonder53” = Wonder for WebObjects 5.3.3

                                •   “Wonder54” = Wonder for WebObjects 5.4.3

                            •   Mailing Lists

                                •   https://lists.sourceforge.net/lists/listinfo/wonder-disc

                                •   https://lists.sourceforge.net/lists/listinfo/wonder-cvs


Friday, September 3, 2010
Q&A
                     Getting Start with Wonder
                     WOWODC 2010




Friday, September 3, 2010

Getting Started with Wonder

  • 1.
    Getting Started withWonder Kieran Kelleher WOWODC 2010 Montreal Green Island Consulting LLC SmartleadsUSA LLC SmartMix Technologies LLC Friday, September 3, 2010
  • 2.
    Getting Started withWonder • Get you started using Wonder • Wonder installation and upgrade - Binaries and Source • Create a Wonder Application • Convert existing non-Wonder to a Wonder Application • Review a few useful features of Wonder • ERXProperties, Properties files usage, ERXEC usage • ERPrototypes and Overriding prototypes Friday, September 3, 2010
  • 3.
    What Is It? • World’s largest Open Source WebObjects project • Umbrella Project for • Patches and Bug Fixes to WebObjects • Very Useful Extensions to Standard WebObjects Functionality • Reusable WOComponents • Powerful Reusable Frameworks • Example Applications * Some verbiage reproduced from Jonathon “Wolf” Rentzsch’s 2002 CAWUG Presentation Friday, September 3, 2010
  • 4.
    Brief History Snippet • A long long time ago in a galaxy far far away... • dotcom: “eResource” (“ER*”), then became NetStruxr • WOnder is acronym for • WebObjects Nodes for Distributing E-Resources • NetStruxr closed • SourceForge project named WONDER was created (~2002) Friday, September 3, 2010
  • 5.
    What’s in It GoogleChart ERChronic ... and much more! (db *)PlugIn ERModernLook ERTaggable ERCaptcha ERProfiling ERIndexing ERModernDefaultSkin ERAttachment ExcelGenerator ERPDFGeneration ERRest ERModernD.T.W. Ajax JavaWOExtensions WOOgnl WOJRebel ERNeutralLook ERExtensions ERJars ERPrototypes ERJavaMail ERDirectToWeb Friday, September 3, 2010
  • 6.
    Why Should YouUse It? • Bug fixes to standard WebObjects frameworks • Even Apple uses Wonder (Branch 2_0_0?) • Improved and Replaced Functionality • Extended and Additional Functionality • The source code has an educational benefit • Why reinvent and debug the wheel? Friday, September 3, 2010
  • 7.
    How Do YouGet It? “Semi-Pro” Way* “Pro” Way* Binaries Source * Terms coined by David Holt on wonder-disc mailing list on May 12, 2010 Friday, September 3, 2010
  • 8.
    Binary Frameworks InitialInstallation $ mkdir WonderBinaries54 $ cd WonderBinaries54 $ curl -O http://webobjects.mdimension.com/hudson/job/Wonder54/lastSuccessfulBuild/artifact/dist/Wonder-Frameworks.tar.gz $ tar -xzvf Wonder-Frameworks.tar.gz $ sudo cp -Rvf *.framework /Library/Frameworks For WebObjects 5.3, replace “54” above with “53” Friday, September 3, 2010
  • 9.
    Binary Frameworks UpgradeInstallation $ cd WonderBinaries54 $ for FRAMEWORK in `echo *.framework`; do sudo rm -r /Library/Frameworks/${FRAMEWORK}; done $ rm -r * $ curl -O http://webobjects.mdimension.com/hudson/job/Wonder54/lastSuccessfulBuild/artifact/dist/Wonder-Frameworks.tar.gz $ tar -xzvf Wonder-Frameworks.tar.gz $ sudo cp -Rvf *.framework /Library/Frameworks For WebObjects 5.3, replace “54” above with “53” Friday, September 3, 2010
  • 10.
    Source Frameworks InitialInstallation $ svn co http://wonder.svn.sourceforge.net/svnroot/wonder/trunk/Wonder --revision <ARG> WonderSource $ cd WonderSource $ ant -Dwonder.patch=54 frameworks; sudo ant -Dwonder.patch=54 frameworks.install [WO 5.4] OR $ ant frameworks; sudo ant frameworks.install [WO 5.3] <ARG> = HEAD to get latest version. Type svn --help checkout for more. Friday, September 3, 2010
  • 11.
    Source Frameworks UpgradeInstallation $ cd ~/Roots/ $ for FRAMEWORK in `echo *.framework`; do sudo rm -r /Library/Frameworks/${FRAMEWORK}; done $ cd /path/to/WonderSource $ svn update --force --accept theirs-full --revision <ARG> $ ant -Dwonder.patch=54 clean; ant -Dwonder.patch=54 frameworks; sudo ant -Dwonder.patch=54 frameworks.install [WO 5.4] OR $ ant clean; ant frameworks; sudo ant frameworks.install [WO 5.3] Friday, September 3, 2010
  • 12.
    Working with WonderSource • Some Advantages of working with Source over Binaries: • Learn much about WebObjects and EOF (and java dev styles?) • Easily browse and search the source • Work with a specific svn version (teams, quality control) • Discover the Hidden Treasures (Don’t miss Chuck Hill later) • Note ERXExtensions classpath file contents for 5.3 vs 5.4 ..... Friday, September 3, 2010
  • 13.
    Demo • Linking Wonder Source projects to your Workspace • Creating a Wonder app • What is different between a Wonder app and a Standard app Friday, September 3, 2010
  • 14.
    Integrating Wonder intoYour Existing Application • Add Frameworks • Adjust Application, Session and DirectAction superclasses • Use ERXGenericRecord instead of EOGenericRecord • Configure Wonder-specific Properties • copy/paste from a new temp Wonder app as a starting point Friday, September 3, 2010
  • 15.
    Integrating Wonder intoan Existing Application • DEMO Friday, September 3, 2010
  • 16.
    Configuring Wonder’s Features • Wonder is configured, more or less, using Properties files. • Check comments and contents of each framework’s Properties file • Where to find Documentation • Java API • Framework “Documentation” directory • http://wiki.objectstyle.org/confluence/display/WONDER/Home • Examine Source code Friday, September 3, 2010
  • 17.
    Select Features • ERXProperties • EOModel Connection Dictionary using Properties • ERXEC usage • ERPrototypes • Over-riding Prototypes via ERXModel and ERXModelGroup Friday, September 3, 2010
  • 18.
    ERXProperties • A variety of ways to organize Properties • ERXProperties replaces and extends deprecated NSProperties • many convenient utility methods including property coercion • log4j configured via Properties • Understanding how ERXProperties works can facilitate better team organization, app administration and general happiness :-) Friday, September 3, 2010
  • 19.
    The Standard WebObjectsWay Override Properties Framework Resources Properties Properties Properties Application Resources WebObjects.properties [user.home] dir -DpropertyName=propertyValue Command Line arguments -DpropertyName=”property Value” Friday, September 3, 2010
  • 20.
    Properties: The WonderWay Properties Properties Properties Properties.<username> Framework Resources Override Properties.<username> Properties.<username> Properties Application Resources WebObjects.properties [user.home] dir ( file1, file2, file3 ) [er.extensions.ERXProperties.OptionalConfigurationFiles] (absolute filepaths AND/OR application Resource filenames) Properties OR [er.extensions.ERXProperties.machinePropertiesPath] /<appName>/Properties (absolute filepath, default “/etc/WebObjects”) Properties.dev [er.extensions.ERXProperties.devPropertiesName] (file extension, App Resource, default “dev”) Properties.<username> Application Resources -DpropertyName=propertyValue Command Line arguments -DpropertyName=”property Value” @see er.extensions.foundation.ERXProperties.pathsForUserAndBundleProperties(boolean) Note: [propertyname] denotes a system property (so properties are determining the loading of more properties!) Friday, September 3, 2010
  • 21.
    Examples of Propertiesfiddling... ## We always want to use @@ as the delimiter and NOT a single @ er.extensions.ERXSimpleTemplateParser.useOldDelimiter=false app.directActionPassword=passw0rd er.extensions.ERXJUnitPassword = @@app.directActionPassword@@ er.extensions.ERXLog4JPassword = @@app.directActionPassword@@ er.extensions.ERXGCPassword = @@app.directActionPassword@@ er.extensions.ERXDirectAction.ChangeSystemPropertyPassword = @@app.directActionPassword@@ app.smtpserver=192.168.3.142 WOSMTPHost=@@app.smtpserver@@ log4j.appender.myMail.SMTPHost=@@app.smtpserver@@ Automatically generated into Resources by build ## Optional properties to load er.extensions.ERXProperties.OptionalConfigurationFiles=deploy.properties log4j.appender.A2.file=/var/log/webobjects_apps/@@build.app.bundle.name@@-@@WOPort@@.log log4j.appender.myMail.Subject=Log4jError (@@build.app.bundle.name@@ @@host@@ @@WOPort@@) Friday, September 3, 2010
  • 22.
    Common Dev/Deploy PropertiesStrategy Friday, September 3, 2010
  • 23.
    EOModel Connection Dictionary WebObjects Way Friday, September 3, 2010
  • 24.
    EOModel Connection Dictionary Wonder Way - Properties File: # For individual eomodels model.URL = jdbc:mysql://hostname/firstdatabase model.DBUser = firstuser model.DBPassword = firstpassword model.DBDriver = model.DBPlugin = # Global, or default where model entry not specified dbConnectURLGLOBAL = jdbc:mysql://hostname/nextdatabase dbConnectUserGLOBAL = nextuser dbConnectPasswordGLOBAL = nextpassword dbConnectDriverGLOBAL = dbConnectPluginGLOBAL = Wonder Way - WOMonitor Launch Arguments: -Dmodel.URL=”jdbc:mysql://localhost/database?useUnicode=true&characterEncoding=UTF-8” -Dmodel.DBUser=firstuser -Dmodel.DBPassword=firstpassword Friday, September 3, 2010
  • 25.
    ERXEC • EOEditingContext subclass • EOEditingContext ec = ERXEC.newEditingContext(); • supports automatic lock/unlock in R-R cycle • er.extensions.ERXEC.safeLocking=true • enabled by default for new Wonder projects • Calls ERXEnterpriseObject state transition will*/did* methods • Implemented by ERXGenericRecord Friday, September 3, 2010
  • 26.
    ERXEC Auto Lock/Unlock • Implicitly supported in Request-Response threads • ERXApplication._endRequest() ... which calls ... • ERXEC.unlockAllContextsForCurrentThread(); • Background threads are your responsibility! • Here is how to do it ... Friday, September 3, 2010
  • 27.
    Runnable lock handling public class MyTask implements Runnable { public void run() { ERXApplication._startRequest(); try { performTask(); } finally { ERXApplication._endRequest(); } } private void performTask() { EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { // Do some EOF stuff with the ec. } catch (Exception e) { // handle exception } finally { ec.unlock(); } } } Friday, September 3, 2010
  • 28.
    Callable lock handling public class MyTask implements Callable<MyResultClass> { public MyResultClass call() { ERXApplication._startRequest(); try { return performTask(); } finally { ERXApplication._endRequest(); } } private MyResultClass performTask() { EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { // Do some EOF stuff with the ec. } catch (Exception e) { // handle exception } finally { ec.unlock(); } return myResult; } } Friday, September 3, 2010
  • 29.
    Passing Objects toa Thread public WOActionResults shuffleStudioAction() { Studio studio = selectedStudio(); EOGlobalID studioGid = (EOGlobalID) ERXEOControlUtilities.convertEOtoGID(studio); ProcessStudioTask task = new ProcessStudioTask(studioGid); MyExecutorServices.executorService().execute(task); return null; } Friday, September 3, 2010
  • 30.
    Thread Hydrates EO public class ProcessStudioTask extends ERXRunnable { private final EOGlobalID _studioGlobalID; public ProcessStudioTask(EOGlobalID studioGlobalID) { _studioGlobalID = studioGlobalID; } @Override public void _run() { EOEditingContext ec = ERXEC.newEditingContext(); ec.lock(); try { Studio studio = (Studio) ERXEOControlUtilities.convertGIDtoEO(ec, _studioGlobalID); } catch (Exception e) { // Handle error } finally { ec.unlock(); } } } Friday, September 3, 2010
  • 31.
    ERPrototypes • DEMO Friday, September 3, 2010
  • 32.
    Overriding Prototypes • ERXModel and ERXModelGroup • Allow “over-riding” of prototypes based on prototype entity naming conventions • Feature configured in system Properties: er.extensions.ERXModelGroup.modelClassName = com.webobjects.eoaccess.ERXModel er.extensions.ERXModel.useExtendedPrototypes = true er.extensions.ERXModelGroup.flattenPrototypes = false Friday, September 3, 2010
  • 33.
    Prototypes Over-ride Order • From lowest to highest priority: • EOPrototypes • EO<adaptorName>Prototypes (Wonder has ‘Memory’ and ‘REST’ adaptor protypes) • EOJDBC<pluginName>Prototypes (Wonder database prototype names) • EOCustomPrototypes • EO<adaptorName>CustomPrototypes • EOJDBC<pluginName>CustomPrototypes • EO<modelName>Prototypes • EO<adaptorName><modelName>Prototypes • EOJDBC<pluginName><modelName>Prototypes Friday, September 3, 2010
  • 34.
    Override Prototypes • DEMO Friday, September 3, 2010
  • 35.
    Resources • http://wiki.objectstyle.org/confluence/display/WONDER/Home • http://projectwonder.blogspot.com/ • http://webobjects.mdimension.com/hudson/ • JavaDoc and Binaries • “Wonder53” = Wonder for WebObjects 5.3.3 • “Wonder54” = Wonder for WebObjects 5.4.3 • Mailing Lists • https://lists.sourceforge.net/lists/listinfo/wonder-disc • https://lists.sourceforge.net/lists/listinfo/wonder-cvs Friday, September 3, 2010
  • 36.
    Q&A Getting Start with Wonder WOWODC 2010 Friday, September 3, 2010