1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.remoting.support;
  17. import org.apache.commons.logging.Log;
  18. import org.apache.commons.logging.LogFactory;
  19. /**
  20. * Abstract base class for classes that access a remote service.
  21. * Provides a "serviceInterface" bean property.
  22. *
  23. * <p>Note that the service interface being used will show some signs of
  24. * remotability, like the granularity of method calls that it offers.
  25. * Furthermore, it has to require serializable arguments etc.
  26. *
  27. * @author Juergen Hoeller
  28. * @since 13.05.2003
  29. * @see org.springframework.remoting.RemoteAccessException
  30. */
  31. public abstract class RemoteAccessor {
  32. protected final Log logger = LogFactory.getLog(getClass());
  33. private Class serviceInterface;
  34. /**
  35. * Set the interface of the service to access.
  36. * Typically required to be able to create a suitable serviuce proxy.
  37. * The interface must be suitable for the particular service and remoting tool.
  38. */
  39. public void setServiceInterface(Class serviceInterface) {
  40. if (!serviceInterface.isInterface()) {
  41. throw new IllegalArgumentException("serviceInterface must be an interface");
  42. }
  43. this.serviceInterface = serviceInterface;
  44. }
  45. /**
  46. * Return the interface of the service to access.
  47. */
  48. protected Class getServiceInterface() {
  49. return serviceInterface;
  50. }
  51. }