@Test public void testExport() throws Exception { service.export(); assertThat(service.getExportedUrls(), hasSize(1)); URL url = service.toUrl(); assertThat(url.getProtocol(), equalTo("mockprotocol2")); assertThat(url.getPath(), equalTo(DemoService.class.getName())); assertThat(url.getParameters(), hasEntry(Constants.ANYHOST_KEY, "true")); assertThat(url.getParameters(), hasEntry(Constants.APPLICATION_KEY, "app")); assertThat(url.getParameters(), hasKey(Constants.BIND_IP_KEY)); assertThat(url.getParameters(), hasKey(Constants.BIND_PORT_KEY)); assertThat(url.getParameters(), hasEntry(Constants.DEFAULT_KEY + "." + Constants.EXPORT_KEY, "true")); assertThat(url.getParameters(), hasEntry(Constants.EXPORT_KEY, "true")); assertThat(url.getParameters(), hasEntry("echo.0.callback", "false")); assertThat(url.getParameters(), hasEntry(Constants.GENERIC_KEY, "false")); assertThat(url.getParameters(), hasEntry(Constants.INTERFACE_KEY, DemoService.class.getName())); assertThat(url.getParameters(), hasKey(Constants.METHODS_KEY)); assertThat(url.getParameters().get(Constants.METHODS_KEY), containsString("echo")); assertThat(url.getParameters(), hasEntry(Constants.SIDE_KEY, Constants.PROVIDER)); Mockito.verify(protocolDelegate).export(Mockito.any(Invoker.class)); }
public synchronized void export() { if (provider != null) { if (export == null) { export = provider.getExport(); } if (delay == null) { delay = provider.getDelay(); } } if (export != null && !export) { return; } if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { @Override public void run() { doExport(); } }, delay, TimeUnit.MILLISECONDS); } else { doExport(); } }
ServiceConfig extends AbstractServiceConfig { public synchronized void export() { if (provider != null) { if (export == null) { export = provider.getExport(); } if (delay == null) { delay = provider.getDelay(); } } if (export != null && !export) { return; } if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { @Override public void run() { doExport(); } }, delay, TimeUnit.MILLISECONDS); } else { doExport(); } } }
ServiceConfig extends AbstractServiceConfig { public synchronized void export() { if (provider != null) { if (export == null) { export = provider.getExport(); } if (delay == null) { delay = provider.getDelay(); } } if (export != null && !export) { return; } if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { @Override public void run() { doExport(); } }, delay, TimeUnit.MILLISECONDS); } else { doExport(); } } ServiceConfig();  ServiceConfig(Service service); }
ServiceConfig extends AbstractServiceConfig { public synchronized void export() { if (provider != null) { if (export == null) { export = provider.getExport(); } if (delay == null) { delay = provider.getDelay(); } } if (export != null && !export) { return; } if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { @Override public void run() { doExport(); } }, delay, TimeUnit.MILLISECONDS); } else { doExport(); } } ServiceConfig();  ServiceConfig(Service service); URL toUrl(); List<URL> toUrls(); @Parameter(excluded = true) boolean isExported(); @Parameter(excluded = true) boolean isUnexported(); synchronized void export(); synchronized void unexport(); Class<?> getInterfaceClass(); void setInterfaceClass(Class<?> interfaceClass); String getInterface(); void setInterface(String interfaceName); void setInterface(Class<?> interfaceClass); T getRef(); void setRef(T ref); @Parameter(excluded = true) String getPath(); void setPath(String path); List<MethodConfig> getMethods(); @SuppressWarnings("unchecked") void setMethods(List<? extends MethodConfig> methods); ProviderConfig getProvider(); void setProvider(ProviderConfig provider); String getGeneric(); void setGeneric(String generic); @Override void setMock(Boolean mock); @Override void setMock(String mock); List<URL> getExportedUrls(); @Deprecated List<ProviderConfig> getProviders(); @Deprecated void setProviders(List<ProviderConfig> providers); @Parameter(excluded = true) String getUniqueServiceName(); }
ServiceConfig extends AbstractServiceConfig { public synchronized void export() { if (provider != null) { if (export == null) { export = provider.getExport(); } if (delay == null) { delay = provider.getDelay(); } } if (export != null && !export) { return; } if (delay != null && delay > 0) { delayExportExecutor.schedule(new Runnable() { @Override public void run() { doExport(); } }, delay, TimeUnit.MILLISECONDS); } else { doExport(); } } ServiceConfig();  ServiceConfig(Service service); URL toUrl(); List<URL> toUrls(); @Parameter(excluded = true) boolean isExported(); @Parameter(excluded = true) boolean isUnexported(); synchronized void export(); synchronized void unexport(); Class<?> getInterfaceClass(); void setInterfaceClass(Class<?> interfaceClass); String getInterface(); void setInterface(String interfaceName); void setInterface(Class<?> interfaceClass); T getRef(); void setRef(T ref); @Parameter(excluded = true) String getPath(); void setPath(String path); List<MethodConfig> getMethods(); @SuppressWarnings("unchecked") void setMethods(List<? extends MethodConfig> methods); ProviderConfig getProvider(); void setProvider(ProviderConfig provider); String getGeneric(); void setGeneric(String generic); @Override void setMock(Boolean mock); @Override void setMock(String mock); List<URL> getExportedUrls(); @Deprecated List<ProviderConfig> getProviders(); @Deprecated void setProviders(List<ProviderConfig> providers); @Parameter(excluded = true) String getUniqueServiceName();  }