From: Olivier Lamy Date: Thu, 1 Mar 2012 10:28:16 +0000 (+0000) Subject: [MRM-1610] Use Jackson as jaxrs provider for cxf for performance reasons. X-Git-Tag: archiva-1.4-M3~1167 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9b37010349781fc3cec59789c913f76706a85759;p=archiva.git [MRM-1610] Use Jackson as jaxrs provider for cxf for performance reasons. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295496 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml index 2b261a588..06a0cb752 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml @@ -33,6 +33,10 @@ javax.xml.bind jaxb-api + + org.codehaus.jackson + jackson-core-asl + commons-collections commons-collections @@ -98,7 +102,8 @@ org.apache.commons.collections;version="[3.2,4)", org.apache.commons.lang;version="[2.4,3)", org.codehaus.plexus.redback.users, - org.apache.maven.index.context;resolution:=optional + org.apache.maven.index.context;resolution:=optional, + org.codehaus.jackson.annotate diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/LegacyArtifactPath.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/LegacyArtifactPath.java index 1f4abdca8..4b34741fb 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/LegacyArtifactPath.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/LegacyArtifactPath.java @@ -18,6 +18,9 @@ package org.apache.archiva.admin.model.beans; * under the License. */ +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; @@ -76,27 +79,32 @@ public class LegacyArtifactPath return path.equals( this.path ); } + @JsonIgnore public String getGroupId() { return artifact.split( ":" )[0]; } + @JsonIgnore public String getArtifactId() { return artifact.split( ":" )[1]; } + @JsonIgnore public String getVersion() { return artifact.split( ":" )[2]; } + @JsonIgnore public String getClassifier() { String classifier = artifact.split( ":" )[3]; return classifier.length() > 0 ? classifier : null; } + @JsonIgnore public String getType() { return artifact.split( ":" )[4]; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 889ac242c..a89ea6909 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -149,12 +149,18 @@ - + + org.codehaus.jackson + jackson-xc + + + org.codehaus.jackson + jackson-core-asl + org.apache.cxf cxf-bundle-jaxrs @@ -163,6 +169,10 @@ org.eclipse.jetty jetty-server + + org.codehaus.jettison + jettison + diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ArchivaRestError.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ArchivaRestError.java index bdfd314ac..100340fa9 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ArchivaRestError.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ArchivaRestError.java @@ -19,6 +19,7 @@ package org.apache.archiva.rest.services; */ import org.apache.archiva.rest.api.services.ArchivaRestServiceException; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import javax.xml.bind.annotation.XmlRootElement; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index b0aace808..1342487ae 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -38,23 +38,13 @@ - - - - - - - - - - + diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java index 880492246..8c78f5dde 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java @@ -36,11 +36,13 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.WebClient; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; import org.codehaus.redback.rest.services.AbstractRestServicesTest; import org.junit.Before; import javax.ws.rs.core.MediaType; import java.io.File; +import java.util.Collections; import java.util.Date; /** @@ -100,13 +102,16 @@ public abstract class AbstractArchivaRestTest { RepositoriesService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RepositoriesService.class ); + RepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); if ( authzHeader != null ) { WebClient.client( service ).header( "Authorization", authzHeader ); } WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; } @@ -115,13 +120,16 @@ public abstract class AbstractArchivaRestTest { ManagedRepositoriesService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - ManagedRepositoriesService.class ); + ManagedRepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); if ( authzHeader != null ) { WebClient.client( service ).header( "Authorization", authzHeader ); } WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; } @@ -129,13 +137,15 @@ public abstract class AbstractArchivaRestTest protected PingService getPingService() { return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - PingService.class ); + PingService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); } protected RemoteRepositoriesService getRemoteRepositoriesService() { return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RemoteRepositoriesService.class ); + RemoteRepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); } @@ -143,17 +153,21 @@ public abstract class AbstractArchivaRestTest protected RepositoryGroupService getRepositoryGroupService() { return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RepositoryGroupService.class ); + RepositoryGroupService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); } protected ProxyConnectorService getProxyConnectorService() { ProxyConnectorService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - ProxyConnectorService.class ); + ProxyConnectorService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; } @@ -161,10 +175,13 @@ public abstract class AbstractArchivaRestTest { NetworkProxyService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - NetworkProxyService.class ); + NetworkProxyService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; } @@ -172,7 +189,8 @@ public abstract class AbstractArchivaRestTest { ArchivaAdministrationService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - ArchivaAdministrationService.class ); + ArchivaAdministrationService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -187,13 +205,16 @@ public abstract class AbstractArchivaRestTest // START SNIPPET: cxf-searchservice-creation SearchService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - SearchService.class ); + SearchService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); if ( authzHeader != null ) { WebClient.client( service ).header( "Authorization", authzHeader ); } WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; // END SNIPPET: cxf-searchservice-creation @@ -203,13 +224,16 @@ public abstract class AbstractArchivaRestTest { CommonServices service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - CommonServices.class ); + CommonServices.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); if ( authzHeader != null ) { WebClient.client( service ).header( "Authorization", authzHeader ); } WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 ); + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); return service; } diff --git a/pom.xml b/pom.xml index 8f508a36b..0af8fc5be 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ 4.1.4 1.4 7.4.5.v20110725 + 1.9.5 jdbc:derby:memory:users-test;create=true org.apache.derby.jdbc.EmbeddedDriver @@ -473,7 +474,17 @@ org.codehaus.jackson jackson-jaxrs - 1.9.5 + ${jacksonVersion} + + + org.codehaus.jackson + jackson-xc + ${jacksonVersion} + + + org.codehaus.jackson + jackson-core-asl + ${jacksonVersion} org.apache.cxf @@ -488,6 +499,10 @@ commons-logging commons-logging + + org.codehaus.jettison + jettison +