1 2 3 4 Previous Next 54 Replies Latest reply on Oct 4, 2007 12:09 PM by starksm64 Go to original post
      • 15. Re: ManagedOperation aspects for the ProfileService.Manageme
        alesj

         

        "scott.stark@jboss.org" wrote:
        ManagedOperations are never property getters if that is what you mean. They are bean methods that may return a value.

        Eh silly me, didn't even think for a second :-(, there are ManagedProperties for that kind of stuff. :-)

        How do you currently invoke those?
        Since I think they should be invoked the same way as ManagedOperations - over the KernelBus.
        That's why we introduced AttributeDispatchContext.

        • 16. Re: ManagedOperation aspects for the ProfileService.Manageme

           

          "alesj" wrote:
          I've added the following code to KernelBus:


          Why did you go to all this extra work of creating joinpoints and all the other rubbish?

          All that was required was to extend the dispatch api to have the name of the target
          and add that to the kernel bus api.

          e.g.
           /**
           * Invoke method / operation
           *
           * @param name the name of the target
           * @param methodName method name
           * @param parameters parameter values
           * @param signature method's parameter types / signatures
           * @return invocation's return object
           * @throws Throwable for any error
           */
           Object invoke(Object name, String methodName, Object parameters[], String[] signature) throws Throwable;
          


          A bus is just the same api as a single context with the target found by looking up
          the name in a registry. The name being the extra parameter.

          The rest of the api you've created, is just useless object construction and irrelevant
          implement details.

          NOTE: Even the joinpoint stuff in the existing KernelBus is irrelevant.
          It is legacy from when I was experimenting with AOP/POJO and JMX implementing the
          Joinpoint api. The DispatchContext replaced this.

          • 17. Re: ManagedOperation aspects for the ProfileService.Manageme
            alesj

             

            "adrian@jboss.org" wrote:

            NOTE: Even the joinpoint stuff in the existing KernelBus is irrelevant.
            It is legacy from when I was experimenting with AOP/POJO and JMX implementing the
            Joinpoint api. The DispatchContext replaced this.


            If you posted this INFO before, I wouldn't go into trouble of writing that rubbish new joinpoint. :-)

            "adrian@jboss.org" wrote:

            All that was required was to extend the dispatch api to have the name of the target
            and add that to the kernel bus api.


            But if I do this, I think we need to add all three ways of dispatching something to context - invoke, get and set - into the KernelBus.

            How to push this change then back to AS trunk?
            Waiting for beta5, cr1?

            ps: we could have changed KernelBus long time ago ;-)

            • 18. Re: ManagedOperation aspects for the ProfileService.Manageme

               

              "alesj" wrote:

              "adrian@jboss.org" wrote:

              All that was required was to extend the dispatch api to have the name of the target
              and add that to the kernel bus api.


              But if I do this, I think we need to add all three ways of dispatching something to context - invoke, get and set - into the KernelBus.


              Correct. If that's not correct then the dispatch context is wrong for the same reason.


              How to push this change then back to AS trunk?
              Waiting for beta5, cr1?


              That depends upon whether Scott needs it for jboss5-beta3.
              If he does, then we'll need to apply your changes to the 2.0 branch
              and create a 2.0-beta5 release of the MC.
              http://anonsvn.jboss.org/repos/jbossas/projects/microcontainer/branches/2_0/

              • 19. Re: ManagedOperation aspects for the ProfileService.Manageme

                 

                "adrian@jboss.org" wrote:

                Correct. If that's not correct then the dispatch context is wrong for the same reason.


                While we are on subject the InvokeDispatchContext IS incorrect.

                1) The getTarget() is redundant, since that is on the plain ControllerContext interface.
                2) The getClassLoader() should not be there.

                As far as I can tell, the classloader is used to get the parameters when they are
                expressed as strings in the metadata/xml

                We need to find a way to remove the getClassLoader()
                and make it an implementation detail, or introduce a permission check
                into the implementations. Exposing classloaders in public methods is a security hole.

                See Class.getClassLoader() or Thread.currentThread().getContextClassLoader()
                for the kind of checks required.

                • 20. Re: ManagedOperation aspects for the ProfileService.Manageme
                  alesj

                   

                  "adrian@jboss.org" wrote:

                  We need to find a way to remove the getClassLoader()
                  and make it an implementation detail, or introduce a permission check
                  into the implementations. Exposing classloaders in public methods is a security hole.

                  See Class.getClassLoader() or Thread.currentThread().getContextClassLoader()
                  for the kind of checks required.

                  Is this enough:
                   public ClassLoader getClassLoader() throws Throwable
                   {
                   SecurityManager sm = System.getSecurityManager();
                   if (sm != null)
                   sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
                   return Configurator.getClassLoader(getBeanMetaData());
                   }
                  


                  Or I need to 'find' something equivalent for the ccl in
                   public ClassLoader getClassLoader() {
                   ClassLoader cl = getClassLoader0();
                   if (cl == null)
                   return null;
                   SecurityManager sm = System.getSecurityManager();
                   if (sm != null) {
                   ClassLoader ccl = ClassLoader.getCallerClassLoader();
                   if (ccl != null && ccl != cl && !cl.isAncestor(ccl)) {
                   sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
                   }
                   }
                   return cl;
                   }
                  


                  • 21. Re: ManagedOperation aspects for the ProfileService.Manageme

                     

                    "alesj" wrote:

                    Is this enough:


                    The question is will the callers have that privilege.

                    e.g. Where this occurs is when somebody is deploying a bean from xml

                    That will run under the privileges of whoever registered the MC context.

                    We should be testing whether they can get access to the classloader
                    of the other context to create the objects, otherwise it is a security hole.

                    We don't want somebody using the MC to create objects they wouldn't otherwise
                    have access to.


                    • 22. Re: ManagedOperation aspects for the ProfileService.Manageme
                      starksm64

                       

                      "alesj" wrote:

                      Eh silly me, didn't even think for a second :-(, there are ManagedProperties for that kind of stuff. :-)

                      How do you currently invoke those?
                      Since I think they should be invoked the same way as ManagedOperations - over the KernelBus.
                      That's why we introduced AttributeDispatchContext.

                      The properties are updated during the ManagementView.process call based on what updateComponent calls have been made. These currently just map back to the deployemnt attachment. For those properties with a ViewUse.RUNTIME setting:

                      public enum ViewUse
                      {
                       /** A read-write property used for creating/updating a config */
                       CONFIGURATION,
                       /** A read-only type of property */ (this comment is wrong, its an extension of CONFIGURATION that has a runtime component the property change should be dispatched to)
                       RUNTIME,
                       /** A read-only type of property that provides runtime stats */
                       STATISTIC
                      }
                      

                      we also need to send the change to the runtime component.


                      • 23. Re: ManagedOperation aspects for the ProfileService.Manageme

                        You can getCallerClassLoader() using code similar to the HACK class in the classloader project, although it is suble because you need to skip reflection classes.

                        • 24. Re: ManagedOperation aspects for the ProfileService.Manageme
                          alesj

                           

                          "adrian@jboss.org" wrote:
                          You can getCallerClassLoader() using code similar to the HACK class in the classloader project, although it is suble because you need to skip reflection classes.

                          Probably there is no reflection invocation in classloading code?

                           protected Class<?> getRequestingClass(Class[] stack)
                           {
                           for (Class clazz : stack)
                           {
                           if (Hack.class.isAssignableFrom(clazz) == false &&
                           JDKChecker.class.isAssignableFrom(clazz) == false &&
                           BaseClassLoaderDomain.class.isAssignableFrom(clazz) == false &&
                           BaseClassLoaderPolicy.class.isAssignableFrom(clazz) == false &&
                           ClassLoader.class.isAssignableFrom(clazz) == false &&
                           Class.class.isAssignableFrom(clazz) == false)
                           {
                           return clazz;
                           }
                           }
                           throw new RuntimeException("Should not be here!");
                           }
                          


                          • 25. Re: ManagedOperation aspects for the ProfileService.Manageme
                            alesj

                             

                            "scott.stark@jboss.org" wrote:

                            The properties are updated during the ManagementView.process call based on what updateComponent calls have been made. These currently just map back to the deployemnt attachment.


                             ManagedProperty ctxProp = serverComp.getProperties().get(prop.getName());
                             // Check for a mapped name
                             if( ctxProp == null )
                             {
                             String mappedName = prop.getMappedName();
                             if( mappedName != null )
                             ctxProp = serverComp.getProperties().get(mappedName);
                             }
                             if( ctxProp == null )
                             {
                             formatter.applyPattern(i18n.getString("ManagementView.InvalidTemplateProperty")); //$NON-NLS-1$
                             Object[] args = {prop.getName()};
                             String msg = formatter.format(args);
                             throw new IllegalArgumentException(msg);
                             }
                             ctxProp.setValue((Serializable)prop.getValue());
                            


                            I'm failing to see where this change gets applied on the server side?
                            ManagementView.process calls MainDeployer.process, which only processes undeployments and new deployments.
                            But I can't see where changed/updated components/deployments are processed ...

                            "scott.stark@jboss.org" wrote:

                            ... we also need to send the change to the runtime component.


                            How should we wire this with ManagementView?
                            Or just use plain KernelBus on the MC side?

                            I get this when running PS tests.
                            Was this fixed?
                            *** CONTEXTS IN ERROR: Name -> Error
                            
                            vfsfile:/C:/projects/jboss5/trunk/build/output/jboss-5.0.0.Beta3/server/profileservice/deploy/testHqldbDS-ds.xml -> org.xml.sax.SAXParseException: Premature end of file.
                            


                            • 26. Re: ManagedOperation aspects for the ProfileService.Manageme
                              starksm64

                               

                              "alesj" wrote:

                              I'm failing to see where this change gets applied on the server side?
                              ManagementView.process calls MainDeployer.process, which only processes undeployments and new deployments.
                              But I can't see where changed/updated components/deployments are processed ...

                              The call to the ctxProp.setValue is the server side invocation on the ManagedProperty that is wired to the metadata. This changes the metadata instance associated with the deployment.

                              "alesj" wrote:

                              Was this fixed?
                              *** CONTEXTS IN ERROR: Name -> Error
                              
                              vfsfile:/C:/projects/jboss5/trunk/build/output/jboss-5.0.0.Beta3/server/profileservice/deploy/testHqldbDS-ds.xml -> org.xml.sax.SAXParseException: Premature end of file.
                              



                              • 27. Re: ManagedOperation aspects for the ProfileService.Manageme
                                starksm64

                                 

                                "alesj" wrote:

                                "scott.stark@jboss.org" wrote:

                                ... we also need to send the change to the runtime component.


                                How should we wire this with ManagementView?
                                Or just use plain KernelBus on the MC side?

                                It has to tie into the setValue call for ViewUse.RUNTIME properties. However that is best done. Seems like within the ManagementViewImpl to the KernelBus is how it has to be done. Don't we need the KernelBus updates to replace the RuntimeComponentDispatcher?


                                • 28. Re: ManagedOperation aspects for the ProfileService.Manageme
                                  alesj

                                   

                                  "scott.stark@jboss.org" wrote:

                                  The call to the ctxProp.setValue is the server side invocation on the ManagedProperty that is wired to the metadata. This changes the metadata instance associated with the deployment.


                                  Changes metadata instance? How, where?
                                  But there is no actual runtime component invocation at the moment, right?

                                  "scott.stark@jboss.org" wrote:

                                  This is what Weston is working on.


                                  Weston, what's the status/progress of this?

                                  • 29. Re: ManagedOperation aspects for the ProfileService.Manageme
                                    alesj

                                     

                                    "scott.stark@jboss.org" wrote:

                                    It has to tie into the setValue call for ViewUse.RUNTIME properties. However that is best done. Seems like within the ManagementViewImpl to the KernelBus is how it has to be done. Don't we need the KernelBus updates to replace the RuntimeComponentDispatcher?


                                    The RuntimeComponentDispatcher will stay, it's the KernelBus that has changed. And by that our RuntimeComponentDispatcher impl has changed as well.

                                    I agree it should go into MVImpl, but what if we are deep into MC impl - which should be PS unaware?