return JavaScope.CLASSPATH.equals(scope) && "/META-INF/persistence.xml".equals(path) || "/WEB-INF/persistence.xml".equals(path);
}
@Override
public Iterable<? extends FileDescriptor> scan(InputStream item, String path, Scope scope, Scanner scanner) throws IOException {
Persistence persistence;
try {
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
persistence = unmarshaller.unmarshal(new StreamSource(item), Persistence.class).getValue();
} catch (JAXBException e) {
throw new IOException("Cannot read model descriptor.", e);
}
Store store = getStore();
PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
persistenceDescriptor.setVersion(persistence.getVersion());
// Create model units
for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
persistenceUnitDescriptor.setName(persistenceUnit.getName());
PersistenceUnitTransactionType transactionType = persistenceUnit.getTransactionType();
if (transactionType != null) {
persistenceUnitDescriptor.setTransactionType(transactionType.name());