com.alibaba.dubbo.rpc.Filter Java Examples

The following examples show how to use com.alibaba.dubbo.rpc.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ITTracingFilter_Consumer.java    From brave with Apache License 2.0 6 votes vote down vote up
/** Shows if you aren't using RpcTracing, the old "dubbo.error_code" works */
@Test public void setsError_onUnimplemented_legacy() {
  ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
      .getExtension("tracing")).isInit = false;

  ((TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
      .getExtension("tracing"))
      .setTracing(tracing);

  assertThatThrownBy(() -> wrongClient.get().sayHello("jorge"))
      .isInstanceOf(RpcException.class);

  MutableSpan span =
      testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*Not found exported service.*");
  assertThat(span.tags())
      .containsEntry("dubbo.error_code", "1");
}
 
Example #2
Source File: ConfigTest.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #3
Source File: ITTracingFilter.java    From brave with Apache License 2.0 5 votes vote down vote up
/** Call this after updating {@link #tracing} */
TracingFilter init() {
  TracingFilter filter = (TracingFilter) ExtensionLoader.getExtensionLoader(Filter.class)
    .getExtension("tracing");
  filter.setTracing(tracing);
  return filter;
}
 
Example #4
Source File: ConfigTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #5
Source File: ProtocolFilterWrapper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
    Invoker<T> last = invoker;
    List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
    if (filters.size() > 0) {
        for (int i = filters.size() - 1; i >= 0; i --) {
            final Filter filter = filters.get(i);
            final Invoker<T> next = last;
            last = new Invoker<T>() {

                public Class<T> getInterface() {
                    return invoker.getInterface();
                }

                public URL getUrl() {
                    return invoker.getUrl();
                }

                public boolean isAvailable() {
                    return invoker.isAvailable();
                }

                public Result invoke(Invocation invocation) throws RpcException {
                    return filter.invoke(next, invocation);
                }

                public void destroy() {
                    invoker.destroy();
                }

                @Override
                public String toString() {
                    return invoker.toString();
                }
            };
        }
    }
    return last;
}
 
Example #6
Source File: ConfigTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #7
Source File: ProtocolFilterWrapper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
    Invoker<T> last = invoker;
    List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
    if (filters.size() > 0) {
        for (int i = filters.size() - 1; i >= 0; i --) {
            final Filter filter = filters.get(i);
            final Invoker<T> next = last;
            last = new Invoker<T>() {

                public Class<T> getInterface() {
                    return invoker.getInterface();
                }

                public URL getUrl() {
                    return invoker.getUrl();
                }

                public boolean isAvailable() {
                    return invoker.isAvailable();
                }

                public Result invoke(Invocation invocation) throws RpcException {
                    return filter.invoke(next, invocation);
                }

                public void destroy() {
                    invoker.destroy();
                }

                @Override
                public String toString() {
                    return invoker.toString();
                }
            };
        }
    }
    return last;
}
 
Example #8
Source File: ConfigTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #9
Source File: ProtocolFilterWrapper.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
    Invoker<T> last = invoker;
    List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
    if (filters.size() > 0) {
        for (int i = filters.size() - 1; i >= 0; i --) {
            final Filter filter = filters.get(i);
            final Invoker<T> next = last;
            last = new Invoker<T>() {

                public Class<T> getInterface() {
                    return invoker.getInterface();
                }

                public URL getUrl() {
                    return invoker.getUrl();
                }

                public boolean isAvailable() {
                    return invoker.isAvailable();
                }

                public Result invoke(Invocation invocation) throws RpcException {
                    return filter.invoke(next, invocation);
                }

                public void destroy() {
                    invoker.destroy();
                }

                @Override
                public String toString() {
                    return invoker.toString();
                }
            };
        }
    }
    return last;
}
 
Example #10
Source File: ConfigTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #11
Source File: ProtocolFilterWrapper.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
    Invoker<T> last = invoker;
    List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
    if (filters.size() > 0) {
        for (int i = filters.size() - 1; i >= 0; i --) {
            final Filter filter = filters.get(i);
            final Invoker<T> next = last;
            last = new Invoker<T>() {

                public Class<T> getInterface() {
                    return invoker.getInterface();
                }

                public URL getUrl() {
                    return invoker.getUrl();
                }

                public boolean isAvailable() {
                    return invoker.isAvailable();
                }

                public Result invoke(Invocation invocation) throws RpcException {
                    return filter.invoke(next, invocation);
                }

                public void destroy() {
                    invoker.destroy();
                }

                @Override
                public String toString() {
                    return invoker.toString();
                }
            };
        }
    }
    return last;
}
 
Example #12
Source File: ConfigTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
Example #13
Source File: ProtocolFilterWrapper.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private static <T> Invoker<T> buildInvokerChain(final Invoker<T> invoker, String key, String group) {
    Invoker<T> last = invoker;
    List<Filter> filters = ExtensionLoader.getExtensionLoader(Filter.class).getActivateExtension(invoker.getUrl(), key, group);
    if (filters.size() > 0) {
        for (int i = filters.size() - 1; i >= 0; i --) {
            final Filter filter = filters.get(i);
            final Invoker<T> next = last;
            last = new Invoker<T>() {

                public Class<T> getInterface() {
                    return invoker.getInterface();
                }

                public URL getUrl() {
                    return invoker.getUrl();
                }

                public boolean isAvailable() {
                    return invoker.isAvailable();
                }

                public Result invoke(Invocation invocation) throws RpcException {
                    return filter.invoke(next, invocation);
                }

                public void destroy() {
                    invoker.destroy();
                }

                @Override
                public String toString() {
                    return invoker.toString();
                }
            };
        }
    }
    return last;
}
 
Example #14
Source File: AbstractInterfaceConfig.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}
 
Example #15
Source File: AbstractInterfaceConfig.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}
 
Example #16
Source File: AbstractInterfaceConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}
 
Example #17
Source File: AbstractInterfaceConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}
 
Example #18
Source File: AbstractInterfaceConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}
 
Example #19
Source File: AbstractInterfaceConfig.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
public void setFilter(String filter) {
    checkMultiExtension(Filter.class, "filter", filter);
    this.filter = filter;
}