Results 1 to 3 of 3

Thread: Spring Annotation Usage

  1. #1

    Default Spring Annotation Usage

    Hi,

    I am using Spring 3.0 in my project. My project architecture is something like this.

    Controller -> delegate -> Service -> DAO -> Adapter layer.

    My question is. I am using annotation. So

    Controller -> @Controller
    Delegate -> ?
    Service -> @Service
    DAO -> @Repository @Transactional
    Adapter -> ?

    Delegate will be injected to Controller. Service will be injected to Delegate. DAO will be injected to Service. Adapter will be injected to DAO. Thats how DI works in my project.

    I am not sure what annotation i have to use in Adapter and Delegate layer. Also can somebody tell me whether the annotation tag that i am using in each layer is correct or not?

    Thanks,
    Pradeep

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello

    Normally I use

    Code:
    Controller -> @Controller
    Service -> @Service + @Transactional
    DAO -> @Repository + @Transactional
    Delegate will be injected to Controller. Service will be injected to Delegate.
    could you post your code about that?, I want to see what does your Delegate than a Service cant does

    Adapter will be injected to DAO.
    Like my previous request

    is really important and mandatory that @Transactional annotation be in the Service and dao layer to let Spring has and handle the transaction control through both layers

    I am not sure what annotation i have to use in Adapter and Delegate layer.
    There are no exists an annotation for these two layers, if is mandatory for your application, you can use the @Component annotation

    Also can somebody tell me whether the annotation tag that i am using in each layer is correct or not?
    The rest is OK, just recall my comment about the @Transactional annotation
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Dec 2008
    Location
    India
    Posts
    295

    Default

    Hey Pradeep,

    Spring already providing @Component annotation so you can use @Component, otherwise make your own annotation by inheriting @Component for ur desired layer. But i must agree with Manuel that his suggest approach is right for standard application.
    Enjoy
    Rohan Chauhan
    ------------------------------------------------------------------------------
    SpringSource Certified Spring 3.0 Professional


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •