Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  /*
   *  DDS (Data Distribution Service) for JacORB
   *
   * Copyright (C) 2005-2012 Gerald Brose / The JacORB Team.
   allaoui <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.
  *
  * Coontact: Ahmed yehdih <ahmed.yehdih@gmail.com>, fouad allaoui
  <fouad.allaoui@gmail.com>, Didier Donsez (didier.donsez@ieee.org)
  * Contributor(s):
  *
  **/
 
 package org.jacorb.dds;
 
 
 
 public class ThreadSubscriber extends Thread  implements PushConsumerOperations{   
         
     private  EventChannel ecs ;
     private ConsumerAdmin ca ;
     private PushConsumer pushConsumer ;
     private ProxyPushSupplier pps ;
     private  org.omg.PortableServer.POA poa ;
     private Vector references_domaines_participant     ;
     private NamingContextExt nc ;
     //all subscriber interested of topic 
     private Vector  all_Sub ;
     private Topic topic ;
     private  org.omg.CORBA.ORB orb = null;
     
     public ThreadSubscriberorg.omg.CORBA.ORB orb , org.omg.PortableServer.POA   poa )
     {
          = null;
          = null;
          = null;
          = null;
          = new Vector();
          = new Vector();
         
         try
         {                       
             this. = orb;
             this. = poa;
             NamingContextExt nc =  NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
              = EventChannelHelper.narrow(nc.resolve(nc.to_name("eventchannel")));
         }
         catch(Exception e)
         {
             e.printStackTrace();
         }
         
           = .for_consumers();
          = .obtain_push_supplier();             
     }   
     
     public void disconnect_push_consumer(){
         ..println("Consumer disconnected.");
     }
     
     public   void run  (){
         
         try 
         {
            PushConsumerPOATie pt = new PushConsumerPOATiethis);
            pt._this_object();
             = PushConsumerHelper.narrow(.servant_to_reference(pt) );
            .connect_push_consumer );
            ..println("PushConsumerImpl registered.");
            .run();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }        
        
        ..println("Quit.");
    }
    
    /*
     * lookup the interested dataReader   by topic name 
     */
    public void Lookup_Sub_interesded_of_topic(String topic_name){
        
        org.omg.dds.DomainParticipant  domain_temp ;
        DomainParticipantImpl domain_impl ;
        Subscriber sub_temp ;
        SubscriberImpl sub_impl ;
        Iterator _it_DomainParticipant = .iterator();
        Iterator _it_Subscriber ;
        
        while(_it_DomainParticipant.hasNext()){
            
            try{
                domain_temp = (DomainParticipant)_it_DomainParticipant.next();
                domain_impl =(DomainParticipantImpl.reference_to_servant(domain_temp);
                _it_Subscriber = domain_impl.getVector_Subscriber().iterator() ;
                
                while(_it_Subscriber.hasNext()){                    
                    sub_temp =  (Subscriber_it_Subscriber.next();
                    if(sub_temp.lookup_datareader(topic_name) != null){                        
                        .add(sub_temp);                    
                    }                    
                }
            }
            catch(Exception e){
                ..println("Exception "+e);
                e.printStackTrace();
            }
        }	               
    }
    
    public synchronized void push(org.omg.CORBA.Any data)
    {
        
        Object instance = null  ;
        boolean is_topicfalse ;
        boolean is_instance = false ;
        Subscriber sub_temp ;
        SubscriberImpl sub_impl_temp ;
        DataReader DR ;
        Class typehelper = null ;
        Class  type_param_extract [] = new Class [1 ];
        java.lang.Object valu_param_extract[] = new java.lang.Object[1];
        Iterator It ;
        
        if(data.type().equal(TopicHelper.type()))
        {                        
            is_topic = true ;
             = TopicHelper.extract(data) ;           
        }
        else 
        {            
            is_instance = true ;
            valu_param_extract[0] = data ;
            type_param_extract[0] = Any.class ;
            
            try{
                typehelper  = ObjectUtil.classForName(.get_type_name()+"Helper") ;
                Method extract = typehelper.getMethod("extract",type_param_extract);
                instance = extract.invoke(null ,valu_param_extract);
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }          
        }
        
        if(is_topic){            
            Lookup_Sub_interesded_of_topic(.get_name());           
        }
        else ifis_instance)
        {           
            try{                
                It = .iterator() ;
                while(It.hasNext()){
                    sub_temp = (Subscriber)It.next() ;
                    sub_impl_temp = (SubscriberImpl).reference_to_servant(sub_temp);
                    sub_impl_temp.setInstance(instance);                    
                    DR = sub_temp.lookup_datareader(.get_name());                    
                    DR.take_instance_from_subscriber() ;
                    
                    if(DR.get_listener()!= null ){                        
                        DR.get_listener().on_data_available(DR);                        
                    }                                                           
                }
                .removeAllElements();                                
            }
            catch (Exception e){
                ..println("Exep = "+e);
                e.printStackTrace();
            }
        }
    }
    
    

Parameters:
arg0
Returns:
    public boolean add(Object arg0) {
        
        return .add(arg0);
    }
New to GrepCode? Check out our FAQ X