Package org.jboss.shrinkwrap.descriptor.api.persistence20

Examples of org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor


        .name( "primary" )
        .transactionType( PersistenceUnitTransactionType._RESOURCE_LOCAL )
        .provider( HibernateOgmPersistence.class.getName() )
        .clazz( Member.class.getName() )
        .getOrCreateProperties();
    PersistenceDescriptor persistenceDescriptor = propertiesContext
        .createProperty().name( Neo4jProperties.DATASTORE_PROVIDER ).value( Neo4j.DATASTORE_PROVIDER_NAME ).up()
        .createProperty()
        .name( Neo4jProperties.DATABASE_PATH )
        .value( neo4jFolder() )
        .up()
View Full Code Here


    @ArquillianResource
    private URL url;

    @Deployment(testable = false)
    public static WebArchive getArchive() {
        PersistenceDescriptor persistenceDescriptor = Descriptors.create(PersistenceDescriptor.class)
                .createPersistenceUnit()
                    .name("test-pu")
                    .transactionType("JTA")
                    .clazz(PersistenceDescriptor.class.getName())
                    .jtaDataSource("test-ds")
                .up();


        Asset persistenceAsset = new StringAsset(persistenceDescriptor.exportAsString());
        return base("jsf-jpa-test.war").addAsWebInfResource(persistenceAsset, "persistence.xml")
                .addClasses(DummyManagedBean.class)
                .addAsWebResource(new ClassLoaderAsset(
                        JPAInjectionTest.class.getPackage().getName().replace('.', '/').concat("/").concat("dummy.xhtml")), "dummy.xhtml");
View Full Code Here

    String encodedString = writer.toString();
    return new StringAsset( encodedString );
  }

  private static Asset createPersistenceXml() {
    PersistenceDescriptor pd = Descriptors.create( PersistenceDescriptor.class ).version( "2.0" );

    PersistenceUnit<PersistenceDescriptor> pu = pd.createPersistenceUnit()
        .name( "primary" )
        .jtaDataSource( System.getProperty( "datasource", "java:jboss/datasources/ExampleDS" ) );

    Properties properties = scenario.getHibernateProperties();
    properties.setProperty( "hibernate.transaction.factory_class", "org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory" );

    for ( Entry<Object, Object> property : properties.entrySet() ) {
      pu.getOrCreateProperties().
          createProperty().
          name( property.getKey().toString() ).
          value( property.getValue().toString() );
    }

    return new StringAsset( pd.exportAsString() );
  }
View Full Code Here

      }
      // Validate Persistence Unit Name
      Project project = getSelectedProject(uiContext);
      if (project.hasFacet(PersistenceFacet.class))
      {
         PersistenceDescriptor config = project.getFacet(PersistenceFacet.class).getConfig();
         for (PersistenceUnit<PersistenceDescriptor> persistenceUnit : config.getAllPersistenceUnit())
         {
            if (persistenceUnitName.getValue().equals(persistenceUnit.getName()))
            {
               validator.addValidationError(persistenceUnitName,
                        "Persistence unit name already exists in persistence descriptor.");
View Full Code Here

      final FileResource<?> configFile = getConfigFile();
      if (!configFile.exists())
      {
         createDefaultConfig(configFile);
      }
      PersistenceDescriptor descriptor = importer.fromStream(configFile.getResourceInputStream());
      return descriptor;
   }
View Full Code Here

      return descriptor;
   }

   private void createDefaultConfig(FileResource<?> descriptor)
   {
      PersistenceDescriptor descriptorContents = Descriptors.create(PersistenceDescriptor.class)
               .version("2.0");
      descriptor.setContents(descriptorContents.exportAsString());
   }
View Full Code Here

      if (project != null)
      {
         PersistenceFacet facet = facetFactory.install(project, PersistenceFacet.class);
         PersistenceContainer container = dataSource.getContainer();
         PersistenceProvider provider = dataSource.getProvider();
         PersistenceDescriptor config = facet.getConfig();
         PersistenceUnit<PersistenceDescriptor> unit = config.createPersistenceUnit();
         unit.name(unitName).description(DEFAULT_UNIT_DESC);
         unit.transactionType(container.isJTASupported() ? PersistenceUnitTransactionType._JTA
                  : PersistenceUnitTransactionType._RESOURCE_LOCAL);
         unit.provider(provider.getProvider());
View Full Code Here

    @ArquillianResource
    private URL url;

    @Deployment(testable = false)
    public static WebArchive getArchive() {
        PersistenceDescriptor persistenceDescriptor = Descriptors.create(PersistenceDescriptor.class)
                .createPersistenceUnit()
                    .name("test-pu")
                    .transactionType("JTA")
                    .clazz(PersistenceDescriptor.class.getName())
                    .jtaDataSource("test-ds")
                .up();


        Asset persistenceAsset = new StringAsset(persistenceDescriptor.exportAsString());
        return base("jsf-jpa-test.war").addAsWebInfResource(persistenceAsset, "persistence.xml")
                .addClasses(DummyManagedBean.class)
                .addAsWebResource(new ClassLoaderAsset(
                        JPAInjectionTest.class.getPackage().getName().replace('.', '/').concat("/").concat("dummy.xhtml")), "dummy.xhtml");
View Full Code Here

      final FileResource<?> configFile = getConfigFile();
      if (!configFile.exists())
      {
         createDefaultConfig(configFile);
      }
      PersistenceDescriptor descriptor = importer.fromStream(configFile.getResourceInputStream());
      return descriptor;
   }
View Full Code Here

   }

   @Override
   protected void createDefaultConfig(FileResource<?> descriptor)
   {
      PersistenceDescriptor descriptorContents = Descriptors.create(PersistenceDescriptor.class)
               .version("2.0");
      descriptor.setContents(descriptorContents.exportAsString());
   }
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor

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.