public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) { // TODO Wrapper类不能正确处理带$的类名 final Wrapper wrapper = Wrapper.getWrapper(proxy.getClass().getName().indexOf('$') < 0 ? proxy.getClass() : type); return new AbstractProxyInvoker<T>(proxy, type, url) { @Override protected Object doInvoke(T proxy, String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Throwable { return wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments); } }; }
public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) { // TODO Wrapper类不能正确处理带$的类名 final Wrapper wrapper = Wrapper.getWrapper(proxy.getClass().getName().indexOf('$') < 0 ? proxy.getClass() : type); return new AbstractProxyInvoker<T>(proxy, type, url) { @Override protected Object doInvoke(T proxy, String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Throwable { return wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments); } }; }
@Override public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) { // TODO Wrapper cannot handle this scenario correctly: the classname contains '$' final Wrapper wrapper = Wrapper.getWrapper(proxy.getClass().getName().indexOf('$') < 0 ? proxy.getClass() : type); return new AbstractProxyInvoker<T>(proxy, type, url) { @Override protected Object doInvoke(T proxy, String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Throwable { return wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments); } }; }
@Override public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) { // TODO Wrapper cannot handle this scenario correctly: the classname contains '$' final Wrapper wrapper = Wrapper.getWrapper(proxy.getClass().getName().indexOf('$') < 0 ? proxy.getClass() : type); return new AbstractProxyInvoker<T>(proxy, type, url) { @Override protected Object doInvoke(T proxy, String methodName, Class<?>[] parameterTypes, Object[] arguments) throws Throwable { return wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments); } }; }
@Override public void objectBegin() throws ParseException { mStack.push(mValue); mStack.push(mType); mStack.push(mWrapper); if (mType == Object.class || Map.class.isAssignableFrom(mType)) { if (!mType.isInterface() && mType != Object.class) { try { mValue = mType.newInstance(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } else if (mType == ConcurrentMap.class) { mValue = new ConcurrentHashMap<String, Object>(); } else { mValue = new HashMap<String, Object>(); } mWrapper = null; } else { try { mValue = mType.newInstance(); mWrapper = Wrapper.getWrapper(mType); } catch (IllegalAccessException e) { throw new ParseException(StringUtils.toString(e)); } catch (InstantiationException e) { throw new ParseException(StringUtils.toString(e)); } } }
@Override public void objectBegin() throws ParseException { mStack.push(mValue); mStack.push(mType); mStack.push(mWrapper); if (mType == Object.class || Map.class.isAssignableFrom(mType)) { if (!mType.isInterface() && mType != Object.class) { try { mValue = mType.newInstance(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } else if (mType == ConcurrentMap.class) { mValue = new ConcurrentHashMap<String, Object>(); } else { mValue = new HashMap<String, Object>(); } mWrapper = null; } else { try { mValue = mType.newInstance(); mWrapper = Wrapper.getWrapper(mType); } catch (IllegalAccessException e) { throw new ParseException(StringUtils.toString(e)); } catch (InstantiationException e) { throw new ParseException(StringUtils.toString(e)); } } }
public void objectBegin() throws ParseException { mStack.push(mValue); mStack.push(mType); mStack.push(mWrapper); if( mType == Object.class || Map.class.isAssignableFrom(mType) ) { if (! mType.isInterface() && mType != Object.class) { try { mValue = mType.newInstance(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } else if (mType == ConcurrentMap.class) { mValue = new ConcurrentHashMap<String, Object>(); } else { mValue = new HashMap<String, Object>(); } mWrapper = null; } else { try { mValue = mType.newInstance(); mWrapper = Wrapper.getWrapper(mType); } catch(IllegalAccessException e){ throw new ParseException(StringUtils.toString(e)); } catch(InstantiationException e){ throw new ParseException(StringUtils.toString(e)); } } }
public void objectBegin() throws ParseException { mStack.push(mValue); mStack.push(mType); mStack.push(mWrapper); if( mType == Object.class || Map.class.isAssignableFrom(mType) ) { if (! mType.isInterface() && mType != Object.class) { try { mValue = mType.newInstance(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } } else if (mType == ConcurrentMap.class) { mValue = new ConcurrentHashMap<String, Object>(); } else { mValue = new HashMap<String, Object>(); } mWrapper = null; } else { try { mValue = mType.newInstance(); mWrapper = Wrapper.getWrapper(mType); } catch(IllegalAccessException e){ throw new ParseException(StringUtils.toString(e)); } catch(InstantiationException e){ throw new ParseException(StringUtils.toString(e)); } } }
private static void json(Object obj, String[] properties, JSONWriter jb, boolean writeClass) throws IOException { if (obj == null) { jb.valueNull(); } else { Wrapper wrapper = Wrapper.getWrapper(obj.getClass()); Object value; jb.objectBegin(); for (String prop : properties) { jb.objectItem(prop); value = wrapper.getPropertyValue(obj, prop); if (value == null) jb.valueNull(); else DEFAULT_CONVERTER.writeValue(value, jb, writeClass); } jb.objectEnd(); } }
private static void json(Object obj, String[] properties, JSONWriter jb, boolean writeClass) throws IOException { if (obj == null) { jb.valueNull(); } else { Wrapper wrapper = Wrapper.getWrapper(obj.getClass()); Object value; jb.objectBegin(); for (String prop : properties) { jb.objectItem(prop); value = wrapper.getPropertyValue(obj, prop); if (value == null) jb.valueNull(); else DEFAULT_CONVERTER.writeValue(value, jb, writeClass); } jb.objectEnd(); } }
private static URL getRegistryURL(URL url) { return url.setPath(RegistryService.class.getName()) .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .addParameter(Constants.CLUSTER_STICKY_KEY, "true") .addParameter(Constants.LAZY_CONNECT_KEY, "true") .addParameter(Constants.RECONNECT_KEY, "false") .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000") .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000") .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000") .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ",")) //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName()) //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect") .addParameter("subscribe.1.callback", "true") .addParameter("unsubscribe.1.callback", "false"); }
private static URL getRegistryURL(URL url) { return url.setPath(RegistryService.class.getName()) .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .addParameter(Constants.CLUSTER_STICKY_KEY, "true") .addParameter(Constants.LAZY_CONNECT_KEY, "true") .addParameter(Constants.RECONNECT_KEY, "false") .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000") .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000") .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000") .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ",")) //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName()) //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect") .addParameter("subscribe.1.callback", "true") .addParameter("unsubscribe.1.callback", "false"); }
private static void json(Object obj, String[] properties, JSONWriter jb, boolean writeClass) throws IOException { if( obj == null ) { jb.valueNull(); } else { Wrapper wrapper = Wrapper.getWrapper(obj.getClass()); Object value; jb.objectBegin(); for( String prop : properties ) { jb.objectItem(prop); value = wrapper.getPropertyValue(obj, prop); if( value == null ) jb.valueNull(); else DEFAULT_CONVERTER.writeValue(value, jb, writeClass); } jb.objectEnd(); } }
private static void json(Object obj, String[] properties, JSONWriter jb, boolean writeClass) throws IOException { if( obj == null ) { jb.valueNull(); } else { Wrapper wrapper = Wrapper.getWrapper(obj.getClass()); Object value; jb.objectBegin(); for( String prop : properties ) { jb.objectItem(prop); value = wrapper.getPropertyValue(obj, prop); if( value == null ) jb.valueNull(); else DEFAULT_CONVERTER.writeValue(value, jb, writeClass); } jb.objectEnd(); } }
private static URL getRegistryURL(URL url) { return url.setPath(RegistryService.class.getName()) .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .addParameter(Constants.CLUSTER_STICKY_KEY, "true") .addParameter(Constants.LAZY_CONNECT_KEY, "true") .addParameter(Constants.RECONNECT_KEY, "false") .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000") .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000") .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000") .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ",")) //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName()) //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect") .addParameter("subscribe.1.callback", "true") .addParameter("unsubscribe.1.callback", "false"); } }
url = url.addParameter(Constants.STUB_EVENT_METHODS_KEY, StringUtils.join(Wrapper.getWrapper(proxy.getClass()).getDeclaredMethodNames(), ",")); url = url.addParameter(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); try {
private static URL getRegistryURL(URL url) { return url.setPath(RegistryService.class.getName()) .removeParameter(Constants.EXPORT_KEY).removeParameter(Constants.REFER_KEY) .addParameter(Constants.INTERFACE_KEY, RegistryService.class.getName()) .addParameter(Constants.CLUSTER_STICKY_KEY, "true") .addParameter(Constants.LAZY_CONNECT_KEY, "true") .addParameter(Constants.RECONNECT_KEY, "false") .addParameterIfAbsent(Constants.TIMEOUT_KEY, "10000") .addParameterIfAbsent(Constants.CALLBACK_INSTANCES_LIMIT_KEY, "10000") .addParameterIfAbsent(Constants.CONNECT_TIMEOUT_KEY, "10000") .addParameter(Constants.METHODS_KEY, StringUtils.join(new HashSet<String>(Arrays.asList(Wrapper.getWrapper(RegistryService.class).getDeclaredMethodNames())), ",")) //.addParameter(Constants.STUB_KEY, RegistryServiceStub.class.getName()) //.addParameter(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString()) //for event dispatch //.addParameter(Constants.ON_DISCONNECT_KEY, "disconnect") .addParameter("subscribe.1.callback", "true") .addParameter("unsubscribe.1.callback", "false"); } }
url = url.addParameter(Constants.STUB_EVENT_METHODS_KEY, StringUtils.join(Wrapper.getWrapper(proxy.getClass()).getDeclaredMethodNames(), ",")); url = url.addParameter(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); try{
url = url.addParameter(Constants.STUB_EVENT_METHODS_KEY, StringUtils.join(Wrapper.getWrapper(proxy.getClass()).getDeclaredMethodNames(), ",")); url = url.addParameter(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); try {
url = url.addParameter(Constants.STUB_EVENT_METHODS_KEY, StringUtils.join(Wrapper.getWrapper(proxy.getClass()).getDeclaredMethodNames(), ",")); url = url.addParameter(Constants.IS_SERVER_KEY, Boolean.FALSE.toString()); try{