{"id":5256,"date":"2014-03-30T20:03:04","date_gmt":"2014-03-30T20:03:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-if-i-want-to-have-my-own-plug-in-architecture-within-grails-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:03:04","modified_gmt":"2014-03-30T20:03:04","slug":"what-if-i-want-to-have-my-own-plug-in-architecture-within-grails-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/what-if-i-want-to-have-my-own-plug-in-architecture-within-grails-collection-of-common-programming-errors\/","title":{"rendered":"What if I want to have my own plug-in architecture within Grails?-Collection of common programming errors"},"content":{"rendered":"<p>Grails uses Spring underneath, so you can inject as many services into your controller as you wish if you know Spring.<\/p>\n<p>But I&#8217;d think about a possible good reason to not do so. When you start putting several services into a controller, it&#8217;s the controller that&#8217;s taking over the order in which they&#8217;re called. It sounds like a workflow to me at that point, something that is best left to a service.<\/p>\n<p>Controllers are part of the web tier. You can&#8217;t expose that process to a client that comes in through another channel besides the web tier if it&#8217;s buried in the controller.<\/p>\n<p>I&#8217;d recommend that you not do this, even if it&#8217;s possible. A better idea would be to expose what sounds like a complex use case in another service. Encapsulate it and hide the details from clients. That&#8217;s what objects are for &#8211; hiding complexity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grails uses Spring underneath, so you can inject as many services into your controller as you wish if you know Spring. But I&#8217;d think about a possible good reason to not do so. When you start putting several services into a controller, it&#8217;s the controller that&#8217;s taking over the order in which they&#8217;re called. It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5256","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5256"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5256\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}