Methods Summary |
---|
public void | addFileset(org.apache.tools.ant.types.FileSet set)
fileSets.add(set);
|
public void | execute()Execute the task
try {
Configuration cfg = getConfiguration();
getSchemaValidator(cfg).validate();
}
catch (HibernateException e) {
throw new BuildException("Schema text failed: " + e.getMessage(), e);
}
catch (FileNotFoundException e) {
throw new BuildException("File not found: " + e.getMessage(), e);
}
catch (IOException e) {
throw new BuildException("IOException : " + e.getMessage(), e);
}
catch (Exception e) {
throw new BuildException(e);
}
|
private org.hibernate.cfg.Configuration | getConfiguration()
Configuration cfg = new Configuration();
if (namingStrategy!=null) {
cfg.setNamingStrategy(
(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
);
}
if (configurationFile!=null) {
cfg.configure( configurationFile );
}
String[] files = getFiles();
for (int i = 0; i < files.length; i++) {
String filename = files[i];
if ( filename.endsWith(".jar") ) {
cfg.addJar( new File(filename) );
}
else {
cfg.addFile(filename);
}
}
return cfg;
|
private java.lang.String[] | getFiles()
List files = new LinkedList();
for ( Iterator i = fileSets.iterator(); i.hasNext(); ) {
FileSet fs = (FileSet) i.next();
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
String[] dsFiles = ds.getIncludedFiles();
for (int j = 0; j < dsFiles.length; j++) {
File f = new File(dsFiles[j]);
if ( !f.isFile() ) {
f = new File( ds.getBasedir(), dsFiles[j] );
}
files.add( f.getAbsolutePath() );
}
}
return ArrayHelper.toStringArray(files);
|
private SchemaValidator | getSchemaValidator(org.hibernate.cfg.Configuration cfg)
Properties properties = new Properties();
properties.putAll( cfg.getProperties() );
if (propertiesFile == null) {
properties.putAll( getProject().getProperties() );
}
else {
properties.load( new FileInputStream(propertiesFile) );
}
cfg.setProperties(properties);
return new SchemaValidator(cfg);
|
public void | setConfig(java.io.File configurationFile)Set a .cfg.xml file
this.configurationFile = configurationFile;
|
public void | setNamingStrategy(java.lang.String namingStrategy)
this.namingStrategy = namingStrategy;
|
public void | setProperties(java.io.File propertiesFile)Set a properties file
if ( !propertiesFile.exists() ) {
throw new BuildException("Properties file: " + propertiesFile + " does not exist.");
}
log("Using properties file " + propertiesFile, Project.MSG_DEBUG);
this.propertiesFile = propertiesFile;
|