Announcement Announcement Module
Collapse
No announcement yet.
AOP with spring dm server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP with spring dm server

    Is it not possible to have my Aspect defined in standalone bundle that is to say seperate from the bundle implementing the service being adviced

  • #2
    Are you using AspectJ with load-time weaving or compile-time weaving?

    This is definitely possible when compile-time weaving is used: dm Server itself uses a number of aspects that are held in bundles that are separate to those that have been advised.

    If you're using load-time weaving then things become significantly more complex. My advice in this case would be to consider using compile-time weaving if possible.

    Comment


    • #3
      i am using runtime weaving support provided by spring AOP

      Basically i have a Bundle(say BundleA) with service interface ,BundleB implementing the interface

      Now i don't want each implementer to have a Aspect defined in there application context ,instead i would prefer to define Aspect in the interface bundle so that all the Bundles which provide implementation are adviced

      Comment


      • #4
        Ah, ok, you're using Spring AOP: that makes things easier.

        When you configure a LoadTimeWeaver bean in your application context, dm Server automatically replaces it with an OSGi-aware load-time weaver implementation: KernelLoadTimeWeaver.

        You'll have to make sure that your bundle manifest imports the package(s) that contain your aspect(s).

        I would recommend giving this a go and letting us know if you encounter any problems and we'll do what we can to help.

        Comment


        • #5
          Hi Andy ,

          This did not work either .

          Regards

          vishal

          Comment


          • #6
            Ok. What was the failure that you encountered? It's going to be very hard to diagnose the problem without more details on what you were trying to do, and what went wrong. We'll need stack traces, log output, etc.

            Comment


            • #7
              Shall i upload my demo bundles ,If it may help

              Comment


              • #8
                Yes, that may help, but we may be able to identify the problem just from the stack trace of the error (assuming you're getting one) so please let us know what this is too.

                Comment


                • #9
                  Hi andy ,
                  I am not getting any Exception as such but my sysouts from the advice
                  I have attached my Demo
                  Last edited by vishalj; Oct 26th, 2009, 12:38 AM.

                  Comment


                  • #10
                    Thanks, Vishal. Could you attach compiled binaries already in their bundles, please? I'd like to be sure that we're both working against the exact same code.

                    Comment


                    • #11
                      Hi Andy ,

                      i have attached the binaries

                      regards,
                      vishal

                      Comment


                      • #12
                        Hi Andy,

                        Have attached the binaries

                        Comment


                        • #13
                          As far as I can tell, this is working as it should. By default dm Server captures System.out and System.err and routes it to the log files. To make things a bit easier I changed the configuration in com.springsource.osgi.medic.properties to disable this so that the output would be visible in the console:

                          Code:
                          dump.root.directory=serviceability/dump
                          log.wrapSysOut=false
                          log.wrapSysErr=false
                          log.dump.level=DEBUG
                          log.dump.bufferSize=10000
                          log.dump.pattern=[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-28.28thread %-64.64logger{64} %X{medic.eventCode} %msg %ex%n

                          I also modified your bundles slightly (to use Import-Package, rather than Import-Bundle for their dependency upon Aspect J) and deployed them. This resulted in the following output:

                          Code:
                          [2009-11-16 16:55:16.121] deployer-recovery            <DE0059I> Starting bundle 'ServiceCounterRef' version '1.0.0'. 
                          com.xyz.myservice.MyServiceImpl
                          Class Name com.xyz.service.IServiceMethod sayHello
                          Hello
                          com.xyz.myservice.MyServiceImpl
                          Class Name com.xyz.service.IServiceMethod sayHello
                          Hello
                          com.xyz.myservice.MyServiceImpl
                          Class Name com.xyz.service.IServiceMethod sayHello
                          Hello
                          com.xyz.myservice.MyServiceImpl
                          Class Name com.xyz.service.IServiceMethod sayHello
                          Hello
                          com.xyz.myservice.MyServiceImpl
                          Class Name com.xyz.service.IServiceMethod sayHello
                          Hello
                          [2009-11-16 16:55:16.267] start-signalling-1           <DE0060I> Started bundle 'ServiceCounterRef' version '1.0.0'.

                          Comment


                          • #14
                            Hi Andy,

                            Can you give us some more insight on regions ,basically user region and kernel region. I have lot of doubts like
                            • what gets into user region and what gets into kernel region ?
                            • What is the configuration to set what gets into user/kernel region ?
                            • Whats shared between user and kernel region ? This is to avoid bloating . Whats the configuration for this ?

                            Any blog explaining these would be of great help.

                            Comment


                            • #15
                              Hi Andy ,

                              Sorry for the incorrect binaries , you can see the aop config being defined in both the implementation bundle(impl.jar/META-INF/spring/module-context.xml) and interface bundle(intf.jar/META-INF/spring/context.xml)

                              I prefer it to be kept only in interface bundle .Is that feasible.
                              Last edited by vishalj; Nov 17th, 2009, 03:47 AM.

                              Comment

                              Working...
                              X