Package com.sun.java.xml.ns.persistence

Examples of com.sun.java.xml.ns.persistence.Persistence


        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());
View Full Code Here


  }

  @Override
  public PersistenceDescriptor scanFile(Store store, StreamSource streamSource) throws IOException {
    DescriptorResolverFactory descriptorResolverFactory = new DescriptorResolverFactory(store);
    Persistence persistence;
    try {
      Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
      persistence = unmarshaller.unmarshal(streamSource, Persistence.class).getValue();
    } catch (JAXBException e) {
      throw new IOException("Cannot read model descriptor.", e);
    }
    PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
    persistenceDescriptor.setName(streamSource.getSystemId());
    persistenceDescriptor.setVersion(persistence.getVersion());
    // Create model units
    for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
      PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
      persistenceUnitDescriptor.setName(persistenceUnit.getName());
      persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
      persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
      persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
View Full Code Here

TOP

Related Classes of com.sun.java.xml.ns.persistence.Persistence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.