I realized that previous workaround suggestion doesn't work. 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»

Use the original definition
@EmployeeHired recordHire(DateTime occurred, @Employee employee) publish to
employeeChannel;

/Patrik


Patrik Nordwall wrote:
> 
> Thanks for reporting this bug.
> 
> 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; 
> 
> I have added jira: http://fornax.itemis.de/jira/browse/CSC-535
> and updated wiki doc (until we fix the bug).
> 
> /Patrik
> 
> 
> rsmith wrote:
>> 
>> I'm very interested in the event-driven additions in Sculptor 1.9.  I'm
>> getting an error when I try to have a service method publish a domain
>> event in the model.
>> 
>> 
>> Following is part of the model.  I get the error when I add 'recordHire'
>> to the model.
>> 
>>      Module employee {
>>      
>>              Service EmployeeService {
>>                      gap
>>                      
>>                      getEmployee delegates to EmployeeRepository.findByKey;
>>                      
>>                      @EmployeeHired recordHire(DateTime occurred, @Employee 
>> employee)
>> publish to employeeChannel;
>>              }
>> 
>>              Entity Employee {
>>                      aggregateRoot
>>                      gap
>>                      
>>                      - EmployeeId empId key;
>>              }
>> 
>> 
>>              DomainEvent EmployeeHired {
>>                      - @EmployeeId employee
>>              }
>>      }
>> 
>>      Module emplifecycle {
>>              
>>              Consumer EmployeeEventProcessor {
>>                      subscribe to employeeChannel
>>              }
>>      }
>> 
>> The error I'm getting when building:
>> 
>> 08:10:28,132  INFO CompositeComponent:100 - Generator(generator):
>> generating 'templates::Root::Root FOR transformedModel' =>
>> [TO_GEN_RESOURCES_TEST:src/test/generated/resources,
>> TO_GEN_SRC_TEST:src/test/generated/java,
>> TO_RESOURCES_TEST:src/test/resources(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_SRC_TEST:src/test/java(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_GEN_WEBROOT:src/main/webapp,
>> TO_RESOURCES:src/main/resources(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_SRC:src/main/java(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_WEBROOT:src/main/webapp(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_GEN_RESOURCES:src/generated/resources, src/generated/java]
>> 08:10:30,076 ERROR Generator:194 - Error in Component generator of type
>> org.eclipse.xpand2.Generator: 
>>         EvaluationException : Ambiguous operations String
>> getDomainPackage(Module module) and String getDomainPackage(DomainEvent
>> event) for param types [Void]
>>         templates::PubSub.xpt[920,28] on line 24
>> 'eventType.getDomainPackage()'                                               
>>                                                                        
>>         templates::Service.xpt[12425,44] on line 352 'EXPAND
>> PubSub::publishAnnotation FOR publish'                                       
>>                                                            
>>         templates::Service.xpt[10150,30] on line 311 'EXPAND
>> serviceMethodAnnotation'                                                     
>>                                                            
>>         templates::Service.xpt[8920,151] on line 275 'EXPAND implMethod
>> FOREACH
>> operations.select(op|op.delegate.==(null)&&op.serviceDelegate.==(null)).reject(e|e.hasHint("EventSourcingScaffold"))'
>>         templates::Service.xpt[1062,26] on line 33 'EXPAND
>> serviceImplSubclass'                                                         
>>                                                              
>>         templates::Root.xpt[1657,53] on line 40 'EXPAND Service::service
>> FOREACH getAllServices(false)'                                               
>>                                                
>>         [23,49] on line 1 'EXPAND templates::Root::Root FOR
>> transformedModel'                                                            
>>                                                             
>> 
>> 08:10:30,078 ERROR WorkflowRunner:423 - Workflow interrupted. Reason:
>> Ambiguous operations String getDomainPackage(Module module) and String
>> getDomainPackage(DomainEvent event) for param types [Void]
>> 08:10:30,078 ERROR WorkflowRunner:450 - [ERROR]: Ambiguous operations
>> String getDomainPackage(Module module) and String
>> getDomainPackage(DomainEvent event) for param types [Void](Element:
>> eventType.getDomainPackage(); Reported by: Generator(generator):
>> generating 'templates::Root::Root FOR transformedModel' =>
>> [TO_GEN_RESOURCES_TEST:src/test/generated/resources,
>> TO_GEN_SRC_TEST:src/test/generated/java,
>> TO_RESOURCES_TEST:src/test/resources(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_SRC_TEST:src/test/java(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_GEN_WEBROOT:src/main/webapp,
>> TO_RESOURCES:src/main/resources(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_SRC:src/main/java(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_WEBROOT:src/main/webapp(overwrite=false,append=false,fileEncoding=iso-8859-1),
>> TO_GEN_RESOURCES:src/generated/resources, src/generated/java])
>> ...
>> ...
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Error-when-trying-to-publish-DomainEvent-in-model-tp29286438s17564p29290863.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to