2 Replies Latest reply on Nov 27, 2005 10:09 AM by johncoleman

    decoupled persistence layer?

    johncoleman

      Hi,

      I am attampting to decouple my business logic from my persistence layer (Cayenne). I do not want to code Cayenne modeller classes into my business layer. The business layer should deal with interfaces and the database access taken care of by services in a container, a bit like EJB!

      Anyway I am using HiveMind and Cayenne.

      I'd like to make Cayenne pick up classes that have been RT changed using javassist (very nice thankyou!) to implement the interface of the business layer. I wrote the code and write the class using writeFile on the new Ct class, which seems to work. I can't find where the class goes though, and although the same class loader is used to fudge the class as the one which runs Cayenne, the modified class is not picked up! I know all my runtime changes before I load the classes. The notes seem to infer that writeFile is all I need to do.

      So where is my new class and how can I force it to be loaded? I don't like JDA BTW. It's no use to instantiate the modified classes manually from the pool, as this also needs to happen in Cayenne which I cannot modify.

      I thought of just copying bean properties using proxy classes but then again the same problem. So I really do need a way to make sure cayenne loads up my version of the class. t's possible the class loader needs a new path adding to it?

      What do you think? I'm running with the latest Tomcat. It's threads kick off the services in HiveMind.

      TIA



        • 1. Re: decoupled persistence layer?
          chiba

          writeFile() writes a class file under the current directory, which is sometime hard to identify if the program is running on Tomcat etc. What if giving a full path to writeFile()?

          • 2. Re: decoupled persistence layer?
            johncoleman

             

            "chiba" wrote:
            writeFile() writes a class file under the current directory, which is sometime hard to identify if the program is running on Tomcat etc. What if giving a full path to writeFile()?


            I wanted to implement my solution without needing to know the context path as my service has no access to it. Instead I now just load the class direct, no need to write temporary copies. Although I suppose that might be handy to save recompiling each time I start the server.