/** * Services convert HTTP requests into the internal grid representation and specify what layer * the response should come from. * * <p>The application context is scanned for objects extending Service, thereby making it easy * to add new services. * * @return */ private Map<String, Service> loadServices() { log.info("Loading GWC Service extensions..."); List<Service> plugins = GeoWebCacheExtensions.extensions(Service.class); Map<String, Service> services = new HashMap<String, Service>(); // Give all service objects direct access to the tileLayerDispatcher for (Service aService : plugins) { services.put(aService.getPathName(), aService); } log.info( "Done loading GWC Service extensions. Found : " + new ArrayList<String>(services.keySet())); return services; }
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
public boolean isServiceEnabled(final Service service) { return getConfig().isEnabled(service.getPathName()); }
/** * Intercepts the {@code getConveyor} and {@code handleRequest} calls to a {@link Service} * instance and checks whether the service is enabled. * * @see * org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation) */ public Object invoke(final MethodInvocation invocation) throws Throwable { final String methodName = invocation.getMethod().getName(); if ("getConveyor".equals(methodName) || "handleRequest".equals(methodName)) { final org.geowebcache.service.Service service = (Service) invocation.getThis(); boolean serviceEnabled; if (service.getPathName().equals("wmts")) { serviceEnabled = geoServer.getService(WMTSInfo.class).isEnabled(); } else { serviceEnabled = gwcFacade.isServiceEnabled(service); } if (!serviceEnabled) { throw new org.geowebcache.service.HttpErrorCodeException( 400, "Service is disabled"); } } return invocation.proceed(); } }
public void testIsServiceEnabled() { Service service = mock(Service.class); when(service.getPathName()).thenReturn("wms"); defaults.setWMSCEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setWMSCEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("tms"); defaults.setTMSEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setTMSEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("wmts"); defaults.setWMTSEnabled(true); assertTrue(mediator.isServiceEnabled(service)); defaults.setWMTSEnabled(false); assertFalse(mediator.isServiceEnabled(service)); when(service.getPathName()).thenReturn("somethingElse"); assertTrue(mediator.isServiceEnabled(service)); }
EasyMock.expect(testService.getPathName()).andStubReturn("testService"); EasyMock.expect(tld.getTileLayer("testLayer")).andStubReturn(layer); EasyMock.expect(layer.isEnabled()).andStubReturn(true);
EasyMock.expect(testService.getPathName()).andStubReturn("testService"); EasyMock.expect(tld.getTileLayer("testLayer")).andStubReturn(layer); EasyMock.expect(layer.isEnabled()).andStubReturn(true);