allow singleton classes (might be bad)
This commit is contained in:
parent
3a003eff29
commit
53d9c7381d
@ -3,6 +3,7 @@ package com.inteligr8.rs;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.ws.rs.ext.RuntimeDelegate;
|
import javax.ws.rs.ext.RuntimeDelegate;
|
||||||
|
|
||||||
import org.apache.cxf.BusFactory;
|
import org.apache.cxf.BusFactory;
|
||||||
@ -11,7 +12,7 @@ import org.apache.cxf.jaxrs.client.WebClient;
|
|||||||
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
|
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
@ -21,22 +22,31 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
|||||||
*
|
*
|
||||||
* @author brian@inteligr8.com
|
* @author brian@inteligr8.com
|
||||||
*/
|
*/
|
||||||
public abstract class ClientCxfImpl extends Client implements InitializingBean {
|
@Component("client.cxf")
|
||||||
|
public class ClientCxfImpl extends Client {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ClientCxfImpl.class);
|
private final Logger logger = LoggerFactory.getLogger(ClientCxfImpl.class);
|
||||||
|
|
||||||
@Override
|
private ClientCxfConfiguration config;
|
||||||
protected abstract ClientCxfConfiguration getConfig();
|
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void afterPropertiesSet() {
|
* This constructor is for Spring use and inheriting APIs
|
||||||
this.register();
|
*/
|
||||||
|
protected ClientCxfImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is for POJO use
|
||||||
|
*/
|
||||||
|
public ClientCxfImpl(ClientCxfConfiguration config) {
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method registers the Apache CXF library as the default provider for
|
* This method registers the Apache CXF library as the default provider for
|
||||||
* the JAX-RS specification.
|
* the JAX-RS specification.
|
||||||
*/
|
*/
|
||||||
|
@PostConstruct
|
||||||
public void register() {
|
public void register() {
|
||||||
if (RuntimeDelegate.getInstance() == null) {
|
if (RuntimeDelegate.getInstance() == null) {
|
||||||
this.logger.info("Setting JAX-RS runtime delegate to the CXF library");
|
this.logger.info("Setting JAX-RS runtime delegate to the CXF library");
|
||||||
@ -94,6 +104,10 @@ public abstract class ClientCxfImpl extends Client implements InitializingBean {
|
|||||||
public void addProvidersAndFilters(List<Object> providersAndFilters) {
|
public void addProvidersAndFilters(List<Object> providersAndFilters) {
|
||||||
// for extension purposes
|
// for extension purposes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ClientCxfConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method retrieves a JAX-RS implementation of the specified API with
|
* This method retrieves a JAX-RS implementation of the specified API with
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.inteligr8.rs;
|
package com.inteligr8.rs;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.ext.RuntimeDelegate;
|
import javax.ws.rs.ext.RuntimeDelegate;
|
||||||
|
|
||||||
@ -9,7 +10,8 @@ import org.glassfish.jersey.internal.RuntimeDelegateImpl;
|
|||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that provides pre-configured JAX-RS Client & WebTarget objects
|
* A class that provides pre-configured JAX-RS Client & WebTarget objects
|
||||||
@ -17,22 +19,32 @@ import org.springframework.beans.factory.InitializingBean;
|
|||||||
*
|
*
|
||||||
* @author brian@inteligr8.com
|
* @author brian@inteligr8.com
|
||||||
*/
|
*/
|
||||||
public abstract class ClientJerseyImpl extends Client implements InitializingBean {
|
@Component("client.jersey")
|
||||||
|
public class ClientJerseyImpl extends Client {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ClientJerseyImpl.class);
|
private final Logger logger = LoggerFactory.getLogger(ClientJerseyImpl.class);
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
protected abstract ClientJerseyConfiguration getConfig();
|
private ClientJerseyConfiguration config;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void afterPropertiesSet() {
|
* This constructor is for Spring use and inheriting APIs
|
||||||
this.register();
|
*/
|
||||||
|
protected ClientJerseyImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is for POJO use
|
||||||
|
*/
|
||||||
|
public ClientJerseyImpl(ClientJerseyConfiguration config) {
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method registers the Jersey library as the default provider for the
|
* This method registers the Jersey library as the default provider for the
|
||||||
* JAX-RS specification.
|
* JAX-RS specification.
|
||||||
*/
|
*/
|
||||||
|
@PostConstruct
|
||||||
public void register() {
|
public void register() {
|
||||||
if (RuntimeDelegate.getInstance() == null) {
|
if (RuntimeDelegate.getInstance() == null) {
|
||||||
this.logger.info("Setting JAX-RS runtime delegate to the Jersey library");
|
this.logger.info("Setting JAX-RS runtime delegate to the Jersey library");
|
||||||
@ -57,6 +69,10 @@ public abstract class ClientJerseyImpl extends Client implements InitializingBea
|
|||||||
clientBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
clientBuilder.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ClientJerseyConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method retrieves a JAX-RS implementation of the specified API with
|
* This method retrieves a JAX-RS implementation of the specified API with
|
||||||
|
Loading…
x
Reference in New Issue
Block a user