mil.dod.th.ose.remote/src/mil/dod/th/ose/remote/RemoteChannelLookupImpl.java
private RemoteChannel syncChannel(final int systemId, final Map<String, Object> properties, 
            final ComponentFactory factory, final boolean persist)
    {
        Set<RemoteChannel> channels = m_ChannelMap.get(systemId);
        if (channels == null)
        {
            // first channel for this id, create the set
            channels = new HashSet<RemoteChannel>();
            m_ChannelMap.put(systemId, channels);
        }
        
        final int currentId = findIdByChannelProps(properties);
        
        // if channel not found add it
        if (currentId == -1)
        {
            final ComponentInstance instance = factory.newInstance(new Hashtable<String, Object>(properties));
            final RemoteChannel channel = (RemoteChannel)instance.getInstance();
            m_Instances.put(channel, instance);
            addChannelToSet(channels, channel, systemId, persist);
            
            m_Logging.debug("Created new channel [%s] for system id 0x%08x", channel, systemId);
            
            sendInitialConnectionMessage(channel);
            return channel;
        }
        
        // remove channel from current system list and add to new id
        final Set<RemoteChannel> otherSet = m_ChannelMap.get(currentId);
        for (RemoteChannel channel : otherSet)
        {
            if (channel.matches(properties))
            {
                removeChannelFromSet(otherSet, channel, currentId);
                addChannelToSet(channels, channel, systemId, persist);
                return channel;
            }
        }
        
        // should not be logically possible to get here, but the compiler is not that smart
        throw new IllegalStateException("Could not find channel, was there in call to findIdByChannelProps");
    }
/**
     * Sync the channel with the lookup using the given properties and create a new channel using the given factory if 
     * channel does not exist in the loop.
     * 
     * @param systemId
     *      id of the controller to associate the channel with, channel can be used to send message to controller with
     *      this id
     * @param properties
     *      properties of the channel, keys are specific to the implementation of the {@link RemoteChannel}.
     * @param factory
     *      factory used to create the channel if it doesn't exist in the lookup
     * @param persist
     *      boolean used to determine if the channel being synced should be persisted
     * @return
     *      Returns the newly synced channel
     */
Sync the channel with the lookup using the given properties and create a new channel using the given factory if
channel does not exist in the loop.

@param systemId
id of the controller to associate the channel with, channel can be used to send message to controller with
this id
@param properties
properties of the channel, keys are specific to the implementation of the  RemoteChannel.
@param factory
factory used to create the channel if it doesn't exist in the lookup
@param persist
boolean used to determine if the channel being synced should be persisted
@return
Returns the newly synced channel
Sync the channel with the lookup using the given properties and create a new channel using the given factory if channel does not exist in the loop . @param systemId id of the controller to associate the channel with channel can be used to send message to controller with this id @param properties properties of the channel keys are specific to the implementation of the RemoteChannel . @param factory factory used to create the channel if it doesn ' t exist in the lookup @param persist boolean used to determine if the channel being synced should be persisted @return Returns the newly synced channel
private RemoteChannel syncChannel(final int systemId, final Map<String, Object> properties, 
            final ComponentFactory factory, final boolean persist)
    {
        Set<RemoteChannel> channels = m_ChannelMap.get(systemId);
        if (channels == null)
        {
            channels = new HashSet<RemoteChannel>();
            m_ChannelMap.put(systemId, channels);
        }
        final int currentId = findIdByChannelProps(properties);
        if (currentId == -1)
        {
            final ComponentInstance instance = factory.newInstance(new Hashtable<String, Object>(properties));
            final RemoteChannel channel = (RemoteChannel)instance.getInstance();
            m_Instances.put(channel, instance);
            addChannelToSet(channels, channel, systemId, persist);
            m_Logging.debug("Created new channel [%s] for system id 0x%08x", channel, systemId);
            sendInitialConnectionMessage(channel);
            return channel;
        }
        final Set<RemoteChannel> otherSet = m_ChannelMap.get(currentId);
        for (RemoteChannel channel : otherSet)
        {
            if (channel.matches(properties))
            {
                removeChannelFromSet(otherSet, channel, currentId);
                addChannelToSet(channels, channel, systemId, persist);
                return channel;
            }
        }
        throw new IllegalStateException("Could not find channel, was there in call to findIdByChannelProps");
    }
private RemoteChannel syncChannel ( final int systemId , final Map < String , Object > properties , final ComponentFactory factory , final boolean persist ) { Set < RemoteChannel > channels = m_ChannelMap . get ( systemId ) ; if ( channels == null ) { channels = new HashSet < RemoteChannel > ( ) ; m_ChannelMap . put ( systemId , channels ) ; } final int currentId = findIdByChannelProps ( properties ) ; if ( currentId == - 1 ) { final ComponentInstance instance = factory . newInstance ( new Hashtable < String , Object > ( properties ) ) ; final RemoteChannel channel = ( RemoteChannel ) instance . getInstance ( ) ; m_Instances . put ( channel , instance ) ; addChannelToSet ( channels , channel , systemId , persist ) ; m_Logging . debug ( "Created new channel [%s] for system id 0x%08x" , channel , systemId ) ; sendInitialConnectionMessage ( channel ) ; return channel ; } final Set < RemoteChannel > otherSet = m_ChannelMap . get ( currentId ) ; for ( RemoteChannel channel : otherSet ) { if ( channel . matches ( properties ) ) { removeChannelFromSet ( otherSet , channel , currentId ) ; addChannelToSet ( channels , channel , systemId , persist ) ; return channel ; } } throw new IllegalStateException ( "Could not find channel, was there in call to findIdByChannelProps" ) ; }
Sync the channel with the lookup using the given properties and create a new channel using the given factory if
 channel does not exist in the loop.
Sync the channel with the lookup using the given properties and create a new channel using the given factory if channel does not exist in the loop .
// first channel for this id, create the set // if channel not found add it // remove channel from current system list and add to new id // should not be logically possible to get here, but the compiler is not that smart