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.aop.framework.adapter;
  17. import org.aopalliance.intercept.Interceptor;
  18. import org.springframework.aop.Advisor;
  19. /**
  20. * Interface for registries of AdvisorAdapters.
  21. *
  22. * <p><i>This is an SPI interface, that should not need to be implemented
  23. * by any Spring user.</i>
  24. *
  25. * @author Rod Johnson
  26. * @version $Id: AdvisorAdapterRegistry.java,v 1.4 2004/04/01 15:35:46 jhoeller Exp $
  27. */
  28. public interface AdvisorAdapterRegistry {
  29. /**
  30. * Return an Advisor wrapping the given advice
  31. * @param advice object that should be an advice, such as
  32. * BeforeAdvice or ThrowsAdvice.
  33. * @return an Advisor wrapping the given advice. Never
  34. * returns null. If the advice parameter is an Advisor, return
  35. * it.
  36. * @throws UnknownAdviceTypeException if no registered AdvisorAdapter
  37. * can wrap the supposed advice
  38. */
  39. Advisor wrap(Object advice) throws UnknownAdviceTypeException;
  40. /**
  41. * Return an AOP Alliance Interceptor to allow use of the given
  42. * Advisor in an interception-based framework.
  43. * Don't worry about the pointcut associated with the Advisor,
  44. * if it's a PointcutAdvisor: just return an interceptor
  45. * @param advisor Advisor to find an interceptor for
  46. * @return an Interceptor to expose this Advisor's behaviour
  47. * @throws UnknownAdviceTypeException if the Advisor type is
  48. * not understood by any registered AdvisorAdapter.
  49. */
  50. Interceptor getInterceptor(Advisor advisor) throws UnknownAdviceTypeException;
  51. /**
  52. * Register the given AdvisorAdapter. Note that it is not necessary to register
  53. * adapters for InterceptionAroundAdvice or AOP Alliance Interceptors:
  54. * these must be automatically recognized by an AdvisorAdapterRegistry
  55. * implementation.
  56. * @param adapter AdvisorAdapter that understands particular Advisor
  57. * and Advice types.
  58. */
  59. void registerAdvisorAdapter(AdvisorAdapter adapter);
  60. }