Using an Event Type Builder Factory

2-22 Oracle Complex Event Processing Developers Guide } static class ForeignExchangeBuilder implements EventBuilder { private MapString,Object values = new HashMapString,Object10; public Object createEvent { return new ForeignExchangeEvent String values.getsymbol, Double values.getprice, String values.getfromRate, String values.gettoRate; } public void putString property, Object value throws IllegalStateException { values.putproperty, value; } } } When you register the event type in the EPN assembly file, use the wlevs:property name=builderFactory child element of the wlevs:event-type element to specify the name of the factory class. The hard-coded builderFactory value of the name attribute alerts Oracle CEP that it should use the specified factory class, rather than its own default factory, when creating instances of this event. For example, in the FX example, the builder factory is registered as shown in bold: wlevs:event-type-repository wlevs:event-type type-name=ForeignExchangeEvent wlevs:classcom.bea.wlevs.example.fx.OutputBeanForeignExchangeEventwlevs:class wlevs:property name=builderFactory bean id=builderFactory class=com.bea.wlevs.example.fx.ForeignExchangeBuilderFactory wlevs:property wlevs:event-type wlevs:event-type-repository

2.7 Accessing the Event Type Repository

The EventTypeRepository is a singleton OSGi service. Because it is a singleton, you only need to specify its interface name to identify it. You can get a service from OSGi in any of the following ways: ■ Section 2.7.1, Using the EPN Assembly File ■ Section 2.7.2, Using the Spring-DM ServiceReference Annotation ■ Section 2.7.3, Using the Oracle CEP Service Annotation For more information, see Oracle Fusion Middleware Java API Reference for Oracle Complex Event Processing.

2.7.1 Using the EPN Assembly File

You can access the EventTypeRepository by specifying an osgi:reference in the EPN assembly file as Example 2–15 shows. Example 2–15 EPN Assembly File With OSGi Reference to EventTypeRepository osgi:reference id=etr interface=com.bea.wlevs.ede.api.EventTypeRepository bean id=outputBean class=com.acme.MyBean property name=eventTypeRepository ref=etr bean Overview of Oracle CEP Events 2-23 Then, in the MyBean class, you can access the EventTypeRepository using the eventTypeRepository property initialized by Spring as Example 2–16 shows. Example 2–16 Accessing the EventTypeRepository in the MyBean Implementation