0

나는 NotificationService라는 유틸리티 서비스를 가지고있다. 서비스 계층에는 서비스를 정의하는 NotificationService 인터페이스와 서비스를 정적으로 제공하는 NotificationServiceUtil 클래스가 있고 서비스 계층에는 NotificationServiceImpl (구현)을 제공하는 Impl 계층이 있다는 점에서 MailService의 행을 따른 것입니다. 그런 다음 ext-spring.xml에 서비스를 등록했습니다.서비스 빌더가없는 liferay 트랜잭션 방식으로 서비스 메소드를 만드는 방법

<bean id="org.mitre.asias.portal.notification.service.NotificationService" 
    class="org.mitre.asias.portal.notification.service.impl.NotificationServiceImpl"> 
    ... 
    </bean> 
    <bean id="org.mitre.asias.portal.notification.service.NotificationServiceUtil" 
    class="org.mitre.asias.portal.notification.service.NotificationServiceUtil"> 
    <property name="service" 
     ref="org.mitre.asias.portal.notification.service.NotificationService" /> 
    </bean> 

트랜잭션을 트랜잭션에 던질 때까지 예상대로 작동합니다.

public void sendAndUpdate(Message message, List<Event> eventsToUpdate) throws SystemException, MessagingException { 
    for (Event event : eventsToUpdate) { 
     eventLocalService.updateEvent(event); 
    } 
    Transport.send(message); 
} 
어떤 이유로 메시지를 보내는 경우 것이 실패 인 아이디어는, 모델 객체에 대한 변경 사항이 롤백 될

그래서이를 다시 시도 할 수 : 나는 거래 할 필요가 NotificationServiceImpl에서 하나의 방법이 나중에 보냅니다. 이 메서드에 주석을 달았습니다.

@Transactional(isolation = Isolation.PORTAL, 
     rollbackFor = { PortalException.class, SystemException.class, MessagingException.class }) 

그러나 걸리지 않았습니다. Annotation을 NotificationService 인터페이스로 옮기려고했지만 여전히 주사위를 사용하지 않았습니다. 디버그 로깅을 org.hibernate.transaction.JDBCTransaction에서 활성화하고 트랜잭션이 해당 메소드 호출에 대해 시작되지 않았지만 하나가 시작되어 루프에서 각 updateEvent 호출에 대해 커밋 된 것을 볼 수 있습니다. 소스에 파고

,을 Liferay이 코드가 ServiceBeanAutoProxyCreator라는 빈 포스트 프로세서가 나타납니다 :

... 
protected Object[] getAdvicesAndAdvisorsForBean(
     Class<?> beanClass, String beanName, TargetSource targetSource) 
    throws BeansException { 

    if (beanName.endsWith(_SERVICE_SUFFIX)) { 
     return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS; 
    } 
    else { 
     return DO_NOT_PROXY; 
    } 
} 

private static final String _SERVICE_SUFFIX = "Service"; 
... 

는 것처럼 보이게 그의 이름 서비스 (내 콩이하는대로로 끝나는 모든 콩 :

<bean class="com.liferay.portal.spring.aop.ServiceBeanAutoProxyCreator"> 
    <property name="methodInterceptor" ref="serviceAdvice" /> 
</bean> 
<bean class="com.liferay.portal.spring.context.PortletBeanFactoryCleaner" /> 
<bean class="com.liferay.portal.spring.context.PortletBeanFactoryPostProcessor" /> 
<bean class="com.liferay.portal.spring.bean.BeanReferenceAnnotationBeanPostProcessor" /> 
<bean id="portletClassLoader" class="com.liferay.portal.kernel.portlet.PortletClassLoaderUtil" factory-method="getClassLoader" /> 
<bean id="servletContextName" class="com.liferay.portal.kernel.portlet.PortletClassLoaderUtil" factory-method="getServletContextName" /> 
<bean id="basePersistence" abstract="true"> 
    <property name="dataSource" ref="liferayDataSource" /> 
    <property name="sessionFactory" ref="liferaySessionFactory" /> 
</bean> 
<bean id="serviceAdvice" class="com.liferay.portal.monitoring.statistics.service.ServiceMonitorAdvice"> 
    <property name="monitoringDestinationName" value="liferay/monitoring" /> 
    <property name="nextMethodInterceptor" ref="asyncAdvice" /> 
</bean> 
<bean id="asyncAdvice" class="com.liferay.portal.messaging.async.AsyncAdvice"> 
    <property name="defaultDestinationName" value="liferay/async_service" /> 
    <property name="nextMethodInterceptor" ref="threadLocalCacheAdvice" /> 
</bean> 
<bean id="threadLocalCacheAdvice" class="com.liferay.portal.cache.ThreadLocalCacheAdvice"> 
    <property name="nextMethodInterceptor" ref="transactionAdvice" /> 
</bean> 
<bean id="transactionAdvice" class="com.liferay.portal.spring.transaction.TransactionInterceptor"> 
    <property name="transactionAttributeSource" ref="transactionAttributeSource" /> 
    <property name="transactionManager" ref="liferayTransactionManager" /> 
</bean> 
<bean id="transactionAttributeSource" class="com.liferay.portal.spring.transaction.AnnotationTransactionAttributeSource" /> 

이 사람이 어떤 생각을 가지고 있습니까 : ...id="org.mitre.asias.portal.notification.service.NotificationService"...)이 서비스 빌더에 따라 트랜잭션 조언을 추가되는 ServiceBeanAopProxy에 싸여되어야한다 base-spring.xml 생성 내가 어떻게이 일을 할 수 있니?

tomcat 6.0.32 컨테이너에 Liferay 6.0 EE sp2를 사용하고 있습니다.

답변

0

인터페이스에

을 Liferay가 이름 서비스로 끝 (빈의 이름이 아닌 클래스 이름에 따라 다름) 콩을 통해 거래를 래핑 (안 인터페이스의 방법에)에 @Transactional 주석을 이동하려고합니다.

또한 코드 배치에 문제가있을 수 있습니다. 당신은 당신의 콩을 어디에 정의합니까? 나는 extplugin에서 생각하니? 서비스 작성자없이 자체 포틀릿에서 Liferay 트랜잭션을 확장하려는 경우 까다로운 작업이 필요할 수 있습니다. 그러나 6.1에서 Liferay 스프링 컨텍스트를 공유 할 수 있어야합니다.