| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| <head> |
| <!-- Matomo --> |
| <script> |
| var _paq = window._paq = window._paq || []; |
| /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ |
| _paq.push(["setDoNotTrack", true]); |
| _paq.push(["disableCookies"]); |
| _paq.push(['trackPageView']); |
| _paq.push(['enableLinkTracking']); |
| (function() { |
| var u="https://analytics.apache.org/"; |
| _paq.push(['setTrackerUrl', u+'matomo.php']); |
| _paq.push(['setSiteId', '79']); |
| var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; |
| g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); |
| })(); |
| </script> |
| <!-- End Matomo Code --> |
| <title>12 The Service Layer 3.0.0.RC2</title> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
| <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen, print" title="Style" charset="utf-8"/> |
| <link rel="stylesheet" href="../css/pdf.css" type="text/css" media="print" title="PDF" charset="utf-8"/> |
| <script type="text/javascript"> |
| function addJsClass() { |
| var classes = document.body.className.split(" "); |
| classes.push("js"); |
| document.body.className = classes.join(" "); |
| } |
| </script> |
| </head> |
| |
| <body class="body" onload="addJsClass();"> |
| <div id="navigation"> |
| <ul> |
| <li> |
| <div id="nav-summary" onmouseover="toggleNavSummary(false)" onmouseout="toggleNavSummary(true)"> |
| <a href="../guide/index.html" class="button">Table of contents</a> |
| |
| <div id="nav-summary-childs" style="display:none;"> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/introduction.html"><strong>1</strong><span>Introduction</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/gettingStarted.html"><strong>2</strong><span>Getting Started</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/upgrading.html"><strong>3</strong><span>Upgrading from Grails 2.x</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/conf.html"><strong>4</strong><span>Configuration</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/commandLine.html"><strong>5</strong><span>The Command Line</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/GORM.html"><strong>6</strong><span>Object Relational Mapping (GORM)</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/theWebLayer.html"><strong>7</strong><span>The Web Layer</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/traits.html"><strong>8</strong><span>Traits</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/webServices.html"><strong>9</strong><span>Web Services</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/async.html"><strong>10</strong><span>Asynchronous Programming</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/validation.html"><strong>11</strong><span>Validation</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/services.html"><strong>12</strong><span>The Service Layer</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/staticTypeCheckingAndCompilation.html"><strong>13</strong><span>Static Type Checking And Compilation</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/testing.html"><strong>14</strong><span>Testing</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/i18n.html"><strong>15</strong><span>Internationalization</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/security.html"><strong>16</strong><span>Security</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/plugins.html"><strong>17</strong><span>Plugins</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/spring.html"><strong>18</strong><span>Grails and Spring</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/hibernate.html"><strong>19</strong><span>Grails and Hibernate</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/scaffolding.html"><strong>20</strong><span>Scaffolding</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/deployment.html"><strong>21</strong><span>Deployment</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0"><a href="../guide/contributing.html"><strong>22</strong><span>Contributing to Grails</span></a> |
| </div> |
| |
| </div> |
| </div> |
| </li> |
| <li class="separator selected"> |
| <a id="ref-button" onclick="localToggle(); return false;" href="#">Quick Reference</a> |
| </li> |
| </ul> |
| </div> |
| <div id="header"> |
| <div class="images clearfix"> |
| |
| <span id="logo"><a href="http://grails.org" target="_blank"><img alt="Grails Logo" title="The Grails Framework" src="../img/grails.png" border="0"/></a></span> |
| |
| |
| </div> |
| <p>See the light - agile, industrial strength, rapid web application development made easy</p> |
| </div> |
| |
| |
| <table id="colset" border="0" cellpadding="0" cellspacing="0"> |
| <tr> |
| <td id="col1"> |
| <div id="main" class="corner-all"> |
| |
| |
| <div class="toc-item prev-left"><a href="../guide/validation.html"><< <strong>11</strong><span>Validation</span></a></div> |
| |
| |
| <span id='toggle-col1' class="toggle">(<a href="#" onclick="localToggle(); return false;">Quick Reference</a>)</span> |
| |
| |
| <div class="toc-item next-right"><a href="../guide/staticTypeCheckingAndCompilation.html"><strong>13</strong><span>Static Type Checking And Compilation</span> >></a></div> |
| |
| |
| |
| <div class="project"> |
| <h1>12 The Service Layer - Reference Documentation</h1> |
| |
| <p><strong>Authors:</strong> Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari</p> |
| |
| <p><strong>Version:</strong> 3.0.0.RC2</p> |
| |
| |
| </div> |
| |
| |
| <div id="table-of-content"> |
| <h2>Table of Contents</h2> |
| |
| <div class="toc-item" style="margin-left:0px"><a href="#declarativeTransactions"><strong>12.1</strong><span>Declarative Transactions</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:10px"><a href="#transactionsRollbackAndTheSession"><strong>12.1.1</strong><span>Transactions Rollback and the Session</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0px"><a href="#scopedServices"><strong>12.2</strong><span>Scoped Services</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0px"><a href="#dependencyInjectionServices"><strong>12.3</strong><span>Dependency Injection and Services</span></a> |
| </div> |
| |
| <div class="toc-item" style="margin-left:0px"><a href="#usingServicesFromJava"><strong>12.4</strong><span>Using Services from Java</span></a> |
| </div> |
| |
| </div> |
| |
| |
| |
| <a name="11. The Service Layer"><!-- Legacy link --></a> |
| <h1 id="services">12 The Service Layer</h1> |
| Grails defines the notion of a service layer. The Grails team discourages the embedding of core application logic inside controllers, as it does not promote reuse and a clean separation of concerns.<p class="paragraph"/>Services in Grails are the place to put the majority of the logic in your application, leaving controllers responsible for handling request flow with redirects and so on.<p class="paragraph"/><h4>Creating a Service</h4><p class="paragraph"/>You can create a Grails service by running the <a href="../ref/Command Line/create-service.html" class="commandLine">create-service</a> command from the root of your project in a terminal window:<p class="paragraph"/><div class="code"><pre>grails create-service helloworld.simple</pre></div><p class="paragraph"/><blockquote class="note"> |
| If no package is specified with the create-service script, Grails automatically uses the application name as the package name. |
| </blockquote><p class="paragraph"/>The above example will create a service at the location <code>grails-app/services/helloworld/SimpleService.groovy</code>. A service's name ends with the convention <code>Service</code>, other than that a service is a plain Groovy class:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">package</span> helloworld<p class="paragraph"/>class SimpleService { |
| }</pre></div> |
| |
| |
| <a name="11.1 Declarative Transactions"><!-- Legacy link --></a> |
| <h2 id="declarativeTransactions">12.1 Declarative Transactions</h2> |
| <h3>Default Declarative Transactions</h3><p class="paragraph"/>Services are typically involved with coordinating logic between <a href="../guide/single.html#GORM" class="guide">domain classes</a>, and hence often involved with persistence that spans large operations. Given the nature of services, they frequently require transactional behaviour. You can use programmatic transactions with the <a href="../ref/Domain Classes/withTransaction.html" class="domainClasses">withTransaction</a> method, however this is repetitive and doesn't fully leverage the power of Spring's underlying transaction abstraction.<p class="paragraph"/>Services enable transaction demarcation, which is a declarative way of defining which methods are to be made transactional. All services are transactional by default. To disable this set the <code>transactional</code> property to <code>false</code>:<p class="paragraph"/><div class="code"><pre>class CountryService { |
| <span class="java-keyword">static</span> transactional = <span class="java-keyword">false</span> |
| }</pre></div><p class="paragraph"/>You may also set this property to <code>true</code> to make it clear that the service is intentionally transactional.<p class="paragraph"/><blockquote class="warning"> |
| Warning: <a href="../guide/single.html#dependencyInjectionServices" class="guide">dependency injection</a> is the <strong class="bold">only</strong> way that declarative transactions work. You will not get a transactional service if you use the <code>new</code> operator such as <code>new BookService()</code> |
| </blockquote><p class="paragraph"/>The result is that all methods are wrapped in a transaction and automatic rollback occurs if a method throws a runtime exception (i.e. one that extends <code>RuntimeException</code>) or an <code>Error</code>. The propagation level of the transaction is by default set to <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/transaction/TransactionDefinition.html#PROPAGATION_REQUIRED" target="blank">PROPAGATION_REQUIRED</a>.<p class="paragraph"/><blockquote class="warning"> |
| Checked exceptions do <strong class="bold">not</strong> roll back transactions. Even though Groovy blurs the distinction between checked and unchecked exceptions, Spring isn't aware of this and its default behaviour is used, so it's important to understand the distinction between checked and unchecked exceptions. |
| </blockquote><p class="paragraph"/><h3>Custom Transaction Configuration</h3><p class="paragraph"/>Grails also provides <code>@Transactional</code> and <code>@NotTransactional</code> annotations for cases where you need more fine-grained control over transactions at a per-method level or need to specify an alternative propagation level. For example, the <code>@NotTransactional</code> annotation can be used to mark a particular method to be skipped when a class is annotated with <code>@Transactional</code>.<p class="paragraph"/><blockquote class="note"> |
| The <code>grails.transaction.Transactional</code> annotation was first introduced in Grails 2.3. Prior to 2.3, Spring's @Transactional annotation was used. |
| </blockquote><p class="paragraph"/><blockquote class="note"> |
| Annotating a service method with <code>Transactional</code> disables the default Grails transactional behavior for that service (in the same way that adding <code>transactional=false</code> does) so if you use any annotations you must annotate all methods that require transactions. |
| </blockquote><p class="paragraph"/>In this example <code>listBooks</code> uses a read-only transaction, <code>updateBook</code> uses a default read-write transaction, and <code>deleteBook</code> is not transactional (probably not a good idea given its name).<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> org.springframework.transaction.annotation.Transactional<p class="paragraph"/>class BookService {<p class="paragraph"/> @Transactional(readOnly = <span class="java-keyword">true</span>) |
| def listBooks() { |
| Book.list() |
| }<p class="paragraph"/> @Transactional |
| def updateBook() { |
| // … |
| }<p class="paragraph"/> def deleteBook() { |
| // … |
| } |
| }</pre></div><p class="paragraph"/>You can also annotate the class to define the default transaction behavior for the whole service, and then override that default per-method. For example, this service is equivalent to one that has no annotations (since the default is implicitly <code>transactional=true</code>):<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> org.springframework.transaction.annotation.Transactional<p class="paragraph"/>@Transactional |
| class BookService {<p class="paragraph"/> def listBooks() { |
| Book.list() |
| }<p class="paragraph"/> def updateBook() { |
| // … |
| }<p class="paragraph"/> def deleteBook() { |
| // … |
| } |
| }</pre></div><p class="paragraph"/>This version defaults to all methods being read-write transactional (due to the class-level annotation), but the <code>listBooks</code> method overrides this to use a read-only transaction:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> org.springframework.transaction.annotation.Transactional<p class="paragraph"/>@Transactional |
| class BookService {<p class="paragraph"/> @Transactional(readOnly = <span class="java-keyword">true</span>) |
| def listBooks() { |
| Book.list() |
| }<p class="paragraph"/> def updateBook() { |
| // … |
| }<p class="paragraph"/> def deleteBook() { |
| // … |
| } |
| }</pre></div><p class="paragraph"/>Although <code>updateBook</code> and <code>deleteBook</code> aren't annotated in this example, they inherit the configuration from the class-level annotation.<p class="paragraph"/>For more information refer to the section of the Spring user guide on <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#transaction-declarative-annotations" target="blank">Using @Transactional</a>.<p class="paragraph"/>Unlike Spring you do not need any prior configuration to use <code>Transactional</code>; just specify the annotation as needed and Grails will detect them up automatically. |
| |
| |
| <a name="11.1.1 Transactions Rollback and the Session"><!-- Legacy link --></a> |
| <h2 id="transactionsRollbackAndTheSession">12.1.1 Transactions Rollback and the Session</h2> |
| <h3>Understanding Transactions and the Hibernate Session</h3><p class="paragraph"/>When using transactions there are important considerations you must take into account with regards to how the underlying persistence session is handled by Hibernate. When a transaction is rolled back the Hibernate session used by GORM is cleared. This means any objects within the session become detached and accessing uninitialized lazy-loaded collections will lead to <code>LazyInitializationException</code>s.<p class="paragraph"/>To understand why it is important that the Hibernate session is cleared. Consider the following example:<p class="paragraph"/><div class="code"><pre>class Author { |
| <span class="java-object">String</span> name |
| <span class="java-object">Integer</span> age<p class="paragraph"/> <span class="java-keyword">static</span> hasMany = [books: Book] |
| }</pre></div><p class="paragraph"/>If you were to save two authors using consecutive transactions as follows:<p class="paragraph"/><div class="code"><pre>Author.withTransaction { status -> |
| <span class="java-keyword">new</span> Author(name: <span class="java-quote">"Stephen King"</span>, age: 40).save() |
| status.setRollbackOnly() |
| }<p class="paragraph"/>Author.withTransaction { status -> |
| <span class="java-keyword">new</span> Author(name: <span class="java-quote">"Stephen King"</span>, age: 40).save() |
| }</pre></div><p class="paragraph"/>Only the second author would be saved since the first transaction rolls back the author <code>save()</code> by clearing the Hibernate session. If the Hibernate session were not cleared then both author instances would be persisted and it would lead to very unexpected results.<p class="paragraph"/>It can, however, be frustrating to get <code>LazyInitializationException</code>s due to the session being cleared.<p class="paragraph"/>For example, consider the following example:<p class="paragraph"/><div class="code"><pre>class AuthorService {<p class="paragraph"/> void updateAge(id, <span class="java-object">int</span> age) { |
| def author = Author.get(id) |
| author.age = age |
| <span class="java-keyword">if</span> (author.isTooOld()) { |
| <span class="java-keyword">throw</span> <span class="java-keyword">new</span> AuthorException(<span class="java-quote">"too old"</span>, author) |
| } |
| } |
| }</pre></div><p class="paragraph"/><div class="code"><pre>class AuthorController {<p class="paragraph"/> def authorService<p class="paragraph"/> def updateAge() { |
| <span class="java-keyword">try</span> { |
| authorService.updateAge(params.id, params.<span class="java-object">int</span>(<span class="java-quote">"age"</span>)) |
| } |
| <span class="java-keyword">catch</span>(e) { |
| render <span class="java-quote">"Author books ${e.author.books}"</span> |
| } |
| } |
| }</pre></div><p class="paragraph"/>In the above example the transaction will be rolled back if the <code>Author</code>'s age exceeds the maximum value defined in the <code>isTooOld()</code> method by throwing an <code>AuthorException</code>. The <code>AuthorException</code> references the author but when the <code>books</code> association is accessed a <code>LazyInitializationException</code> will be thrown because the underlying Hibernate session has been cleared.<p class="paragraph"/>To solve this problem you have a number of options. One is to ensure you query eagerly to get the data you will need:<p class="paragraph"/><div class="code"><pre>class AuthorService { |
| … |
| void updateAge(id, <span class="java-object">int</span> age) { |
| def author = Author.findById(id, [fetch:[books:<span class="java-quote">"eager"</span>]]) |
| ...</pre></div><p class="paragraph"/>In this example the <code>books</code> association will be queried when retrieving the <code>Author</code>.<p class="paragraph"/><blockquote class="note"> |
| This is the optimal solution as it requires fewer queries then the following suggested solutions. |
| </blockquote><p class="paragraph"/>Another solution is to redirect the request after a transaction rollback:<p class="paragraph"/><div class="code"><pre>class AuthorController {<p class="paragraph"/> AuthorService authorService<p class="paragraph"/> def updateAge() { |
| <span class="java-keyword">try</span> { |
| authorService.updateAge(params.id, params.<span class="java-object">int</span>(<span class="java-quote">"age"</span>)) |
| } |
| <span class="java-keyword">catch</span>(e) { |
| flash.message <span class="java-quote">"Can't update age"</span> |
| redirect action:<span class="java-quote">"show"</span>, id:params.id |
| } |
| } |
| }</pre></div><p class="paragraph"/>In this case a new request will deal with retrieving the <code>Author</code> again. And, finally a third solution is to retrieve the data for the <code>Author</code> again to make sure the session remains in the correct state:<p class="paragraph"/><div class="code"><pre>class AuthorController {<p class="paragraph"/> def authorService<p class="paragraph"/> def updateAge() { |
| <span class="java-keyword">try</span> { |
| authorService.updateAge(params.id, params.<span class="java-object">int</span>(<span class="java-quote">"age"</span>)) |
| } |
| <span class="java-keyword">catch</span>(e) { |
| def author = Author.read(params.id) |
| render <span class="java-quote">"Author books ${author.books}"</span> |
| } |
| } |
| }</pre></div><p class="paragraph"/><h3>Validation Errors and Rollback</h3><p class="paragraph"/>A common use case is to rollback a transaction if there are validation errors. For example consider this service:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> grails.validation.ValidationException<p class="paragraph"/>class AuthorService {<p class="paragraph"/> void updateAge(id, <span class="java-object">int</span> age) { |
| def author = Author.get(id) |
| author.age = age |
| <span class="java-keyword">if</span> (!author.validate()) { |
| <span class="java-keyword">throw</span> <span class="java-keyword">new</span> ValidationException(<span class="java-quote">"Author is not valid"</span>, author.errors) |
| } |
| } |
| }</pre></div><p class="paragraph"/>To re-render the same view that a transaction was rolled back in you can re-associate the errors with a refreshed instance before rendering:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> grails.validation.ValidationException<p class="paragraph"/>class AuthorController {<p class="paragraph"/> def authorService<p class="paragraph"/> def updateAge() { |
| <span class="java-keyword">try</span> { |
| authorService.updateAge(params.id, params.<span class="java-object">int</span>(<span class="java-quote">"age"</span>)) |
| } |
| <span class="java-keyword">catch</span> (ValidationException e) { |
| def author = Author.read(params.id) |
| author.errors = e.errors |
| render view: <span class="java-quote">"edit"</span>, model: [author:author] |
| } |
| } |
| }</pre></div> |
| |
| |
| <a name="11.2 Scoped Services"><!-- Legacy link --></a> |
| <h2 id="scopedServices">12.2 Scoped Services</h2> |
| By default, access to service methods is not synchronised, so nothing prevents concurrent execution of those methods. In fact, because the service is a singleton and may be used concurrently, you should be very careful about storing state in a service. Or take the easy (and better) road and never store state in a service.<p class="paragraph"/>You can change this behaviour by placing a service in a particular scope. The supported scopes are: |
| <ul class="star"> |
| <li><code>prototype</code> - A new service is created every time it is injected into another class</li> |
| <li><code>request</code> - A new service will be created per request</li> |
| <li><code>flash</code> - A new service will be created for the current and next request only</li> |
| <li><code>flow</code> - In web flows the service will exist for the scope of the flow</li> |
| <li><code>conversation</code> - In web flows the service will exist for the scope of the conversation. ie a root flow and its sub flows</li> |
| <li><code>session</code> - A service is created for the scope of a user session</li> |
| <li><code>singleton</code> (default) - Only one instance of the service ever exists</li> |
| </ul><p class="paragraph"/><blockquote class="note"> |
| If your service is <code>flash</code>, <code>flow</code> or <code>conversation</code> scoped it must implement <code>java.io.Serializable</code> and can only be used in the context of a Web Flow. |
| </blockquote><p class="paragraph"/>To enable one of the scopes, add a static scope property to your class whose value is one of the above, for example<p class="paragraph"/><div class="code"><pre><span class="java-keyword">static</span> scope = <span class="java-quote">"flow"</span></pre></div><p class="paragraph"/><blockquote class="note"> |
| For new Grails apps since 2.3, default controller scope is <code>singleton</code>, resulting in <code>prototype</code> scope services that are effectively per-controller singletons. If non-singleton services are required, controller scope should be changed as well. |
| </blockquote> |
| |
| |
| <a name="11.3 Dependency Injection and Services"><!-- Legacy link --></a> |
| <h2 id="dependencyInjectionServices">12.3 Dependency Injection and Services</h2> |
| <h4>Dependency Injection Basics</h4><p class="paragraph"/>A key aspect of Grails services is the ability to use <a href="http://www.springframework.org/" target="blank">Spring Framework</a>'s dependency injection features. Grails supports "dependency injection by convention". In other words, you can use the property name representation of the class name of a service to automatically inject them into controllers, tag libraries, and so on.<p class="paragraph"/>As an example, given a service called <code>BookService</code>, if you define a property called <code>bookService</code> in a controller as follows:<p class="paragraph"/><div class="code"><pre>class BookController { |
| def bookService |
| … |
| }</pre></div><p class="paragraph"/>In this case, the Spring container will automatically inject an instance of that service based on its configured scope. All dependency injection is done by name. You can also specify the type as follows:<p class="paragraph"/><div class="code"><pre>class AuthorService { |
| BookService bookService |
| }</pre></div><p class="paragraph"/><blockquote class="note"> |
| NOTE: Normally the property name is generated by lower casing the first letter of the type. For example, an instance of the <code>BookService</code> class would map to a property named <code>bookService</code>.<p class="paragraph"/>To be consistent with standard JavaBean conventions, if the first 2 letters of the class name are upper case, the property name is the same as the class name. For example, the property name of the <code>JDBCHelperService</code> class would be <code>JDBCHelperService</code>, not <code>jDBCHelperService</code> or <code>jdbcHelperService</code>.<p class="paragraph"/>See section 8.8 of the JavaBean specification for more information on de-capitalization rules. |
| </blockquote><p class="paragraph"/><h4>Dependency Injection and Services</h4><p class="paragraph"/>You can inject services in other services with the same technique. If you had an <code>AuthorService</code> that needed to use the <code>BookService</code>, declaring the <code>AuthorService</code> as follows would allow that:<p class="paragraph"/><div class="code"><pre>class AuthorService { |
| def bookService |
| }</pre></div><p class="paragraph"/><h4>Dependency Injection and Domain Classes / Tag Libraries</h4><p class="paragraph"/>You can even inject services into domain classes and tag libraries, which can aid in the development of rich domain models and views:<p class="paragraph"/><div class="code"><pre>class Book { |
| … |
| def bookService<p class="paragraph"/> def buyBook() { |
| bookService.buyBook(<span class="java-keyword">this</span>) |
| } |
| }</pre></div><p class="paragraph"/><h4>Service Bean Names</h4><p class="paragraph"/>The default bean name which is associated with a service can be problematic if there are multiple services with the same name defined in different packages. For example consider the situation where an application defines a service class named <code>com.demo.ReportingService</code> and the application uses a plugin named <code>ReportingUtilities</code> and that plugin provides a service class named <code>com.reporting.util.ReportingService</code>. The default bean name for each of those would be <code>reportingService</code> so they would conflict with each other. Grails manages this by changing the default bean name for services provided by plugins by prefixing the bean name with the plugin name. In the scenario described above the <code>reportingService</code> bean would be an instance of the <code>com.demo.ReportingService</code> class defined in the application and the <code>reportingUtilitiesReportingService</code> bean would be an instance of the <code>com.reporting.util.ReportingService</code> class provided by the <code>ReportingUtilities</code> plugin. For all service beans provided by plugins, if there are no other services with the same name within the application or other plugins in the application then a bean alias will be created which does not include the plugin name and that alias points to the bean referred to by the name that does include the plugin name prefix. For example, if the <code>ReportingUtilities</code> plugin provides a service named <code>com.reporting.util.AuthorService</code> and there is no other <code>AuthorService</code> in the application or in any of the plugins that the application is using then there will be a bean named <code>reportingUtilitiesAuthorService</code> which is an instance of this <code>com.reporting.util.AuthorService</code> class and there will be a bean alias defined in the context named <code>authorService</code> which points to that same bean. |
| |
| <a name="11.4 Using Services from Java"><!-- Legacy link --></a> |
| <h2 id="usingServicesFromJava">12.4 Using Services from Java</h2> |
| One of the powerful things about services is that since they encapsulate re-usable logic, you can use them from other classes, including Java classes. There are a couple of ways you can reuse a service from Java. The simplest way is to move your service into a package within the <code>grails-app/services</code> directory. The reason this is important is that it is not possible to import classes into Java from the default package (the package used when no package declaration is present). So for example the <code>BookService</code> below cannot be used from Java as it stands:<p class="paragraph"/><div class="code"><pre>class BookService { |
| void buyBook(Book book) { |
| // logic |
| } |
| }</pre></div><p class="paragraph"/>However, this can be rectified by placing this class in a package, by moving the class into a sub directory such as <code>grails-app/services/bookstore</code> and then modifying the package declaration:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">package</span> bookstore<p class="paragraph"/>class BookService { |
| void buyBook(Book book) { |
| // logic |
| } |
| }</pre></div><p class="paragraph"/>An alternative to packages is to instead have an interface within a package that the service implements:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">package</span> bookstore<p class="paragraph"/><span class="java-keyword">interface</span> BookStore { |
| void buyBook(Book book) |
| }</pre></div><p class="paragraph"/>And then the service:<p class="paragraph"/><div class="code"><pre>class BookService <span class="java-keyword">implements</span> bookstore.BookStore { |
| void buyBook(Book b) { |
| // logic |
| } |
| }</pre></div><p class="paragraph"/>This latter technique is arguably cleaner, as the Java side only has a reference to the interface and not to the implementation class (although it's always a good idea to use packages). Either way, the goal of this exercise to enable Java to statically resolve the class (or interface) to use, at compile time.<p class="paragraph"/>Now that this is done you can create a Java class within the <code>src/java</code> directory and add a setter that uses the type and the name of the bean in Spring:<p class="paragraph"/><div class="code"><pre>// src/java/bookstore/BookConsumer.java |
| <span class="java-keyword">package</span> bookstore;<p class="paragraph"/><span class="java-keyword">public</span> class BookConsumer {<p class="paragraph"/> <span class="java-keyword">private</span> BookStore store;<p class="paragraph"/> <span class="java-keyword">public</span> void setBookStore(BookStore storeInstance) { |
| <span class="java-keyword">this</span>.store = storeInstance; |
| } |
| … |
| }</pre></div><p class="paragraph"/>Once this is done you can configure the Java class as a Spring bean in <code>grails-app/conf/spring/resources.xml</code> (for more information see the section on <a href="../guide/single.html#spring" class="guide">Grails and Spring</a>):<p class="paragraph"/><div class="code"><pre><span class="xml-tag"><bean id=<span class="xml-quote">"bookConsumer"</span> class=<span class="xml-quote">"bookstore.BookConsumer"</span>></span> |
| <span class="xml-tag"><property name=<span class="xml-quote">"bookStore"</span> ref=<span class="xml-quote">"bookService"</span> /></span> |
| <span class="xml-tag"></bean></span></pre></div><p class="paragraph"/>or in <code>grails-app/conf/spring/resources.groovy</code>:<p class="paragraph"/><div class="code"><pre><span class="java-keyword">import</span> bookstore.BookConsumer<p class="paragraph"/>beans = { |
| bookConsumer(BookConsumer) { |
| bookStore = ref(<span class="java-quote">"bookService"</span>) |
| } |
| }</pre></div> |
| |
| |
| |
| <div style="clear:both;margin-top:15px;"></div> |
| |
| <div class="toc-item prev-left"><a href="../guide/validation.html"><< <strong>11</strong><span>Validation</span></a></div> |
| |
| <div class="toc-item next-right"><a href="../guide/staticTypeCheckingAndCompilation.html"><strong>13</strong><span>Static Type Checking And Compilation</span> >></a></div> |
| |
| <div style="clear:both"></div> |
| </div> |
| </td> |
| <td id="col2"> |
| <div class="local clearfix"> |
| <div class="local-title"> |
| <a href="../guide/index.html" target="mainFrame">Quick Reference</a> |
| <span class="toggle">(<a href="#" onclick="localToggle(); return false;">hide</a>)</span> |
| </div> |
| <div class="menu"> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Command Line</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/alias.html">alias</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/bug-report.html">bug-report</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/clean.html">clean</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/compile.html">compile</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/console.html">console</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-app.html">create-app</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-command.html">create-command</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-controller.html">create-controller</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-domain-class.html">create-domain-class</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-functional-test.html">create-functional-test</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-integration-test.html">create-integration-test</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-interceptor.html">create-interceptor</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-plugin.html">create-plugin</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-script.html">create-script</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-service.html">create-service</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-tag-lib.html">create-tag-lib</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/create-unit-test.html">create-unit-test</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/dependency-report.html">dependency-report</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/doc.html">doc</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/generate-all.html">generate-all</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/generate-controller.html">generate-controller</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/generate-views.html">generate-views</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/help.html">help</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/list-plugins.html">list-plugins</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/package-plugin.html">package-plugin</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/package.html">package</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/plugin-info.html">plugin-info</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/run-app.html">run-app</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/schema-export.html">schema-export</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/shell.html">shell</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/stats.html">stats</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/test-app.html">test-app</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Command%20Line/war.html">war</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Constraints</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Constraints/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Constraints/attributes.html">attributes</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/bindable.html">bindable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/blank.html">blank</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/creditCard.html">creditCard</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/email.html">email</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/inList.html">inList</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/matches.html">matches</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/max.html">max</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/maxSize.html">maxSize</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/min.html">min</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/minSize.html">minSize</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/notEqual.html">notEqual</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/nullable.html">nullable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/range.html">range</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/scale.html">scale</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/size.html">size</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/unique.html">unique</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/url.html">url</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/validator.html">validator</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Constraints/widget.html">widget</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Controllers</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Controllers/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Controllers/actionName.html">actionName</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/afterInterceptor.html">afterInterceptor</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/allowedMethods.html">allowedMethods</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/beforeInterceptor.html">beforeInterceptor</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/bindData.html">bindData</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/chain.html">chain</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/controllerName.html">controllerName</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/defaultAction.html">defaultAction</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/errors.html">errors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/flash.html">flash</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/forward.html">forward</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/grailsApplication.html">grailsApplication</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/hasErrors.html">hasErrors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/namespace.html">namespace</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/params.html">params</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/redirect.html">redirect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/render.html">render</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/request.html">request</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/respond.html">respond</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/response.html">response</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/responseFormats.html">responseFormats</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/scope.html">scope</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/servletContext.html">servletContext</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/session.html">session</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/withForm.html">withForm</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Controllers/withFormat.html">withFormat</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Database Mapping</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/autoImport.html">autoImport</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/autoTimestamp.html">autoTimestamp</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/batchSize.html">batchSize</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/cache.html">cache</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/cascade.html">cascade</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/column.html">column</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/comment.html">comment</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/discriminator.html">discriminator</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/dynamicInsert.html">dynamicInsert</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/dynamicUpdate.html">dynamicUpdate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/fetch.html">fetch</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/id.html">id</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/ignoreNotFound.html">ignoreNotFound</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/indexColumn.html">indexColumn</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/insertable.html">insertable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/joinTable.html">joinTable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/lazy.html">lazy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/order.html">order</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/sort.html">sort</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/table.html">table</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/type.html">type</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/updateable.html">updateable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Database%20Mapping/version.html">version</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Domain Classes</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/addTo.html">addTo</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/attach.html">attach</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/belongsTo.html">belongsTo</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/clearErrors.html">clearErrors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/constraints.html">constraints</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/count.html">count</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/countBy.html">countBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/createCriteria.html">createCriteria</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/delete.html">delete</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/discard.html">discard</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/embedded.html">embedded</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/errors.html">errors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/executeQuery.html">executeQuery</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/executeUpdate.html">executeUpdate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/exists.html">exists</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/fetchMode.html">fetchMode</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/find.html">find</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findAll.html">findAll</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findAllBy.html">findAllBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findAllWhere.html">findAllWhere</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findBy.html">findBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findOrCreateBy.html">findOrCreateBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findOrCreateWhere.html">findOrCreateWhere</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findOrSaveBy.html">findOrSaveBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findOrSaveWhere.html">findOrSaveWhere</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/findWhere.html">findWhere</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/first.html">first</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/get.html">get</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/getAll.html">getAll</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/getDirtyPropertyNames.html">getDirtyPropertyNames</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/getPersistentValue.html">getPersistentValue</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/hasErrors.html">hasErrors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/hasMany.html">hasMany</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/hasOne.html">hasOne</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/ident.html">ident</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/instanceOf.html">instanceOf</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/isAttached.html">isAttached</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/isDirty.html">isDirty</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/last.html">last</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/list.html">list</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/listOrderBy.html">listOrderBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/load.html">load</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/lock.html">lock</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/mapWith.html">mapWith</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/mappedBy.html">mappedBy</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/mapping.html">mapping</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/merge.html">merge</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/namedQueries.html">namedQueries</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/properties.html">properties</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/read.html">read</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/refresh.html">refresh</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/removeFrom.html">removeFrom</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/save.html">save</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/transients.html">transients</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/validate.html">validate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/where.html">where</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/whereAny.html">whereAny</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/withCriteria.html">withCriteria</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/withNewSession.html">withNewSession</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/withSession.html">withSession</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Domain%20Classes/withTransaction.html">withTransaction</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Plug-ins</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/URL%20mappings.html">URL mappings</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/codecs.html">codecs</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/controllers.html">controllers</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/core.html">core</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/dataSource.html">dataSource</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/domainClasses.html">domainClasses</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/hibernate.html">hibernate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/i18n.html">i18n</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/logging.html">logging</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/scaffolding.html">scaffolding</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/services.html">services</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Plug-ins/servlets.html">servlets</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Services</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Services/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Services/scope.html">scope</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Services/transactional.html">transactional</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Servlet API</h1><div class="menu-sub"> |
| |
| |
| <div class="menu-item"><a href="../ref/Servlet%20API/request.html">request</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Servlet%20API/response.html">response</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Servlet%20API/servletContext.html">servletContext</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Servlet%20API/session.html">session</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Tag Libraries</h1><div class="menu-sub"> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/Usage.html">Usage</a></div> |
| |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/actionName.html">actionName</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/controllerName.html">controllerName</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/flash.html">flash</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/pageScope.html">pageScope</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/params.html">params</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/request.html">request</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/response.html">response</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/servletContext.html">servletContext</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tag%20Libraries/session.html">session</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| <div class="menu-block"><h1 class="menu-title" onclick="toggleRef(this.parentNode.childNodes[1])">Tags</h1><div class="menu-sub"> |
| |
| |
| <div class="menu-item"><a href="../ref/Tags/actionSubmit.html">actionSubmit</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/actionSubmitImage.html">actionSubmitImage</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/applyLayout.html">applyLayout</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/checkBox.html">checkBox</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/collect.html">collect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/cookie.html">cookie</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/country.html">country</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/countrySelect.html">countrySelect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/createLink.html">createLink</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/createLinkTo.html">createLinkTo</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/currencySelect.html">currencySelect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/datePicker.html">datePicker</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/each.html">each</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/eachError.html">eachError</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/else.html">else</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/elseif.html">elseif</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/external.html">external</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/field.html">field</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/fieldValue.html">fieldValue</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/findAll.html">findAll</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/form.html">form</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/formatBoolean.html">formatBoolean</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/formatDate.html">formatDate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/formatNumber.html">formatNumber</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/grep.html">grep</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/hasErrors.html">hasErrors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/header.html">header</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/hiddenField.html">hiddenField</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/if.html">if</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/img.html">img</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/include.html">include</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/isAvailable.html">isAvailable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/isNotAvailable.html">isNotAvailable</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/javascript.html">javascript</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/join.html">join</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/layoutBody.html">layoutBody</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/layoutHead.html">layoutHead</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/layoutTitle.html">layoutTitle</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/link.html">link</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/localeSelect.html">localeSelect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/message.html">message</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/meta.html">meta</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/pageProperty.html">pageProperty</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/paginate.html">paginate</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/passwordField.html">passwordField</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/radio.html">radio</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/radioGroup.html">radioGroup</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/render.html">render</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/renderErrors.html">renderErrors</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/resource.html">resource</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/select.html">select</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/set.html">set</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/sortableColumn.html">sortableColumn</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/submitButton.html">submitButton</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/textArea.html">textArea</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/textField.html">textField</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/timeZoneSelect.html">timeZoneSelect</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/unless.html">unless</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/uploadForm.html">uploadForm</a> |
| </div> |
| |
| <div class="menu-item"><a href="../ref/Tags/while.html">while</a> |
| </div> |
| |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| </td> |
| </tr> |
| </table> |
| |
| <div id="footer"> |
| Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. |
| |
| </div> |
| |
| <script type="text/javascript" src="../js/docs.js"></script> |
| |
| </body> |
| </html> |