def __init__(self, communicator, name, params, client_request_class=None):
        Listener.__init__(self,
                          communicator,
                          name,
                          params,
                          client_request_class=client_request_class)

        if not params.has_key('service_name'):
            params['service_name'] = self.get_name()

        host = params.get('host')
        port = int(params.get('port'))
        protocol = params.get('protocol')
        if protocol is None:
            protocol = 'tcp'

        ice_url = "%s -h %s -p %d" % (protocol, host, port)

        properties = Ice.createProperties()

        for property_name, property_value in params.iteritems():
            #Passing configs to Ice as properties. Ice will pick its
            #own configs and ignore others.
            properties.setProperty(property_name, property_value)

        data = Ice.InitializationData()
        data.properties = properties

        self._proxy = Ice.initialize(sys.argv, data)
        self._adapter = self._proxy.createObjectAdapterWithEndpoints(
            get_app().get_name(), ice_url)

        self.add_service(IceJsonDispatcher(self), name=params['service_name'])
def get_instance_name():
    '''
    Returns application's instance name.
    
    @return: str
    '''
    return get_app().get_instance_name()
def get_full_name():
    '''
    Returns application's full name.
    
    @return: str
    '''
    return get_app().get_full_name()
def unregister_component(name):
    '''
    Unregisters the component from the application context by the given name.
    
    @param name: component name 
    '''

    return get_app().unregister_component(name)
def get_application_dir():
    '''
    Returns application running path.
    
    @rtype: str
    '''

    return get_app().get_application_dir()
def get_default_settings_folder_name():
    '''
    Returns default settings folder name.
    
    @return: str
    '''

    return get_app().get_default_settings_folder_name()
def get_options():
    '''
    Returns applications options.
    
    @return: {}
    '''

    return get_app().get_options()
def get_component(name):
    '''
    Returns the component using the given name.
    
    @param name: component name
    @return: object
    '''

    return get_app().get_component(name)
def register_component(name, instance):
    '''
    Registers a component in application context.
    
    @param name: component name
    @param instance: a instance of the component
    '''

    return get_app().register_component(name, instance)
def delist_app(app_name, instance_name):
    """
    Delists an application into current application as child.
    
    @param app_name: name of child application.
    @param instance_name: application instance name. 
    """

    return get_app().delist_app(app_name, instance_name)
def enlist_app(app_name, instance_name, user_name, ticket, listener_params):
    '''
    Enlists an application.
    
    @param app_name: application name
    @param instance_name: application instance name
    @param user_name: user name
    @param ticket: ticket of the user
    @param listener_params: parameters of the listener
    '''
    return get_app().enlist_app(app_name, instance_name, user_name, ticket,
                                listener_params)
    def _get_listener_settings_(self, config_store=None):
        '''
        Returns listener settings.
        
        @return: dict
        '''
        listener_settings = {}
        if config_store is None:
            config_name = "%s.communication" % get_app().get_name()
            config_store = config.get_config_store(config_name)

        sections = config_store.get_sections()
        self.__default_listener_name = config_store.get(
            'global', 'default', None)
        for name in sections:
            if name != 'global':
                data = config_store.get_section_data(name)
                if not data.has_key('type'):
                    raise CommunicatorException('Listener[%s] has not type.' %
                                                name)
                listener_settings[name] = data
                if self.__default_listener_name is None:
                    self.__default_listener_name = name
        return listener_settings
def introduce():
    '''
    Introduces the application.
    '''
    return get_app().introduce()
def get_context():
    '''
    Returns application context.
    '''

    return get_app().get_context()