Issue Details (XML | Word | Printable)

Key: CSC-535
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Patrik Nordwall
Reporter: Patrik Nordwall
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Fornax Cartridge Sculptor

Generation error when publish eventType not defined

Created: 28/Jul/10 09:17 PM   Updated: 13/Mar/11 07:04 PM
Component/s: Generator
Affects Version/s: None
Fix Version/s: 2.0.0

Time Tracking:
Not Specified


 Description  « Hide
Reported in forum: http://old.nabble.com/Error-when-trying-to-publish-DomainEvent-in-model-td29286438s17564.html

@EmployeeHired recordHire(DateTime occurred, @Employee employee) publish to employeeChannel;

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Patrik Nordwall added a comment - 28/Jul/10 09:22 PM
The intention was that it should not be necessary to define eventType when return type or parameter is a DomainEvent.

A workaround until we fix the bug is to define the eventType excplicity:

@EmployeeHired recordHire(DateTime occurred, @Employee employee) publish EmployeeHired to employeeChannel;


Patrik Nordwall added a comment - 28/Jul/10 10:50 PM
The publish annotations for service operations are generated twice.

Patrik Nordwall added a comment - 28/Jul/10 10:53 PM
Previous workaround suggestion doesn't work.
A better workaround is to add the following to src/main/resources/templates/SpecialCases.xpt:

«REM»Workaround for CSC-535«ENDREM»
«AROUND templates::PubSub::publishAnnotation FOR Publish»
«ENDAROUND»

«REM»Workaround for CSC-535«ENDREM»
«AROUND templates::Service::serviceMethodAnnotation FOR ServiceOperation»
«targetDef.proceed()»
«IF publish != null»«EXPAND fixedPublishAnnotation FOR publish»«ENDIF-»
«ENDAROUND»

«REM»Workaround for CSC-535«ENDREM»
«DEFINE fixedPublishAnnotation FOR Publish»
«LET eventType == null ? null : eventType.getDomainPackage() + "." + eventType.name + ".class"
AS eventTypeClass-»
«formatAnnotationParameters("@" + fw("event.annotation.Publish"), {
eventTypeClass != null, "eventType", eventTypeClass,
topic != null, "topic", '"' + topic + '"',
eventBus != null, "eventBus", '"' + eventBus + '"'
    }) -»
«ENDLET-»
«ENDDEFINE»

Patrik Nordwall added a comment - 29/Jul/10 08:31 PM
Even better, add the following to src/main/resources/templates/SpecialCases.xpt:

«REM»Workaround for CSC-535«ENDREM»
«AROUND templates::PubSub::publishAnnotation FOR Publish»
«ENDAROUND»

«REM»Workaround for CSC-535«ENDREM»
«AROUND templates::Service::serviceMethodAnnotation FOR ServiceOperation»
«targetDef.proceed()»
«IF publish != null»«EXPAND fixedPublishAnnotation FOR publish»«ENDIF-»
«ENDAROUND»

«REM»Workaround for CSC-535«ENDREM»
«AROUND templates::Repository::repositoryMethodAnnotation FOR RepositoryOperation»
«targetDef.proceed()»
«IF publish != null»«EXPAND fixedPublishAnnotation FOR publish»«ENDIF-»
«ENDAROUND»

«REM»Workaround for CSC-535«ENDREM»
«DEFINE fixedPublishAnnotation FOR Publish»
«LET eventType == null ? null : eventType.getDomainPackage() + "." + eventType.name + ".class"
AS eventTypeClass-»
«formatAnnotationParameters("@" + fw("event.annotation.Publish"), {
eventTypeClass != null, "eventType", eventTypeClass,
topic != null, "topic", '"' + topic + '"',
eventBus != null, "eventBus", '"' + eventBus + '"'
    }) -»
«ENDLET-»
«ENDDEFINE»

Patrik Nordwall added a comment - 20/Jan/11 09:23 AM
Fixed (a long time ago)

Patrik Nordwall added a comment - 13/Mar/11 07:04 PM
Closed all 2.0.0 tickets