[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences ...
Max Rydahl Andersen
mandersen at jboss.com
Wed Nov 15 11:12:06 EST 2006
User: mandersen
Date: 06/11/15 11:12:06
Modified: hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences
AbstractConsoleConfigurationPreferences.java
ConsoleConfigurationPreferences.java
StandAloneConsoleConfigurationPreferences.java
Log:
HBX-822 Automatically use Eclipse's project classpath
HBX-821 Support Hibernate EntityManager/JPA
HBX-823 Do not require hibernate.cfg.xml for core configuration to work
Revision Changes Path
1.6 +24 -9 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: AbstractConsoleConfigurationPreferences.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/AbstractConsoleConfigurationPreferences.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- AbstractConsoleConfigurationPreferences.java 23 Oct 2006 13:22:53 -0000 1.5
+++ AbstractConsoleConfigurationPreferences.java 15 Nov 2006 16:12:06 -0000 1.6
@@ -27,6 +27,7 @@
import java.util.Properties;
import org.hibernate.console.HibernateConsoleRuntimeException;
+import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.util.StringHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -45,16 +46,17 @@
static final String PROJECT_ATTRIB = "project";
static final String USE_PROJECT_CLASSPATH_ATTRIB = "use-project-classpath";
+
private String projectName;
private String name = "<unknown>";
- private boolean useAnnotations = false;
protected String entityResolverName = null;
private boolean useProjectClasspath;
+ private ConfigurationMode configurationMode;
- public AbstractConsoleConfigurationPreferences(String name, boolean annotations, String projectName, boolean useProjectclassPath, String entityResolver) {
+ public AbstractConsoleConfigurationPreferences(String name, ConfigurationMode configurationMode, String projectName, boolean useProjectclassPath, String entityResolver) {
setName(name);
- useAnnotations = annotations;
+ this.configurationMode = configurationMode;
entityResolverName = entityResolver;
this.projectName = projectName;
this.useProjectClasspath = useProjectclassPath;
@@ -64,8 +66,8 @@
}
- public boolean useAnnotations() {
- return useAnnotations ;
+ public ConfigurationMode getConfigurationMode() {
+ return configurationMode;
}
public void setName(String name) {
@@ -95,12 +97,14 @@
/** generic xml dumper that just dumps the toString representation of the paramters
* @param useAnnotations */
- protected static void writeStateTo(Node node, String name, String entityResolver, boolean useAnnotations, String projectName, boolean useProjectClasspath, Object cfgFile, Object propertyFilename, Object[] mappings, Object[] customClasspath) {
+ protected static void writeStateTo(Node node, String name, String entityResolver, ConfigurationMode configurationMode, String projectName, boolean useProjectClasspath, Object cfgFile, Object propertyFilename, Object[] mappings, Object[] customClasspath) {
Document doc = node.getOwnerDocument();
Element n = createElementWithAttribute(doc, CONFIGURATION_TAG, NAME_ATTRIB, name);
- if(useAnnotations) {
+ /*if(useAnnotations) {
n.setAttribute(ANNOTATIONS_ATTRIB, "true");
- }
+ }*/
+ n.setAttribute(CONFIGURATION_MODE_ATTRIB, configurationMode.toString());
+
if(StringHelper.isNotEmpty(entityResolver)) {
n.setAttribute(ENTITYRESOLVER_ATTRIB, entityResolver);
}
@@ -175,7 +179,18 @@
String attribute = node.getAttribute(ANNOTATIONS_ATTRIB);
- useAnnotations = ((attribute != null) && attribute.equalsIgnoreCase("true"));
+ if(attribute!=null) {
+ boolean oldAnnotationFlag = ((attribute != null) && attribute.equalsIgnoreCase("true"));
+ if(oldAnnotationFlag) {
+ configurationMode = ConfigurationMode.ANNOTATIONS;
+ } else {
+ configurationMode = ConfigurationMode.CORE;
+ }
+ } else {
+ attribute = node.getAttribute(CONFIGURATION_MODE_ATTRIB);
+ configurationMode = ConfigurationMode.parse( attribute );
+ }
+
attribute = node.getAttribute( PROJECT_ATTRIB );
setProjectName( attribute );
1.5 +55 -12 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConsoleConfigurationPreferences.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/ConsoleConfigurationPreferences.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ConsoleConfigurationPreferences.java 23 Oct 2006 13:22:53 -0000 1.4
+++ ConsoleConfigurationPreferences.java 15 Nov 2006 16:12:06 -0000 1.5
@@ -22,7 +22,10 @@
package org.hibernate.console.preferences;
import java.io.File;
+import java.io.Serializable;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.w3c.dom.Element;
@@ -33,20 +36,60 @@
*/
public interface ConsoleConfigurationPreferences {
- final String PATH_TAG = "path";
- final String CLASSPATH_TAG = "classpath";
- final String MAPPING_TAG = "mapping";
- final String MAPPINGS_TAG = "mappings";
- final String HIBERNATE_PROPERTIES_TAG = "hibernate-properties";
- final String LOCATION_ATTRIB = "location";
- final String HIBERNATE_CONFIG_XML_TAG = "hibernate-config-xml";
- final String NAME_ATTRIB = "name";
- final String CONFIGURATION_TAG = "configuration";
- final String ANNOTATIONS_ATTRIB = "annotations";
- final String ENTITYRESOLVER_ATTRIB = "entityresolver";
+ static final String PATH_TAG = "path";
+ static final String CLASSPATH_TAG = "classpath";
+ static final String MAPPING_TAG = "mapping";
+ static final String MAPPINGS_TAG = "mappings";
+ static final String HIBERNATE_PROPERTIES_TAG = "hibernate-properties";
+ static final String LOCATION_ATTRIB = "location";
+ static final String HIBERNATE_CONFIG_XML_TAG = "hibernate-config-xml";
+ static final String NAME_ATTRIB = "name";
+ static final String CONFIGURATION_TAG = "configuration";
+ static final String ANNOTATIONS_ATTRIB = "annotations";
+ static final String ENTITYRESOLVER_ATTRIB = "entityresolver";
+ static final String CONFIGURATION_MODE_ATTRIB = "configuration-factory";
+
+ // TODO: we should move this to some classhandler
+ static public class ConfigurationMode implements Serializable {
+
+ private static final Map INSTANCES = new HashMap();
+
+ public static final ConfigurationMode CORE = new ConfigurationMode( "CORE" );
+ public static final ConfigurationMode ANNOTATIONS = new ConfigurationMode( "ANNOTATIONS" );
+ public static final ConfigurationMode JPA = new ConfigurationMode( "JPA" );
+
+ static {
+ INSTANCES.put( CORE.name, CORE );
+ INSTANCES.put( ANNOTATIONS.name, ANNOTATIONS );
+ INSTANCES.put( JPA.name, JPA );
+ }
+
+ private final String name;
+
+ public ConfigurationMode(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+
+ public static ConfigurationMode parse(String name) {
+ ConfigurationMode rtn = ( ConfigurationMode ) INSTANCES.get( name );
+ if ( rtn == null ) {
+ // default is POJO
+ rtn = CORE;
+ }
+ return rtn;
+ }
+ }
- public abstract boolean useAnnotations();
+ public abstract ConfigurationMode getConfigurationMode();
public abstract String getName();
1.6 +2 -2 jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: StandAloneConsoleConfigurationPreferences.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/preferences/StandAloneConsoleConfigurationPreferences.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- StandAloneConsoleConfigurationPreferences.java 23 Oct 2006 13:22:53 -0000 1.5
+++ StandAloneConsoleConfigurationPreferences.java 15 Nov 2006 16:12:06 -0000 1.6
@@ -45,7 +45,7 @@
private File[] customClasspath;
public StandAloneConsoleConfigurationPreferences(String name, File xmlconfig, File propertiesFile, File[] mappingFiles, File[] customClasspath) {
- super(name, false, null, false, null);
+ super(name, ConfigurationMode.CORE, null, false, null);
this.cfgFile = xmlconfig;
this.propertyFilename = propertiesFile;
this.mappings = mappingFiles;
@@ -90,7 +90,7 @@
}
public void writeStateTo(Element node) {
- writeStateTo(node, getName(), getEntityResolverName(), useAnnotations(), null, false, cfgFile, propertyFilename, mappings, customClasspath);
+ writeStateTo(node, getName(), getEntityResolverName(), getConfigurationMode(), null, false, cfgFile, propertyFilename, mappings, customClasspath);
}
More information about the jboss-cvs-commits
mailing list