1 2 3 Previous Next 40 Replies Latest reply on Jan 21, 2006 7:25 AM by adrian.brock Go to original post
      • 15. Re: Change DomainClassLoader getPackages signature

         

        "scott.stark@jboss.org" wrote:

        In terms of updating the xml deployment layer, is this something that should wait for the schema driven version or are we keeping the BeanSchemaBinding around?


        We should be switching over to the annotated schema once all the issues are resolved.
        This should not affect anybody since I don't anticipate (or support) anybody using
        the BeanSchemaBinding class directly.
        In fact, the removal of this class is one of the aims of using the annotated approach.

        Feel free to update the BeanSchemaBinding with the classloader metadata.
        But I'd suggest we get the XXXMetaData classes right first.

        • 16. Re: Change DomainClassLoader getPackages signature

          I see you added both?

          http://anoncvs.forge.jboss.com/changelog/JBoss?cs=MAIN:starksm:20051105191252
          http://anoncvs.forge.jboss.com/changelog/JBoss?cs=MAIN:starksm:20051106031544

          One is used for the beaninfo, the other for the construction.
          But only the bean level one (beaninfo) is tested.

          • 17. Re: Change DomainClassLoader getPackages signature
            starksm64

            Yes, the only place it has an effect is if a constructor also specifies a factory method. I had a test but did not really like the usecase. I think the ctor class loader should be rolled back and the bean class loader used instead.

            I also agree that passing the class loader in as an attribute ala 1 and 3 is not a good idea, and that a deployment class loader is needed. I would like to:

            1. improve the tests security configuration to get rid of the hard-coded security policy hacks that were added.
            2. add the deployment level class loader info with another mock vfs class loader test.
            3. look into nested deployments with different scoped class loaders to see how the ejb/war mismatch fits into the new MC. This gets back to another issue of class loader relationships. A war pojo talking to an ejb deployment needs its class loader to ignore the classes exported by the ejb to avoid the call by reference conflicts. The war class loader metadata needs to be augmented by the ejb class loader exports. This is going to require augmentation of the base metadata from the deployment via another aspect. What is the best way to do this via the current MC features?

            • 18. Re: Change DomainClassLoader getPackages signature

              Update:
              I already changed it to:
              * Use a ClassLoaderMetaData on the bean which is used everywhere
              * Fix the "whenRequired" for classloader injection to be "DESCRIBED" see

              ClassLoaderMetaData.visit()
              - the default is that a dependency is required at instantiation unless the metadata visit overrides.
              * I am now writing a test for re-install and adding the xml versions of it.

              • 19. Re: Change DomainClassLoader getPackages signature

                 

                "scott.stark@jboss.org" wrote:

                1. improve the tests security configuration to get rid of the hard-coded security policy hacks that were added.


                Ok, but I think that is really an orthogonal issue? i.e. test framework


                2. add the deployment level class loader info with another mock vfs class loader test.


                Ok. But the current kernel tests don't really have a "deployment". The xml versions of
                the test do.
                These should probably be brought inline with the programmatic versions using
                an AbstractKernelDeployment rather than deploying beans individually.
                AbstractKernelDependencyTest
                 protected ControllerContext install(int number, String name) throws Throwable
                 {
                 if (xmltest)
                 {
                 deploy(number);
                 return util.getContext(name);
                 }
                 else
                 {
                 return util.install(beanMetaDatas[number]);
                 }
                 }
                


                I can look at fixing this if you like?

                • 20. Re: Change DomainClassLoader getPackages signature

                   

                  "scott.stark@jboss.org" wrote:

                  3. look into nested deployments with different scoped class loaders to see how the ejb/war mismatch fits into the new MC. This gets back to another issue of class loader relationships. A war pojo talking to an ejb deployment needs its class loader to ignore the classes exported by the ejb to avoid the call by reference conflicts. The war class loader metadata needs to be augmented by the ejb class loader exports. This is going to require augmentation of the base metadata from the deployment via another aspect. What is the best way to do this via the current MC features?


                  You'll have to explain it more explicitly. I don't think this is an issue for the MC?

                  The MC MetaData doesn't care about what the classloader does or how it gets constructed
                  (although this can be described in MC metadata, even if it just "use this factory to create the
                  classloader"), you are just saying use this one.


                  • 21. Re: Change DomainClassLoader getPackages signature

                    I'm not sure if this is relevant? But just a heads up on "good design".

                    I expect a lot of the behavioural changes (that are not expressed through
                    annotations and their overrides) to be done through factory injection.

                    e.g. The new jca implementation allows different implementations of the timer
                    just based on an implementing a factory interface:

                    <?xml version="1.0" encoding="UTF-8"?>
                    
                    <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
                     xmlns="urn:jboss:bean-deployer">
                    
                     <bean name="TimerFactory" class="org.jboss.jca.plugins.rar.timer.JDKTimerFactory"/>
                    
                     <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory">
                     <property name="timerFactory"><inject bean="TimerFactory"/></property>
                     </bean>
                    
                     <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
                     <start method="start">
                     <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
                     </start>
                     </bean>
                    
                    </deployment>
                    


                    • 22. Re: Change DomainClassLoader getPackages signature
                      starksm64

                       

                      "adrian@jboss.org" wrote:

                      Ok, but I think that is really an orthogonal issue? i.e. test framework

                      Correct, but its getting in the way of testing.

                      "adrian@jboss.org" wrote:

                      Ok. But the current kernel tests don't really have a "deployment". The xml versions of
                      the test do.
                      These should probably be brought inline with the programmatic versions using
                      an AbstractKernelDeployment rather than deploying beans individually.
                      AbstractKernelDependencyTest
                       protected ControllerContext install(int number, String name) throws Throwable
                       {
                       if (xmltest)
                       {
                       deploy(number);
                       return util.getContext(name);
                       }
                       else
                       {
                       return util.install(beanMetaDatas[number]);
                       }
                       }
                      


                      I can look at fixing this if you like?


                      Yes, that would be good as this discrepency is why I simply did not get into changing the KernelDeployment.


                      • 23. Re: Change DomainClassLoader getPackages signature
                        starksm64

                         

                        "adrian@jboss.org" wrote:

                        You'll have to explain it more explicitly. I don't think this is an issue for the MC?

                        The MC MetaData doesn't care about what the classloader does or how it gets constructed
                        (although this can be described in MC metadata, even if it just "use this factory to create the
                        classloader"), you are just saying use this one.


                        Its not a proper MC level notion, the question is more of what does the MC offer in terms of hooks/design for augmenting pojo creation based on relationships, and this is related to the "good design" comment. Clearly I need a class loader factory, but it needs to know about the relationships the class loader has to other class loaders to "do the right thing". The problem is that this is a non-trivial function of the pojo interaction between the two domains. A call-by-value interaction can leave the ejb interfaces/types as visible from a war class loader that is doing child first loading. A call-by-reference interaction cannot. So one implementation might have the factory look at all injections from the war to the ejb deployment to determine if there were call-by-reference uses. Alternatively, the processing of the injection metadata might have a vistor that updates the class loader metadata to do this and the factory simply uses the metadata it receives. I'm not clear on what factilities the MC offers to explore these alternatives.


                        • 24. Re: Change DomainClassLoader getPackages signature
                          starksm64

                           

                          "adrian@jboss.org" wrote:
                          Update:
                          I already changed it to:
                          * Use a ClassLoaderMetaData on the bean which is used everywhere
                          ...


                          Ok, I need to understand the visitor pattern better. I'll go over these changes when their done.


                          • 25. Re: Change DomainClassLoader getPackages signature

                             

                            "scott.stark@jboss.org" wrote:
                            "adrian@jboss.org" wrote:
                            Update:
                            I already changed it to:
                            * Use a ClassLoaderMetaData on the bean which is used everywhere
                            ...


                            Ok, I need to understand the visitor pattern better. I'll go over these changes when their done.


                            The PreprocessMetaDataVisitor serves as a context as you walk the tree.

                            Currently this is only used for getting access to the controller context (for the bean name),
                            the whenRequired of the dependency and collecting all the dependencies.

                            At certain points in the tree you want to override the context, e.g. property injections
                            are only required at "Configured" rather than the default "Instantiated".

                            • 26. Re: Change DomainClassLoader getPackages signature

                               

                              "scott.stark@jboss.org" wrote:
                              The problem is that this is a non-trivial function of the pojo interaction between the two domains. A call-by-value interaction can leave the ejb interfaces/types as visible from a war class loader that is doing child first loading. A call-by-reference interaction cannot. So one implementation might have the factory look at all injections from the war to the ejb deployment to determine if there were call-by-reference uses. Alternatively, the processing of the injection metadata might have a vistor that updates the class loader metadata to do this and the factory simply uses the metadata it receives. I'm not clear on what factilities the MC offers to explore these alternatives.


                              I think I still need more concrete examples/use cases.

                              I believe you are trying to control visibility at the classloader level based on how the beans
                              interact across the classloaders and the configuration options of the deployment?

                              * I'm not sure the MC has all this information you need? You can get access to the methods and the parameter types from the beaninfo/classinfo, but those types might be interfaces/super classes of the real implementation classes passed.

                              And it would require an alternate ClassAdapter/ClassInfo implementation that doesn't use
                              reflection since you need the classloading to do the reflection in the first place.
                              This is similar to what I discussed with Bill about sharing the aop/javassist metadata
                              via the ClassInfo so you can fully understand the dependencies before classloading
                              is required.

                              * Since the MC implements hotdeployment, any changes to one bean's usage
                              could need to trigger redeployment of the whole classloader space to cover
                              new overlaps and reconstruct the classloaders accordingly.

                              There is already a tentative attempt at abstracting away the reflection/aop
                              integration (and dependencies it introducies) so I don't have to deal with these issues
                              (which I can't possibly understand?)
                              See KernelControllerContextActions$DescribeAction
                              and AbstractBeanInfo's delegation to the ClassAdapter.

                              But Bill and I have been unable to agree on how this should work.
                              Bill has been reticent to do anything but "baby steps" before AOP/2.0

                              • 27. Re: Change DomainClassLoader getPackages signature
                                starksm64

                                 

                                I believe you are trying to control visibility at the classloader level based on how the beans interact across the classloaders and the configuration options of the deployment?


                                Yes, the simplest concrete example is should the war class loader be configured to exclude "the exported classes of its ejb peer", where the quoted statement is the metadata to determine. Certainly one way is through navigation of the dependencies at the class metadata level, which requires a lot of work. Another way would be via knowing that the war class loader depends on the ejb class loader for the "ejb-client-classes" where these were described by the ejb class loader metadata. Suppose the "ejb-client-classes" approach is to be used. There is still the question of whether this is a behavior of the class loader factory (a):

                                a1. The dependencies of the war class loader are part of its metadata. The factory traverses dependencies to other class loaders and simply adds the target class loaders exports as excludes that should be visible in the war class loader.

                                or is this a behavior of the dependency itself (b):
                                b1. a relationship visitor augments the war class loader metadata with information from the dependee class loader.
                                b2. the class loader factory simply uses the augmented metadata, and knows nothing about the war-ejb class loader relationship.

                                I tend to think that (b) is the correct abstraction. The questions are:
                                1. does the MC have hooks for both approaches?
                                2. which is the better fit?


                                • 28. Re: Change DomainClassLoader getPackages signature

                                  OSGI solves this problem by having both a notion of export and import.
                                  For the WAR case, the classloader (really module in OSGI) would both
                                  export and import its ejb client classes.
                                  i.e. I have these classes, but I'm happy to use somebody else's if they are compatible.

                                  There is then an algorithm used to decide which of the EJB and WAR modules
                                  actually serves as the exporter (with all classloading requests for those classes
                                  going to the exporter's classloader).

                                  The alogirthm is mainly based on who provides the most compatible version
                                  of the classes. e.g. if the EJB exports V1.8 and the WAR exports V1.7 but is
                                  happy to use V1.7+ then the EJB's classes will be used.

                                  • 29. Re: Change DomainClassLoader getPackages signature

                                    So this is really a deployment/module time thing
                                    that requires something to keep track of dependencies.

                                    Case 1:
                                    Deploy EJB (classes at V1.8 but will use V1.8+)
                                    Deploy WAR (classes at V.1.7 but will use V1.7+)
                                    Ok will use WAR will use EJB classes

                                    Case 2:
                                    Deploy WAR (classes at V.1.7 but will use V1.7+)
                                    Deploy EJB (classes at V1.8 but will use V1.8+)
                                    Not OK. The WAR already started using V1.7 classes.

                                    Solutions to Case2:
                                    * Just fail
                                    * Force a redeploy of the WAR to resolve the issue

                                    If this belongs in the MC work, it is in the aspectized deployers or profile service plugins
                                    which have a "WHAT DO I NEED TO DO?" notion and in the later case an "offline" mode.
                                    Rather than the MC which just has a more direct "DO THIS" style metadata.