Search in sources :

Example 6 with EventType

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

the class Consumer method removeSubscription.

/**
	 * Remove a subscription from this consumer. After invoking this, events of
	 * the parameter's type will no longer be received.
	 * 
	 * @param structClassName
	 *           Unsubscribes from this IDL struct (Java class). By passing in
	 *           null here, no events of any type will be received.
	 * @throws AcsJException
	 *            Thrown if there is some CORBA problem (like this consumer has
	 *            never subscribed to the IDL struct).
	 */
public void removeSubscription(Class structClass) throws AcsJException {
    String type = "*";
    String domain = "*";
    // If the developer is not unsubscribing from everything...
    if (structClass != null) {
        // get the type/domain to unsubscribe from
        type = structClass.getName().substring(structClass.getName().lastIndexOf('.') + 1);
        domain = getChannelDomain();
        // Remove the handler function if there is one...
        synchronized (m_handlerFunctions) {
            if (m_handlerFunctions.containsKey(structClass.getName())) {
                // remove the subscription from the hash
                m_handlerFunctions.remove(structClass.getName());
            } else {
                throw new AcsJJavaAnyEx("Unsubscribing from '" + structClass.getName() + "' type of event when not actually subscribed to this type.");
            }
        }
    } else // they're removing all subscriptions so let's clear the hash
    {
        m_handlerFunctions.clear();
    }
    try {
        // Unsubscribe to events
        EventType[] added = {};
        EventType[] removed = { new EventType(domain, type) };
        // really unsubscribe from events
        m_consumerAdmin.subscription_change(added, removed);
    } catch (org.omg.CosNotifyComm.InvalidEventType e) {
        String msg = "'" + type + "' event type is invalid for the '" + m_channelName + "' channel: ";
        throw new alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx(msg + e.getMessage());
    }
}
Also used : AcsJJavaAnyEx(alma.ACSErrTypeJavaNative.wrappers.AcsJJavaAnyEx) EventType(org.omg.CosNotification.EventType) AcsJCORBAProblemEx(alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)

Example 7 with EventType

use of org.omg.CosNotification.EventType 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

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