Package org.apache.jena.jdbc.preprocessing

Examples of org.apache.jena.jdbc.preprocessing.CommandPreProcessor


                        if (i instanceof CommandPreProcessor) {
                            // If it implements the right interface initialize
                            // and
                            // register it
                            CommandPreProcessor pp = (CommandPreProcessor) i;
                            pp.initialize(initProps);
                            conn.addPreProcessor(pp);

                            LOGGER.info("Initialized pre-processor " + ppClassName + " successfully");
                        } else {
                            // Otherwise throw an error
                            LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                    + " parameter, references a class that exists but does not implement the required interface");
                            throw new SQLException(
                                    "Parameter "
                                            + PARAM_PRE_PROCESSOR
                                            + " includes the value "
                                            + ppClassName
                                            + " which references a class that does not implement the expected CommandPreProcessor interface, please ensure that the class name is corect and that the class implements the required interface");
                        }
                    } catch (ClassNotFoundException e) {
                        // Unable to find the referenced class
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that did not exist", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be found, please ensure that the class name is correct and the JAR containing this class is on your class path",
                                e);
                    } catch (InstantiationException e) {
                        // Unable to instantiate the referenced class
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that exists but does not have an appropriate constructor", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be sucessfully instantiated, this class must have an unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
                                e);
                    } catch (IllegalAccessException e) {
                        // Referenced class is not accessible
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that exists but is inaccessible", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be sucessfully instantiated, this class must have a publicly accessible unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
                                e);
                    } catch (SQLException e) {
                        // Throw as-is
                        throw e;
                    } catch (Exception e) {
                        // Unexpected error
                        LOGGER.error(
                                "Invalid value for "
                                        + PARAM_PRE_PROCESSOR
                                        + " parameter, references a class that attempting to initialize produced an unexpected exception",
                                e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which caused an unexpected exception when trying to instantiate it, see the inner exception for details",
                                e);
                    }
                }
            }

            // Attempt registration of results post-processors
            ppObj = ps.get(PARAM_POST_PROCESSOR);
            List<String> postProcessors;
            if (ppObj != null) {

                if (ppObj instanceof String) {
                    // Single instance to try and register
                    postProcessors = new ArrayList<String>();
                    postProcessors.add(ppObj.toString());
                } else if (ppObj instanceof List<?>) {
                    // Multiple instances to try and register
                    postProcessors = (List<String>) ppObj;
                } else {
                    // Parameter set to some unexpected type
                    LOGGER.error("Driver Parameter " + PARAM_POST_PROCESSOR + " has unexpected invalid value");
                    throw new SQLException("Parameter " + PARAM_POST_PROCESSOR + " was set to a value of unexpected type "
                            + ppObj.getClass().getCanonicalName()
                            + ", expected either a String or List<String> as the parameter value");
                }

                // Try and create each pre-processor
                for (String ppClassName : postProcessors) {
                    // Ignore null values
                    if (ppClassName == null)
                        continue;

                    try {
                        LOGGER.info("Attempting to initialize post-processor " + ppClassName);
                        Class<?> c = Class.forName(ppClassName);
                        Object i = c.newInstance();

                        if (i instanceof ResultsPostProcessor) {
                            // If it implements the right interface initialize
                            // and
                            // register it
                            ResultsPostProcessor pp = (ResultsPostProcessor) i;
                            pp.initialize(initProps);
                            conn.addPostProcessor(pp);

                            LOGGER.info("Initialized post-processor " + ppClassName + " successfully");
                        } else {
                            // Otherwise throw an error
View Full Code Here


                        if (i instanceof CommandPreProcessor) {
                            // If it implements the right interface initialize
                            // and
                            // register it
                            CommandPreProcessor pp = (CommandPreProcessor) i;
                            pp.initialize(initProps);
                            conn.addPreProcessor(pp);

                            LOGGER.info("Initialized pre-processor " + ppClassName + " successfully");
                        } else {
                            // Otherwise throw an error
                            LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                    + " parameter, references a class that exists but does not implement the required interface");
                            throw new SQLException(
                                    "Parameter "
                                            + PARAM_PRE_PROCESSOR
                                            + " includes the value "
                                            + ppClassName
                                            + " which references a class that does not implement the expected CommandPreProcessor interface, please ensure that the class name is corect and that the class implements the required interface");
                        }
                    } catch (ClassNotFoundException e) {
                        // Unable to find the referenced class
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that did not exist", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be found, please ensure that the class name is correct and the JAR containing this class is on your class path",
                                e);
                    } catch (InstantiationException e) {
                        // Unable to instantiate the referenced class
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that exists but does not have an appropriate constructor", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be sucessfully instantiated, this class must have an unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
                                e);
                    } catch (IllegalAccessException e) {
                        // Referenced class is not accessible
                        LOGGER.error("Invalid value for " + PARAM_PRE_PROCESSOR
                                + " parameter, references a class that exists but is inaccessible", e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which references a class that could not be sucessfully instantiated, this class must have a publicly accessible unparameterized constructor to be usable with this parameter.  If this is not possible try calling addPreProcessor() on the returned JenaConnection instead",
                                e);
                    } catch (SQLException e) {
                        // Throw as-is
                        throw e;
                    } catch (Exception e) {
                        // Unexpected error
                        LOGGER.error(
                                "Invalid value for "
                                        + PARAM_PRE_PROCESSOR
                                        + " parameter, references a class that attempting to initialize produced an unexpected exception",
                                e);
                        throw new SQLException(
                                "Parameter "
                                        + PARAM_PRE_PROCESSOR
                                        + " includes the value "
                                        + ppClassName
                                        + " which caused an unexpected exception when trying to instantiate it, see the inner exception for details",
                                e);
                    }
                }
            }

            // Attempt registration of results post-processors
            ppObj = ps.get(PARAM_POST_PROCESSOR);
            List<String> postProcessors;
            if (ppObj != null) {

                if (ppObj instanceof String) {
                    // Single instance to try and register
                    postProcessors = new ArrayList<String>();
                    postProcessors.add(ppObj.toString());
                } else if (ppObj instanceof List<?>) {
                    // Multiple instances to try and register
                    postProcessors = (List<String>) ppObj;
                } else {
                    // Parameter set to some unexpected type
                    LOGGER.error("Driver Parameter " + PARAM_POST_PROCESSOR + " has unexpected invalid value");
                    throw new SQLException("Parameter " + PARAM_POST_PROCESSOR + " was set to a value of unexpected type "
                            + ppObj.getClass().getCanonicalName()
                            + ", expected either a String or List<String> as the parameter value");
                }

                // Try and create each pre-processor
                for (String ppClassName : postProcessors) {
                    // Ignore null values
                    if (ppClassName == null)
                        continue;

                    try {
                        LOGGER.info("Attempting to initialize post-processor " + ppClassName);
                        Class<?> c = Class.forName(ppClassName);
                        Object i = c.newInstance();

                        if (i instanceof ResultsPostProcessor) {
                            // If it implements the right interface initialize
                            // and
                            // register it
                            ResultsPostProcessor pp = (ResultsPostProcessor) i;
                            pp.initialize(initProps);
                            conn.addPostProcessor(pp);

                            LOGGER.info("Initialized post-processor " + ppClassName + " successfully");
                        } else {
                            // Otherwise throw an error
View Full Code Here

TOP

Related Classes of org.apache.jena.jdbc.preprocessing.CommandPreProcessor

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.