Revision: 11866
http://datanucleus.svn.sourceforge.net/datanucleus/?rev=11866&view=rev
Author: andy_jefferson
Date: 2011-01-26 19:03:01 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
remove commented out code
Modified Paths:
--------------
platform/core/trunk/src/java/org/datanucleus/store/schema/SchemaTool.java
Modified: platform/core/trunk/src/java/org/datanucleus/store/schema/SchemaTool.java
===================================================================
--- platform/core/trunk/src/java/org/datanucleus/store/schema/SchemaTool.java 2011-01-26 17:00:51 UTC (rev 11865)
+++ platform/core/trunk/src/java/org/datanucleus/store/schema/SchemaTool.java 2011-01-26 19:03:01 UTC (rev 11866)
@@ -236,7 +236,7 @@
}
}
- // Create a PMF for use with this mode
+ // Create a NucleusContext for use with this mode
boolean requiresAutoStartTable = false;
NucleusContext nucleusCtx = null;
try
@@ -255,21 +255,17 @@
nucleusCtx = getNucleusContextForMode(mode, tool.getApi(), props, persistenceUnitName,
ddlFilename, tool.isVerbose());
-// pmf = getPMFForMode(mode, tool.getApi(), props,
-// persistenceUnitName, ddlFilename, tool.isVerbose());
}
else
{
nucleusCtx = getNucleusContextForMode(mode, tool.getApi(), null, persistenceUnitName,
ddlFilename, tool.isVerbose());
-// pmf = getPMFForMode(mode, tool.getApi(), null,
-// persistenceUnitName, ddlFilename, tool.isVerbose());
}
}
catch (Exception e)
{
- // Unable to create a PMF so likely input errors
- LOGGER.error("Error creating PMF", e);
+ // Unable to create a NucleusContext so likely input errors
+ LOGGER.error("Error creating NucleusContext", e);
System.out.println(LOCALISER.msg(false, "014008", e.getMessage()));
System.exit(1);
return;
@@ -388,189 +384,16 @@
}
/**
- * Method to create a PersistenceManagerFactory for the specified mode of SchemaTool
+ * Method to create a NucleusContext for the specified mode of SchemaTool
* @param mode Mode of operation of SchemaTool
* @param api Persistence API
* @param userProps Map containing user provided properties (usually input via a file)
* @param persistenceUnitName Name of the persistence-unit (if any)
* @param ddlFile Name of a file to output DDL to
* @param verbose Verbose mode
- * @return The PersistenceManagerFactory to use
- * @throws NucleusException Thrown if an error occurs in creating the required PMF
+ * @return The NucleusContext to use
+ * @throws NucleusException Thrown if an error occurs in creating the required NucleusContext
*/
- /*protected static JDOPersistenceManagerFactory getPMFForMode(int mode, String api, Map userProps,
- String persistenceUnitName, String ddlFile, boolean verbose)
- {
- Map props = new HashMap();
- if (persistenceUnitName != null)
- {
- // persistence-unit specified so take the persistence properties from that
- // Note that this will create the persistence with the properties for the <persistence-unit>
- props.put("javax.jdo.option.PersistenceUnitName", persistenceUnitName);
- }
-
- if (userProps != null)
- {
- // Properties specified by the user in a file
- props.putAll(userProps);
- }
- else
- {
- // Properties specified via System properties (only support particular ones)
- String[] propNames =
- {
- "datanucleus.ConnectionURL",
- "datanucleus.ConnectionDriverName",
- "datanucleus.ConnectionUserName",
- "datanucleus.ConnectionPassword",
- "datanucleus.Mapping",
- "javax.jdo.option.ConnectionURL",
- "javax.jdo.option.ConnectionDriverName",
- "javax.jdo.option.ConnectionUserName",
- "javax.jdo.option.ConnectionPassword",
- "javax.jdo.option.Mapping"
- };
- for (int i=0;i<propNames.length;i++)
- {
- if (System.getProperty(propNames[i]) != null)
- {
- props.put(propNames[i], System.getProperty(propNames[i]));
- }
- }
-
- if (persistenceUnitName == null &&
- (props.get("javax.jdo.option.ConnectionURL") == null) &&
- (props.get("datanucleus.ConnectionURL") == null) &&
- (props.get("javax.persistence.jdbc.url") == null))
- {
- // No URL or persistence-unit defined, so fall back to some (undocumented) properties file
- File file = new File(System.getProperty("user.home") + "/datanucleus.properties");
- if (file.exists())
- {
- try
- {
- InputStream is = new FileInputStream(file);
- Properties fileProps = new Properties();
- fileProps.load(is);
- props.putAll(fileProps);
- is.close();
- }
- catch (IOException ioe)
- {
- // Ignore this
- }
- }
- else
- {
- throw new NucleusException(LOCALISER.msg("014041"));
- }
- }
- }
-
- // Use our PMF
- props.put("javax.jdo.PersistenceManagerFactoryClass", JDOPersistenceManagerFactory.class.getName());
-
- // Set the API
- props.put("datanucleus.persistenceApiName", api);
-
- // Disable autostart mechanism
- props.put("datanucleus.autostartmechanism", "None");
-
- // Tag on the mandatory props that we must have for each mode
- if (mode == SCHEMATOOL_CREATE_MODE)
- {
- if (ddlFile != null)
- {
- // the tables must not be created in the DB, so do not validate (DDL is being output to a file)
- props.put("datanucleus.validateconstraints", "false");
- props.put("datanucleus.validatecolumns", "false");
- props.put("datanucleus.validatetables", "false");
- }
- props.put("datanucleus.autocreateschema", "true");
- props.put("datanucleus.autocreatetables", "true");
- props.put("datanucleus.autocreateconstraints", "true");
- props.put("datanucleus.fixeddatastore", "false");
- props.put("datanucleus.readOnlydatastore", "false");
- props.put("datanucleus.rdbms.checkexisttablesorviews", "true");
- }
- else if (mode == SCHEMATOOL_DELETE_MODE)
- {
- props.put("datanucleus.fixeddatastore", "false");
- props.put("datanucleus.readonlydatastore", "false");
- }
- else if (mode == SCHEMATOOL_VALIDATE_MODE)
- {
- props.put("datanucleus.autocreateschema", "false");
- props.put("datanucleus.autocreatetables", "false");
- props.put("datanucleus.autocreateconstraints", "false");
- props.put("datanucleus.autocreatecolumns", "false");
- props.put("datanucleus.validatetables", "true");
- props.put("datanucleus.validatecolumns", "true");
- props.put("datanucleus.validateconstraints", "true");
- }
-
- // Create the PMF that we will use to communicate with the datastore
- JDOPersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(props);
-
- if (verbose)
- {
- String msg = LOCALISER.msg(false, "014020");
- LOGGER.info(msg);
- System.out.println(msg);
-
- // TODO Some persistence properties will be stored against the StoreManager
- Map<String,Object> pmfProps = pmf.getNucleusContext().getPersistenceConfiguration().getPersistenceProperties();
- Set<String> keys = pmfProps.keySet();
- List<String> keyNames = new ArrayList<String>(keys);
- Collections.sort(keyNames);
- Iterator keyNamesIter = keyNames.iterator();
- while (keyNamesIter.hasNext())
- {
- String key = (String)keyNamesIter.next();
- Object value = pmfProps.get(key);
- boolean display = true;
- if (!key.startsWith("datanucleus"))
- {
- display = false;
- }
- else if (key.equals("datanucleus.connectionpassword"))
- {
- // Don't show passwords
- display = false;
- }
- else if (value == null)
- {
- display = false;
- }
- else if (value instanceof String && StringUtils.isWhitespace((String)value))
- {
- display = false;
- }
-
- if (display)
- {
- // Print the property to sysout
- msg = LOCALISER.msg(false, "014022", key, value);
- LOGGER.info(msg);
- System.out.println(msg);
- }
- }
- System.out.println();
- }
- return pmf;
- }*/
-
- /**
- * Method to create a PersistenceManagerFactory for the specified mode of SchemaTool
- * @param mode Mode of operation of SchemaTool
- * @param api Persistence API
- * @param userProps Map containing user provided properties (usually input via a file)
- * @param persistenceUnitName Name of the persistence-unit (if any)
- * @param ddlFile Name of a file to output DDL to
- * @param verbose Verbose mode
- * @return The PersistenceManagerFactory to use
- * @throws NucleusException Thrown if an error occurs in creating the required PMF
- */
protected static NucleusContext getNucleusContextForMode(int mode, String api, Map userProps,
String persistenceUnitName, String ddlFile, boolean verbose)
{
@@ -836,7 +659,7 @@
System.out.println();
}
- // The PMF will have initialised the MetaDataManager with the persistence-unit
+ // The NucleusContext will have initialised the MetaDataManager with the persistence-unit
filemds = metaDataMgr.getFileMetaData();
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|