Java 类javax.persistence.SynchronizationType 实例源码

项目:tomee    文件:JtaEntityManager.java   
public JtaEntityManager(final String unitName, final JtaEntityManagerRegistry registry, final EntityManagerFactory entityManagerFactory,
                        final Map properties, final boolean extended, final String synchronizationType) {
    if (registry == null) {
        throw new NullPointerException("registry is null");
    }
    if (entityManagerFactory == null) {
        throw new NullPointerException("entityManagerFactory is null");
    }
    this.unitName = unitName;
    this.registry = registry;
    this.entityManagerFactory = entityManagerFactory;
    this.properties = properties;
    this.extended = extended;
    this.synchronizationType = !isJPA21(entityManagerFactory) || synchronizationType == null ?
            null : SynchronizationType.valueOf(synchronizationType.toUpperCase(Locale.ENGLISH));
    final String globalTimerConfig = SystemInstance.get().getProperty("openejb.jpa.timer");
    final Object localTimerConfig = properties == null ? null : properties.get("openejb.jpa.timer");
    this.timer = localTimerConfig == null ? (globalTimerConfig == null || Boolean.parseBoolean(globalTimerConfig)) : Boolean.parseBoolean(localTimerConfig.toString());
    logger = unitName == null ? baseLogger : baseLogger.getChildLogger(unitName);
    final String wrapConfig = ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ?
            ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getUnitProperties().getProperty("openejb.jpa.query.wrap-no-tx", "true") : "true";
    this.wrapNoTxQueries = wrapConfig == null || "true".equalsIgnoreCase(wrapConfig);
}
项目:BotLibre    文件:DatabaseReadOnlyNetwork.java   
public DatabaseReadOnlyNetwork(EntityManager entityManager, boolean isShortTerm) {
    super(new EntityManagerImpl(entityManager.unwrap(ServerSession.class), SynchronizationType.UNSYNCHRONIZED), isShortTerm);
    ServerSession server = entityManager.unwrap(ServerSession.class);
    if (!server.getProperties().containsKey("network")) {
        server.setProperty("network", this);
    }
}
项目:tomee    文件:JtaEntityManager.java   
public static boolean isJPA21(final EntityManagerFactory entityManagerFactory) {
    return ReloadableEntityManagerFactory.class.isInstance(entityManagerFactory) ?
            hasMethod(
                    ReloadableEntityManagerFactory.class.cast(entityManagerFactory).getEntityManagerFactoryCallable().getProvider(),
                    "generateSchema", String.class, Map.class)
            : hasMethod(entityManagerFactory.getClass(), "createEntityManager", SynchronizationType.class);
}
项目:tomee    文件:ReloadableEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(final SynchronizationType synchronizationType) {
    EntityManager em;
    try {
        em = delegate().createEntityManager(synchronizationType);
    } catch (final LinkageError le) {
        em = delegate.createEntityManager(synchronizationType);
    }

    if (logCriteriaJpql) {
        return new QueryLogEntityManager(em, logCriteriaJpqlLevel);
    }
    return em;
}
项目:tomee    文件:ReloadableEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(final SynchronizationType synchronizationType, final Map map) {
    EntityManager em;
    try {
        em = delegate().createEntityManager(synchronizationType, map);
    } catch (final LinkageError le) {
        em = delegate.createEntityManager(synchronizationType, map);
    }

    if (logCriteriaJpql) {
        return new QueryLogEntityManager(em, logCriteriaJpqlLevel);
    }
    return em;
}
项目:tomee    文件:StatefulContainer.java   
private Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> createEntityManagers(final BeanContext beanContext) {
    // create the extended entity managers
    final Index<EntityManagerFactory, BeanContext.EntityManagerConfiguration> factories = beanContext.getExtendedEntityManagerFactories();
    Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> entityManagers = null;
    if (factories != null && factories.size() > 0) {
        entityManagers = new Index<>(new ArrayList<>(factories.keySet()));
        for (final Map.Entry<EntityManagerFactory, BeanContext.EntityManagerConfiguration> entry : factories.entrySet()) {
            final EntityManagerFactory entityManagerFactory = entry.getKey();

            JtaEntityManagerRegistry.EntityManagerTracker entityManagerTracker = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
            final EntityManager entityManager;
            if (entityManagerTracker == null) {
                final Map properties = entry.getValue().getProperties();
                final SynchronizationType synchronizationType = entry.getValue().getSynchronizationType();
                if (synchronizationType != null) {
                    if (properties != null) {
                        entityManager = entityManagerFactory.createEntityManager(synchronizationType, properties);
                    } else {
                        entityManager = entityManagerFactory.createEntityManager(synchronizationType);
                    }
                } else if (properties != null) {
                    entityManager = entityManagerFactory.createEntityManager(properties);
                } else {
                    entityManager = entityManagerFactory.createEntityManager();
                }
                entityManagerTracker = new JtaEntityManagerRegistry.EntityManagerTracker(entityManager, synchronizationType != SynchronizationType.UNSYNCHRONIZED);
            } else {
                entityManagerTracker.incCounter();
            }
            entityManagers.put(entityManagerFactory, entityManagerTracker);
        }
    }
    return entityManagers;
}
项目:tomee    文件:ManagedContainer.java   
private Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> createEntityManagers(final BeanContext beanContext) {
    // create the extended entity managers
    final Index<EntityManagerFactory, BeanContext.EntityManagerConfiguration> factories = beanContext.getExtendedEntityManagerFactories();
    Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker> entityManagers = null;
    if (factories != null && factories.size() > 0) {
        entityManagers = new Index<EntityManagerFactory, JtaEntityManagerRegistry.EntityManagerTracker>(new ArrayList<EntityManagerFactory>(factories.keySet()));
        for (final Map.Entry<EntityManagerFactory, BeanContext.EntityManagerConfiguration> entry : factories.entrySet()) {
            final EntityManagerFactory entityManagerFactory = entry.getKey();

            JtaEntityManagerRegistry.EntityManagerTracker entityManagerTracker = entityManagerRegistry.getInheritedEntityManager(entityManagerFactory);
            final EntityManager entityManager;
            if (entityManagerTracker == null) {
                final SynchronizationType synchronizationType = entry.getValue().getSynchronizationType();
                final Map properties = entry.getValue().getProperties();
                if (synchronizationType != null) {
                    if (properties != null) {
                        entityManager = entityManagerFactory.createEntityManager(synchronizationType, properties);
                    } else {
                        entityManager = entityManagerFactory.createEntityManager(synchronizationType);
                    }
                } else if (properties != null) {
                    entityManager = entityManagerFactory.createEntityManager(properties);
                } else {
                    entityManager = entityManagerFactory.createEntityManager();
                }
                entityManagerTracker = new JtaEntityManagerRegistry.EntityManagerTracker(entityManager, synchronizationType != SynchronizationType.UNSYNCHRONIZED);
            } else {
                entityManagerTracker.incCounter();
            }
            entityManagers.put(entityManagerFactory, entityManagerTracker);
        }
    }
    return entityManagers;
}
项目:testee.fi    文件:JpaInjectionServicesTest.java   
private InjectionPoint persistenceContext(String unitName) {
    final InjectionPoint ip = mock(InjectionPoint.class);
    final Annotated annotated = mock(Annotated.class);
    when(ip.getAnnotated()).thenReturn(annotated);
    final PersistenceContext annotation = new PersistenceContext() {
        @Override
        public Class<? extends Annotation> annotationType() {
            return null;
        }

        @Override
        public String name() {
            return null;
        }

        @Override
        public String unitName() {
            return unitName;
        }

        @Override
        public PersistenceContextType type() {
            return null;
        }

        @Override
        public SynchronizationType synchronization() {
            return null;
        }

        @Override
        public PersistenceProperty[] properties() {
            return new PersistenceProperty[0];
        }
    };
    when(annotated.getAnnotation(PersistenceContext.class)).thenReturn(annotation);
    return ip;
}
项目:cibet    文件:CibetEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType arg0) {
   EntityManager em = nativeEntityManagerFactory.createEntityManager(arg0);
   log.debug("create new CibetEntityManager with native " + em);
   return new CibetEntityManager(this, em, loadEager);
}
项目:cibet    文件:CibetEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType arg0, Map arg1) {
   EntityManager em = nativeEntityManagerFactory.createEntityManager(arg0, arg1);
   log.debug("create new CibetEntityManager with native " + em);
   return new CibetEntityManager(this, em, loadEager);
}
项目:cibet    文件:JdbcBridgeEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
   return null;
}
项目:cibet    文件:JdbcBridgeEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
   return null;
}
项目:jpasecurity    文件:DelegatingEntityManagerFactory.java   
public EntityManager createEntityManager(SynchronizationType type, Map properties) {
    return delegate.createEntityManager(type, properties);
}
项目:jpasecurity    文件:DelegatingEntityManagerFactory.java   
public EntityManager createEntityManager(SynchronizationType type) {
    return delegate.createEntityManager(type);
}
项目:jpasecurity    文件:SecureEntityManagerFactory.java   
public SecureEntityManager createEntityManager(SynchronizationType synchronizationType, Map properties) {
    return createSecureEntityManager(super.createEntityManager(synchronizationType, properties), properties);
}
项目:jpasecurity    文件:SecureEntityManagerFactory.java   
public SecureEntityManager createEntityManager(SynchronizationType synchronizationType) {
    return createSecureEntityManager(super.createEntityManager(synchronizationType),
            Collections.<String, Object>emptyMap());
}
项目:jpasecurity    文件:MockitoPersistenceProvider.java   
@Override
public EntityManager createEntityManager(SynchronizationType arg0) {
    return null;
}
项目:jpasecurity    文件:MockitoPersistenceProvider.java   
@Override
public EntityManager createEntityManager(SynchronizationType arg0, Map arg1) {
    return null;
}
项目:training    文件:MockStockPriceEntityManagerFactory.java   
public EntityManager createEntityManager(SynchronizationType st) {
    throw new UnsupportedOperationException("Not supported.");
}
项目:training    文件:MockStockPriceEntityManagerFactory.java   
public EntityManager createEntityManager(SynchronizationType st, Map map) {
    throw new UnsupportedOperationException("Not supported.");
}
项目:kumuluzee    文件:PersistenceContextResourceFactory.java   
public PersistenceContextResourceFactory(String unitName, EntityManagerFactory emf, TransactionType transactionType, SynchronizationType sync) {
    this.unitName = unitName;
    this.emf = emf;
    this.sync = sync;
    this.transactionType = transactionType;
}
项目:Genji    文件:TpEm.java   
public static EntityManager getEntityManager(SynchronizationType st) {
    return emf.createEntityManager(st);
}
项目:switchyard    文件:EntityManagerImpl.java   
public EntityManagerImpl(EntityManagerFactoryImpl entityManagerFactory, PersistenceContextType pcType, SynchronizationType synchronizationType, PersistenceUnitTransactionType transactionType, boolean discardOnClose, Class sessionInterceptorClass, Map properties) {
    super(entityManagerFactory, pcType, synchronizationType, transactionType, discardOnClose, sessionInterceptorClass, properties);
}
项目:ef-orm    文件:JefEntityManagerFactory.java   
@SuppressWarnings("rawtypes")
public EntityManager createEntityManager(Map map) {
    return createEntityManager(SynchronizationType.SYNCHRONIZED, map);
}
项目:ef-orm    文件:JefEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
    return createEntityManager(synchronizationType, Collections.EMPTY_MAP);
}
项目:ef-orm    文件:JefEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType, @SuppressWarnings("rawtypes") Map map) {
    EntityManager result = new JefEntityManager(this, map);
    log.debug("[JPA DEBUG]:creating EntityManager:{} at {}", result, Thread.currentThread());
    return result;
}
项目:spearal-jpa2    文件:EntityManagerFactoryWrapper.java   
public EntityManager createEntityManager(SynchronizationType syncType, Map params) {
    EntityManager entityManager = entityManagerFactory.createEntityManager(syncType, params);
    return new EntityManagerWrapper(entityManager);
}
项目:spearal-jpa2    文件:EntityManagerFactoryWrapper.java   
public EntityManager createEntityManager(SynchronizationType syncType) {
    EntityManager entityManager = entityManagerFactory.createEntityManager(syncType);
    return new EntityManagerWrapper(entityManager);
}
项目:bundles    文件:DelegatedEntityManagerFactory.java   
@Override
public EntityManager createEntityManager() {
    return createEntityManager(SynchronizationType.UNSYNCHRONIZED, Collections.emptyMap());
}
项目:bundles    文件:DelegatedEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(Map map) {
    return emf.createEntityManager(SynchronizationType.UNSYNCHRONIZED, map);
}
项目:bundles    文件:DelegatedEntityManagerFactory.java   
@Override
public EntityManager createEntityManager(SynchronizationType synchronizationType) {
    return emf.createEntityManager(synchronizationType, Collections.emptyMap());
}
项目:tomee    文件:BeanContext.java   
public EntityManagerConfiguration(final Map properties, final SynchronizationType synchronizationType) {
    this.properties = properties;
    this.synchronizationType = synchronizationType;
}
项目:tomee    文件:BeanContext.java   
public SynchronizationType getSynchronizationType() {
    return synchronizationType;
}
项目:kumuluzee    文件:TxScopedEntityManagerFactory.java   
public static EntityManagerWrapper buildEntityManagerWrapper(String unitName, EntityManagerFactory emf, SynchronizationType sync) {

        JtaTransactionHolder jtaHolder = JtaTransactionHolder.getInstance();

        TransactionManager transactionManager = jtaHolder.getTransactionManager();
        TransactionSynchronizationRegistry transactionSynchronizationRegistry = jtaHolder.getTransactionSynchronizationRegistry();

        NonTxEntityManagerHolder emHolder = new NonTxEntityManagerHolder();

        EntityManager em = new TxScopedEntityManager(unitName, emf, sync, transactionManager, transactionSynchronizationRegistry, emHolder);

        return new TxScopedEntityManagerWrapper(em, emHolder);
    }