/** * Check whether a service reference has been set, * and whether it matches the specified service. * @see #setServiceInterface * @see #setService */ protected void checkServiceInterface() throws IllegalArgumentException { Class<?> serviceInterface = getServiceInterface(); Assert.notNull(serviceInterface, "Property 'serviceInterface' is required"); Object service = getService(); if (service instanceof String) { throw new IllegalArgumentException("Service [" + service + "] is a String " + "rather than an actual service reference: Have you accidentally specified " + "the service bean name as value instead of as reference?"); } if (!serviceInterface.isInstance(service)) { throw new IllegalArgumentException("Service interface [" + serviceInterface.getName() + "] needs to be implemented by service [" + service + "] of class [" + service.getClass().getName() + "]"); } }
/** * Get a proxy for the given service object, implementing the specified * service interface. * <p>Used to export a proxy that does not expose any internals but just * a specific interface intended for remote access. Furthermore, a * {@link RemoteInvocationTraceInterceptor} will be registered (by default). * @return the proxy * @see #setServiceInterface * @see #setRegisterTraceInterceptor * @see RemoteInvocationTraceInterceptor */ protected Object getProxyForService() { checkService(); checkServiceInterface(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addInterface(getServiceInterface()); if (this.registerTraceInterceptor != null ? this.registerTraceInterceptor : this.interceptors == null) { proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName())); } if (this.interceptors != null) { AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance(); for (Object interceptor : this.interceptors) { proxyFactory.addAdvisor(adapterRegistry.wrap(interceptor)); } } proxyFactory.setTarget(getService()); proxyFactory.setOpaque(true); return proxyFactory.getProxy(getBeanClassLoader()); }
/** * Check whether the service reference has been set. * @see #setService */ protected void checkService() throws IllegalArgumentException { Assert.notNull(getService(), "Property 'service' is required"); }
/** * Get a proxy for the given service object, implementing the specified * service interface. * <p>Used to export a proxy that does not expose any internals but just * a specific interface intended for remote access. Furthermore, a * {@link RemoteInvocationTraceInterceptor} will be registered (by default). * @return the proxy * @see #setServiceInterface * @see #setRegisterTraceInterceptor * @see RemoteInvocationTraceInterceptor */ protected Object getProxyForService() { checkService(); checkServiceInterface(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addInterface(getServiceInterface()); if (this.registerTraceInterceptor != null ? this.registerTraceInterceptor : this.interceptors == null) { proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName())); } if (this.interceptors != null) { AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance(); for (Object interceptor : this.interceptors) { proxyFactory.addAdvisor(adapterRegistry.wrap(interceptor)); } } proxyFactory.setTarget(getService()); proxyFactory.setOpaque(true); return proxyFactory.getProxy(getBeanClassLoader()); }
/** * Check whether the service reference has been set. * @see #setService */ protected void checkService() throws IllegalArgumentException { Assert.notNull(getService(), "Property 'service' is required"); }
/** * Get a proxy for the given service object, implementing the specified * service interface. * <p>Used to export a proxy that does not expose any internals but just * a specific interface intended for remote access. Furthermore, a * {@link RemoteInvocationTraceInterceptor} will be registered (by default). * @return the proxy * @see #setServiceInterface * @see #setRegisterTraceInterceptor * @see RemoteInvocationTraceInterceptor */ protected Object getProxyForService() { checkService(); checkServiceInterface(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addInterface(getServiceInterface()); if (this.registerTraceInterceptor != null ? this.registerTraceInterceptor : this.interceptors == null) { proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName())); } if (this.interceptors != null) { AdvisorAdapterRegistry adapterRegistry = GlobalAdvisorAdapterRegistry.getInstance(); for (Object interceptor : this.interceptors) { proxyFactory.addAdvisor(adapterRegistry.wrap(interceptor)); } } proxyFactory.setTarget(getService()); proxyFactory.setOpaque(true); return proxyFactory.getProxy(getBeanClassLoader()); }
/** * Check whether a service reference has been set, * and whether it matches the specified service. * @see #setServiceInterface * @see #setService */ protected void checkServiceInterface() throws IllegalArgumentException { Class<?> serviceInterface = getServiceInterface(); Assert.notNull(serviceInterface, "Property 'serviceInterface' is required"); Object service = getService(); if (service instanceof String) { throw new IllegalArgumentException("Service [" + service + "] is a String " + "rather than an actual service reference: Have you accidentally specified " + "the service bean name as value instead of as reference?"); } if (!serviceInterface.isInstance(service)) { throw new IllegalArgumentException("Service interface [" + serviceInterface.getName() + "] needs to be implemented by service [" + service + "] of class [" + service.getClass().getName() + "]"); } }
/** * Check whether the service reference has been set. * @see #setService */ protected void checkService() throws IllegalArgumentException { Assert.notNull(getService(), "Property 'service' is required"); }
/** * Check whether a service reference has been set, * and whether it matches the specified service. * @see #setServiceInterface * @see #setService */ protected void checkServiceInterface() throws IllegalArgumentException { Class<?> serviceInterface = getServiceInterface(); Assert.notNull(serviceInterface, "Property 'serviceInterface' is required"); Object service = getService(); if (service instanceof String) { throw new IllegalArgumentException("Service [" + service + "] is a String " + "rather than an actual service reference: Have you accidentally specified " + "the service bean name as value instead of as reference?"); } if (!serviceInterface.isInstance(service)) { throw new IllegalArgumentException("Service interface [" + serviceInterface.getName() + "] needs to be implemented by service [" + service + "] of class [" + service.getClass().getName() + "]"); } }