Package org.apache.commons.digester3.plugins

Examples of org.apache.commons.digester3.plugins.PluginException


        HashMap<String, Object> source2 = new HashMap<String, Object>();
        source2.put( "attr1", "source2.attr1" ); // should not be used
        source2.put( "attr2", "source2.attr2" );

        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "$", source1 );
        expander.addSource( "var", source2 );

        digester.setSubstitutor( new VariableSubstitutor( expander ) );
        digester.addObjectCreate( "root/bean", SimpleTestBean.class );
        digester.addSetProperties( "root/bean" );
        digester.addSetNext( "root/bean", "addSimpleTestBean" );
View Full Code Here


        HashMap<String, Object> verbs = new HashMap<String, Object>();
        verbs.put( "1", "gyre" );
        verbs.put( "2", "gimble" );

        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "noun", nouns );
        expander.addSource( "verb", verbs );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addCallMethod( "root", "setAlpha", 0 );
View Full Code Here

        String xml = "<root alpha='${attr1}'/>";
        StringReader input = new StringReader( xml );
        Digester digester = new Digester();

        // Configure the digester as required
        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "$", new HashMap<String, Object>() );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addSetProperties( "root" );
View Full Code Here

    {
        Digester digester = new Digester();

        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "$", mutableSource );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        int useRootObj = -1;
        Class<?>[] callerArgTypes = new Class[] { String.class, String.class };
        CallMethodRule caller = new CallMethodRule( useRootObj, "addProperty", callerArgTypes.length, callerArgTypes );
        digester.addRule( "root/property", caller );
View Full Code Here

        StringReader input = new StringReader( xml );
        Digester digester = new Digester();

        // Configure the digester as required
        MultiVariableExpander expander = new MultiVariableExpander();
        digester.setSubstitutor( new VariableSubstitutor( expander ) );
        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addSetProperties( "root" );

        // Parse our test input.
        SimpleTestBean root = digester.parse( input );
View Full Code Here

        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "$", source1 );
        expander.addSource( "var", source2 );

        digester.setSubstitutor( new VariableSubstitutor( expander ) );
        digester.addObjectCreate( "root/bean", SimpleTestBean.class );
        digester.addSetProperties( "root/bean" );
        digester.addSetNext( "root/bean", "addSimpleTestBean" );

        // Parse our test input.
View Full Code Here

        verbs.put( "2", "gimble" );

        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "noun", nouns );
        expander.addSource( "verb", verbs );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addCallMethod( "root", "setAlpha", 0 );

        // Parse our test input.
View Full Code Here

        Digester digester = new Digester();

        // Configure the digester as required
        MultiVariableExpander expander = new MultiVariableExpander();
        expander.addSource( "$", new HashMap<String, Object>() );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        digester.addObjectCreate( "root", SimpleTestBean.class );
        digester.addSetProperties( "root" );

        // Parse our test input.
View Full Code Here

                }
              }
            }
        }catch( Throwable e ){
         
          throw( new PluginException( "Failed to read plugin file", e ));
       
        }finally{
       
          if ( zis != null ){
           
            try{
              zis.close();
             
            }catch( Throwable e ){
             
              Debug.printStackTrace(e);
            }
          }
        }

        pos = prefix.lastIndexOf("_");
        String filename_id = null, filename_version = null;
        if ( pos != -1 ){
          filename_id       = prefix.substring(0,pos);             
          filename_version    = prefix.substring(pos+1);
        }
       
        if ( properties == null ){
         
            // one valid possibility here, this is a built-in plugin. this doesn't have
            // a plugin.properties
                   
          if (filename_id != null) {
         
            id       = filename_id;             
            version    = filename_version;
                     
            PluginInterface pi = installer.getPluginManager().getPluginInterfaceByID( id );

            ok =    pi != null &&
                pi.getPluginDirectoryName() == null ||
                    pi.getPluginDirectoryName().length() == 0 );
          }
         
          if ( !ok ){
         
            throw( new PluginException( "Mandatory file 'plugin.properties' not found in plugin file" ));
          }
        }else{ // properties != null
       
          // unfortunately plugin.id isn't mandatory for the properties, and neither is plugin.version
       
          PluginInitializer.checkJDKVersion( "", properties, false );
          PluginInitializer.checkAzureusVersion("", properties, false);
         
          id    = properties.getProperty( "plugin.id" );
          version  = properties.getProperty( "plugin.version" );
         
          // Force both versions to be the same if they are both defined.
          String prop_version = version;
          if (prop_version != null && filename_version != null && !filename_version.equals(prop_version)) {
              throw new PluginException("inconsistent versions [file=" + filename_version + ", prop=" + prop_version + "]");
          }

        }
       
        if ( id == null ){
         
          // see if plugin is already loaded, if so we can get the id from it
         
          String  plugin_class = properties.getProperty("plugin.class");
         
          if ( plugin_class == null ){
           
            String  plugin_classes = properties.getProperty( "plugin.classes" );
           
            if ( plugin_classes != null ){
             
              int  semi_pos = plugin_classes.indexOf(";");
             
              if ( semi_pos == -1 ){
               
                plugin_class  = plugin_classes;
               
              }else{
               
                plugin_class = plugin_classes.substring( 0, semi_pos );
              }
            }
          }
         
          if ( plugin_class != null ){
           
            try{
              PluginInterface pi = installer.getPluginManager().getPluginInterfaceByClass( plugin_class );
             
              if ( pi != null ){
               
                id  = pi.getPluginID();
              }
            }catch( Throwable ignore ){
             
            }
          }
        }
       
        pos = prefix.lastIndexOf("_");
   
        if ( pos != -1 ){
   
          id       = id==null?prefix.substring(0,pos):id;

            // see if we can normalise the ID based on SF values
         
          try{
            SFPluginDetailsLoader  loader = SFPluginDetailsLoaderFactory.getSingleton();
         
            String[]  ids = loader.getPluginIDs();
           
            for (int i=0;i<ids.length;i++){
             
              if ( ids[i].equalsIgnoreCase(id)){
               
                id = ids[i];
               
                break;
              }
            }
          }catch( Throwable e ){
           
            Debug.printStackTrace(e);
          }

          version    = version == null?prefix.substring(pos+1):version;

        }
       
        this.name = id;
       
        if ( properties != null ){
         
          String plugin_name = properties.getProperty( "plugin.name" );
         
          if ( plugin_name != null ){
           
            this.name = plugin_name;
          }
        }
       
        ok  = id != null && version != null;
      }
    }
   
    if ( !ok ){
     
      throw( new PluginException( "Invalid plugin file name: must be of form <pluginid>_<version>.[jar|zip]" ));
    }
  }
View Full Code Here

    unload( false );
  }
 
  protected void unload( boolean for_reload ) throws PluginException {
    if (!isUnloadable()) {
      throw new PluginException("Plugin isn't unloadable");
    }
       
    String dir = pi.getPluginDirectoryName();
       
    // if not dir based then just test this one
View Full Code Here

TOP

Related Classes of org.apache.commons.digester3.plugins.PluginException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.