Examples of GazeHandlerFactory


Examples of de.dfki.km.text20.services.evaluators.gaze.GazeHandlerFactory

        final Collection<OptionRequestVersion> requestedVersions = ou.getAll(OptionRequestVersion.class);

        GazeEvaluatorImpl.this.logger.fine("Obtained request to return an evaluator for " + listener.getClass());

        // Select the proper plugin
        final GazeHandlerFactory selectedCreator = this.pluginManager.getPlugin(GazeHandlerFactory.class, new OptionPluginSelector<GazeHandlerFactory>(new PluginSelector<GazeHandlerFactory>() {

            @Override
            public boolean selectPlugin(GazeHandlerFactory creator) {

                GazeEvaluatorImpl.this.logger.finer("Examining plugin factory " + creator);

                final PluginInformation pi = GazeEvaluatorImpl.this.pluginInformation;

                if (!creator.getEvaluatorType().isAssignableFrom(listener.getClass()))
                    return false;

                GazeEvaluatorImpl.this.logger.finer("Plugin looks promising");

                // Now check the requested versions
                for (OptionRequestVersion rqv : requestedVersions) {
                    // Check if we're dealing with the proper listener.
                    if (!rqv.getListener().isAssignableFrom(listener.getClass()))
                        continue;

                    GazeEvaluatorImpl.this.logger.finer("Found a version request. Checking authors ... ");

                    // Check author
                    if (rqv.getAuthor() != null) {
                        if (!pi.getInformation(Information.AUTHORS, creator).contains(rqv.getAuthor()))
                            return false;
                    }

                    GazeEvaluatorImpl.this.logger.finer("Checking implementaiton version ... ");

                    // Check version
                    if (rqv.getVersion() >= 0) {
                        final Collection<String> information = pi.getInformation(Information.VERSION, creator);
                        if (information.size() != 1) return false;

                        final int version = Integer.parseInt(information.iterator().next());

                        // We accept any newer version
                        if (version < rqv.getVersion()) return false;
                    }

                    GazeEvaluatorImpl.this.logger.finer("Checking capabilities ... ");

                    // Check capabilities
                    if (rqv.getCapabilities().length > 0) {
                        final Collection<String> information = pi.getInformation(Information.CAPABILITIES, creator);

                        // Must match all caps
                        if (!information.containsAll(Arrays.asList(rqv.getCapabilities())))
                            return false;
                    }
                }

                GazeEvaluatorImpl.this.logger.finer("All tests passed. Plugin selected.");

                return true;
            }
        }));

        // No handler to spawn something found, tthis is bad
        if (selectedCreator == null) {
            this.logger.warning("No handler found for requested listener " + listener.getClass().getInterfaces()[0]);
            return;
        }

        final GazeHandler spawnEvaluator = selectedCreator.spawnEvaluator(listener, new OptionGazeEvaluatorPassthrough(options), new OptionGazeEvaluator(this));

        // Even worse: the handler was unable to spawn something
        if (spawnEvaluator == null) { throw new IllegalStateException("Unable to spawn the selected evaluator. This is a bug."); }

        // Register the evaluator
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.