Search in sources :

Example 1 with EventType

use of org.omg.CosNotification.EventType in project ACS by ACS-Community.

the class NCSubscriber method addFilter.

/**
	 * This method manages the filtering capabilities used to control subscriptions.
	 * <p>
	 * A constraint evaluates to true when both of the following conditions are true:
	 *   A member of the constraint's EventTypeSeq matches the message's event type.
	 *   The constraint expression evaluates to true.
	 * 
	 * @return FilterID (see OMG NotificationService spec 3.2.4.1)
	 * @throws AcsJCORBAProblemEx
	 */
protected int addFilter(String eventTypeName) throws AcsJCORBAProblemEx {
    try {
        // Create the filter
        FilterFactory filterFactory = channel.default_filter_factory();
        Filter filter = filterFactory.create_filter(getFilterLanguage());
        // Information needed to construct the constraint expression object
        // (any domain, THE event type)
        // Note that TAO will internally convert the event type name 
        // to the expression "$type_name=='<our_eventTypeName>'", 
        // see orbsvcs/Notify/Notify_Constraint_Interpreter.cpp
        // The old Consumer class used 'getChannelDomain()' instead of "*"..?
        EventType[] t_info = { new EventType("*", eventTypeName) };
        // Add constraint expression object to the filter
        // no constraints other than the eventTypeName already given above
        String constraint_expr = "";
        ConstraintExp[] cexp = { new ConstraintExp(t_info, constraint_expr) };
        filter.add_constraints(cexp);
        // Add the filter to the proxy and return the filter ID
        int filterId = proxySupplier.add_filter(filter);
        if (logger.isLoggable(AcsLogLevel.DELOUSE)) {
            NcFilterInspector insp = new NcFilterInspector(proxySupplier, channelName + "::" + clientName + "::ProxySupplier", logger);
            logger.log(AcsLogLevel.DELOUSE, "Added filter for '" + eventTypeName + "'. Current " + insp.getFilterInfo());
        //				NcFilterInspector insp2 = new NcFilterInspector(
        //						sharedConsumerAdmin, channelName + "::" + clientName + "::Admin", logger);
        //				logger.log(AcsLogLevel.DEBUG, "Admin filters: " + insp2.getFilterInfo());
        }
        return filterId;
    } catch (org.omg.CosNotifyFilter.InvalidGrammar e) {
        Throwable cause = new Throwable("'" + eventTypeName + "' filter is invalid for the '" + channelName + "' channel: " + e.getMessage());
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
    } catch (org.omg.CosNotifyFilter.InvalidConstraint e) {
        Throwable cause = new Throwable("'" + eventTypeName + "' filter is invalid for the '" + channelName + "' channel: " + e.getMessage());
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(cause);
    }
}
Also used : InvalidEventType(org.omg.CosNotifyComm.InvalidEventType) EventType(org.omg.CosNotification.EventType) ConstraintExp(org.omg.CosNotifyFilter.ConstraintExp) FilterFactory(org.omg.CosNotifyFilter.FilterFactory) Filter(org.omg.CosNotifyFilter.Filter) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)

Example 2 with EventType

use of org.omg.CosNotification.EventType in project ACS by ACS-Community.

the class NcFilterInspector method getFilterInfo.

public String getFilterInfo() {
    String ret = "NC filter info for '" + serverObjectName + "' ";
    int[] filterIds = serverObject.get_all_filters();
    ret += "(" + filterIds.length + " filters total): ";
    for (int filterId : filterIds) {
        ret += "{ filterId=" + filterId + "; ";
        try {
            Filter f = serverObject.get_filter(filterId);
            String grammarName = f.constraint_grammar();
            ret += "grammar=" + grammarName + "; ";
            ret += "constraints: { ";
            for (ConstraintInfo ci : f.get_all_constraints()) {
                String cExp = ci.constraint_expression.constraint_expr;
                ret += "expr=" + cExp + "; ";
                for (EventType eT : ci.constraint_expression.event_types) {
                    String typeName = eT.type_name;
                    ret += "type=" + typeName + "; ";
                    String domainName = eT.domain_name;
                    ret += "domain=" + domainName + "; ";
                }
            }
            ret += "}; ";
        } catch (FilterNotFound ex) {
            ret += "FilterNotFound!";
        }
        ret += "}; ";
    }
    return ret;
}
Also used : ConstraintInfo(org.omg.CosNotifyFilter.ConstraintInfo) Filter(org.omg.CosNotifyFilter.Filter) EventType(org.omg.CosNotification.EventType) FilterNotFound(org.omg.CosNotifyFilter.FilterNotFound)

Example 3 with EventType

use of org.omg.CosNotification.EventType in project ACS by ACS-Community.

the class StructuredEventCreator method getCORBAEvent.

/**
	 * Method used to create a pre-filled CORBA event.
	 * 
	 * @param typeName
	 *           The structured event's type_name.
	 * @param eventName
	 *           Name of the event.
	 * @return A pre-filled CORBA event.
	 */
private StructuredEvent getCORBAEvent(String typeName, String eventName) {
    // return value
    StructuredEvent event = new StructuredEvent();
    // event.header.fixed_header.event_type
    String channelDomain = alma.acscommon.ALMADOMAIN.value;
    EventType event_type = new EventType(channelDomain, typeName);
    //
    FixedEventHeader fixed_header = new FixedEventHeader(event_type, eventName);
    // event.header.variable_header
    Property[] variable_header = new Property[0];
    // event.header
    event.header = new EventHeader(fixed_header, variable_header);
    return event;
}
Also used : EventType(org.omg.CosNotification.EventType) StructuredEvent(org.omg.CosNotification.StructuredEvent) FixedEventHeader(org.omg.CosNotification.FixedEventHeader) FixedEventHeader(org.omg.CosNotification.FixedEventHeader) EventHeader(org.omg.CosNotification.EventHeader) Property(org.omg.CosNotification.Property)

Example 4 with EventType

use of org.omg.CosNotification.EventType in project ACS by ACS-Community.

the class NCPublisher method getCORBAEvent.

/**
	 * Method used to create a pre-filled CORBA event.
	 * 
	 * @param typeName
	 *            The structured event's type_name.
	 * @param eventName
	 *            Name of the event.
	 * @return A pre-filled CORBA event.
	 */
protected StructuredEvent getCORBAEvent(String typeName, String eventName) {
    // return value
    StructuredEvent event = new StructuredEvent();
    // event.header.fixed_header.event_type
    String channelDomain = alma.acscommon.ALMADOMAIN.value;
    EventType event_type = new EventType(channelDomain, typeName);
    FixedEventHeader fixed_header = new FixedEventHeader(event_type, eventName);
    // event.header.variable_header
    Property[] variable_header = new Property[0];
    // event.header
    event.header = new EventHeader(fixed_header, variable_header);
    return event;
}
Also used : InvalidEventType(org.omg.CosNotifyComm.InvalidEventType) EventType(org.omg.CosNotification.EventType) StructuredEvent(org.omg.CosNotification.StructuredEvent) FixedEventHeader(org.omg.CosNotification.FixedEventHeader) FixedEventHeader(org.omg.CosNotification.FixedEventHeader) EventHeader(org.omg.CosNotification.EventHeader) Property(org.omg.CosNotification.Property)

Example 5 with EventType

use of org.omg.CosNotification.EventType in project ACS by ACS-Community.

the class Consumer method addSubscription.

/**
	 * Add a subscription to a given (IDL struct) Java class. Use this method
	 * only when Consumer has been subclassed and processEvent overridden.
	 * 
	 * @param structClass
	 *           Type of event to subscribe to (i.e., alma.CORR.DataStruct.class).
	 *           If <code>null</code> then all events are subscribed.
	 * @throws AcsJEventSubscriptionFailureEx
	 *            Thrown if the subscription failed.
	 */
public void addSubscription(Class<? extends IDLEntity> structClass) throws AcsJEventSubscriptionFailureEx {
    String type = "*";
    String domain = "*";
    if (structClass != null) {
        type = structClass.getSimpleName();
        // "ALMA"
        domain = getChannelDomain();
    }
    try {
        // Subscribe to events
        EventType[] added = { new EventType(domain, type) };
        EventType[] removed = {};
        // really subscribe to the events
        m_consumerAdmin.subscription_change(added, removed);
    } catch (Throwable thr) {
        // org.omg.CosNotifyComm.InvalidEventType or other
        AcsJEventSubscriptionFailureEx ex = new AcsJEventSubscriptionFailureEx(thr);
        ex.setChannelName(m_channelName);
        ex.setEventName(type);
        throw ex;
    }
}
Also used : EventType(org.omg.CosNotification.EventType) AcsJEventSubscriptionFailureEx(alma.acsncErrType.wrappers.AcsJEventSubscriptionFailureEx)

Aggregations

EventType (org.omg.CosNotification.EventType)7 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)3 Filter (org.omg.CosNotifyFilter.Filter)3 EventHeader (org.omg.CosNotification.EventHeader)2 FixedEventHeader (org.omg.CosNotification.FixedEventHeader)2 Property (org.omg.CosNotification.Property)2 StructuredEvent (org.omg.CosNotification.StructuredEvent)2 InvalidEventType (org.omg.CosNotifyComm.InvalidEventType)2 ConstraintExp (org.omg.CosNotifyFilter.ConstraintExp)2 FilterFactory (org.omg.CosNotifyFilter.FilterFactory)2 AcsJJavaAnyEx (alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx)1 AcsJEventSubscriptionFailureEx (alma.acsncErrType.wrappers.AcsJEventSubscriptionFailureEx)1 ConstraintInfo (org.omg.CosNotifyFilter.ConstraintInfo)1 FilterNotFound (org.omg.CosNotifyFilter.FilterNotFound)1