/** * Example license header for Java files * * http://www.andromda.org/ */ // // Attention: Generated code! Do not modify by hand! // Generated by: ejb/SpringSessionBean.vsl in andromda-spring-cartridge. // package org.andromda.test.3.ejb; /** * @see org.andromda.test.3.RentalService */ public class RentalServiceBean extends org.springframework.ejb.support.AbstractStatelessSessionBean implements org.andromda.test.3.RentalService { /** * The serial version UID of this class. Needed for serialization. */ private static final long serialVersionUID = -3944978507978207926L; private org.andromda.test.3.RentalService rentalService; /** * @see org.andromda.test.3.RentalService#getAllCars() */ public java.util.List getAllCars() { org.andromda.spring.PrincipalStore.setSessionContext(super.getSessionContext()); try { return this.rentalService.getAllCars(); } catch (Exception exception) { final Throwable cause = getRootCause(exception); if (cause instanceof Exception) { throw new javax.ejb.EJBException((Exception)cause); } throw new javax.ejb.EJBException(exception); } } /** * @see org.andromda.test.3.RentalService#getCustomersByName(java.lang.String) */ public java.util.List getCustomersByName(java.lang.String name) { org.andromda.spring.PrincipalStore.setSessionContext(super.getSessionContext()); try { return this.rentalService.getCustomersByName(name); } catch (Exception exception) { final Throwable cause = getRootCause(exception); if (cause instanceof Exception) { throw new javax.ejb.EJBException((Exception)cause); } throw new javax.ejb.EJBException(exception); } } /** * Every Spring Session EJB needs to * call this to instantiate the Spring * Business Object. * * @see org.springframework.ejb.support.AbstractStatelessSessionBean#onEjbCreate() */ @Override protected void onEjbCreate() { this.rentalService = (org.andromda.test.3.RentalService) getBeanFactory().getBean("rentalService"); } /** * Override default BeanFactoryLocator implementation to * provide singleton loading of the application context Bean factory. * * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext) */ @Override public void setSessionContext(javax.ejb.SessionContext sessionContext) { super.setSessionContext(sessionContext); super.setBeanFactoryLocator( org.springframework.context.access.ContextSingletonBeanFactoryLocator.getInstance("beanRefFactory.xml")); super.setBeanFactoryLocatorKey("beanRefFactory"); } /** * Finds the root cause of the parent exception * by traveling up the exception tree. * @param throwable * @return Throwable root cause */ private static Throwable getRootCause(Throwable throwable) { if (throwable != null) { // Reflectively get any exception causes. try { Throwable targetException = null; // java.lang.reflect.InvocationTargetException String exceptionProperty = "targetException"; if (org.apache.commons.beanutils.PropertyUtils.isReadable(throwable, exceptionProperty)) { targetException = (Throwable)org.apache.commons.beanutils.PropertyUtils.getProperty(throwable, exceptionProperty); } else { exceptionProperty = "causedByException"; //javax.ejb.EJBException if (org.apache.commons.beanutils.PropertyUtils.isReadable(throwable, exceptionProperty)) { targetException = (Throwable)org.apache.commons.beanutils.PropertyUtils.getProperty(throwable, exceptionProperty); } } if (targetException != null) { throwable = targetException; } } catch (Exception exception) { // just print the exception and continue exception.printStackTrace(); } if (throwable.getCause() != null) { throwable = throwable.getCause(); throwable = getRootCause(throwable); } } return throwable; } }