PersistenceContentHandlerpublic class PersistenceContentHandler extends Object implements ContentHandler
Fields Summary |
---|
private static final String | NAMESPACE_URI | private static final String | ELEMENT_PERSISTENCE_UNIT | private static final String | ELEMENT_PROVIDER | private static final String | ELEMENT_JTA_DATA_SOURCE | private static final String | ELEMENT_NON_JTA_DATA_SOURCE | private static final String | ELEMENT_MAPPING_FILE | private static final String | ELEMENT_JAR_FILE | private static final String | ELEMENT_CLASS | private static final String | ELEMENT_EXCLUDE_UNLISTED_CLASSES | private static final String | ELEMENT_PROPERTY | private static final String | ATTRIBUTE_NAME | private static final String | ATTRIBUTE_VALUE | private static final String | ATTRIBUTE_TRANSACTION_TYPE | private SEPersistenceUnitInfo | persistenceUnitInfo | private Vector | persistenceUnits | private StringBuffer | stringBuffer | private boolean | readCharacters |
Constructors Summary |
---|
public PersistenceContentHandler()
super();
stringBuffer = new StringBuffer();
persistenceUnits = new Vector();
|
Methods Summary |
---|
public void | characters(char[] ch, int start, int length)
if (readCharacters) {
stringBuffer.append(ch, start, length);
}
| public void | endDocument()
| public void | endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
String string = stringBuffer.toString().trim();
stringBuffer.delete(0, stringBuffer.length());
readCharacters = false;
if (NAMESPACE_URI.equals(namespaceURI)) {
if (ELEMENT_PROVIDER.equals(localName)) {
persistenceUnitInfo.setPersistenceProviderClassName(string);
return;
} else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
persistenceUnitInfo.setJtaDataSource(
// Create a dummy DataSource that will
// throw an exception on access
new DataSourceImpl(string, null, null, null));
return;
} else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
persistenceUnitInfo.setNonJtaDataSource(
// Create a dummy DataSource that will
// throw an exception on access
new DataSourceImpl(string, null, null, null));
return;
} else if (ELEMENT_MAPPING_FILE.equals(localName)) {
persistenceUnitInfo.getMappingFileNames().add(string);
return;
} else if (ELEMENT_JAR_FILE.equals(localName)) {
persistenceUnitInfo.getJarFiles().add(string);
return;
} else if (ELEMENT_CLASS.equals(localName)) {
persistenceUnitInfo.getManagedClassNames().add(string);
return;
} else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
if (string.equals("true") || string.equals("1")){
persistenceUnitInfo.setExcludeUnlistedClasses(true);
} else {
persistenceUnitInfo.setExcludeUnlistedClasses(false);
}
return;
} else if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
if (persistenceUnitInfo != null){
persistenceUnits.add(persistenceUnitInfo);
persistenceUnitInfo = null;
}
}
}
| public void | endPrefixMapping(java.lang.String prefix)
| public java.util.Vector | getPersistenceUnits()
return persistenceUnits;
| public void | ignorableWhitespace(char[] ch, int start, int length)
| public void | processingInstruction(java.lang.String target, java.lang.String data)
| public void | setDocumentLocator(org.xml.sax.Locator locator)
| public void | skippedEntity(java.lang.String name)
| public void | startDocument()
| public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
if (NAMESPACE_URI.equals(namespaceURI)) {
if (ELEMENT_PERSISTENCE_UNIT.equals(localName)) {
persistenceUnitInfo = new SEPersistenceUnitInfo();
persistenceUnitInfo.setPersistenceUnitName(atts.getValue(ATTRIBUTE_NAME));
String transactionType = atts.getValue(ATTRIBUTE_TRANSACTION_TYPE);
if(transactionType != null) {
persistenceUnitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(transactionType));
}
return;
} else if (ELEMENT_PROPERTY.equals(localName)) {
String name = atts.getValue(ATTRIBUTE_NAME);
String value = atts.getValue(ATTRIBUTE_VALUE);
persistenceUnitInfo.getProperties().setProperty(name, value);
} else if (ELEMENT_PROVIDER.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_JTA_DATA_SOURCE.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_NON_JTA_DATA_SOURCE.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_MAPPING_FILE.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_JAR_FILE.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_EXCLUDE_UNLISTED_CLASSES.equals(localName)) {
readCharacters = true;
return;
} else if (ELEMENT_CLASS.equals(localName)) {
readCharacters = true;
return;
}
}
| public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
|
|