Package org.jasen.core

Examples of org.jasen.core.PluginContainer


                plugins = new Vector(config.getPluginConfigurations().size());

                JasenPlugin plugin = null;
                ProbabilityCalculator pluginCalc = null;
                PluginContainer container = null;
                Properties props = null;
                JasenPluginConfiguration pluginConfig = null;

                while(i.hasNext()) {
                    pluginConfig = (JasenPluginConfiguration)i.next();

                    plugin = (JasenPlugin)Class.forName(pluginConfig.getType(), true, loader).newInstance();

                    logger.debug("Initialising plugin: " + plugin.getClass().getName());

                    // initialise the plugin
                    if(pluginConfig.getProperties() != null) {
                        props = new Properties();
                        props.load(this.getClass().getClassLoader().getResourceAsStream(pluginConfig.getProperties()));
                    }
                    else {
                        props = null;
                    }

                    plugin.init(props);

                    if(pluginConfig.getCalculator() != null) {
                        pluginCalc = (ProbabilityCalculator)Class.forName(pluginConfig.getCalculator(), true, loader).newInstance();
                    }

                    // Add the plugin to a container
                    container = new PluginContainer();
                    container.setName(pluginConfig.getName());
                    container.setDisplayName(pluginConfig.getDisplayName());
                    container.setDescription(pluginConfig.getDescription());
                    container.setCalculator(pluginCalc);
                    container.setPlugin(plugin);

                    // Add the container to the list
                    plugins.add(container);
                }
            }
View Full Code Here


        ParserData parserData = htmlParser.parse(mm, wrapper, tokenizer);

        // Now, loop through the plugins in order and test...
        if(plugins != null) {

            PluginContainer container = null;
            JasenTestResult pluginResult = null;

            double[] probabilities = new double[plugins.size()];
            double[] pointProbabilities = null;
            int points = 0;
            float min = 0.0f;
            float max = 0.0f;
            int pointThreshold = 1;
            float prob = 0.5f;
            double finalProbability = 0.5d;
            boolean thresholdReached = false;

            String[][] testResults = new String[plugins.size()][4];

            long time;
           
            // Ensure the ignore list is sorted for the binary search
            if(ignored != null) {
                Arrays.sort(ignored);
            }

            for (int i = 0; i < plugins.size(); i++)
            {
                time = System.currentTimeMillis();

                container = (PluginContainer)plugins.get(i);
               
                // Determine if we should ignore this plugin
                if(ignored != null && ignored.length > 0 && Arrays.binarySearch(ignored, container.getName()) > -1) {
                    probabilities[i] =  JasenEngineConfiguration.getInstance().getGuess();
                   
                    testResults[i][RESULT_INDEX_PROBABILITY] = String.valueOf(probabilities[i])
                    testResults[i][RESULT_INDEX_TIME] = "0";
                    testResults[i][RESULT_INDEX_NAME] = container.getName();
                    testResults[i][RESULT_INDEX_PROBABILITY] = container.getDisplayName();
                }
                else
                {
                    try
                    {
                        pluginResult = container.getPlugin().test(this, mm, wrapper, parserData, parser);
                    }
                    catch (JasenException e)
                    {
                        // We couldn't execute this plugin... record the error and continue
                        ErrorHandlerBroker.getInstance().getErrorHandler().handleException(e);

                        probabilities[i] = JasenEngineConfiguration.getInstance().getGuess();
                    }

                    testResults[i][RESULT_INDEX_NAME] = container.getName();
                    testResults[i][RESULT_INDEX_DISPLAY] = container.getDisplayName();

                    if(pluginResult != null) {
                        if(pluginResult.isAbsolute()) {
                            // We know it's definately spam
                            result.setProbability(1.0d);
View Full Code Here

            List plugins = JasenScanner.getInstance().getPlugins();
           
            if(plugins != null) {
               
                Iterator i = plugins.iterator();
                PluginContainer container = null;
               
                while(i.hasNext()) {
                    container = (PluginContainer)i.next();
                    System.out.println ("Name:\t" + container.getName());
                    System.out.println ("Display Name:\t" + container.getDisplayName());
                    System.out.println ("Description:\t" + container.getDescription());
                    System.out.println ("--------------------------");
                }
            }
        }
        catch (Exception e)
View Full Code Here

TOP

Related Classes of org.jasen.core.PluginContainer

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.