}
@ManagedOperation
@Description("dump the current configuration for this persistence unit in a file")
public void dump(final String file) {
final PersistenceUnitInfoImpl info = reloadableEntityManagerFactory.entityManagerFactoryCallable.getUnitInfo();
final Persistence.PersistenceUnit pu = new Persistence.PersistenceUnit();
pu.setJtaDataSource(info.getJtaDataSourceName());
pu.setNonJtaDataSource(info.getNonJtaDataSourceName());
pu.getClazz().addAll(info.getManagedClassNames());
pu.getMappingFile().addAll(info.getMappingFileNames());
pu.setName(info.getPersistenceUnitName());
pu.setProvider(info.getPersistenceProviderClassName());
pu.setTransactionType(info.getTransactionType().name());
pu.setExcludeUnlistedClasses(info.excludeUnlistedClasses());
pu.setSharedCacheMode(PersistenceUnitCaching.fromValue(info.getSharedCacheMode().name()));
pu.setValidationMode(PersistenceUnitValidationMode.fromValue(info.getValidationMode().name()));
for (final URL url : info.getJarFileUrls()) {
pu.getJarFile().add(url.toString());
}
for (final String key : info.getProperties().stringPropertyNames()) {
final Persistence.PersistenceUnit.Properties.Property prop = new Persistence.PersistenceUnit.Properties.Property();
prop.setName(key);
prop.setValue(info.getProperties().getProperty(key));
if (pu.getProperties() == null) {
pu.setProperties(new Persistence.PersistenceUnit.Properties());
}
pu.getProperties().getProperty().add(prop);
}
final Persistence persistence = new Persistence();
persistence.setVersion(info.getPersistenceXMLSchemaVersion());
persistence.getPersistenceUnit().add(pu);
try {
final FileWriter writer = new FileWriter(file);
final JAXBContext jc = JAXBContextFactory.newInstance(Persistence.class);