Package javax.persistence.spi

Examples of javax.persistence.spi.PersistenceUnitInfo


    JpaDialect jpaDialect = emfInfo.getJpaDialect();
    EntityManagerPlusOperations plusOperations = null;
    if (jpaDialect != null && jpaDialect.supportsEntityManagerPlusOperations()) {
      plusOperations = jpaDialect.getEntityManagerPlusOperations(rawEntityManager);
    }
    PersistenceUnitInfo pui = emfInfo.getPersistenceUnitInfo();
    Boolean jta = (pui != null ? pui.getTransactionType() == PersistenceUnitTransactionType.JTA : null);
    return createProxy(rawEntityManager, plusOperations, jpaDialect, jta, containerManaged);
  }
View Full Code Here


    public void processPersistenceUnitClasses() {
        Set<String> entityClassNames = new HashSet<String>();
        Set<String> weavableClassNames = new HashSet<String>();
       
        // Iterate through the classes are defined with annotations.
        PersistenceUnitInfo puInfo = m_project.getPUInfo();

        processPersistenceUnitClasses(puInfo.getManagedClassNames(), entityClassNames, weavableClassNames);

        for (URL url : puInfo.getJarFileUrls()) {
            processPersistenceUnitClasses(PersistenceUnitProcessor.getClassNamesFromURL(url), entityClassNames, weavableClassNames);
        }

        if (! puInfo.excludeUnlistedClasses()) {
            processPersistenceUnitClasses(PersistenceUnitProcessor.getClassNamesFromURL(puInfo.getPersistenceUnitRootUrl()), entityClassNames, weavableClassNames);
        }

        // Iterate though the classes that are defined in XML.
        for (Map.Entry<URL, Document> urlToDoc : m_project.getMappingFiles().entrySet()) {
            //classSet.addAll(buildEntityClassSetFromXMLDocument(urlToDoc.getValue(), urlToDoc.getKey().getFile(), m_loader, includeMappedSuperclasses, includeEmbeddables));
View Full Code Here

        }
    }

    private Map<URL, Document> readExplicitlySpecifiedMappingFiles(boolean throwExceptionOnFail) {
        Map<URL, Document> list = new HashMap<URL, Document>();
        final PersistenceUnitInfo puInfo = m_project.getPUInfo();
        for (String mf : puInfo.getMappingFileNames()) {
            try {
                Enumeration<URL> mfURLs = m_loader.getResources(mf);
                if (mfURLs.hasMoreElements()) {
                    URL nextURL = mfURLs.nextElement();
                    if (mfURLs.hasMoreElements()) {
                        handleORMException(ValidationException.nonUniqueMappingFileName(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
                    }
                    InputStream stream = null;
                    stream = nextURL.openStream();
                    Document document = XMLHelper.parseDocument(stream, nextURL.getFile(), m_loader);
                    list.put(nextURL, document);
                    try {
                        stream.close();
                    } catch (IOException e) {}
                } else {
                    handleORMException(ValidationException.mappingFileNotFound(puInfo.getPersistenceUnitName(), mf), mf, throwExceptionOnFail);
                }
            } catch (IOException e) {
                handleORMException(PersistenceUnitLoadingException.exceptionLoadingORMXML(mf, e), mf, throwExceptionOnFail);
            }
        }
View Full Code Here

        m_project.setMappingFiles(list);
    }

    private Map<URL,Document> readStandardMappingFiles() {
        Map<URL, Document> list = new HashMap<URL, Document>();
        final PersistenceUnitInfo puInfo = m_project.getPUInfo();
        Collection<URL> rootUrls = new HashSet<URL>(puInfo.getJarFileUrls());
        rootUrls.add(puInfo.getPersistenceUnitRootUrl());
        final String ormXMLFile = "META-INF/orm.xml";
        for(URL rootURL : rootUrls) {
            logMessage("Searching for default mapping file in " + rootURL); // NOI18N
            URL ormURL = null;
            InputStream stream = null;
View Full Code Here

        PersistenceProvider provider;
        final String appLocation =
                getVerifierContext().getAbstractArchive().getArchiveUri();
        final InstrumentableClassLoader cl =
                InstrumentableClassLoader.class.cast(pu.getClassLoader());
        PersistenceUnitInfo pi = new AVKPersistenceUnitInfoImpl(pu, appLocation, cl);
        logger.fine("PersistenceInfo for PU is :\n" + pi);
        Properties props = new Properties();
        // This property is set to indicate that TopLink should only
        // validate the descriptors etc. and not try to login to database.
        props.put(EntityManagerFactoryProvider.TOPLINK_VALIDATION_ONLY_PROPERTY,
View Full Code Here

    private void dropTablesFromDB(boolean dropTables,
            PersistenceUnitDescriptor bundle) {
        if(dropTables) {
            File dropFile = getDDLFile(bundle, dropJdbcFileName, false);
            if (dropFile.exists()) {
                PersistenceUnitInfo pi = new Java2DBPersistenceUnitInfoImpl(
                    bundle,
                    appDeployedLocation,
                    null);
                executeDDLStatement(dropFile, pi.getNonJtaDataSource());
            } else if (isSupportedPersistenceProvider(bundle)){
                logI18NWarnMessage(
                    "ejb.BaseProcessor.cannotdroptables", //NOI18N
                    appRegisteredName, dropFile.getName(), null);
            }
View Full Code Here

        overrides.put(providerPropertyNamesHolder.ddlGenerationMode, DDL_SQL_SCRIPT_GENERATION);

        final InstrumentableClassLoader cl =
                InstrumentableClassLoader.class.cast(
                    persistenceUnitDescriptor.getClassLoader());
        PersistenceUnitInfo pi = new Java2DBPersistenceUnitInfoImpl(
                persistenceUnitDescriptor,
                appDeployedLocation,
                cl);
        if(debug)
View Full Code Here

        checkForDataSourceOverride(pud);

        calculateDefaultDataSource(pud);

        PersistenceUnitInfo pInfo = new PersistenceUnitInfoImpl(pud, providerContainerContractInfo);

        String applicationLocation = providerContainerContractInfo.getApplicationLocation();
        final boolean fineMsgLoggable = logger.isLoggable(Level.FINE);
        if(fineMsgLoggable) {
            logger.fine("Loading persistence unit for application: \"" + applicationLocation + "\"pu Root is: " +
                    pud.getPuRoot());
            logger.fine("PersistenceInfo for this pud is :\n" + pInfo); // NOI18N
        }

        PersistenceProvider provider;
        try {
            // See we use application CL as opposed to system CL to loadPU
            // provider. This allows user to get hold of provider specific
            // implementation classes in their code. But this also means
            // provider must not use appserver implementation classes directly
            // because once we implement isolation in our class loader hierarchy
            // the only classes available to application class loader would be
            // our appserver interface classes. By Sahoo
            provider =
                    PersistenceProvider.class.cast(
                    providerContainerContractInfo.getClassLoader()
                    .loadClass(pInfo.getPersistenceProviderClassName())
                    .newInstance());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }

        // XXX  - use DeploymentContext directly instead of creating helper instance first

        if (providerContainerContractInfo.isJava2DBRequired()) {
            processor = new JPAJava2DBProcessor(new Java2DBProcessorHelper(providerContainerContractInfo.getDeploymentContext()));
            java2db = processor.isJava2DbPU(pud);
        }

        Map<String, Object> overRides = new HashMap<String, Object>( (java2db)? integrationPropertiesWithJava2DB : integrationPropertiesWithoutJava2DB );

        // Check if the persistence unit requires Bean Validation
        ValidationMode validationMode = getValidationMode(pud);
        if(validationMode == ValidationMode.AUTO || validationMode == ValidationMode.CALLBACK ) {
            overRides.put(VALIDATOR_FACTORY, providerContainerContractInfo.getValidatorFactory());
        }

        if(!providerContainerContractInfo.isWeavingEnabled()) {
            overRides.put(ECLIPSELINK_WEAVING_PROPERTY, System.getProperty(ECLIPSELINK_WEAVING_PROPERTY,"false")); // NOI18N
        }

        EntityManagerFactory emf = provider.createContainerEntityManagerFactory(pInfo, overRides);

        if (fineMsgLoggable) {
            logger.logp(Level.FINE, "PersistenceUnitLoader", "loadPU", // NOI18N
                        "emf = {0}", emf); // NOI18N
        }

        PersistenceUnitsDescriptor parent = pud.getParent();
        RootDeploymentDescriptor containingBundle = parent.getParent();
        providerContainerContractInfo.registerEMF(pInfo.getPersistenceUnitName(), pud.getPuRoot(), containingBundle, emf);

        if(fineMsgLoggable) {
            logger.fine("Finished loading persistence unit for application: " // NOI18N
                    applicationLocation);
        }
View Full Code Here

        PersistenceProvider provider;
        final String appLocation =
                getVerifierContext().getAbstractArchive().getURI().getPath();
        final InstrumentableClassLoader cl =
                InstrumentableClassLoader.class.cast(pu.getParent().getClassLoader());
        PersistenceUnitInfo pi = new AVKPersistenceUnitInfoImpl(pu, appLocation, cl);
        logger.fine("PersistenceInfo for PU is :\n" + pi);
        Properties props = new Properties();
        // This property is set to indicate that TopLink should only
        // validate the descriptors etc. and not try to login to database.
        props.put(PersistenceUnitProperties.VALIDATION_ONLY_PROPERTY,
View Full Code Here

                    "Persistence units defined by the bundle will not be available until the bundle is refreshed");
            throw new InvalidPersistenceUnitException();
          }
     
          for(ManagedPersistenceUnitInfo info : persistenceUnits){
            PersistenceUnitInfo pUnitInfo = info.getPersistenceUnitInfo();
       
            emfs.put(pUnitInfo.getPersistenceUnitName(), new CountingEntityManagerFactory(
                providerService.createContainerEntityManagerFactory(
                    pUnitInfo, info.getContainerProperties()), pUnitInfo.getPersistenceUnitName()));
          }
        } finally {
          //Remember to unget the provider
          containerContext.ungetService(provider);
        }
View Full Code Here

TOP

Related Classes of javax.persistence.spi.PersistenceUnitInfo

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.