1 2 3 4 Previous Next 47 Replies Latest reply on Sep 8, 2005 7:17 PM by starksm64 Go to original post
      • 15. Re: HARDeployer removal proposal
        starksm64

        The lack of an instant reply does not neccessarily mean lack of interest.

        An interface is not necessarily needed, and in general is not useful as the service layer deals with mbeans, not instance implementation.

        It would be that the service exposed such an attribute on the mbean interface. The xmbean deployment already has similar notions for a service that wants to know its MBeanService and ObjectName without having to subclass ServiceMBeanSupport. This is handled via reflection rather than an interface contract as the xmbean container is driven by attributes on descriptor rather than interfaces on the pojo.

        However, I think this is better handled as an extended service lifecycle event such as init(DeploymentInfo). The DeploymentInfo could be made available to the ServiceController/ServiceConfigurator either explicitly, or via a MainDeployer query if its not already there.

        • 16. Re: HARDeployer removal proposal
          sebersole

           

          "scott.stark@jboss.org" wrote:
          The lack of an instant reply does not neccessarily mean lack of interest.

          Understood. Had simply realized that I had been a bit scatter-brained in some of my responses; just wanted to pull them all together.

          • 17. Re: HARDeployer removal proposal
            sebersole

            So here's my thoughts after the weekend.

            Why not have the MBean have the option of running in what is basically two modes:
            1) har-deployment : essentially what we have now. Leave HARDeployer for now until the capability for "an MBean to know about the deployment it came from" gets solidified; once that capability exists, remove the HARDeployer and simply have the MBean grab its DeploymentInfo.url and use that as the HarUrl if it is a .har.
            2) auto-detection : if no HarUrl is set, then use functionality similiar to what you have described. I am not certain, though, that the current context classloader approach is the correct one. I think I'd rather use the DeploymentInfo.ucl. I am worried about start/stop calls from somewhere other than the controller. But for now, I am using the exact code you posted since its a PIA to manually locate ones DeploymentInfo.

            • 18. Re: HARDeployer removal proposal
              starksm64

              The ServiceMBeanSupport base class now has a getDeploymentInfo() convience method that can be accessed in the start/startService method:

               protected void startService() throws Exception
               {
               DeploymentInfo sdi = getDeploymentInfo();
              
              


              This info is not available until after the create method has returned so it cannot be accessed from create/createService.


              • 19. Re: HARDeployer removal proposal
                sebersole

                Cool.

                So I'll play with changing "mode" #1 above to not rely on having the HarUrl set externally. During startService(), I'll get the DeploymentInfo and see if it's url ends in .har (.har/ too i guess) and if so proceeded exactly as the functionality did before with the HARDeployer.

                Quick related question. I am working on adding support for Hibernate deployments into the new admin console. One of the difficulties I ran into was trying to locate all "Hibernate deployments" for selection. So currently that code iterates every single deployment on that server :) Would it make sense to have another mbean here that acts as a registry of Hibernate deployments (the mbean registers itself) so that that code can efficiently locate them?

                • 20. Re: HARDeployer removal proposal
                  starksm64

                  Which new admin console?

                  If you have an mbean for every deployment that has a unique jmx attribute, such as type=har, you can query for all such mbeans:

                   ObjectName query = new ObjectName("*:type=har,*");
                   MBeanServer server = ...;
                   Set matches = server.queryNames(query, null);
                   Iterator names = matches.iterator();
                   while( names.hasNext() )
                   {
                   ObjectName mbean = (ObjectName) names.next();
                   }
                  



                  • 21. Re: HARDeployer removal proposal
                    ccrouch

                     

                    "scott.stark@jboss.org" wrote:
                    Which new admin console?


                    New is always relative...

                    http://jira.jboss.com/jira/browse/JBADMCON

                    • 22. Re: HARDeployer removal proposal
                      sebersole

                      Currently the object-name is completely user-defined.

                      • 23. Re: HARDeployer removal proposal
                        starksm64

                        They should only be specifying one attribute value. The structure should be coming from the deployer.

                        • 24. Re: HARDeployer removal proposal
                          sebersole

                          What deployer :))

                          • 25. Re: HARDeployer removal proposal
                            starksm64

                            The thing loading instances in memory that need to be monitored.

                            • 26. Re: HARDeployer removal proposal
                              sebersole

                              I was just joking as the name of the topic is about removing the deployer :)

                              So, if I do remove the HARDeployer, these will get processed by the SARDeployer (provided we add .har to its extensions). So should SARDeployer do this? Granted this is not my expertise (by a long stretch), but I seem to recall that the MBean itself could actually override what its service name should be; i seem to recall something about this during my looks through SubDeployerSupport and ServiceMBeanSupport.

                              Any examples you know off the top of your head that you could point me to? I tried looking at TreeCache, since it is the closest I know of in terms of controller interaction, etc. But it seemed to also just accept the user-supplied object-name also. JCA overrode this value, but did so in the specific deployer as opposed to within the MBeans. So not sure where I should look for examples of this.

                              Thanks

                              • 27. Re: HARDeployer removal proposal
                                starksm64

                                There is no notion of templates in the current SARDeployer. So if users are not be be trusted with setting the object name to follow a pattern to use for querying har deployments, you can:

                                1. write an mbean that simply contains the service names of the har services. This does not even have to be an mbean service. The first har deployment could create a simple java bean and register it.

                                2. simply bind the har service names into a set/list/array in jndi.

                                3. use XSLSubDeployer to create a templatized deployment like the *-ds.xml that does enforce the naming pattern using a trivial xslt style sheet:

                                 <mbean code="org.jboss.deployment.XSLSubDeployer" name="jboss.har:service=HibernateDeployer">
                                 <attribute name="DdSuffix">-har.xml</attribute>
                                 <attribute name="XslUrl">resource:HARTemplate.xsl</attribute>
                                 </mbean>
                                



                                • 28. Re: HARDeployer removal proposal
                                  sebersole

                                  In regards to #1, when you say "register it" do you mean register it with the MBean server? Can simple pojos be registered with the MBean server? That'd be sweet (and perfect). If not, I think it'd be OK to have a HibernateDeploymentRegistryMBean (or maybe even a generic DeploymentRegistryMBean that segments by "types") as part of the base package (whatever hibernate.deployer becomes), which the console code could use to pull lists.

                                  • 29. Re: HARDeployer removal proposal
                                    starksm64

                                    Yes, pojos can be registered. The simplest is the StandardMBean pattern of a pojo + MBean interface (maybe this is not a pojo to you because of the interface contract).

                                    There is also the code intensive ModelMBean which requires no contract on the pojo. Our XMBean externalizes all of the code to an xml file. There are annotation driven mbeans as well in the aop layer.

                                    // StandardMBean example

                                    package jmx;
                                    
                                    import javax.management.MBeanServer;
                                    import javax.management.MBeanServerFactory;
                                    import javax.management.ObjectName;
                                    
                                    public class TestStandardMBean
                                    {
                                     public static interface JavaBeanMBean
                                     {
                                     public String getName();
                                     public void setName(String name);
                                     public String displayString();
                                     }
                                     public static class JavaBean
                                     implements JavaBeanMBean
                                     {
                                     private String name = "SomeBean";
                                    
                                     public String getName()
                                     {
                                     return name;
                                     }
                                     public void setName(String name)
                                     {
                                     this.name = name;
                                     }
                                    
                                     public String displayString()
                                     {
                                     StringBuffer tmp = new StringBuffer(super.toString());
                                     tmp.append('(');
                                     tmp.append("name=");
                                     tmp.append(name);
                                     tmp.append(')');
                                     return tmp.toString();
                                     }
                                     }
                                    
                                     public static void main(String[] args) throws Exception
                                     {
                                     MBeanServer server = MBeanServerFactory.createMBeanServer("TestModelMBean");
                                     JavaBean resource = new JavaBean();
                                     ObjectName name = new ObjectName("test:type=har,bean=JavaBean");
                                     server.registerMBean(resource, name);
                                    
                                     System.out.println("JavaBean.name: "+server.getAttribute(name, "Name"));
                                     Object[] iargs = {};
                                     String[] sig = {};
                                     System.out.println("JavaBean.displayString: "+server.invoke(name, "displayString", iargs, sig));
                                    
                                     }
                                    
                                    }
                                    
                                    Output:
                                    
                                    JavaBean.name: SomeBean
                                    JavaBean.displayString: jmx.TestStandardMBean$JavaBean@5740bb(name=SomeBean)
                                    


                                    // ModelMBean example
                                    package jmx;
                                    
                                    import javax.management.modelmbean.ModelMBean;
                                    import javax.management.modelmbean.RequiredModelMBean;
                                    import javax.management.modelmbean.ModelMBeanInfo;
                                    import javax.management.modelmbean.DescriptorSupport;
                                    import javax.management.modelmbean.ModelMBeanAttributeInfo;
                                    import javax.management.modelmbean.ModelMBeanOperationInfo;
                                    import javax.management.modelmbean.ModelMBeanInfoSupport;
                                    import javax.management.modelmbean.ModelMBeanConstructorInfo;
                                    import javax.management.modelmbean.ModelMBeanNotificationInfo;
                                    import javax.management.ObjectName;
                                    import javax.management.MBeanServerFactory;
                                    import javax.management.MBeanServer;
                                    import javax.management.Descriptor;
                                    import javax.management.MBeanOperationInfo;
                                    
                                    public class TestModelMBean
                                    {
                                     public static class JavaBean
                                     {
                                     private String name = "SomeBean";
                                    
                                     public String getName()
                                     {
                                     return name;
                                     }
                                     public void setName(String name)
                                     {
                                     this.name = name;
                                     }
                                    
                                     public String displayString()
                                     {
                                     StringBuffer tmp = new StringBuffer(super.toString());
                                     tmp.append('(');
                                     tmp.append("name=");
                                     tmp.append(name);
                                     tmp.append(')');
                                     return tmp.toString();
                                     }
                                     }
                                    
                                     public static void main(String[] args) throws Exception
                                     {
                                     MBeanServer server = MBeanServerFactory.createMBeanServer("TestModelMBean");
                                     JavaBean resource = new JavaBean();
                                     ModelMBean modelmbean = new RequiredModelMBean();
                                     modelmbean.setModelMBeanInfo(getModelMBeanInfo());
                                     modelmbean.setManagedResource(resource, "ObjectReference");
                                     ObjectName name = new ObjectName("test:type=har,bean=JavaBean");
                                     server.registerMBean(modelmbean, name);
                                    
                                     System.out.println("JavaBean.name: "+server.getAttribute(name, "Name"));
                                     Object[] iargs = {};
                                     String[] sig = {};
                                     System.out.println("JavaBean.displayString: "+server.invoke(name, "displayString", iargs, sig));
                                    
                                     }
                                    
                                     private static ModelMBeanInfo getModelMBeanInfo()
                                     {
                                     final boolean READABLE = true;
                                     final boolean WRITABLE = true;
                                    
                                     // build 'Name' read-write attribute
                                     Descriptor nameDesc = new DescriptorSupport();
                                     nameDesc.setField("name", "Name");
                                     nameDesc.setField("descriptorType", "attribute");
                                     nameDesc.setField("displayName", "JavaBean Name");
                                     nameDesc.setField("getMethod", "getName");
                                    
                                     ModelMBeanAttributeInfo nameInfo =
                                     new ModelMBeanAttributeInfo(
                                     "Name", // attribute name
                                     String.class.getName(), // attribute type
                                     "JavaBean Name", // description
                                     READABLE, WRITABLE, false, // read write
                                     nameDesc // descriptor
                                     );
                                    
                                     // Build getName getter operation
                                     Descriptor getNameDesc = new DescriptorSupport();
                                     getNameDesc.setField("name", "getName");
                                     getNameDesc.setField("descriptorType", "operation");
                                     getNameDesc.setField("role", "getter");
                                     ModelMBeanOperationInfo getNameInfo =
                                     new ModelMBeanOperationInfo(
                                     "getName", // name & description
                                     "Obtains the Name attribute",
                                     null, // signature
                                     String.class.getName(), // return type
                                     MBeanOperationInfo.INFO, // impact
                                     getNameDesc // descriptor
                                     );
                                    
                                     // build 'toString' getter operation
                                     Descriptor toStringDesc = new DescriptorSupport();
                                     toStringDesc.setField("name", "displayString");
                                     toStringDesc.setField("descriptorType", "operation");
                                     toStringDesc.setField("role", "getter");
                                    
                                     ModelMBeanOperationInfo toStringInfo =
                                     new ModelMBeanOperationInfo(
                                     "displayString", // name & description
                                     "Obtains the bean string representation",
                                     null, // signature
                                     void.class.getName(), // return type
                                     MBeanOperationInfo.INFO, // impact
                                     toStringDesc // descriptor
                                     );
                                    
                                     // MBean descriptor
                                     Descriptor mbeanDesc = new DescriptorSupport();
                                     mbeanDesc.setField("name", RequiredModelMBean.class.getName());
                                     mbeanDesc.setField("descriptorType", "MBean");
                                     mbeanDesc.setField("currencyTimeLimit", "-1");
                                    
                                     // create ModelMBeanInfo
                                     ModelMBeanConstructorInfo[] ctors = null;
                                     ModelMBeanAttributeInfo[] attrs = {nameInfo};
                                     ModelMBeanOperationInfo[] ops = {getNameInfo, toStringInfo};
                                     ModelMBeanNotificationInfo[] notify = null;
                                     ModelMBeanInfo info = new ModelMBeanInfoSupport(
                                     RequiredModelMBean.class.getName(),
                                     "JavaBean",
                                     attrs,
                                     ctors,
                                     ops,
                                     notify,
                                     mbeanDesc
                                     );
                                    
                                     return info;
                                    
                                     }
                                    }
                                    
                                    Output:
                                    
                                    JavaBean.name: SomeBean
                                    JavaBean.displayString: jmx.TestModelMBean$JavaBean@337838(name=SomeBean)