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());
}
}
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());
}
}
Aggregations