Japanese Advanced Topics

Last updated by admin 4 years ago

???????????? {excerpt:hidden=true}Advanced Topics{excerpt}

Grails?????? {excerpt:hidden=true}Grails Artifacts{excerpt}

{excerpt:hidden=true} Grails takes the separation of concerns approach splitting a Grails application in three layers or tiers:{excerpt}

Grails??Grails?????????3????????????????????????????: {excerpt:hidden=true}

  • web tier: presentation logic resides here. Artifacts are:
  • business logic tier: business logic controlled by a middle tier that supports transactional demarcation. Artifacts are:
  • persistence tier: operates within the transactional boundries of the business tier and is also controlled by a middle tier, deals with persistence details. Artifacts are:
    • domain class persistence methods
    • data sources
    • ORM tool sessions and factories.
{excerpt}
  • web?: ?????????????????????????????????:
  • ?????????: ?????????????????????????????????????????????????:
  • ????: ????????????????????????????????????????????????????????????:
    • ??????? ???????
    • ??????
    • ORM ???????????????
{excerpt:hidden=true} Grails requires users to provide some of the artifacts in the above list. Configuration of these artifacts is taken care of by Grails based on a number of conventions per artifact type.{excerpt}

Grails??????????????????????????????????????????Grails?????????????????????????

???????????? {excerpt:hidden=true}Injection behavior{excerpt}

{excerpt:hidden=true} Whenever injection of beans is supported the default behaviour is injection by type.{excerpt}

beans???????????????????????????????????????????????????

CountryService countryService
{excerpt:hidden=true} In this example a bean of type CountryService is required.{excerpt}

?????????CountryService?bean??????

{excerpt:hidden=true} To enable injection by name add a "byName" property to the class and set it to true:{excerpt}

??????????????????????????????"byName"?????????????true??????:

boolean byName = true
{excerpt:hidden=true} In the example above this would require a bean named "countryService".{excerpt}

?????????"countryService"??????bean?????????

{excerpt:hidden=true} When beans should not be available for injection create an "available" property and set it false. This property can be used to avoid type conflicts.{excerpt}

bean???????????????????????"available"????????????false???????????????????????????????????????

boolean available = true

???????? {excerpt:hidden=true}Configurational properties{excerpt}

{excerpt:hidden=true} When property names are reserved for the configuration of specific artifacts in Grails other properties with the same name but not the same type are ignored.{excerpt}

Grails??????????????????????????????????????????????????????

class SomeService {
    boolean transactional = false
    String transactional = "false" // ????????????????????????
}