14 Replies Latest reply on Aug 13, 2009 7:21 AM by Daniel Bevenius

    StructureDeployer that supports subdeployments

    Daniel Bevenius Master

      Hi,

      I'm writing a StructureDeployer to determine an esb deployment. An esb archive is exactly like a JarStructure which is what we've been using until now.

      We have now got a requirement to support subdeployments. For example, we could have the following layout:

      test.esb:
      META-INF/
       deployment.xml
       jboss-esb.xml
      org/jboss/esb
       Test.class
      wars/
       war1.war
       war2.war

      Now, since the wars dir does not have a META-INF directory it will not be identifed as a subdeployment when using the JarStructure deployer.

      So I was thinking that I could simply use the same code in JarStructure for our EsbStructure, but remove the requirement of subdeployment needing to have a META-INF directory. But this leads to all sorts of deployment errors.
      Is anyone aware of an example of a StructureDeployer that support subdeployments in this manner? Or is there another way to accomplish this?

      Thanks,

      /Daniel


        • 1. Re: StructureDeployer that supports subdeployments
          Ales Justin Master

           

          "beve" wrote:

          Is anyone aware of an example of a StructureDeployer that support subdeployments in this manner? Or is there another way to accomplish this?

          There is DirectoryStructure which considers every directory as a potential location for sub-deployments.
          It was developed to support old .sar/lib, but it's deprecated and commented out.
          (still part of JBossAS, but left out on purpose)

          I guess in your case it would be best to either have this new structure deployer,
          or force every .esb user to jboss-structure.xml.

          Or, you can use StructureProcessor, which can modify structure info just before we pass it to real deployers.
          See SeamTempModificationTypeMatcher in seam-int project:
          - http://anonsvn.jboss.org/repos/jbossas/projects/jboss-seam-int/trunk/microcontainer/src/main/java/org/jboss/seam/integration/microcontainer/deployers/SeamTempModificationTypeMatcher.java
          (this is callback matched with the current default StructureProcessor impl)

          • 2. Re: StructureDeployer that supports subdeployments
            Daniel Bevenius Master

            Hi Ales,

            thanks for the your help on this!

            The DirectoryStructure solution works well but since it's deprecated I'll look into your second solution.

            Regarding the solution with a StructureProcessor and the example you gave , SeamTempModificationTypeMatcher. Could you explain a little more how this could be used to solve the issue with subdirectory deployments?

            Thanks,

            /Daniel

            • 3. Re: StructureDeployer that supports subdeployments
              Ales Justin Master

               

              "beve" wrote:

              Regarding the solution with a StructureProcessor and the example you gave , SeamTempModificationTypeMatcher. Could you explain a little more how this could be used to solve the issue with subdirectory deployments?

              You would write your own EsbModificationTypeMatcher.
              Where ModificationTypeStructureProcessor picks up this EMTM by MC's incallback.

              e.g.
              public class EsbModificationTypeMatcher implements ModificationTypeMatcher
              {
               private StructureDeployer warStructureDeployer = null; // get it injected
               private VFSStructuralDeployers deployers = null; // get it injected
              
               public boolean determineModification(VirtualFile root, StructureMetaData structureMetaData)
               {
               try
               {
               if (root.getName().endsWith(".esb"))
               {
               VirtualFile wars = root.getChild("wars");
               if (wars != null)
               {
               List<VirtualFile> children = wars.getChildren();
               for (VirtualFile war : children)
               {
               StructureContext context = new StructureContext(root, root, war, structureMetaData, deployers, null);
               warStructureDeployer.determineStructure(context);
               }
               }
               return true;
               }
               }
               catch (Exception ignored)
               {
               }
               return false;
               }
              
               public boolean determineModification(VirtualFile root, ContextInfo contextInfo)
               {
               // cannot change sub-deployment
               return false;
               }
              }
              


              Perhaps try something like this.
              If this doesn't work, I would fallback to writing my own StructureDeployer.
              Where you can extend JARStructure (to only understand .esb) + change its candidateStructureVisitorFactory.

              • 4. Re: StructureDeployer that supports subdeployments
                Daniel Bevenius Master

                For the moment I'm going to simply use a modified DirectoryStructure. If I have time before our next release I'll go back I'll try the solutions that you've given as I understand that this solution is not optimal.

                Thanks,

                /Daniel

                • 5. Re: StructureDeployer that supports subdeployments
                  Ales Justin Master

                   

                  "beve" wrote:
                  For the moment I'm going to simply use a modified DirectoryStructure. If I have time before our next release I'll go back I'll try the solutions that you've given as I understand that this solution is not optimal.

                  You should at least add a short-circuit check.
                  As we already have issues with slow boot time,
                  and this structure deployer affects all deployments,
                  hence every unnecessary extra step is costly.

                  • 6. Re: StructureDeployer that supports subdeployments
                    Daniel Bevenius Master

                     

                    You should at least add a short-circuit check.
                    As we already have issues with slow boot time,
                    and this structure deployer affects all deployments,
                    hence every unnecessary extra step is costly.

                    I've re-opened the jira for this and we will at the very least add the short-circuit check and hopefully have time to look into your other suggestions.

                    Regards,

                    /Daniel



                    • 7. Re: StructureDeployer that supports subdeployments
                      Ales Justin Master

                       

                      "beve" wrote:

                      I've re-opened the jira for this and we will at the very least add the short-circuit check and hopefully have time to look into your other suggestions.

                      I can hack you a few examples, and you test them.
                      e.g. trying to make JARStructure more flexible

                      Or even better, you provide me with your valid use cases,
                      and I'll include this as part of Deployers impl / tests,
                      as I see this should be a good use case - nice structure deployers extensions.
                      Hence any future demand should be easy - having this as an impl entry point.

                      I need to do new Deployers anyway, as I have some small bugs fixes ready.

                      • 8. Re: StructureDeployer that supports subdeployments
                        Daniel Bevenius Master

                         

                        Or even better, you provide me with your valid use cases,
                        and I'll include this as part of Deployers impl / tests,

                        I'd be happy to provide the use cases that we have.

                        The requirement we have today is to support sub-deployments that are located in sub directories. This is required so that we are backward compatible. For ESB 5 we can look having more strict deployment rules, such as wars should be packaged in a wars directory for example.

                        For us it would be great to have a StructureDeployer implementation that takes a suffix for the type of deployment being deployed. We'd also need this deployer to be able have the option of supporting all types of sub-deployments.

                        I've tried extending the JarStructure but that did not really work for me. I'm now trying just to extend AbstractVFSStructureDeployer and making this as flexible as possible.

                        Not sure if that was the type of use case you meant. I've got some unit test for this too. Let me know if you'd like them and I'll send you them (they are not checked in).


                        as I see this should be a good use case - nice structure deployers extensions.
                        Hence any future demand should be easy - having this as an impl entry point.

                        It would be really nice to have something like this I think:)

                        Thanks,

                        /Daniel





                        • 10. Re: StructureDeployer that supports subdeployments
                          Daniel Bevenius Master

                           

                          I still need to test this; I'll use your esb example + some other hacks.

                          Nice, I'll give this a spin from my end as well.

                          Thanks!

                          /Daniel

                          • 12. Re: StructureDeployer that supports subdeployments
                            Daniel Bevenius Master

                            I've tried this with the ESB and I'm using the following configuration for the GroupingStructure:

                            <bean name="GroupingStructure" class="org.jboss.soa.esb.listeners.deployers.mc.GroupingStructure">
                             <property name="shortCircuitFilter">
                             <inject bean="EsbFilter"/>
                             </property>
                             <property name="metaDataPaths">
                             <array elementClass="java.lang.String">
                             <value>META-INF</value>
                             <value>.</value>
                             </array>
                             </property>
                             <property name="libs">
                             <set elementClass="java.lang.String">
                             <value>.</value>
                             <value>jars</value>
                             </set>
                             </property>
                             <property name="libFilter">
                             <inject bean="JarFilter"/>
                             </property>
                             <property name="groups">
                             <set elementClass="java.lang.String">
                             <value>.</value>
                             <value>wars</value>
                             </set>
                             </property>
                             <property name="groupFilter">
                             <inject bean="WarFilter"/>
                             </property>
                             </bean>

                            I've simply copied your GroupingStructure into our project for the time being hence the different package name.

                            So we can now have jars in either the root, or in a sub directory named 'jars'.
                            And we can have wars in either the root, or in a sub directory named 'wars'.

                            Now, we are going to have users that have wars in sub directories that have different names then 'wars'.
                            These users will have the following options (as I see it):
                            1. Renaming their sub directory to 'wars'.
                            2. Adding their sub directory names to the 'groups' list above.
                            3. Add a META-INF/jboss-structure.xml to their .esb archive:
                            <?xml version="1.0" encoding="UTF-8"?>
                            <structure>
                             <context>
                             <path name=""/>
                             <metaDataPath>
                             <path name="META-INF"/>
                             <path name="."/>
                             </metaDataPath>
                             <classpath>
                             <path name=""/>
                             <path name="." suffixes=".jar"/>
                             </classpath>
                             </context>
                             <context>
                             <path name="subdir/testwar.war"/>
                             <metaDataPath>
                             <path name="WEB-INF"/>
                             </metaDataPath>
                             <classpath>
                             <path name="subdir/testwar.war/WEB-INF/classes"/>
                             </classpath>
                             </context>
                            </structure>
                            

                            4. Last resort (because of the negative performance impact) activate the DirectoryStructure by uncommenting it in deployers/directory-deployer-jboss-beans.xml.

                            Have I missed any options here?

                            Thanks for writing the GroupingStructure! I think it will be very useful.

                            Regards,

                            /Daniel







                            • 13. Re: StructureDeployer that supports subdeployments
                              Ales Justin Master

                               

                              "beve" wrote:

                              Have I missed any options here?

                              Looks OK. :-)

                              I guess users now have so many options they shouldn't complain anymore. ;-)

                              • 14. Re: StructureDeployer that supports subdeployments
                                Daniel Bevenius Master

                                Thanks for you help on this Ales!

                                Regards,

                                /Daniel