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;
 
 
The sole purpose of this class is to allow the creation and destruction of DomainParticipant objects. DomainParticipantFactory itself has no factory. It is either a pre-existing singleton object that can be accessed by means of the get_instance class operation on the DomainParticipantFactory.
 
 {
 
     private org.omg.CORBA.ORB orb;
 
     private org.omg.PortableServer.POA poa;
 
 
     private ThreadSubscriber Consummer;
 
     private Vector allParticipant;
 
 
     private DomainParticipantFactory ref;

    
Sets the pOA attribute of this object

Parameters:
poa The new pOA value
 
     public void setPOA (org.omg.PortableServer.POA poa)
     {
         this. = poa;
     }

    
Sets the oRB attribute of this object

Parameters:
orb The new oRB value
 
     public void setORB (org.omg.CORBA.ORB orb)
     {
         this. = orb;
     }
 
     public DomainParticipantFactoryImpl (org.omg.CORBA.ORB orb,
             org.omg.PortableServer.POA poa)
     {
         this. = orb;
         this. = poa;
         try
         {
             NamingContextExt nc = NamingContextExtHelper.narrow (orb.resolve_initial_references ("NameService"));
             EventChannelImpl channel = new EventChannelImpl (orbpoa);
             org.omg.CORBA.Object o = poa.servant_to_reference (channel);
             /* event channel used by event service */
             nc.rebind (nc.to_name ("eventchannel"), o);
        }
        catch (Exception e)
        {
        }
         = new Vector ();
        /* thread send message for all suscriber */
         = new ThreadSubscriber (orbpoa);
        .start ();
    }

    
This operation creates a new DomainParticipant object. The DomainParticipant signifies that the calling application intends to join the Domain identified by the domainId argument.
    public org.omg.dds.DomainParticipant create_participant (int domainId,
            org.omg.dds.DomainParticipantQos qos,
            org.omg.dds.DomainParticipantListener a_listener)
    {
        org.omg.dds.DomainParticipant ref = null;
        org.jacorb.dds.DomainParticipantImpl impl = new org.jacorb.dds.DomainParticipantImpl (domainId,
                                                                                              qos,
                                                                                              a_listener);
        impl.setORB ();
        impl.setPOA ();
        try
        {
            // get the root naming context
            ref = has_domainId (domainId);
            if (ref != nullreturn ref;
            org.omg.CORBA.Object objRef = .resolve_initial_references ("NameService");
            // Use NamingContextExt which is part of the Interoperable
            // Naming Service (INS) specification.
            NamingContextExt ncRef = NamingContextExtHelper.narrow (objRef);
            // get object reference from the servant (and implicitly register
            // it)
            org.omg.CORBA.Object oref = .servant_to_reference (impl);
            ref = org.omg.dds.DomainParticipantHelper.narrow (oref);
            if (ncRef != null)
            {
                // bind the Object Reference in Naming
                NameComponent path[] = ncRef.to_name (new Integer (domainId).toString ());
                ncRef.rebind (pathref);
                .add (ref);
                .add (ref);
            }
        }
        catch (Exception e)
        {
        }
        return ref;
    }

    
This operation deletes an existing DomainParticipant. This operation can only be invoked if all domain entities belonging to the participant have already been deleted.

Parameters:
a_participant
Returns:
RETCODE_OK.value if succes Otherwise the error PRECONDITION_NOT_MET is returned.
    public int delete_participant (org.omg.dds.DomainParticipant a_participant)
    {
        try
        {
            boolean delete_ok = ((DomainParticipantImpl.reference_to_servant (a_participant)).isDeletable ();
            if (delete_ok)
            {
                org.omg.CORBA.Object objRef = .resolve_initial_references ("NameService");
                // Use NamingContextExt which is part of the Interoperable
                // Naming Service (INS) specification.
                NamingContextExt ncRef = NamingContextExtHelper.narrow (objRef);
                String id = new Integer (a_participant.get_domain_id ()).toString ();
                NameComponent path[] = ncRef.to_name (id);
                ncRef.unbind (path);
            }
            else
            {
                return .;
            }
        }
        catch (Exception e)
        {
            ..println ("ERROR: " + e);
            e.printStackTrace (.);
        }
        return .;
    }

    

Parameters:
domainId
Returns:
a participant has a same domainId
    public DomainParticipant has_domainId (int domainId)
    {
        Iterator it = .iterator ();
        DomainParticipant temp;
        while (it.hasNext ())
        {
            temp = (DomainParticipantit.next ();
            if (temp.get_domain_id () == domainId)
            {
                return temp;
            }
        }
        return null;
    }

    

Parameters:
domainId
Returns:
a Participant has a same domaiId
    public org.omg.dds.DomainParticipant lookup_participant (int domainId)
    {
        org.omg.dds.DomainParticipant ref = null;
        try
        {
            org.omg.CORBA.Object objRef = .resolve_initial_references ("NameService");
            // Use NamingContextExt instead of NamingContext. This is
            // part of the Interoperable naming Service.
            NamingContextExt ncRef = NamingContextExtHelper.narrow (objRef);
            ref = DomainParticipantHelper.narrow (ncRef.resolve_str (new Integer (domainId).toString ()));
        }
        catch (Exception e)
        {
            ..println ("ERROR: " + e);
            e.printStackTrace (.);
        }
        return ref;
    }

    

Parameters:
qos
Returns:
    {
        this. = qos;
        return 0;
    }
    public void get_default_participant_qos (
            org.omg.dds.DomainParticipantQosHolder qos)
    {
        qos.value = this.;
    }

    

Returns:
Returns the orb.
    public org.omg.CORBA.ORB getOrb ()
    {
        return ;
    }

    

Returns:
Returns the poa.
    public org.omg.PortableServer.POA getPoa ()
    {
        return ;
    }
New to GrepCode? Check out our FAQ X