Changes for page Building Concurrent Applications with WebObjects and Scala
Last modified by Ravi Mendis on 2012/02/11 08:28
From version 168.1
edited by Pascal Robert
on 2012/02/11 08:28
on 2012/02/11 08:28
Change comment:
There is no comment for this version
To version 170.2
edited by Pascal Robert
on 2023/11/13 11:58
on 2023/11/13 11:58
Change comment:
Updated the relative links.
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,0 +1,1 @@ 1 +WebObjects with Scala - Tags
-
... ... @@ -1,0 +1,1 @@ 1 +webobjects|scala|programming|concurrent|squeryl|favourite - Content
-
... ... @@ -1,11 +1,9 @@ 1 -Processors today ship with dual or quad cores. Server processors ship with between 8 to 32 cores. Programs that are developed in languages like Java, Ruby, Groovy, Python and Perl struggle to exploit all that power. On the other hand, Scala, as its name suggests is built from the ground-up for [[concurrent programming>>http://en.wikipedia.org/wiki/Concurrent_computing]] a methodology that can take advantage of these modern multi-core processors. 1 +Processors today ship with dual or quad cores. Server processors ship with between 8 to 32 cores. Programs that are developed in languages like Java, Ruby, Groovy, Python and Perl struggle to exploit all that power. On the other hand, Scala, as its name suggests is built from the ground-up for [[concurrent programming>>url:http://en.wikipedia.org/wiki/Concurrent_computing||shape="rect"]] - a methodology that can take advantage of these modern multi-core processors. 2 2 3 -If you use Scala for a concurrent programming application, the chances are that you're using Scala [[Actors>>http://en.wikipedia.org/wiki/Actor_model]] to do that. 3 +If you use Scala for a concurrent programming application, the chances are that you're using Scala [[Actors>>url:http://en.wikipedia.org/wiki/Actor_model||shape="rect"]] to do that. 4 4 5 5 {{info title="Scala Actors"}} 6 - 7 -Concurrent programming in Scala is based on *Actors* (with an inbox) - a simple metaphor that is analogous to *Message Queues*. 8 - 6 +Concurrent programming in Scala is based on **Actors** (with an inbox) - a simple metaphor that is analogous to **Message Queues**. 9 9 {{/info}} 10 10 11 11 == Using Scala Actors with EOF == ... ... @@ -13,13 +13,13 @@ 13 13 EOF being notoriously single-threaded, is incredibly unsuitable for use with Scala Actors: 14 14 15 15 * EOs are mutable objects and as such they cannot be passed safely to Scala Actors 16 -* Fetching and updating EOs from within Scala Actors can cause [[deadlocks>>http://en.wikipedia.org/wiki/Deadlock]] with the WebObjects application 14 +* Fetching and updating EOs from within Scala Actors can cause [[deadlocks>>url:http://en.wikipedia.org/wiki/Deadlock||shape="rect"]] with the WebObjects application 17 17 18 18 Instead you can still use EOF but in a limited fashion - only to execute SQL. 19 19 20 20 ===== Using EOAccess to execute SQL ===== 21 21 22 -Use Wonder API: [[ERXEOAccessUtilities.evaluateSQLWithEntityNamed()>>http://wocommunity.org/documents/javadoc/wonder/latest/er/extensions/eof/ERXEOAccessUtilities.html#evaluateSQLWithEntity(com.webobjects.eocontrol.EOEditingContext,%20com.webobjects.eoaccess.EOEntity,%20java.lang.String)]] 20 +Use Wonder API: [[ERXEOAccessUtilities.evaluateSQLWithEntityNamed()>>url:http://wocommunity.org/documents/javadoc/wonder/latest/er/extensions/eof/ERXEOAccessUtilities.html#evaluateSQLWithEntity(com.webobjects.eocontrol.EOEditingContext,%20com.webobjects.eoaccess.EOEntity,%20java.lang.String)||shape="rect"]] 23 23 24 24 ===== Caveats ===== 25 25 ... ... @@ -31,19 +31,19 @@ 31 31 32 32 You may also manipulate the database from outside the EOF stack. 33 33 34 -[[Squeryl>>http://max-l.github.com/Squeryl/index.html]] is.. 32 +[[Squeryl>>url:http://max-l.github.com/Squeryl/index.html||shape="rect"]] is.. 35 35 36 ->A Scala ORM and [[Domain-specific language>>http://en.wikipedia.org/wiki/Domain-specific_language]] for talking with Databases {{quote}}{{/quote}}34 +>A Scala ORM and [[Domain-specific language>>url:http://en.wikipedia.org/wiki/Domain-specific_language||shape="rect"]] for talking with Databases 37 37 38 38 You may update the database from Scala Actors using Squeryl instead of using EOF. The advantage here is that you may access the database concurrently avoiding the single-threaded EOF bottleneck in your application. However the same caveat applies - you will need to refresh EOs in the EOF stack for the WebObjects application to reflect the changes made by Squeryl. 39 39 40 -To generate a Squeryl schema from an EO model see [[WebObjects and Squeryl]]. 38 +To generate a Squeryl schema from an EO model see [[doc:documentation.WebObjects and Squeryl]]. 41 41 42 42 === Advantages === 43 43 44 44 ==== 1. Immutable Objects ==== 45 45 46 -Squeryl allows you to define simple, [[POSOs>>http://en.wikipedia.org/wiki/Plain_Old_Java_Object]] that are immutable and so are able to be safely passed between Scala Actors. 44 +Squeryl allows you to define simple, [[POSOs>>url:http://en.wikipedia.org/wiki/Plain_Old_Java_Object||shape="rect"]] that are immutable and so are able to be safely passed between Scala Actors. 47 47 48 48 ==== 2. Explicit Transaction Control ==== 49 49 ... ... @@ -76,7 +76,7 @@ 76 76 77 77 The partial update generates SQL like: 78 78 79 -{{code value="SQL"}}77 +{{code 0="SQL"}} 80 80 81 81 update Song set 82 82 year = (year + 1) ... ... @@ -89,6 +89,6 @@ 89 89 90 90 === References === 91 91 92 -* WOWODC '10 [[Slides>>http://www.wocommunity.org/wowodc10/slides/Scala+WO.pdf]] & [[Podcast>>http://www.wocommunity.org/podcasts/wowodc/2010/ScalaSession.mov]] 93 -* [[Actors in Scala - Chapter 1. Concurrency Everywhere>>http://www.artima.com/samples/ActorsInScalaPrePrintCh1.pdf]] 94 -* Scala Actors [[A Short Tutorial>>http://www.scala-lang.org/node/242]] 90 +* WOWODC '10 [[Slides>>url:http://www.wocommunity.org/wowodc10/slides/Scala+WO.pdf||shape="rect"]] & [[Podcast>>url:http://www.wocommunity.org/podcasts/wowodc/2010/ScalaSession.mov||shape="rect"]] 91 +* [[Actors in Scala - Chapter 1. Concurrency Everywhere>>url:http://www.artima.com/samples/ActorsInScalaPrePrintCh1.pdf||shape="rect"]] 92 +* Scala Actors [[A Short Tutorial>>url:http://www.scala-lang.org/node/242||shape="rect"]]