13 Replies Latest reply on Feb 10, 2012 11:15 PM by Kamesh Sampath

    Extending JBoss Server

    Kamesh Sampath Newbie



      I am trying to write a JBoss AS7 Adapter for my custom server which is an extension JBoss AS7. When i try to write adapter for i face few issues bacause at many places i see the JBoss AS plugin uses the checking for ServerUtil#isJBoss7 where it checks for the severTypes only from JBossServerCore plugins, thereby my custom serverType is not getting processed and few intiailizations and other stuff fails, rather than checking by serverTypeId can we not check to see if the server is an instance of JBoss7Server ?


      is there any way to overcome this ?


      My Platform details is


      Eclipse Platform -- Version: 3.7.1Build id: M20110909-1335

      JBoss Tools  -- 2.3.0.qualifier (Development Build)



        • 1. Re: Extending JBoss Server
          Max Rydahl Andersen Master

          the class used to implement it doesn't really have anything to do with this.


          That said I also don't like that we have so many isJBoss<something> instead of just having polymorphic methods/class delegates to handle these cases.


          What kind of additional behavior is it you are looking to add ?

          • 2. Re: Extending JBoss Server
            Kamesh Sampath Newbie

            Hi Max,


            Actually am writing an adapter for custom application deployed in JBoss AS7 and it has few addtional attibutres like classpath settings, ports etc.,  For most of the cases am resuing the JBossAS7 plugin classes, in some cases the class which i have extented form JBossAS7Server is not being recogonized as JBoss AS7 server and xpath's are not added to the custom server ,  when i debugged i see it goes checking where it is recogonizing only serverType with id declared in jboss.as.core plugin for AS7 serverTypes alone as AS7 server, since my plugin has a custom id it its not considering this as JBoss AS7 Server.


            When i define the server and open the server configuration i see the Server "Ports" are empty as opposed to it getting picked from the xpath files for AS7  like how it does for tradtional AS7 server/runtimes,


            Can you please let me know how to fix this ? My server is absolutely AS7 except for few customzations which i will allow the user to do via this adapter.



            • 3. Re: Extending JBoss Server
              Max Rydahl Andersen Master

              Right now it is probably not possible to do extend dynamically - contributions welcome to make that happen.


              I'm still not fully understanding why you need to write custom adapter if it is just about having custom parameters set ? You can adjust those via eclipse in the launch configuration and you can even share it with others for reuse.


              Do you need something more specific ?

              • 4. Re: Extending JBoss Server
                Kamesh Sampath Newbie

                let me try to see if i can submit a patch for the same. One possible solution is to make us provide the runtimeTypeExtension and serverTypeExtension similar to how we have the behaviorExtension so that the extensible adapters can still be considered as their extending parent when packaged together. Not sure how this sounds


                back to the customization part, we need to do lot more than just setting of paramter, like validation of the modules before deployement, custom deployment methods and its very specific for our bundle that is configured on top of JBoss.




                • 5. Re: Extending JBoss Server
                  Rob Stryker Master

                  Hi Kamesh:


                  Right now the XPath model is a (should be public) singleton model. The API is fairly stable but of course we make no guarantees on it's long-term stability. We're not really geared at this time to extension. But, if you're willing to work through the problems, we'd be glad to help you as much as we can and accept any patches you have.


                  First of all, just not registering as as7 is not your only problem. Even if your server were recognized as as7, it would then check the specific server type id, (as7? as71? eap6? all based on the server type id) and get a customized list of properties and xpaths. Obviously jboss as changes quite often, many times without enough notice to us, and so we have to change port xpaths between minor versions.  So even if we got rid of that pesky isAS7 method, we're still storing properties as defaulted from a file hidden inside our bundle.


                  I have made some changes to our codebase just now to try to allow you a bit of an easier time at it. If your server type is custom for as71, then I suggest at your bundle startup, you do something like this:


                  XPathModel.addServerTypeToURLMapping("org.your.server.type.id", XPathModel.get("org.jboss.ide.eclipse.as.runtime.71"))


                  If your server type is in fact meant to be one server type for ALL of as7, then I am not sure we can help you. The infrastructure is set up such that each specific version of jboss gets a different set of ports as default. If you'd like to hand-craft your own port customizations, you can also do that. You would then need to register your own IServerLifecycleListener, and, when a new server of your type has been added, you would need to check for / find / or add the Ports category, and then add the queries by hand.


                  You can do this entirely via API and hand-crafting your categories and queries, or, you can use a properties file such as we use. An example of the file is here:



                  AN example of how you'd use it is something like:


                  ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {

                      public void serverAdded(IServer server) {

                          // find the port category

                          XPathCategory c = XPathModel.getDefault().getCategory(server, "ports");

                          // your own properties file url

                          URL url = you.find.it.however..... // you can do this part

                          XPathModel.addQueriesToCategoryFromDefaultFile(server, c, "", url);





                  These changes are available in svn now. Not sure what you're building off of. As always, these classes are still officially internal, but if you're willing to play ball, have at it  

                  1 of 1 people found this helpful
                  • 6. Re: Extending JBoss Server
                    Max Rydahl Andersen Master

                    *Extension sounds a bit too much meta for me you would introduce a choice when pointing to an AS7 what "kind" of AS7 it is ?


                    ...the list of things you mention sounds more like things you would change on the AS7 runtime it self - not in the server adapter....?

                    I guess you also need to fix standalone.sh to run it outside ?

                    • 7. Re: Extending JBoss Server
                      Kamesh Sampath Newbie

                      Hi Rob,


                      Thanks a lot for your insight. I kind of acheived what I want using a mechanism of extension points like you already have for beahvior.


                      I tried to create two new extension points serverTypesExtesion and runtimeTypesExtension, these two extension points would allow the extenders to add their Custom JBoss servers as the alias for the serverTypes/runtimeTypes defined in the jboss.as.core plugin.  then i made a small tweak to the XPathModel static method where you set up the rtPortsFile Hashmap to add the extended runtime ports. There you go i was able to see the default ports coming up.


                      If my approach above sounds good to you, i can open a ticket and I can contribute a patch and we can take it from there.


                      Right now I am facing the same issue with the Pollers , trying to write my custom Poller as again we have the id checks... Do you have any thoughts around that.



                      • 8. Re: Extending JBoss Server
                        Kamesh Sampath Newbie

                        thanks max, but we have our own limitations on adding to standlone.sh, thats the reason we are trying to an extension. Moreover what i told is just a brief we have lot more to do with respect to server behavior, starting/stopping and publishing based on the custom modules that we deploy on top of our bundle.

                        • 9. Re: Extending JBoss Server
                          Kamesh Sampath Newbie

                          Hi Rob:


                          Based on your thoughts above I tried to do a alternate approach without extensions and code changes to the code base attaching listener. Attached a snippet that worked, its based on your code above.


                          I have another question do we need to do the same for the runtime too ?


                          But all this happened i took the latest update and worked on top of it, thanks for the update.



                          • 10. Re: Extending JBoss Server
                            Max Rydahl Andersen Master

                            doesn't this code cause possible clashes with type's that have "70" string in them but aren't related to JBoss servers at  all ?

                            • 11. Re: Extending JBoss Server
                              Kamesh Sampath Newbie

                              thats a valid point and i have fixed it with a regex that checks my server types alone. thanks for your thoughts.

                              • 12. Re: Extending JBoss Server
                                Rob Stryker Master

                                Hi Kamesh:


                                Are you still having an issue with pollers?


                                I could potentially add in an additional extension point, to add your own server-type mapping to specific polling id's.  Currently we have a poller extension point like this:


                                        name="JBoss 7 Manager Service"



                                I could perhaps add something like:

                                <serverPollerMapping   pollerId="org.jboss.ide.eclipse.as.core.server.JBoss7ManagerServicePoller" serverTypes="your.custom.server.type"/>


                                But of course some other changes would need to be made where the pollers vs the server type are being discovered. This is in org.jboss.ide.eclipse.as.core.ExtensionManager in the method named loadPollers.  Might require some work though, but I'm sure it could be done.


                                Let me know if you want to work on a patch for this.

                                • 13. Re: Extending JBoss Server
                                  Kamesh Sampath Newbie

                                  Hi Rob,


                                  I dont mind contributing the code, but I am in middle of another thing, will finish that and reach out to you on the process of getting this done.


                                  Thanks for all your thoughts/suggestions.