Search in sources :

Example 1 with Filter

use of org.omg.CosNotifyFilter.Filter in project ACS by ACS-Community.

the class ACSRemoteAccess method createFilter.

/**
	 * This method can not be used in the current implementation of ACS logging
	 * But it will be useful for archiving.
	 */
private void createFilter() {
    // create filter
    if (eventChannel == null)
        return;
    FilterFactory filterFactory = eventChannel.default_filter_factory();
    Filter filter = null;
    try {
        filter = filterFactory.create_filter("EXTENDED_TCL");
    } catch (InvalidGrammar e) {
        System.out.println("Invalid grammar in ACSRemoteAccess::createFilter(): " + e);
    }
    // create constaints
    try {
        ConstraintInfo[] info = filter.add_constraints(createConstraints());
    } catch (InvalidConstraint e) {
        System.out.println("Invalid constraint in ACSRemoteAccess::createFilter(): " + e);
    }
// add constraints to filter
}
Also used : ConstraintInfo(org.omg.CosNotifyFilter.ConstraintInfo) Filter(org.omg.CosNotifyFilter.Filter) InvalidGrammar(org.omg.CosNotifyFilter.InvalidGrammar) InvalidConstraint(org.omg.CosNotifyFilter.InvalidConstraint) FilterFactory(org.omg.CosNotifyFilter.FilterFactory)

Example 2 with Filter

use of org.omg.CosNotifyFilter.Filter 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 3 with Filter

use of org.omg.CosNotifyFilter.Filter 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 4 with Filter

use of org.omg.CosNotifyFilter.Filter in project ACS by ACS-Community.

the class Consumer method addFilter.

/**
	 * Adds a single filter to this consumer. With ALMA's use of IDL structs for
	 * ICD events, this method is no longer useful. May become deprecated in
	 * future ACS releases.
	 * 
	 * @return The filter ID of the newly created filter. This is only useful for
	 *         removing filters. Returns -1 on failure.
	 * @param structClassName
	 *           IDL struct Java class filter is to be applied to.
	 * @param filter
	 *           The filter string in extended trader constraint language.
	 * @throws AcsJException
	 *            Thrown if there is some CORBA problem (like the filter is not
	 *            using the correct grammar).
	 */
public int addFilter(Class<? extends IDLEntity> structClassName, String filter) throws AcsJException {
    String type = structClassName.getName().substring(structClassName.getName().lastIndexOf('.') + 1);
    try {
        FilterFactory t_filterFactory = m_channel.default_filter_factory();
        // create the filter
        Filter t_filter = t_filterFactory.create_filter(getFilterLanguage());
        EventType[] t_eType = { new EventType(getChannelDomain(), type) };
        ConstraintExp[] t_cexp = { new ConstraintExp(t_eType, filter) };
        t_filter.add_constraints(t_cexp);
        // add the filter to the proxy
        return m_proxySupplier.add_filter(t_filter);
    } catch (org.omg.CosNotifyFilter.InvalidGrammar e) {
        String msg = "'" + filter + "' filter is invalid for the '" + m_channelName + "' channel: ";
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(msg + e.getMessage());
    } catch (org.omg.CosNotifyFilter.InvalidConstraint e) {
        String msg = "'" + filter + "' filter is invalid for the '" + m_channelName + "' channel: ";
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(msg + e.getMessage());
    }
}
Also used : 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)

Aggregations

Filter (org.omg.CosNotifyFilter.Filter)4 EventType (org.omg.CosNotification.EventType)3 FilterFactory (org.omg.CosNotifyFilter.FilterFactory)3 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)2 ConstraintExp (org.omg.CosNotifyFilter.ConstraintExp)2 ConstraintInfo (org.omg.CosNotifyFilter.ConstraintInfo)2 InvalidEventType (org.omg.CosNotifyComm.InvalidEventType)1 FilterNotFound (org.omg.CosNotifyFilter.FilterNotFound)1 InvalidConstraint (org.omg.CosNotifyFilter.InvalidConstraint)1 InvalidGrammar (org.omg.CosNotifyFilter.InvalidGrammar)1