1 2 3 Previous Next 32 Replies Latest reply on Dec 18, 2007 6:09 PM by alesj

    BSH script from client

    alesj

      I've ported the old BSH deployer to our new deployers - splitting it in two: parsing and real BeanShellScript deployer.

      The thing that I haven't ported is this:

       public URL createScriptDeployment(String bshScript, String scriptName)
       throws DeploymentException
       {
       try
       {
       File scriptFile = File.createTempFile(scriptName, ".bsh");
       FileWriter fw = new FileWriter(scriptFile);
       try
       {
       fw.write(bshScript);
       }
       finally
       {
       fw.close();
       }
      
       URL scriptURL = scriptFile.toURL();
       mainDeployer.deploy(scriptURL);
       return scriptURL;
       }
       catch(IOException e)
       {
       throw new DeploymentException("Failed to deploy: "+scriptName, e);
       }
       }
      


      Since with the new aspectized deployers all we need to do is to create BeanShellScript instance and put it in deployment attachments, where it will be picked-up by the bsh-script aspect deployer.

      Where/how is the best place to put this - if we still need it?
      Registering a separate (m)bean, which holds a ref to main deployer and creates new deployment on the fly with just the script instance attached?

        • 1. Re: BSH script from client
          starksm64

          That is really a debatable operation on the management interface of some remote deployer component. I would not even port this.

          • 2. Re: BSH script from client
            alesj

            I've created a separate bean shell client bean - LegacyBeanShellScriptClient.

            Its usage in bsh-deployers-beans.xml is currently commented.

            • 3. Re: BSH script from client
              alesj

              We still need to port the actual deployer structure to
              <server-configruation>/deployers/bsh.deployer
              - META-INF/bsh-deployers-beans.xml
              - bsh-deployer.jar

              How does this - bsh-deployer.xml + coresponding lib - get into current AS build?

              • 4. Re: BSH script from client

                You need to change varia/build.xml
                such that it creates a structure like
                bsh.deployer/
                bsh.deployer/META-INF/bsh-deployers-beans.xml
                bsh.deployer/bsh-deployer.jar

                Then update build/build-distr.xml
                such that this directory structure is copied into server/{all|default}/deployers

                • 5. Re: BSH script from client
                  alesj

                   

                  "adrian@jboss.org" wrote:
                  You need to change varia/build.xml
                  such that it creates a structure like
                  bsh.deployer/
                  bsh.deployer/META-INF/bsh-deployers-beans.xml
                  bsh.deployer/bsh-deployer.jar

                  Then update build/build-distr.xml
                  such that this directory structure is copied into server/{all|default}/deployers


                  Sure.
                  And I guess I need to remove copying of the bsh-deployer.xml to deploy dir as well - simply by deleting it in trunk. :-)
                  But where was the initial BeanShellSubDeployer class present - since I fail to find it. Or is this not present anymore in the current as5 trunk build?

                  • 6. Re: BSH script from client

                     

                    "alesj" wrote:

                    But where was the initial BeanShellSubDeployer class present - since I fail to find it. Or is this not present anymore in the current as5 trunk build?


                    ?

                    [ejort@warjort varia]$ find . -iname BeanShellSubDeployer.java
                    ./src/main/org/jboss/varia/deployment/BeanShellSubDeployer.java
                    


                    • 7. Re: BSH script from client
                      alesj

                       

                      "adrian@jboss.org" wrote:
                      [ejort@warjort varia]$ find . -iname BeanShellSubDeployer.java
                      ./src/main/org/jboss/varia/deployment/BeanShellSubDeployer.java

                      Not .java file. ;-)
                      .class file.
                      In which .jar was/is present in current build?
                      Or, since nobody picked-up -deployer.xml files any more, there was no need for it to be present in current build?

                      • 8. Re: BSH script from client
                        alesj

                         

                        "adrian@jboss.org" wrote:
                        You need to change varia/build.xml
                        such that it creates a structure like
                        bsh.deployer/
                        bsh.deployer/META-INF/bsh-deployers-beans.xml
                        bsh.deployer/bsh-deployer.jar

                        Then update build/build-distr.xml
                        such that this directory structure is copied into server/{all|default}/deployers

                        Done.


                        • 9. Re: BSH script from client
                          dimitris

                          I was looking into org.jboss.test.jmx.test.DeployXMBeanUnitTestCase failures.

                          The interceptors-xmbean.sar includes an embeded/nested .bsh script, which is not picked up by the new deployer, and so the test fails.
                          ...
                          jmx/interceptors/scripts/
                          jmx/interceptors/scripts/SecurityConfig.bsh
                          ...

                          How this .bsh script can be picked up? Do we need to change the bootstrap-beans.xml ?

                          • 10. Re: BSH script from client
                            starksm64

                            This should be picked up by the bsh deployer Ales ported over. It should not require a change to the bootstrap-beans.xml as bsh should not be a bootstrap supported capability. I see that there is a deployers/bsh.deployer/, and this should be all that is needed. If the script is not getting deployed we need to look at why the bsh deployer is not being used.

                            • 11. Re: BSH script from client
                              alesj

                              I'll have a look today.
                              My first guess would be that .bsh file is not listed as part of metadata files in that nested sar.

                              • 12. Re: BSH script from client

                                 

                                "scott.stark@jboss.org" wrote:
                                This should be picked up by the bsh deployer Ales ported over. It should not require a change to the bootstrap-beans.xml as bsh should not be a bootstrap supported capability.


                                Whether it should or it shouldn't, it currently does require a change in bootstrap-beans.xml
                                i.e. for subdeployments you have to tell the FileStructure deployer what plain file
                                extensions are deployable.
                                I updated the JIRA issue with the required change.

                                Maybe we could add some mechanism where a deployer can automagically
                                register/unregister matching alogrithms with the FileStructure for otherwise
                                unrecognised files.

                                e.g.

                                public interface FileMatcher
                                {
                                 boolean isDeployable(VirtualFile file);
                                }
                                
                                public class FileStructure implements StructureDeployer
                                {
                                 ...
                                
                                 @InCallback
                                 public void addFileMatcher(FileMatcher fm) {...};
                                 @UnCallback
                                 public void removeFileMatcher(FileMatcher fm) {...};
                                }
                                


                                The bean shell deployer could then implement FileMatcher to say
                                it wants files ending with .bsh and the MC will do the injection onto the FileStructure
                                without any extra xml or code.

                                • 13. Re: BSH script from client
                                  dimitris

                                  I did a quick test with the added '.bsh' suffix in the FileStructure deployer but it didn't work.

                                  Do we actually recurse inside a deployment, or look only in the root? Is this controlled somewhere?

                                  • 14. Re: BSH script from client

                                     

                                    "dimitris@jboss.org" wrote:
                                    I did a quick test with the added '.bsh' suffix in the FileStructure deployer but it didn't work.

                                    Do we actually recurse inside a deployment, or look only in the root? Is this controlled somewhere?


                                    That's because the FileStructure algorithm is broken. ;-)
                                    It expects a - in the file name.

                                     public static boolean isKnownFile(String name)
                                     {
                                     if (name == null)
                                     throw new IllegalArgumentException("Null name");
                                    
                                     int index = name.lastIndexOf('-');
                                     if (index == -1)
                                     return false;
                                     String suffix = name.substring(index);
                                     return fileSuffixes.contains(suffix);
                                     }
                                    


                                    It should be interating over fileSuffixes and using endsWith().

                                    1 2 3 Previous Next