From 94b880fd4d3f1947b05c1f94f964daf3f29a1b8a Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 28 Mar 2018 10:13:51 -0400 Subject: [PATCH] Remove accidentally committed useless file --- .../main/java/ca/uhn/fhir/util/StopWatch.java | 4 +- .../java/ca/uhn/fhir/jpa/dao/DaoConfig.java | 4 +- .../ca/uhn/fhir/jpa/dao/ISearchBuilder.java | 4 +- .../ca/uhn/fhir/jpa/dao/SearchBuilder.java | 4 +- .../jpa/util/StatelessSessionFactoryBean.java | 157 ------------------ 5 files changed, 8 insertions(+), 165 deletions(-) delete mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StatelessSessionFactoryBean.java diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java index 63c9fe115a2..9ad4acc1908 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/StopWatch.java @@ -20,9 +20,9 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java index 4a9fb531754..b804e2fa6cb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java @@ -17,9 +17,9 @@ import java.util.*; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java index 9299fe2428e..f78f8617f90 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index fc35027209a..2469110cda2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao; * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StatelessSessionFactoryBean.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StatelessSessionFactoryBean.java deleted file mode 100644 index 6dcf062e73b..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/StatelessSessionFactoryBean.java +++ /dev/null @@ -1,157 +0,0 @@ -package ca.uhn.fhir.jpa.util; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; -import org.hibernate.SessionFactory; -import org.hibernate.StatelessSession; -import org.hibernate.engine.spi.SessionImplementor; -import org.springframework.aop.framework.ProxyFactory; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.orm.jpa.EntityManagerFactoryUtils; -import org.springframework.orm.jpa.LocalEntityManagerFactoryBean; -import org.springframework.transaction.support.ResourceHolderSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import java.sql.Connection; - -import static org.springframework.orm.jpa.EntityManagerFactoryUtils.ENTITY_MANAGER_SYNCHRONIZATION_ORDER; -import static org.springframework.util.ReflectionUtils.invokeMethod; - -/** - * Hibernate's {@link StatelessSession} factory which will be bound to the - * current transaction. This factory returns a Proxy which delegates method - * calls to the underlying {@link StatelessSession} bound to transaction. At the - * end of the transaction the session is automatically closed. This class - * borrows idea's from {@link DataSourceUtils}, - * {@link EntityManagerFactoryUtils}, {@link ResourceHolderSynchronization} and - * {@link LocalEntityManagerFactoryBean}. - */ -public class StatelessSessionFactoryBean implements FactoryBean { - - private SessionFactory sessionFactory; - - @Autowired - public StatelessSessionFactoryBean(SessionFactory theSessionFactory) { - this.sessionFactory = theSessionFactory; - } - - @Override - public StatelessSession getObject() throws Exception { - StatelessSessionInterceptor statelessSessionInterceptor = new StatelessSessionInterceptor( - sessionFactory); - return ProxyFactory.getProxy(StatelessSession.class, statelessSessionInterceptor); - } - - @Override - public Class getObjectType() { - return StatelessSession.class; - } - - @Override - public boolean isSingleton() { - return true; - } - - /** - * Use this to override the {@link SessionFactory} obtained from the - * {@link EntityManagerFactory}. Please note that the connection will still - * be used from the {@link EntityManager}. - */ - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - private static class StatelessSessionInterceptor implements MethodInterceptor { - - private final SessionFactory sessionFactory; - - public StatelessSessionInterceptor( - SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - private void bindWithTransaction(StatelessSession statelessSession) { - TransactionSynchronizationManager - .registerSynchronization(new StatelessSessionSynchronization(sessionFactory, - statelessSession)); - TransactionSynchronizationManager.bindResource(sessionFactory, statelessSession); - } - - private StatelessSession getCurrentSession() { - if (!TransactionSynchronizationManager.isActualTransactionActive()) { - throw new IllegalStateException( - "There should be an active transaction for the current thread."); - } - StatelessSession statelessSession = (StatelessSession) TransactionSynchronizationManager - .getResource(sessionFactory); - if (statelessSession == null) { - statelessSession = openNewStatelessSession(); - bindWithTransaction(statelessSession); - } - return statelessSession; - } - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - StatelessSession statelessSession = getCurrentSession(); - return invokeMethod(invocation.getMethod(), statelessSession, invocation.getArguments()); - } - - /** - * It is important we obtain the physical (real) connection otherwise it - * will be double proxied and there will be problems releasing the - * connection. - */ - private Connection obtainPhysicalConnection() { - EntityManager entityManager = EntityManagerFactoryUtils - .getTransactionalEntityManager(sessionFactory); - SessionImplementor sessionImplementor = (SessionImplementor) entityManager - .getDelegate(); -// return sessionImplementor.getTransactionCoordinator().getJdbcCoordinator() -// .getLogicalConnection().getConnection(); - return null; - } - - private StatelessSession openNewStatelessSession() { - Connection connection = obtainPhysicalConnection(); - return sessionFactory.openStatelessSession(connection); - } - } - - private static class StatelessSessionSynchronization extends TransactionSynchronizationAdapter { - - private final SessionFactory sessionFactory; - private final StatelessSession statelessSession; - - public StatelessSessionSynchronization(SessionFactory sessionFactory, - StatelessSession statelessSession) { - this.sessionFactory = sessionFactory; - this.statelessSession = statelessSession; - } - - @Override - public void beforeCommit(boolean readOnly) { - if (!readOnly) { -// ((TransactionContext) statelessSession).flu - } - } - - @Override - public void beforeCompletion() { - TransactionSynchronizationManager.unbindResource(sessionFactory); - statelessSession.close(); - } - - @Override - public int getOrder() { - return ENTITY_MANAGER_SYNCHRONIZATION_ORDER - 100; - } - - } - -}