Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues

Bug 989

Summary: Notification Service filter
Product: JacORB Reporter: zhangtao <dlh.zhangtao>
Component: Notification ServiceAssignee: Alphonse Bendt <pho.lst>
Status: NEW ---    
Severity: major CC: dlh.zhangtao, jacorb
Priority: P5    
Version: 3.4   
Hardware: PC   
OS: Linux   
Attachments: notification service as server push_consumer
redefineSeverityAny picture
notifIdAny picture

Description zhangtao 2014-06-24 23:45:25 CEST
Created attachment 441 [details]
notification service    as  server   push_consumer

1、set notification service filter for example :
     <constrainList>
    <org.omg.CosNotifyFilter.ConstraintExp>
      <event__types>
        <org.omg.CosNotification.EventType>
          <domain__name>TMN</domain__name>
          <type__name>*</type__name>
        </org.omg.CosNotification.EventType>
      </event__types>
      <constraint__expr>( $severity == 5 )</constraint__expr>
    </org.omg.CosNotifyFilter.ConstraintExp>
  </constrainList>
2、java programe for example:  

   int redefineSeverity = 5;
   Any redefineSeverityAny = getOrb().create_any();
  // redefineSeverityAny.insert_long(redefineSeverity);
	SeverityTypeHelper.insert(redefineSeverityAny,SeverityType.from_int(redefineSeverity));
     alarmNotifyEvent.filterable_data[6] = new Property("severity", redefineSeverityAny);
   
  SeverityTypeHelper.class   by IDL for example :

   package npInterface;
/**
 * Generated from IDL enum "SeverityType".
 *
 * @author JacORB IDL compiler V 3.4
 * @version generated at 2014-4-9 15:58:20
 */

public abstract class SeverityTypeHelper
{
	private volatile static org.omg.CORBA.TypeCode _type;
	public static org.omg.CORBA.TypeCode type ()
	{
		if (_type == null)
		{
			synchronized(SeverityTypeHelper.class)
			{
				if (_type == null)
				{
					_type = org.omg.CORBA.ORB.init().create_enum_tc(npInterface.SeverityTypeHelper.id(),"SeverityType",new String[]{"CLEARED","INDETERMINATED","WARNING","MINOR","MAJOR","CRITICAL"});
				}
			}
		}
		return _type;
	}

	public static void insert (final org.omg.CORBA.Any any, final npInterface.SeverityType s)
	{
		any.type(type());
		write( any.create_output_stream(),s);
	}

	public static npInterface.SeverityType extract (final org.omg.CORBA.Any any)
	{
		org.omg.CORBA.portable.InputStream in = any.create_input_stream();
		try
		{
			return read (in);
		}
		finally
		{
			try
			{
				in.close();
			}
			catch (java.io.IOException e)
			{
			throw new RuntimeException("Unexpected exception " + e.toString() );
			}
		}
	}

	public static String id()
	{
		return "IDL:npInterface/SeverityType:1.0";
	}
	public static SeverityType read (final org.omg.CORBA.portable.InputStream in)
	{
		return SeverityType.from_int(in.read_long());
	}

	public static void write (final org.omg.CORBA.portable.OutputStream out, final SeverityType s)
	{
		out.write_long(s.value());
	}
}
////////////////////////////////////////
  SeverityType.class by IDL  for example :

   package npInterface;
/**
 * Generated from IDL enum "SeverityType".
 *
 * @author JacORB IDL compiler V 3.4
 * @version generated at 2014-4-9 15:58:20
 */

public final class SeverityType
	implements org.omg.CORBA.portable.IDLEntity
{
	/** Serial version UID. */
	private static final long serialVersionUID = 1L;
	private int value = -1;
	public static final int _CLEARED = 0;
	public static final SeverityType CLEARED = new SeverityType(_CLEARED);
	public static final int _INDETERMINATED = 1;
	public static final SeverityType INDETERMINATED = new SeverityType(_INDETERMINATED);
	public static final int _WARNING = 2;
	public static final SeverityType WARNING = new SeverityType(_WARNING);
	public static final int _MINOR = 3;
	public static final SeverityType MINOR = new SeverityType(_MINOR);
	public static final int _MAJOR = 4;
	public static final SeverityType MAJOR = new SeverityType(_MAJOR);
	public static final int _CRITICAL = 5;
	public static final SeverityType CRITICAL = new SeverityType(_CRITICAL);
	public int value()
	{
		return value;
	}
	public static SeverityType from_int(int value)
	{
		switch (value) {
			case _CLEARED: return CLEARED;
			case _INDETERMINATED: return INDETERMINATED;
			case _WARNING: return WARNING;
			case _MINOR: return MINOR;
			case _MAJOR: return MAJOR;
			case _CRITICAL: return CRITICAL;
			default: throw new org.omg.CORBA.BAD_PARAM();
		}
	}
	public String toString()
	{
		switch (value) {
			case _CLEARED: return "CLEARED";
			case _INDETERMINATED: return "INDETERMINATED";
			case _WARNING: return "WARNING";
			case _MINOR: return "MINOR";
			case _MAJOR: return "MAJOR";
			case _CRITICAL: return "CRITICAL";
			default: throw new org.omg.CORBA.BAD_PARAM();
		}
	}
	protected SeverityType(int i)
	{
		value = i;
	}
	/**
	 * Designate replacement object when deserialized from stream. See
	 * http://www.omg.org/docs/ptc/02-01-03.htm#Issue4271
	 *
	 * @throws java.io.ObjectStreamException
	 */
	java.lang.Object readResolve()
	throws java.io.ObjectStreamException
	{
		return from_int(value());
	}
}

Quesstion:

(1)run : ntfy -port 9001
(2)run : java programe
then: 
ntfy find error for example :

zhangtao@zhangtao-Lenovo-V480:~$ ntfy -port 9001
INFO Initialising ORB with ID: 
INFO InterceptorManager started with 0 Server Interceptors, 0 Client Interceptors and 1 IOR Interceptors
INFO oid: 5F 45 43 46 61 63 74 6F 72 79                               _ECFactoryobject is activated
INFO Using server ID (2358635612) for transient POA
INFO ClientConnectionManager: created new ClientGIOPConnection to 10.31.4.7:9001 (53c04c06)
INFO ORB run
INFO Opened new server-side TCP/IP transport to 10.31.4.7:54449
INFO EventReliability=BestEffort
INFO ConnectionReliability=BestEffort
INFO oid: 00 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO Using server ID (2358635612) for transient POA
INFO oid: 01 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO set MaxNumberOfConsumers=0
INFO set MaxNumberOfSuppliers=0
INFO oid: 02 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO oid: 03 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO create TaskProcessor
INFO set Error Threshold to : 3
INFO oid: 04 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO ClientConnectionManager: found ClientGIOPConnection to 10.31.4.7:9001 (53c04c06)
INFO Created filter for Grammar: EXTENDED_TCL
INFO oid: 05 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO ClientConnectionManager: found ClientGIOPConnection to 10.31.4.7:9001 (53c04c06)
INFO set QoS: StartTimeSupported=true
INFO set QoS: StopTimeSupported=true
INFO set QoS: StartTimeSupported=true
INFO set QoS: StopTimeSupported=true
INFO oid: 06 01 2B 46 49 4B 40 3C 24 24 3D 07 1F 1F 2A 46 24 28 1F    ..+FIK@<$$=...*F$(.object is activated
INFO ClientConnectionManager: found ClientGIOPConnection to 10.31.4.7:9001 (53c04c06)
INFO connect sequence_push_supplier
WARNING unexpected error during match. match result defaults to false
java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy1.match_structured(Unknown Source)
	at org.omg.CosNotifyFilter.FilterPOATie.match_structured(FilterPOATie.java:82)
	at org.omg.CosNotifyFilter._FilterStub.match_structured(_FilterStub.java:554)
	at org.jacorb.notification.StructuredEventMessage.match(StructuredEventMessage.java:263)
	at org.jacorb.notification.AbstractMessage.match(AbstractMessage.java:553)
	at org.jacorb.notification.AbstractMessage$MessageHandle.match(AbstractMessage.java:241)
	at org.jacorb.notification.engine.FilterProxySupplierTask.filter(FilterProxySupplierTask.java:221)
	at org.jacorb.notification.engine.FilterProxySupplierTask.doFilter(FilterProxySupplierTask.java:117)
	at org.jacorb.notification.engine.AbstractFilterTask.doWork(AbstractFilterTask.java:76)
	at org.jacorb.notification.engine.AbstractTask.run(AbstractTask.java:63)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.jacorb.notification.filter.AbstractFilterUsageDecorator$FilterInvocationHandler.invoke(AbstractFilterUsageDecorator.java:58)
	... 13 more
Caused by: org.omg.CORBA.BAD_OPERATION: Cannot extract long
	at org.jacorb.orb.Any.checkExtract(Any.java:118)
	at org.jacorb.orb.Any.extract_long(Any.java:372)
	at org.jacorb.notification.filter.EvaluationResult.getLong(EvaluationResult.java:255)
	at org.jacorb.notification.filter.EvaluationResult.compareTo(EvaluationResult.java:451)
	at org.jacorb.notification.filter.etcl.EqOperator.evaluate(EqOperator.java:44)
	at org.jacorb.notification.filter.etcl.BinaryOperator.evaluate(BinaryOperator.java:46)
	at org.jacorb.notification.filter.etcl.UnaryOperator.evaluate(UnaryOperator.java:43)
	at org.jacorb.notification.filter.etcl.ETCLFilterConstraint.evaluate(ETCLFilterConstraint.java:92)
	at org.jacorb.notification.filter.AbstractFilter.match_NoLock(AbstractFilter.java:707)
	at org.jacorb.notification.filter.AbstractFilter.match_ReadLock(AbstractFilter.java:688)
	at org.jacorb.notification.filter.AbstractFilter.match_structured_internal(AbstractFilter.java:795)
	at org.jacorb.notification.filter.AbstractFilter.match_structured(AbstractFilter.java:776)
	... 18 more


   
Now : I can sure the quesstion is "SeverityTypeHelper.insert(redefineSeverityAny,SeverityType.from_int(redefineSeverity));"

I hope anyone give some help!!!
Comment 1 Nick Cross 2014-06-25 05:41:32 CEST
Can you not use redefineSeverityAny.insert_long(redefineSeverity) ?
Comment 2 zhangtao 2014-06-25 06:10:25 CEST
(In reply to Nick Cross from comment #1)
> Can you not use redefineSeverityAny.insert_long(redefineSeverity) ?

yes, i Can't use it , this is my server service, other client service must use 

SeverityTypeHelper.insert(redefineSeverityAny,SeverityType.from_int(redefineSeverity));

because ,my client service use the enum value!
Comment 3 Nick Cross 2014-06-25 07:26:17 CEST
I don't quite follow your problem. You already have the int looking at your code so just insert it ?
Comment 4 zhangtao 2014-06-25 20:27:32 CEST
(In reply to Nick Cross from comment #3)
> I don't quite follow your problem. You already have the int looking at your
> code so just insert it ?

so,my server service running is ok. but, one date input it,the notification service just error so that. and founed it in java founction such as :

public boolean push_structured_events(StructuredEvent[] dataReadyEvent ){
		if (!isConnectStatus()){
			return false;
		}
		try {
			getSequenceProxyPushConsumer().push_structured_events(dataReadyEvent);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

now ,my Any Object if insert_long or insert_string is no problem. just enmu Object error appeared!
Comment 5 zhangtao 2014-06-25 20:55:28 CEST
Created attachment 442 [details]
redefineSeverityAny  picture

int redefineSeverity = (Integer) alarmMap.get("redefine_severity");

Any redefineSeverityAny = getOrb().create_any();

SeverityTypeHelper.insert(redefineSeverityAny,SeverityType.from_int(redefineSeverity));

alarmNotifyEvent.filterable_data[6] = new Property("severity", redefineSeverityAny);
Comment 6 zhangtao 2014-06-25 21:09:16 CEST
Created attachment 443 [details]
notifIdAny  picture

int notificationId = (Integer) alarmMap.get("notification_id");
Any notifIdAny = getOrb().create_any();
NotifIdTypeHelper.insert(notifIdAny, notificationId);
alarmNotifyEvent.filterable_data[0] = new Property("notificationId", notifIdAny);

this is long type!  is  ok!