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.ejb.access;
  17. import java.lang.reflect.InvocationTargetException;
  18. import javax.ejb.EJBObject;
  19. import javax.naming.NamingException;
  20. /**
  21. * Superclass for interceptors proxying remote Stateless Session Beans.
  22. *
  23. * <p>Such an interceptor must be the last interceptor in the advice chain.
  24. * In this case, there is no target object.
  25. *
  26. * @author Rod Johnson
  27. * @version $Id: AbstractRemoteSlsbInvokerInterceptor.java,v 1.7 2004/05/18 07:54:00 jhoeller Exp $
  28. */
  29. public abstract class AbstractRemoteSlsbInvokerInterceptor extends AbstractSlsbInvokerInterceptor {
  30. /**
  31. * Return a new instance of the stateless session bean.
  32. * Can be overridden to change the algorithm.
  33. */
  34. protected EJBObject newSessionBeanInstance() throws NamingException, InvocationTargetException {
  35. if (logger.isDebugEnabled()) {
  36. logger.debug("Trying to create reference to remote EJB");
  37. }
  38. // Invoke the superclass's generic create method
  39. EJBObject session = (EJBObject) create();
  40. // if it throws remote exception (wrapped in bean exception), retry?
  41. if (logger.isDebugEnabled()) {
  42. logger.debug("Obtained reference to remote EJB: " + session);
  43. }
  44. return session;
  45. }
  46. }