1 2 Previous Next 17 Replies Latest reply on Jul 21, 2006 11:35 AM by Adrian Brock

    JBAOP-87 - Annotation Dependencies

    Adrian Brock Master

      I think Kabir has got the basic test working?
      but obviously this needs some more tests.

      This functionality also ties into "write your own dependency" feature
      that hasn't been done yet in the MC.
      The idea being that you can change the dependency to be something
      other than a direct name in the MC.

      e.g.

      @Retention(RetentionPolicy.RUNTIME)
      @Dependency(name="domain", factory="org.jboss.security.SecurityDomainDependencyFactory")
      public @interface SecurityDomain
      {
       String domain();
      
       String securityManagerName() default "SecurityManager";
      }
      


      And the dependency will be satisfied when the factory says that the
      domain is installed into the security manager.

        • 1. Re: JBAOP-87 - Annotation Dependencies
          Kabir Khan Master

          I have added some more tests for this (JBAOP-239).

          Is the rest of JBAOP-87 simply a matter of annotating things from the "aspects" module - or do I need to look at other modules as well?

          • 2. Re: JBAOP-87 - Annotation Dependencies
            Kabir Khan Master

            Is the plan for it to be possible to create nested annotations from the MC xml?

            e.g some xml like

             <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">
             <annotation ....>
             </bean>
            


            which could result in something like
            @Containing(dependency=@TestAnnotationDependency(data="Dependency1"),
            contained=@Contained(dependencies= {@TestAnnotationDependency(data="Dependency2"), @TestAnnotationDependency(data="Dependency3")}))
            public class NestedAnnotatedSimpleBeanImpl extends SimpleBeanImpl
            {
            
            }
            


            • 3. Re: JBAOP-87 - Annotation Dependencies
              Adrian Brock Master

              Yes, but currently only strings are supported by AnnotationAttributeMetaData

              Like I said on a different thread, there should be a way to construct
              all objects that can go in all annotations.

              For primitive types, this would just be the same as what
              StringValueMetaData does, i.e. use TypeInfo.convertValue.

              I'm not sure what the syntax would look like for the annotation
              you describe?

              • 4. Re: JBAOP-87 - Annotation Dependencies
                Kabir Khan Master

                Yes, I guess how this works at the moment is kind of hackish - I construct a string, similar to the -aop.xml annotation introductions/overides, that I pass in to the aop annotation creator. I'll look at doing this differently.

                I'll try to come up with an xml syntax once I've looked into it

                • 5. Re: JBAOP-87 - Annotation Dependencies
                  Adrian Brock Master

                  I think it will be a good idea to make the MC annotation xml more free format.
                  Writing your example annotation in xml would be very verbose
                  and pointless unless we are going to allow injections into the annotation,
                  e.g.

                  <!-- Potentially injected annotation construction -->
                  <annotation name="Blah">
                   <attribute name="DataSourceName"><inject bean="SomeDS" property="name"/>
                  </annotation>
                  


                  Better would be to just support:
                  <annotation>
                  @Containing(dependency=@TestAnnotationDependency(data="Dependency1"),
                  contained=@Contained(dependencies= {@TestAnnotationDependency(data="Dependency2"), @TestAnnotationDependency(data="Dependency3")}))
                  </annotation>
                  


                  • 6. Re: JBAOP-87 - Annotation Dependencies
                    Adrian Brock Master

                    Also as part of the metadata stuff I'm doing, I've been looking
                    at what it would take to move the AOP Annotation implementation into container and fix it to make it properly.

                    This is because I need a generic method to populate annotations
                    at all levels of metadata, e.g. (pseudo xml)

                    <deployment ...>
                     <annotation>@DeploymentLevelAnnotation</annotation>
                    </deployment>
                    
                    or
                    
                    <deployment subsystem="JCA">
                     <annotation>@SecurityDomain("DefaultJCARealm")</annotation>
                    </deployment>
                    


                    However when I looked at the AOP implementation, it has two problems:
                    1) It does not implement the Annotation properly - no annotationType()
                    2) It does not add default values

                    Obviously to apply default values, is going to require javassist
                    to read them from the annotation interface class.

                    I'd also like to be able to use constructed annotations without javassist
                    in the classpath, even if that means default values won't be applied.

                    So what I'd like is an annotation factory that can vary based
                    on whether javassist is in the classpath.


                    • 7. Re: JBAOP-87 - Annotation Dependencies
                      Kabir Khan Master

                      I've got this moved out the container on my machine. I'll try to get the javassist stuff working this weekend, and then I'll update the mc snapshot jars in the repository.

                      I've kept the signature of the AnnotationCreator.create method untyped since I'm not sure at this stage if I want to force JDK 1.4 users to have their annotation interfaces implementing org.jboss.lang.Annotation

                       public static Object createAnnotation(final String annotationExpr, final Class annotation) throws Exception
                      



                      • 8. Re: JBAOP-87 - Annotation Dependencies
                        Kabir Khan Master

                        BTW how should we manage the dependency from AOP on the container?

                        jboss-aop.deployer contains the aop stuff
                        jboss-bean.deployer contains jboss-container.jar

                        I will also need to create a retroed version of the jboss-container.jar that can be used with the aop JDK 1.4 distribution.

                        • 9. Re: JBAOP-87 - Annotation Dependencies
                          Adrian Brock Master

                          container is meant to be a common set of repositories for use by everybody.
                          The packaging of it in jboss-bean.deployer is purely historical.

                          I don't understand the other part. If their annotation implements
                          the JDK5 class Annotation then it can't possibly work in JDK1.4
                          without some weaving?

                          I know BIll did some stuff with annotationc that lets you use
                          interfaces instead of annotations, but since the implementation
                          is all "generated" code anyway, I don't know why it can't be typesafe?

                          • 10. Re: JBAOP-87 - Annotation Dependencies
                            Bill Burke Master

                            the interface isn't weaved, the class that is annotated is weaved. (for the jdk1.4 interface replacement of annotations).

                            • 11. Re: JBAOP-87 - Annotation Dependencies
                              Kabir Khan Master

                              Yes, the original thinking was to keep allowing simple interfaces to be used as the type for annotation overloads.

                              But I had to fix some things in JBoss Retro, so the annotations recognized by the annotation helper must now implement org.jboss.lang.Annotation.

                              If the code is woven from JDK 5 annotation types, the resulting interfaces will implement org.jboss.lang.Annotation. If people want to do this manually or use the old annotation compiler with jdk 1.4 they can still supply an interface, but the interface will need to implement org.jboss.lang.Annotation interface

                              • 12. Re: JBAOP-87 - Annotation Dependencies
                                Kabir Khan Master

                                BTW I managed to get the microcontainer retroed and all tests passing with jdk 1.4

                                • 13. Re: JBAOP-87 - Annotation Dependencies
                                  Kabir Khan Master

                                  I mean the "container" module :-)

                                  • 14. Re: JBAOP-87 - Annotation Dependencies
                                    Kabir Khan Master

                                    I have moved the AnnotationCreator and the things it needs from the aop project into the container project as requested. It lives in org.jboss.annotation.factory.AnnotationCreator

                                    1 2 Previous Next