Author: luca
Date: Fri Mar 23 10:32:40 2012
New Revision: 1304268
URL: http://svn.apache.org/viewvc?rev=1304268&view=rev
Log:
Move business logic into public method, out of main, so it can be invoked by
clients.
Modified:
oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/Profiler.java
Modified:
oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/Profiler.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/Profiler.java?rev=1304268&r1=1304267&r2=1304268&view=diff
==============================================================================
--- oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/Profiler.java
(original)
+++ oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/Profiler.java
Fri Mar 23 10:32:40 2012
@@ -55,6 +55,11 @@ import org.xml.sax.SAXException;
public class Profiler {
private static Logger LOG = Logger.getLogger(Profiler.class.getName());
+
+ /**
+ * Optional directory to serialize the profiles to.
+ */
+ private File outputDir;
/**
* Command line invocation method.
@@ -68,9 +73,36 @@ public class Profiler {
usage();
}
File configFile = new File(args[0]);
- File outputDir = null;
- if (args.length == 2)
- outputDir = new File(args[1]);
+ Profiler profiler = new Profiler();
+ if (args.length == 2) {
+ profiler.setOutputDir( new File(args[1]) );
+ }
+
+ // run profiler
+ profiler.makeProfiles(configFile);
+
+ }
+
+ /**
+ * No argument constructor.
+ */
+ public Profiler() {}
+
+ /**
+ * Setter method for output directory.
+ * @param outputDir
+ */
+ public void setOutputDir(File outputDir) {
+ this.outputDir = outputDir;
+ }
+
+ /**
+ * Method to generate OODT profiles according to the specifications
contained in a configuration file.
+ *
+ * @param configFile
+ * @return
+ */
+ public List<Profile> makeProfiles(final File configFile) throws Exception {
// parse THREDDS catalogs, create OODT profiles
ProfileHandler profileHandler = new OpendapProfileHandler();
@@ -99,6 +131,8 @@ public class Profiler {
FileUtils.writeStringToFile(file, xml);
}
+ return profiles;
+
}
private static XMLQuery buildXMLQuery(final File file) throws SAXException {