* @return the client
*/
public Client createWithValues(Object... varValues) {
serviceFactory.setBus(getBus());
checkResources(false);
ClassResourceInfo cri = null;
try {
Endpoint ep = createEndpoint();
if (getServiceClass() != null) {
for (ClassResourceInfo info : serviceFactory.getClassResourceInfo()) {
if (info.getServiceClass().isAssignableFrom(getServiceClass())
|| getServiceClass().isAssignableFrom(info.getServiceClass())) {
cri = info;
break;
}
}
if (cri == null) {
// can not happen in the reality
throw new RuntimeException("Service class " + getServiceClass().getName()
+ " is not recognized");
}
} else {
cri = serviceFactory.getClassResourceInfo().get(0);
}
boolean isRoot = cri.getURITemplate() != null;
ClientProxyImpl proxyImpl = null;
ClientState actualState = getActualState();
if (actualState == null) {
proxyImpl =
new ClientProxyImpl(URI.create(getAddress()), proxyLoader, cri, isRoot,
inheritHeaders, varValues);
} else {
proxyImpl =
new ClientProxyImpl(actualState, proxyLoader, cri, isRoot,
inheritHeaders, varValues);
}
initClient(proxyImpl, ep, actualState == null);
ClassLoader theLoader = proxyLoader == null ? cri.getServiceClass().getClassLoader() : proxyLoader;
Class<?>[] ifaces = new Class[]{Client.class, InvocationHandlerAware.class, cri.getServiceClass()};
Client actualClient = (Client)ProxyHelper.getProxy(theLoader, ifaces, proxyImpl);
notifyLifecycleManager(actualClient);
this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, actualClient, ep);
return actualClient;
} catch (IllegalArgumentException ex) {
String message = ex.getLocalizedMessage();
if (cri != null) {
String expected = cri.getServiceClass().getSimpleName();
if ((expected + " is not an interface").equals(message)) {
message += "; make sure CGLIB is on the classpath";
}
}
LOG.severe(ex.getClass().getName() + " : " + message);