Esempio n. 1
0
  @Override
  protected void doStart() throws Exception {
    // need to setup entity manager first
    if (getEndpoint().isSharedEntityManager()) {
      this.entityManager =
          SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory);
    } else {
      this.entityManager = entityManagerFactory.createEntityManager();
    }
    LOG.trace("Created EntityManager {} on {}", entityManager, this);

    super.doStart();
  }
Esempio n. 2
0
 private LockingStrategy newLockTxProxy(
     final String appId, final String uniqueId, final String ttl) {
   final JpaLockingStrategy lock = new JpaLockingStrategy();
   lock.entityManager = SharedEntityManagerCreator.createSharedEntityManager(factory);
   lock.setApplicationId(appId);
   lock.setUniqueId(uniqueId);
   lock.setLockTimeout(Beans.newDuration(ttl).getSeconds());
   return (LockingStrategy)
       Proxy.newProxyInstance(
           JpaLockingStrategy.class.getClassLoader(),
           new Class[] {LockingStrategy.class},
           new TransactionalLockInvocationHandler(lock, this.txManager));
 }