/** * @deprecated use {@link JPAFacadeHelper} instead. This method pierces * the published-API boundary, as does the JPAFacadeHelper utilization. */ public static OpenJPAEntityManagerFactory toEntityManagerFactory( org.apache.openjpa.kernel.BrokerFactory factory) { return JPAFacadeHelper.toEntityManagerFactory(factory); }
/** * @deprecated use {@link JPAFacadeHelper} instead. This method pierces * the published-API boundary, as does the JPAFacadeHelper utilization. */ public static OpenJPAEntityManagerFactory toEntityManagerFactory( org.apache.openjpa.kernel.BrokerFactory factory) { return JPAFacadeHelper.toEntityManagerFactory(factory); }
/** * @deprecated use {@link JPAFacadeHelper} instead. This method pierces * the published-API boundary, as does the JPAFacadeHelper utilization. */ public static OpenJPAEntityManagerFactory toEntityManagerFactory( org.apache.openjpa.kernel.BrokerFactory factory) { return JPAFacadeHelper.toEntityManagerFactory(factory); }
/** * @deprecated use {@link JPAFacadeHelper} instead. This method pierces * the published-API boundary, as does the JPAFacadeHelper utilization. */ public static OpenJPAEntityManagerFactory toEntityManagerFactory( org.apache.openjpa.kernel.BrokerFactory factory) { return JPAFacadeHelper.toEntityManagerFactory(factory); }
/** * @deprecated use {@link JPAFacadeHelper} instead. This method pierces * the published-API boundary, as does the JPAFacadeHelper utilization. */ public static OpenJPAEntityManagerFactory toEntityManagerFactory( org.apache.openjpa.kernel.BrokerFactory factory) { return JPAFacadeHelper.toEntityManagerFactory(factory); }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults, using <code>map</code> as overrides. This method * will return the same logical factory for invocations with the same * overrides. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) { ConfigurationProvider cp = new PersistenceProductDerivation. ConfigurationProviderImpl(map); try { return JPAFacadeHelper.toEntityManagerFactory( Bootstrap.getBrokerFactory(cp, null)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults, using <code>map</code> as overrides. This method * will return the same logical factory for invocations with the same * overrides. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) { ConfigurationProvider cp = new PersistenceProductDerivation. ConfigurationProviderImpl(map); try { return JPAFacadeHelper.toEntityManagerFactory( Bootstrap.getBrokerFactory(cp, null)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults, using <code>map</code> as overrides. This method * will return the same logical factory for invocations with the same * overrides. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) { ConfigurationProvider cp = new PersistenceProductDerivation. ConfigurationProviderImpl(map); try { return JPAFacadeHelper.toEntityManagerFactory( Bootstrap.getBrokerFactory(cp, null)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults, using <code>map</code> as overrides. This method * will return the same logical factory for invocations with the same * overrides. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) { ConfigurationProvider cp = new PersistenceProductDerivation. ConfigurationProviderImpl(map); try { return JPAFacadeHelper.toEntityManagerFactory( Bootstrap.getBrokerFactory(cp, null)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults, using <code>map</code> as overrides. This method * will return the same logical factory for invocations with the same * overrides. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory(Map map) { ConfigurationProvider cp = new PersistenceProductDerivation. ConfigurationProviderImpl(map); try { return JPAFacadeHelper.toEntityManagerFactory( Bootstrap.getBrokerFactory(cp, null)); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { try { _ret = PersistenceExceptions.getRollbackTranslator(this); // this assumes that serialized Brokers are from something // that extends AbstractBrokerFactory. Object factoryKey = in.readObject(); AbstractBrokerFactory factory = AbstractBrokerFactory.getPooledFactoryForKey(factoryKey); byte[] brokerBytes = (byte[]) in.readObject(); ObjectInputStream innerIn = new BrokerBytesInputStream(brokerBytes, factory.getConfiguration()); Broker broker = (Broker) innerIn.readObject(); EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) JPAFacadeHelper.toEntityManagerFactory( broker.getBrokerFactory()); broker.putUserObject(JPAFacadeHelper.EM_KEY, this); initialize(emf, broker); } catch (RuntimeException re) { try { re = _ret.translate(re); } catch (Exception e) { // ignore } throw re; } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { try { ret = PersistenceExceptions.getRollbackTranslator(this); // this assumes that serialized Brokers are from something // that extends AbstractBrokerFactory. Object factoryKey = in.readObject(); AbstractBrokerFactory factory = AbstractBrokerFactory.getPooledFactoryForKey(factoryKey); byte[] brokerBytes = (byte[]) in.readObject(); ObjectInputStream innerIn = new BrokerBytesInputStream(brokerBytes, factory.getConfiguration()); Broker broker = (Broker) innerIn.readObject(); EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) JPAFacadeHelper.toEntityManagerFactory( broker.getBrokerFactory()); broker.putUserObject(JPAFacadeHelper.EM_KEY, this); initialize(emf, broker); } catch (RuntimeException re) { try { re = ret.translate(re); } catch (Exception e) { // ignore } throw re; } }
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { try { _ret = PersistenceExceptions.getRollbackTranslator(this); // this assumes that serialized Brokers are from something // that extends AbstractBrokerFactory. Object factoryKey = in.readObject(); AbstractBrokerFactory factory = AbstractBrokerFactory.getPooledFactoryForKey(factoryKey); byte[] brokerBytes = (byte[]) in.readObject(); ObjectInputStream innerIn = new BrokerBytesInputStream(brokerBytes, factory.getConfiguration()); Broker broker = (Broker) innerIn.readObject(); EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) JPAFacadeHelper.toEntityManagerFactory( broker.getBrokerFactory()); broker.putUserObject(JPAFacadeHelper.EM_KEY, this); initialize(emf, broker); } catch (RuntimeException re) { try { re = _ret.translate(re); } catch (Exception e) { // ignore } throw re; } }
/** * Loads the entity manager specified by <code>name</code>, applying * the properties in <code>m</code> as overrides to the properties defined * in the XML configuration file for <code>name</code>. If <code>name</code> * is <code>null</code>, this method loads the XML in the resource * identified by <code>resource</code>, and uses the first resource found * when doing this lookup, regardless of the name specified in the XML * resource or the name of the jar that the resource is contained in. * This does no pooling of EntityManagersFactories. */ public OpenJPAEntityManagerFactory createEntityManagerFactory(String name, String resource, Map m) { PersistenceProductDerivation pd = new PersistenceProductDerivation(); try { Object poolValue = Configurations.removeProperty(EMF_POOL, m); ConfigurationProvider cp = pd.load(resource, name, m); if (cp == null) return null; BrokerFactory factory = getBrokerFactory(cp, poolValue, null); return JPAFacadeHelper.toEntityManagerFactory(factory); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
/** * Return a persistence manager facade to the given broker retaining * previously associated persistence context type. */ public static OpenJPAEntityManager toEntityManager(Broker broker) { if (broker == null) return null; broker.lock(); try { OpenJPAEntityManager em = (OpenJPAEntityManager) broker.getUserObject(EM_KEY); if (em == null) { EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) toEntityManagerFactory(broker.getBrokerFactory()); em = emf.newEntityManagerImpl(broker); broker.putUserObject(EM_KEY, em); } return em; } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } finally { broker.unlock(); } }
/** * Determines whether the specified state manager is managed by an open * broker within the persistence unit of the provided EMF instance. * @param emf OpenJPAEntityManagerFactory * @param sm StateManager * @return true if this state manager is managed by a broker within * this persistence unit. */ public static boolean isManagedBy(OpenJPAEntityManagerFactory emf, Object entity) { // Assert a valid emf was provided, it is open, and the entity is PC if (emf == null || !emf.isOpen() || !ImplHelper.isManageable(entity)) { return false; } // Assert the context is a broker PersistenceCapable pc = (PersistenceCapable)entity; if (!(pc.pcGetGenericContext() instanceof Broker)) { return false; } // Assert the broker is available and open Broker broker = (Broker)pc.pcGetGenericContext(); if (broker == null || broker.isClosed()) { return false; } // Assert the emf associated with the PC is the same as the provided emf OpenJPAEntityManagerFactory eemf = JPAFacadeHelper.toEntityManagerFactory(broker.getBrokerFactory()); if (eemf == emf && eemf.isOpen()) { return true; } return false; }