Skip to main content

Re: AttributeStore and Listeners.

  • From: binod pg < >
  • To:
  • Subject: Re: AttributeStore and Listeners.
  • Date: Tue, 05 Nov 2013 17:35:26 +0530
  • Organization: Oracle Corporation

Hi Tom,

I have been thinking about it too. If this sounds attractive, then may be containers
can do a reflection trickery to find the generic type information?

For example, if a class like the one below this mail is annotated with SipListener, container
can retrieve the type parameter  using reflection, right?

        for (Type type : MyListener.class.getGenericInterfaces()) {
            if (type instanceof ParameterizedType) {
                ParameterizedType pt = (ParameterizedType) type;
                if (AttributeStoreListener.class.equals(pt.getRawType())) {
if (SipApplicationSession.class.equals(pt.getActualTypeArguments()[0])) {
                        //Invoke event?
                    }
                }
            }
        }


thanks,
Binod.

@SipListener
public class MyListener implements AttributeStoreListener<SipApplicationSession> {

    @Override
public void attributeAdded(AttributeStoreBindingEvent<SipApplicationSession> ev) {
        System.out.print(ev.getName() + "--" + ev.getAttributeStore());
    }

    @Override
public void attributeRemoved(AttributeStoreBindingEvent<SipApplicationSession> ev) {
    }

    @Override
public void attributeReplaced(AttributeStoreBindingEvent<SipApplicationSession> ev) {
    }
}



On 11/5/2013 5:04 PM, Tom Strickland wrote:
After chatting about this briefly with Keith...

This seems like an attractive idea, but don't we lose the generic-type information at runtime? If so, how will the container tell that a class implementing AttributeStoreListener<SipSession> is interested in SipSession-related events?

Tom


On 5 November 2013 09:43, binod pg < <mailto: >> wrote:

    Hi everyone,

    At the moment, for SipSession and SipApplicationSession, there are
    two sets of attribute listeners

    SipSessionBindingListener
    SipSessionAttributeListener
    SipApplicationSessionBindingListener
    SipApplicationSessionAttributeListener

    With the new AttributeStores like ForkingContext (SipCall), we
    probably have more of these listeners.

    Would the following more generic listeners make sense instead?
                  AttributeStoreBindingEvent<T extends AttributeStore>,
                  AttributeStoreBindlingListener<T extends
    AttributeStore>,
                  AttributeStoreListener<T extends AttributeStore>,

    And deprecate the specific listeners for SipSession and SAS?

    thanks,
    Binod.



--------------------

Note: The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. CafeX Communications.




AttributeStore and Listeners.

binod pg 11/05/2013

Re: AttributeStore and Listeners.

Tom Strickland 11/05/2013

Re: AttributeStore and Listeners.

binod pg 11/05/2013

Re: AttributeStore and Listeners.

Tom Strickland 11/05/2013
 
 
Close
loading
Please Confirm
Close