</id>\r
<url>http://repository.springsource.com/maven/bundles/external\r
</url>\r
+ </repository>\r
+ <repository>\r
+ <id>repository.springsource.release</id>\r
+ <name>SpringSource GA Repository</name>\r
+ <url>http://repo.springsource.org/release</url>\r
</repository>\r
</repositories>\r
<dependencies>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.context</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-context</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.context.support</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-context-support</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.aspects</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-aspects</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.test</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-test</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.beans</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-beans</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.transaction</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-tx</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
- <groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.web</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.core</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
- </dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-web</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.aop</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-core</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.expression</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
+ <artifactId>spring-aop</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
</dependency>\r
<dependency>\r
- <groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.orm</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
- </dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-expression</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-orm</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
+ </dependency>\r
<dependency>\r
- <groupId>org.springframework</groupId>\r
- <artifactId>org.springframework.jdbc</artifactId>\r
- <version>3.2.2.RELEASE</version>\r
- </dependency>\r
+ <groupId>org.springframework</groupId>\r
+ <artifactId>spring-jdbc</artifactId>\r
+ <version>4.2.4.RELEASE</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.springframework.security</groupId>\r
<artifactId>spring-security-core</artifactId>\r
- <version>3.1.3.RELEASE</version>\r
+ <version>4.0.3.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework.security</groupId>\r
<artifactId>spring-security-config</artifactId>\r
- <version>3.1.3.RELEASE</version>\r
+ <version>4.0.3.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.springframework.security</groupId>\r
<artifactId>spring-security-remoting</artifactId>\r
- <version>3.1.3.RELEASE</version>\r
+ <version>4.0.3.RELEASE</version>\r
</dependency>\r
<dependency>\r
<groupId>org.jboss.logging</groupId>\r
import org.springframework.beans.BeansException;\r
import org.springframework.context.ApplicationContext;\r
import org.springframework.context.ApplicationContextAware;\r
-import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor;\r
+import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;\r
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;\r
import org.springframework.security.access.AccessDecisionVoter;\r
import org.springframework.security.authentication.AuthenticationProvider;\r
this.remoteSource = remoteSource;\r
}\r
\r
- private Object getService(Class<?> clazz, String serviceSuffix, CommonsHttpInvokerRequestExecutor executor) {\r
+ private Object getService(Class<?> clazz, String serviceSuffix, HttpComponentsHttpInvokerRequestExecutor executor) {\r
if(serviceMap.containsKey(clazz)) {\r
return serviceMap.get(clazz);\r
}\r
public static Object getService(Class<?> clazz,\r
String serviceSuffix,\r
ICdmRemoteSource remoteSource,\r
- CommonsHttpInvokerRequestExecutor executor) {\r
+ HttpComponentsHttpInvokerRequestExecutor executor) {\r
\r
String baseUrl;\r
if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) {\r
\r
\r
public static IUserService getUserService(ICdmRemoteSource remoteSource) {\r
- return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new CommonsHttpInvokerRequestExecutor());\r
+ return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());\r
}\r
\r
@Override\r
public IMetadataService getMetadataService() {\r
- return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new CommonsHttpInvokerRequestExecutor());\r
+ return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new HttpComponentsHttpInvokerRequestExecutor());\r
}\r
\r
public static IMetadataService getMetadataService(ICdmRemoteSource remoteSource) {\r
- return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new CommonsHttpInvokerRequestExecutor());\r
+ return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());\r
}\r
\r
@Override\r
if(cdmPermissionEvaluator != null) {\r
return cdmPermissionEvaluator;\r
}\r
- List<AccessDecisionVoter> decisionVoters = new ArrayList<AccessDecisionVoter>();\r
+ List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<AccessDecisionVoter<? extends Object>>();\r
decisionVoters.add(new GrantAlwaysVoter());\r
decisionVoters.add(new TaxonNodeVoter());\r
decisionVoters.add(new TaxonBaseVoter());\r
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
+import org.hibernate.SessionFactory;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.hibernate.property.Getter;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.property.access.spi.Getter;
import org.osgi.framework.Bundle;
+import org.hibernate.boot.Metadata;
+
public class CdmModelCacher {
public Map<String, CdmModelFieldPropertyFromClass> generateModelClassMap() {
-
- Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH);
- Iterator<PersistentClass> classMappingIterator = configuration.getClassMappings();
-
- Map<String, CdmModelFieldPropertyFromClass> modelClassMap = new HashMap<String, CdmModelFieldPropertyFromClass>();
-
- while(classMappingIterator.hasNext()) {
- PersistentClass persistentClass = classMappingIterator.next();
- Class mappedClass = persistentClass.getMappedClass();
- String mappedClassName = mappedClass.getName();
-
- CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
- System.out.println("Adding class : " + mappedClassName + " to cache");
- addGetters(persistentClass, cmgmfc);
- modelClassMap.put(mappedClassName, cmgmfc);
- }
+
+ // A SessionFactory is set up once for an application!
+ final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
+ .configure(HB_CONFIG_FILE_PATH) // configures settings from hibernate.cfg.xml
+ .build();
+ SessionFactory sessionFactory = null;
+ Map<String, CdmModelFieldPropertyFromClass> modelClassMap = new HashMap<String, CdmModelFieldPropertyFromClass>();
+ try {
+ sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
+ Configuration configuration = buildConfiguration(HB_CONFIG_FILE_PATH);
+ Map<String, ClassMetadata> classMetaDataMap = sessionFactory.getAllClassMetadata();
+ Metadata metadata = new MetadataSources( registry ).getMetadataBuilder().applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE ).build();
+
+
+ for(ClassMetadata classMetaData :classMetaDataMap.values()) {
+ Class mappedClass = classMetaData.getMappedClass();
+
+ String mappedClassName = mappedClass.getName();
+
+ PersistentClass persistentClass =metadata.getEntityBinding(mappedClassName);
+ CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
+ System.out.println("Adding class : " + mappedClassName + " to cache");
+ addGetters(persistentClass, cmgmfc);
+ modelClassMap.put(mappedClassName, cmgmfc);
+ }
+ }
+ catch (Exception e) {
+ // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
+ // so destroy it manually.
+ StandardServiceRegistryBuilder.destroy( registry );
+ }
+
+
return modelClassMap;
}
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor;
+import org.apache.http.client.methods.HttpPost;
+import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;
import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
* @date 27 Jan 2015
*
*/
-public class CdmAuthenticatedHttpInvokerRequestExecutor extends CommonsHttpInvokerRequestExecutor {
+public class CdmAuthenticatedHttpInvokerRequestExecutor extends HttpComponentsHttpInvokerRequestExecutor {
@Override
- protected PostMethod createPostMethod(HttpInvokerClientConfiguration config) throws IOException {
- PostMethod postMethod = super.createPostMethod(config);
+ protected HttpPost createHttpPost(HttpInvokerClientConfiguration config) throws IOException {
+ HttpPost postMethod = super.createHttpPost(config);
SecurityContext securityContext = CdmApplicationState.getCurrentSecurityContext();
if(securityContext != null) {
if ((auth != null) && (auth.getName() != null) &&
(auth.getCredentials() != null)) {
String base64 = auth.getName() + ":" + auth.getCredentials().toString();
- postMethod.setRequestHeader("Authorization", "Basic " +
+ postMethod.setHeader("Authorization", "Basic " +
new String(Base64.encodeBase64(base64.getBytes())));
}
}
if ( isTempSession ) {
// TODO: On the next major release, add an
// 'isJTA' or 'getTransactionFactory' method to Session.
- isJTA = session.getTransactionCoordinator()
+ /*isJTA = session.getTransactionCoordinator()
.getTransactionContext().getTransactionEnvironment()
.getTransactionFactory()
- .compatibleWithJtaSynchronization();
-
+ .compatibleWithJtaSynchronization();*/
+ isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
if ( !isJTA ) {
// Explicitly handle the transactions only if we're not in
// a JTA environment. A lazy loading temporary session can
// TODO: On the next major release, add an
// 'isJTA' or 'getTransactionFactory' method to Session.
- boolean isJTA = session.getTransactionCoordinator()
+ /*boolean isJTA = session.getTransactionCoordinator()
.getTransactionContext().getTransactionEnvironment()
.getTransactionFactory()
.compatibleWithJtaSynchronization();
+ */
+ boolean isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta();
if ( !isJTA ) {
// Explicitly handle the transactions only if we're not in