FileDocCategorySizeDatePackage
BasePluginWrapper.javaAPI DocJBoss 4.2.110435Fri Jul 13 21:02:14 BST 2007org.jboss.console.plugins.helpers

BasePluginWrapper

public class BasePluginWrapper extends AbstractPluginWrapper
see
author
Sacha Labourey.
version
$Revision: 57191 $

Revisions:

23 dec 2002 Sacha Labourey:

  • First implementation

Fields Summary
protected bsh.Interpreter
interpreter
protected String
pluginName
protected String
pluginVersion
protected String
scriptName
protected String
scriptContent
protected ScriptPlugin
script
protected PluginContext
pluginCtx
Constructors Summary
public BasePluginWrapper()

   
   // Static --------------------------------------------------------
   
   // Constructors --------------------------------------------------
      
       super (); 
Methods Summary
protected java.lang.StringgetPluginIdentifier()

      try
      {
         return script.getName (pluginCtx);
      }
      catch (UndeclaredThrowableException ute)
      {
         return "ServletPluginHelper Wrapping script '" + this.scriptName + "'";
      }
   
protected java.lang.StringgetPluginVersion()

      try
      {
         System.out.println ("Version : " + script.getVersion (pluginCtx));
         return script.getVersion (pluginCtx);
      }
      catch (UndeclaredThrowableException ute)
      {
         return "unknown version";
      }
   
protected org.jboss.console.manager.interfaces.TreeNodegetTreeForResource(java.lang.String profile, org.jboss.console.manager.interfaces.ManageableResource resource)

      try
      {
         TreeNode result = script.getTreeForResource (resource, pluginCtx);
         // result = fixUrls (result); // no really necessary now!
         return result;
      }
      catch (UndeclaredThrowableException ute)
      {
         ute.printStackTrace(); // TODO CHANGE TO LOG.DEBUG!!!
         return null; // we decide for the plugin: we don't provide content
      }
   
public voidinit(javax.servlet.ServletConfig servletConfig)

      super.init (servletConfig);
      
      loadScript (this.scriptName);      
      pluginCtx = new SimplePluginContext ();

   
protected booleanisResourceToBeManaged(org.jboss.console.manager.interfaces.ManageableResource resource)

      if (checker != null)
         return super.isResourceToBeManaged(resource);
      else
      {
         try
         {
            return isResourceToBeManaged_Script (pm, resource);
         }
         catch (UndeclaredThrowableException ute)
         {
            ute.printStackTrace();
            return false; // we decide for the plugin (not implemented by it)
         }
      }
   
protected booleanisResourceToBeManaged_Script(org.jboss.console.manager.PluginManager master, org.jboss.console.manager.interfaces.ManageableResource resource)

      return script.isResourceToBeManaged(resource, pluginCtx);
   
protected voidloadScript(java.lang.String scriptName)

      URL url = Thread.currentThread().getContextClassLoader().getResource(scriptName);
      if (url == null)
         throw new IllegalArgumentException("Resource not found: " + scriptName);

      interpreter = new Interpreter ();
      //System.out.println(Thread.currentThread().getContextClassLoader());
      interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
      //interpreter.eval (new java.io.InputStreamReader (url.openStream()), new NameSpace (this.rootContextName), this.rootContextName);
      interpreter.eval (new java.io.InputStreamReader (url.openStream()));
      //interpreter.source (url.getFile(), new bsh.NameSpace(this.rootContextName));
      
      script = (ScriptPlugin)interpreter.getInterface(ScriptPlugin.class);
      
   
public voidreadConfigurationParameters(javax.servlet.ServletConfig config)

      
      /*
      try
      {
         this.rootContextName = config.getServletContext().getServletContextName();
         log.info ("XXXXXXXXXXXXXXXXXX* * " + rootContextName);
         log.info ("XXXXXXXXXXXXXXXXXX* * " + rootContextName);         
      }
      catch (Exception ignored) {}
      getRealPath("/");
      */
      
      super.readConfigurationParameters(config);
      
      this.scriptName = config.getInitParameter("ScriptName");