diff options
author | Olivier Lamy <olamy@apache.org> | 2012-03-01 10:28:16 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-03-01 10:28:16 +0000 |
commit | 9b37010349781fc3cec59789c913f76706a85759 (patch) | |
tree | 774389c76c0acb325f3d075ca0419363f74d727e /archiva-modules | |
parent | edec35c9beba0c0434e034031ba3881fbef40a58 (diff) | |
download | archiva-9b37010349781fc3cec59789c913f76706a85759.tar.gz archiva-9b37010349781fc3cec59789c913f76706a85759.zip |
[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
Diffstat (limited to 'archiva-modules')
6 files changed, 62 insertions, 24 deletions
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 @@ -34,6 +34,10 @@ <artifactId>jaxb-api</artifactId> </dependency> <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + </dependency> + <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </dependency> @@ -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 </Import-Package> </instructions> </configuration> 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 @@ </exclusion> </exclusions> </dependency> - <!-- <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-jaxrs</artifactId> </dependency> - --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-xc</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle-jaxrs</artifactId> @@ -163,6 +169,10 @@ <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> </exclusion> + <exclusion> + <groupId>org.codehaus.jettison</groupId> + <artifactId>jettison</artifactId> + </exclusion> </exclusions> </dependency> <dependency> 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 @@ <context:annotation-config/> <context:component-scan base-package="org.apache.archiva.rest.services"/> - <!-- convertTypesToStrings --> - <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider"> - <!-- without that String 2.0 are transformed to 2 which is not correct for versions --> - <!-- side effect json boolean are string rather than boolean --> - <property name="convertTypesToStrings" value="true"/> - <!--property name="serializeAsArray" value="true"/--> - - </bean> <jaxrs:server id="archivaServices" address="/archivaServices"> <jaxrs:providers> - <ref bean="jsonProvider"/> - <!-- <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/> - --> + <ref bean="authenticationInterceptor#rest"/> <ref bean="permissionInterceptor#rest"/> <ref bean="archivaRestServiceExceptionMapper"/> 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; } |