Posted By:
Alex_Visseq
Posted On:
Friday, October 24, 2003 01:54 AM
How to apply a filter for each event of a sequence ? I try to push an event sequence (org.omg.CosNotification.StructuredEvent[] events) from a PushSupplier to a consumer, using the org.omg.CosNotifyFilter API. My example consists in pushing events with different header type names, and filter them on this header type name. Here are the code lines : public org.omg.CosNotification.StructuredEvent[] createEvents() { org.omg.CosNotification.StructuredEvent[] batched = new org.omg.CosNotification.StructuredEvent[4]; for (int i = 0 ; i < 4 ; i++) { batched[i] = new org.omg.CosNotification.StructuredEvent(); batched[i].header = new EventH
More>>
How to apply a filter for each event of a sequence ?
I try to push an event sequence (org.omg.CosNotification.StructuredEvent[] events) from a PushSupplier to a consumer, using the org.omg.CosNotifyFilter API. My example consists in pushing events with different header type names, and filter them on this header type name. Here are the code lines :
public org.omg.CosNotification.StructuredEvent[] createEvents()
{
org.omg.CosNotification.StructuredEvent[] batched = new org.omg.CosNotification.StructuredEvent[4];
for (int i = 0 ; i
< 4 ; i++)
{
batched[i] = new org.omg.CosNotification.StructuredEvent();
batched[i].header = new EventHeader();
batched[i].header.fixed_header = new FixedEventHeader();
batched[i].header.fixed_header.event_type = new EventType();
batched[i].header.fixed_header.event_type.domain_name = "domain";
switch (i)
{
case 0:
batched[i].header.fixed_header.event_type.type_name = "Music";
break;
case 1:
batched[i].header.fixed_header.event_type.type_name = "Training";
break;
case 2:
batched[i].header.fixed_header.event_type.type_name = "Tennis";
break;
case 3:
batched[i].header.fixed_header.event_type.type_name = "Training";
break;
default:
break;
}
batched[i].header.fixed_header.event_name = "";
batched[i].header.variable_header = new Property[0];
batched[i].filterable_data = new Property[1];
batched[i].filterable_data[0] = new Property();
batched[i].filterable_data[0].name = "Story";
batched[i].filterable_data[0].value = orb.create_any();
batched[i].filterable_data[0].value.insert_string("My filterable data");
batched[i].remainder_of_body = orb.create_any();
}
return batched;
}
Here is the filter defined in the consumer :
org.omg.CosNotifyFilter.FilterFactory filter_factory = _channel.default_filter_factory();
org.omg.CosNotifyFilter.Filter filter = filter_factory.create_filter("EXTENDED_TCL");
ConstraintExp constraints[] = new ConstraintExp[1];
constraints[0] = new ConstraintExp();
constraints[0].event_types = new EventType[1];
constraints[0].event_types[0] = new EventType();
constraints[0].event_types[0].domain_name = "domain";
constraints[0].event_types[0].type_name = "Training";
constraints[0].constraint_expr = "";
filter.add_constraints(constraints);
_supplier.add_filter(filter);
My problem is that either the first event in the sequence respect the filter, and all the sequence is pushed, either it does not respect the filter, and nothing is pushed. I would like to push only events which respect the filter into the sequence. Is it possible ?
Thanks
Alex
<<Less