Github user csivaguru commented on a diff in the pull request: https://github.com/apache/storm/pull/1816#discussion_r91615776 --- Diff: external/storm-pmml/src/main/java/org/apache/storm/pmml/runner/jpmml/JpmmlFactory.java --- @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.storm.pmml.runner.jpmml; + +import org.apache.storm.pmml.runner.ModelRunnerFactory; +import org.dmg.pmml.IOUtil; +import org.dmg.pmml.PMML; +import org.jpmml.evaluator.Evaluator; +import org.jpmml.evaluator.ModelEvaluator; +import org.jpmml.evaluator.ModelEvaluatorFactory; +import org.jpmml.manager.PMMLManager; +import org.xml.sax.SAXException; + +import java.io.File; +import java.io.IOException; +import java.util.Objects; + +import javax.xml.bind.JAXBException; + +/* + * This class consists exclusively of static factory methods that create + * object instances that are essential to work with the Jpmml library + */ +public class JpmmlFactory { + /** + * Creates a new {@link PMML} object representing the PMML model defined in the XML {@link File} specified as argument + */ + public static PMML newPmml(File file) throws JAXBException, SAXException, IOException { + Objects.requireNonNull(file); + return IOUtil.unmarshal(file); + } + + /** + * Creates a new {@link Evaluator} object representing the PMML model defined in the {@link PMML} argument + */ + public static Evaluator newEvaluator(PMML pmml) { + Objects.requireNonNull(pmml); + final PMMLManager pmmlManager = new PMMLManager(pmml); + return (ModelEvaluator<?>)pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance()); + } + + /** + * Creates a new {@link Evaluator} object representing the PMML model defined in the XML {@link File} specified as argument + */ + public static Evaluator newEvaluator(File file) throws IOException, JAXBException, SAXException { + Objects.requireNonNull(file); + return newEvaluator(newPmml(file)); + } + + + public static class ModelRunner implements ModelRunnerFactory { --- End diff -- Consider renaming, Having two ModelRunner artifacts (Class here) and the interface might be confusing.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---