Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add workaround for RESTEasy 2.x/3.x incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Nov 13, 2013
1 parent a89f319 commit 8a17230
Showing 1 changed file with 17 additions and 1 deletion.
@@ -1,5 +1,6 @@
package org.zanata.rest.client;

import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -22,6 +23,7 @@
import org.jboss.resteasy.client.ClientExecutor;
import org.jboss.resteasy.client.ClientRequestFactory;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.client.core.ClientInterceptorRepository;
import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
Expand Down Expand Up @@ -297,7 +299,21 @@ public URI getResourceURI(String projectSlug, String versionSlug) {
* @param interceptor
*/
public void registerPrefixInterceptor(Object interceptor) {
crf.getPrefixInterceptors().registerInterceptor(interceptor);
ClientInterceptorRepository repo = getPrefixInterceptors();
repo.registerInterceptor(interceptor);
}

/**
* Workaround for signature incompatibility between RESTEasy 2.x and 3.x
* @return
*/
private ClientInterceptorRepository getPrefixInterceptors() {
try {
Method m = crf.getClass().getMethod("getPrefixInterceptors");
return (ClientInterceptorRepository) m.invoke(crf);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected IVersionResource createIVersionResource() {
Expand Down

0 comments on commit 8a17230

Please sign in to comment.