HessianProxyFactory hessianProxyFactory = new HessianProxyFactory(); boolean isHessian2Request = url.getParameter(Constants.HESSIAN2_REQUEST_KEY, Constants.DEFAULT_HESSIAN2_REQUEST); hessianProxyFactory.setHessian2Request(isHessian2Request); boolean isOverloadEnabled = url.getParameter(Constants.HESSIAN_OVERLOAD_METHOD_KEY, Constants.DEFAULT_HESSIAN_OVERLOAD_METHOD); hessianProxyFactory.setOverloadEnabled(isOverloadEnabled); String client = url.getParameter(Constants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT); if ("httpclient".equals(client)) { HessianConnectionFactory factory = new HttpClientConnectionFactory(); factory.setHessianProxyFactory(hessianProxyFactory); hessianProxyFactory.setConnectionFactory(factory); } else if (client != null && client.length() > 0 && !Constants.DEFAULT_HTTP_CLIENT.equals(client)) { throw new IllegalStateException("Unsupported http protocol client=\"" + client + "\"!"); HessianConnectionFactory factory = new DubboHessianURLConnectionFactory(); factory.setHessianProxyFactory(hessianProxyFactory); hessianProxyFactory.setConnectionFactory(factory); hessianProxyFactory.setConnectTimeout(timeout); hessianProxyFactory.setReadTimeout(timeout); return (T) hessianProxyFactory.create(serviceType, url.setProtocol("http").toJavaURL(), Thread.currentThread().getContextClassLoader());
/** * Set the password that this factory should use to access the remote service. * Default is none. * <p>The password will be sent by Hessian via HTTP Basic Authentication. * @see com.caucho.hessian.client.HessianProxyFactory#setPassword */ public void setPassword(String password) { this.proxyFactory.setPassword(password); }
/** * Set the username that this factory should use to access the remote service. * Default is none. * <p>The username will be sent by Hessian via HTTP Basic Authentication. * @see com.caucho.hessian.client.HessianProxyFactory#setUser */ public void setUsername(String username) { this.proxyFactory.setUser(username); }
/** * Set whether version 2 of the Hessian protocol should be used for * parsing requests and replies. Default is "false". * @see com.caucho.hessian.client.HessianProxyFactory#setHessian2Request */ public void setHessian2(boolean hessian2) { this.proxyFactory.setHessian2Request(hessian2); this.proxyFactory.setHessian2Reply(hessian2); }
@Override public void setHessianProxyFactory(HessianProxyFactory factory) { RequestConfig requestConfig = RequestConfig.custom() .setConnectionRequestTimeout((int) factory.getConnectTimeout()) .setSocketTimeout((int) factory.getReadTimeout()) .build(); httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build(); }
/** * Create the Hessian proxy that is wrapped by this interceptor. * @param proxyFactory the proxy factory to use * @return the Hessian proxy * @throws MalformedURLException if thrown by the proxy factory * @see com.caucho.hessian.client.HessianProxyFactory#create */ protected Object createHessianProxy(HessianProxyFactory proxyFactory) throws MalformedURLException { Assert.notNull(getServiceInterface(), "'serviceInterface' is required"); return proxyFactory.create(getServiceInterface(), getServiceUrl(), getBeanClassLoader()); }
@SuppressWarnings("unchecked") protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException { HessianProxyFactory hessianProxyFactory = new HessianProxyFactory(); String client = url.getParameter(Constants.CLIENT_KEY, Constants.DEFAULT_HTTP_CLIENT); if ("httpclient".equals(client)) { hessianProxyFactory.setConnectionFactory(new HttpClientConnectionFactory()); } else if (client != null && client.length() > 0 && ! Constants.DEFAULT_HTTP_CLIENT.equals(client)) { throw new IllegalStateException("Unsupported http protocol client=\"" + client + "\"!"); } int timeout = url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT); hessianProxyFactory.setConnectTimeout(timeout); hessianProxyFactory.setReadTimeout(timeout); return (T) hessianProxyFactory.create(serviceType, url.setProtocol("http").toJavaURL(), Thread.currentThread().getContextClassLoader()); }
@Override public void init(FilterConfig filterConfig) throws ServletException { if(isServer) { ssoServerUrl = filterConfig.getServletContext().getContextPath(); } else if (StringUtils.isEmpty(ssoServerUrl)) { throw new IllegalArgumentException("ssoServerUrl不能为空"); } if (authenticationRpcService == null) { try { authenticationRpcService = (AuthenticationRpcService) new HessianProxyFactory() .create(AuthenticationRpcService.class, ssoServerUrl + "/rpc/authenticationRpcService"); } catch (MalformedURLException e) { new IllegalArgumentException("authenticationRpcService初始化失败"); } } if (filters == null || filters.length == 0) { throw new IllegalArgumentException("filters不能为空"); } for (ClientFilter filter : filters) { filter.setSsoServerUrl(ssoServerUrl); filter.setAuthenticationRpcService(authenticationRpcService); filter.init(filterConfig); } }
HessianProxyFactory factory = new HessianProxyFactory(); factory.setUser("neo"); factory.setPassword("thereisnospoon"); MyInterface service = (MyInterface) factory.create(MyInterface.class, "http://example.com/hessian/MyService");
/** * Init method exec after properties set * @throws MalformedURLException throwed if hessian url is malformed */ public void init() throws MalformedURLException { HessianProxyFactory factory = new HessianProxyFactory(); factory.setHessian2Reply(true); factory.setHessian2Request(true); remote = (NodeRepositoriesService) factory.create(NodeRepositoriesService.class, config.serviceUrl()); }
url = value; else if (type.equals("user")) setUser(value); else if (type.equals("password")) setPassword(value); return create(apiClass, url);
private RemoteJMX getProxy() { if (_jmxProxy == null) { try { HessianProxyFactory proxy = new HessianProxyFactory(); proxy.getSerializerFactory().addFactory(new JMXSerializerFactory()); _jmxProxy = (RemoteJMX) proxy.create(_url); } catch (Exception e) { throw new RuntimeException(e); } } return _jmxProxy; } }
/** * Set the HessianProxyFactory instance to use. * If not specified, a default HessianProxyFactory will be created. * <p>Allows to use an externally configured factory instance, * in particular a custom HessianProxyFactory subclass. */ public void setProxyFactory(@Nullable HessianProxyFactory proxyFactory) { this.proxyFactory = (proxyFactory != null ? proxyFactory : new HessianProxyFactory()); }
HessianProxyFactory factory = new HessianProxyFactory(); factory.setHessian2Request(true); // Do something
@Override protected <T> T createService(ConnectionDescriptor connectionDescriptor, Class<T> serviceInterface, String serviceId, boolean stateful) { final HessianProxyFactoryBean proxyFactoryBean = new HessianProxyFactoryBean(); proxyFactoryBean.setServiceInterface(serviceInterface); proxyFactoryBean.setServiceUrl(connectionDescriptor.getLocation().toString()); final HessianConnectionFactory factory = new StatefulHessianConnectionFactory(serviceSecurityContext); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final HessianProxyFactory proxyFactory = new HessianProxyFactory(classLoader); factory.setHessianProxyFactory(proxyFactory); proxyFactory.setConnectionFactory(factory); proxyFactoryBean.setProxyFactory(proxyFactory); proxyFactoryBean.afterPropertiesSet(); @SuppressWarnings("unchecked") final T service = clientInterceptorUtil.addHttpInterceptors((T) proxyFactoryBean.getObject(), connectionDescriptor); return service; }
public AbstractHessianInput getHessian2Input(InputStream is) { AbstractHessianInput in; if (_isDebug) is = new HessianDebugInputStream(is, new PrintWriter(System.out)); in = new Hessian2Input(is); in.setRemoteResolver(getRemoteResolver()); in.setSerializerFactory(getSerializerFactory()); return in; }
/** * Set whether to allow non-serializable types as Hessian arguments * and return values. Default is "true". */ public void setAllowNonSerializable(boolean allowNonSerializable) { this.proxyFactory.getSerializerFactory().setAllowNonSerializable(allowNonSerializable); }
/** * Set whether version 2 of the Hessian protocol should be used for * parsing requests. Default is "false". * @see com.caucho.hessian.client.HessianProxyFactory#setHessian2Request */ public void setHessian2Request(boolean hessian2) { this.proxyFactory.setHessian2Request(hessian2); }
/** * Specify a custom HessianConnectionFactory to use for the Hessian client. */ public void setConnectionFactory(HessianConnectionFactory connectionFactory) { this.proxyFactory.setConnectionFactory(connectionFactory); }
/** * Set the socket connect timeout to use for the Hessian client. * @see com.caucho.hessian.client.HessianProxyFactory#setConnectTimeout */ public void setConnectTimeout(long timeout) { this.proxyFactory.setConnectTimeout(timeout); }