Announcement Announcement Module
Collapse
No announcement yet.
GORM domain from Java code. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GORM domain from Java code.

    I have something like this


    1) Grails application --> Invokes message listener written in Java
    2) Message Listener --> Reflectively invokes service classes written in Java
    3) Now I want to create GORM Domain objects from these classes

    For this I think I need to do two things (Correct me if I am wrong)
    A) Get access to Grails applicationContext
    B) Get the beans that I need e.g. domain objects and perform operations on them.

    But before I do that can anyone help me how to do "A" ?

  • #2
    So you want to instantiate the domain classes from your Java code? Do you then want to save them? What sort of operations? If you want access to the save() method and the validation errors, then I'm afraid you're best off waiting for Grails 2.0 which makes these things available to Java code.

    Comment


    • #3
      Originally posted by pledbrook View Post
      So you want to instantiate the domain classes from your Java code? Do you then want to save them? What sort of operations? If you want access to the save() method and the validation errors, then I'm afraid you're best off waiting for Grails 2.0 which makes these things available to Java code.
      We have JMS Listeners (not using JMS plugin or spring JMSTemplate) that are loading service classes based on contents , so we are using class.forName to load service classes.

      What I want to do is load grails beans from these service classes. I am assuming that once I am able to load beans from service classes from grails context I will be back in dependency injected mechanism and everything will be using grails.

      BTW When Grails 2.0 coming out ? Can I access it from any nightly releases?
      Last edited by mahmood.khurram; Jul 28th, 2011, 03:51 PM.

      Comment


      • #4
        I think I am able get my beans from servlets like this , If I warp this in singleton class then I am not reloading application context and I can call my groovy domain objects from my groovy beans.

        GrailsApplication application = (GrailsApplication) getServletContext().getAttribute(GrailsApplication .APPLICATION_ID);

        Comment

        Working...
        X