| Method from org.hibernate.tool.ant.ConfigurationTask Detail: |
public void addConfiguredFileSet(FileSet fileSet) {
fileSets.add(fileSet);
}
|
protected boolean addFile(File filename) {
try {
if ( filename.getName().endsWith(".jar") ) {
cfg.addJar( filename );
return true;
}
else {
cfg.addFile(filename);
return true;
}
}
catch (HibernateException he) {
throw new BuildException("Failed in building configuration when adding " + filename, he);
}
}
|
protected Configuration createConfiguration() {
return new Configuration();
}
|
protected void doConfiguration(Configuration configuration) {
validateParameters();
if (entityResolver != null) {
try {
Class resolver = ReflectHelper.classForName(entityResolver, this.getClass());
Object object = resolver.newInstance();
configuration.setEntityResolver((EntityResolver) object);
getProject().log("Using " + entityResolver + " as entity resolver");
}
catch (Exception e) {
throw new BuildException("Could not create or find " + entityResolver + " class to use for entity resolvement");
}
}
if (namingStrategy != null) {
try {
Class resolver = ReflectHelper.classForName(namingStrategy, this.getClass());
Object object = resolver.newInstance();
configuration.setNamingStrategy((NamingStrategy) object);
getProject().log("Using " + namingStrategy + " as naming strategy");
}
catch (Exception e) {
throw new BuildException("Could not create or find " + namingStrategy + " class to use for naming strategy");
}
}
if (configurationFile != null) configuration.configure( configurationFile );
addMappings(getFiles() );
Properties p = getProperties();
if(p!=null) {
configuration.setProperties(p);
}
}
|
public final Configuration getConfiguration() {
if(cfg==null) {
cfg = createConfiguration();
doConfiguration(cfg);
cfg.buildMappings(); // needed otherwise not all assocations are made!
}
return cfg;
}
|
public File getConfigurationFile() {
return configurationFile;
}
|
protected Properties getProperties() {
if (propertyFile!=null) {
Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ?
try {
properties.load(new FileInputStream(propertyFile) );
return properties;
}
catch (FileNotFoundException e) {
throw new BuildException(propertyFile + " not found.",e);
}
catch (IOException e) {
throw new BuildException("Problem while loading " + propertyFile,e);
}
} else {
return null;
}
}
|
public File getPropertyFile() {
return propertyFile;
}
|
public void setConfigurationFile(File configurationFile) {
this.configurationFile = configurationFile;
}
|
public void setEntityResolver(String entityResolverName) {
this.entityResolver = entityResolverName;
}
|
public void setNamingStrategy(String namingStrategy) {
this.namingStrategy = namingStrategy;
}
|
public void setPropertyFile(File propertyFile) {
this.propertyFile = propertyFile;
}
|
protected void validateParameters() throws BuildException {
// noop
}
|