/** * 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()); }
/** * 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()); }
@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 hessianProxyFactory = new HessianProxyFactory(); boolean isHessian2Request = url.getParameter(Constants.HESSIAN2_REQUEST_KEY, Constants.DEFAULT_HESSIAN2_REQUEST); hessianProxyFactory.setHessian2Request(isHessian2Request);
HessianProxyFactory hessianProxyFactory = new HessianProxyFactory(); boolean isHessian2Request = url.getParameter(Constants.HESSIAN2_REQUEST_KEY, Constants.DEFAULT_HESSIAN2_REQUEST); hessianProxyFactory.setHessian2Request(isHessian2Request);
/** * 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()); }
/** * 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()); }
public void startup(Properties props){ this.url = (String) props.remove(RPC_PARAM_PREFIX + "url") ; this.factory = new HessianProxyFactory(); RPCServiceProxyImplFactory.setProperties(factory, props) ; }
HessianProxyFactory factory = new HessianProxyFactory(); factory.setHessian2Request(true); // Do something
public static void main(String[] args) throws MalformedURLException{ String url = "http://localhost:8080/hessian/remote/helloService.htm"; HessianProxyFactory factory = new HessianProxyFactory(); HelloService hello = (HelloService) factory.create(HelloService.class, url); System.out.println(hello.sayHi("Hessian")); } }
class myService { def myRemoteService static transactional = false private MyRemoteService getService(String remoteServiceURL) { HessianProxyFactory factory = new HessianProxyFactory(); try { return (MyRemoteService) factory.create(MyRemoteService.class, url); } catch (MalformedURLException e) { e.printStackTrace() } return null } def someRemoteMethod(String remoteServiceURL) { getService(remoteServiceURL).myRemoteMethod() } }
/** * Returns the initial context */ public Context getInitialContext(Hashtable<?,?> env) { try { String url = (String) env.get(Context.PROVIDER_URL); HessianProxyFactory factory = new HessianProxyFactory(); NamingProxy proxy = (NamingProxy) factory.create(NamingProxy.class, url); HessianModel model = new HessianModel(proxy); return new ContextImpl(model, (Hashtable) env); } catch (Exception e) { throw new RuntimeException(e); } } }
HessianProxyFactory factory = new HessianProxyFactory(); factory.setUser("neo"); factory.setPassword("thereisnospoon"); MyInterface service = (MyInterface) factory.create(MyInterface.class, "http://example.com/hessian/MyService");
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; } }
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; } }
@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()); }
@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()); }
/** * 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()); }
@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; }
/** * Constructor. * @param config Module configuration. */ public NodeRepositoryHessian(NRServiceConfig config) throws MalformedURLException { HessianProxyFactory factory = new HessianProxyFactory(); factory.setHessian2Reply(true); factory.setHessian2Request(true); final NodeRepository nr = (NodeRepository) factory.create(NodeRepository.class, config.serviceUrl()); if (config.microcache() != null) { this.remote = new CachingNodeRepository(nr, expiration(config.microcache().intValue())); } else { this.remote = nr; } }