public static EntityManager create()

in jpa-cdi/src/main/java/org/apache/aries/jpa/cdi/EntityManagerProducer.java [27:50]


    public static EntityManager create(JpaTemplate template) {
        return (EntityManager) Proxy.newProxyInstance(EntityManager.class.getClassLoader(),
                new Class<?>[]{EntityManager.class},
                (proxy, method, args) -> {
                    try {
                        return template.txExpr(TransactionType.Supports, em -> {
                            try {
                                return method.invoke(em, args);
                            } catch (RuntimeException e) {
                                throw e;
                            } catch (Exception e) {
                                throw new RuntimeException(e);
                            }
                        });
                    } catch (RuntimeException e) {
                        if (e.getClass() == RuntimeException.class
                                && e.getCause() != null
                                && e.getCause().toString().equals(e.getMessage())) {
                            throw e.getCause();
                        }
                        throw e;
                    }
                });
    }