Sets the MINA connector and establishes the connection to the world
model. Adds protocol filters.

@return {@code true} if connection is set-up correctly, else
{@code false}.
557841
protected boolean setConnector() {
		if (this.host == null) {
			log.error("No host value set, cannot set up socket connector.");
			return false;
		}
		if (this.port < 0 || this.port > 65535) {
			log.error("Port value is invalid {}.", Integer.valueOf(this.port));
			return false;
		}
		if (this.executors == null) {
			this.executors = new ExecutorFilter(1);
		}
		this.connector = new NioSocketConnector();
		this.connector.getSessionConfig().setWriterIdleTime(
				SolverWorldModelInterface.TIMEOUT_PERIOD /2);
		this.connector.getSessionConfig().setReaderIdleTime(
				(int) Math.ceil(TIMEOUT_PERIOD * 1.1));
		if (!this.connector.getFilterChain().contains(
				WorldModelSolverProtocolCodecFactory.CODEC_NAME)) {
			this.connector.getFilterChain().addLast(
					WorldModelSolverProtocolCodecFactory.CODEC_NAME,
					new ProtocolCodecFilter(
							new WorldModelSolverProtocolCodecFactory(true)));
		}
		this.connector.getFilterChain().addLast("ExecutorPool", this.executors);
		this.connector.setHandler(this.ioHandler);
		log.debug("Connector set up successful.");
		return true;
	}
602992
protected boolean _connect(long timeout) {
    log.debug("Attempting connection...");
    ConnectFuture connFuture = this.connector.connect(new InetSocketAddress(
        this.host, this.port));
    if (!connFuture.awaitUninterruptibly(timeout)) {
      log.warn("Unable to connect to world model after {}ms.",
          Long.valueOf(this.connectionTimeout));
      return false;
    }
    if (!connFuture.isConnected()) {
      log.debug("Failed to connect.");
      return false;
    }

    try {
      log.debug("Attempting connection to {}:{}.", this.host,
          Integer.valueOf(this.port));
      this.session = connFuture.getSession();
    } catch (RuntimeIoException ioe) {
      log.error(String.format(
          "Could not create session to World Model (C) %s:%d.", this.host,
          Integer.valueOf(this.port)), ioe);
      return false;
    }
    return true;
  }
140185
def setConnection(self, connection):
        
        # define custom properties
        if not isinstance(connection, orb.Connection):
            conn = orb.Connection.byName(connection)
            if not conn:
                raise orb.errors.BackendNotFound(connection)
            connection = conn(self)
        else:
            connection.setDatabase(self)

        self.__connection = connection
1167143
protected RabbitMqQueueFactory<T, ID, DATA> setDefaultConnectionFactory(
            ConnectionFactory connectionFactory, boolean setMyOwnConnectionFactory) {
        if (myOwnConnectionFactory && this.defaultConnectionFactory != null) {
            // destroy this.defaultConnectionFactory
        }
        this.defaultConnectionFactory = connectionFactory;
        myOwnConnectionFactory = setMyOwnConnectionFactory;
        return this;
    }
167002
public function connect()
    {
        try {
            // Instantiate an S3 client
            $this->setS3Client(new S3Client([
                        'version' => $this->supplier['version'],
                        'region' => $this->supplier['region'],
                        'http'    => $this->supplier['http']
                    ]
                )
            );
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
639985
public ActiveMqQueueFactory<T, ID, DATA> setDefaultConnectionFactory(
            ActiveMQConnectionFactory connectionFactory) {
        return setDefaultConnectionFactory(connectionFactory, false);
    }
788327
def connectRelay(self):
        
        self.protocol = self.connector.buildProtocol(None)
        self.connected = True
        self.protocol.makeConnection(self)
1173810
public boolean join() {
        Message joinMessage = new Message(MessageType.JOIN, this.channelName);
        List<Message> response;

        try {
            response = connection.request(
                MessageFilters.message(MessageType.RPL_NAMREPLY, null, "=", channelName),
                MessageFilters.message(MessageType.RPL_ENDOFNAMES, null, channelName),
                joinMessage);
        } catch (InterruptedException e) {
            return false;
        }

        List<String> names = new ArrayList<String>();

        for (Message message : response) {
            if (message.getType() == MessageType.RPL_NAMREPLY) {
                String[] args = message.getArgs();

                for (String name : args[args.length - 1].split(" ")) {
                    names.add(name.replaceFirst("^[@+]", ""));
                }
            }
        }

        this.names = names;

        return true;
    }
595473
protected RabbitMqQueue<ID, DATA> setConnectionFactory(ConnectionFactory connectionFactory,
            boolean setMyOwnConnectionFactory) {
        if (myOwnConnectionFactory && this.connectionFactory != null) {
            // destroy this.connectionFactory
        }
        this.connectionFactory = connectionFactory;
        myOwnConnectionFactory = setMyOwnConnectionFactory;
        return this;
    }
179009
public synchronized boolean addStateChange(ConnectionState newConnectionState)
    {
        if ( state.get() != State.STARTED )
        {
            return false;
        }

        ConnectionState previousState = currentConnectionState;
        if ( previousState == newConnectionState )
        {
            return false;
        }
        currentConnectionState = newConnectionState;

        ConnectionState localState = newConnectionState;
        boolean isNegativeMessage = ((newConnectionState == ConnectionState.LOST) || (newConnectionState == ConnectionState.SUSPENDED) || (newConnectionState == ConnectionState.READ_ONLY));
        if ( !isNegativeMessage && initialConnectMessageSent.compareAndSet(false, true) )
        {
            localState = ConnectionState.CONNECTED;
        }

        postState(localState);

        return true;
    }
483391
@Override
    public boolean chain ( ServerMessageBlock2 n ) {
        n.setSessionId(Smb2Constants.UNSPECIFIED_SESSIONID);
        return super.chain(n);
    }
498253
protected <F extends ConnectFuture> ConnectFuture connectInternal(final ResourceAddress remoteAddress, final IoHandler handler, final IoSessionInitializer<F> initializer) {
        
        ConnectFuture future;

        final String nextProtocol = remoteAddress.getOption(ResourceAddress.NEXT_PROTOCOL);
        ResourceAddress transport = remoteAddress.getTransport();
        if (transport != null) {
            BridgeConnector connector = bridgeServiceFactory.newBridgeConnector(transport);
            future = connector.connect(transport, handler, new IoSessionInitializer<F>() {
                @Override
                public void initializeSession(IoSession session, F future) {
                    REMOTE_ADDRESS.set(session, remoteAddress);
                    setLocalAddressFromSocketAddress(session, getTransportName(), nextProtocol);

                    if (initializer != null) {
                        initializer.initializeSession(session, future);
                    }
                }
            });

        } else {

            T socketAddress = socketAddressFactory.createSocketAddress(remoteAddress);

            future = connector.connect(socketAddress, new IoSessionInitializer<F>() {
                @Override
                public void initializeSession(IoSession session, F future) {

                    // connectors don't need lookup so set this directly on the session
                    session.setAttribute(BridgeConnectHandler.DELEGATE_KEY, handler);
                    REMOTE_ADDRESS.set(session, remoteAddress);
                    setLocalAddressFromSocketAddress(session, getTransportName(), nextProtocol);

                    if (initializer != null) {
                        initializer.initializeSession(session, future);
                    }
                }
            });
        }

        return future;
    }
275916
protected boolean _load ()
    {
        java.util.Iterator it =
            this.getOjbMetaTreeModel ().getRepository().iterator();
        java.util.ArrayList newChildren = new java.util.ArrayList();

        /* @todo make this work */

//        newChildren.add(new OjbMetaJdbcConnectionDescriptorNode(
//            this.getOjbMetaTreeModel ().getRepository(),
//            this.getOjbMetaTreeModel (),
//            this,
//            this.getOjbMetaTreeModel ().getRepository().getDefaultJdbcConnection()));

        while (it.hasNext())
        {
            org.apache.ojb.broker.metadata.ClassDescriptor cld = (org.apache.ojb.broker.metadata.ClassDescriptor)it.next();
            OjbMetaClassDescriptorNode cldNode =
            	new OjbMetaClassDescriptorNode(this.getOjbMetaTreeModel ().getRepository(),
					                           this.getOjbMetaTreeModel (),
     						                   this, cld);
            cldToNodes.put(cld, cldNode);
            newChildren.add(cldNode);
        }
        java.util.Collections.sort(newChildren);
        this.alChildren = newChildren;
        this.getOjbMetaTreeModel ().nodeStructureChanged(this);
        return true;
    }
646170
public boolean setSecondaryHostFail() {
    if (secondaryHostFail.compareAndSet(false, true)) {
      secondaryHostFailNanos = System.nanoTime();
      currentConnectionAttempts.set(0);
      return true;
    }
    return false;
  }
34324
public ConnectionFactoryBuilder setProtocol(Protocol prot) {
    switch (prot) {
    case TEXT:
      opFact = new AsciiOperationFactory();
      break;
    case BINARY:
      opFact = new BinaryOperationFactory();
      break;
    default:
      assert false : "Unhandled protocol: " + prot;
    }
    return this;
  }
350492
protected boolean checkConnection()
    {
        super.checkConnection();
        try
        {
            if (_jarConnection!=_connection)
                newConnection();
        }
        catch(IOException e)
        {
            LogSupport.ignore(log,e);
            _jarConnection=null;
        }
        
        return _jarConnection!=null;
    }
326490
public void setVpcPeeringConnections(java.util.Collection<VpcPeeringConnection> vpcPeeringConnections) {
        if (vpcPeeringConnections == null) {
            this.vpcPeeringConnections = null;
            return;
        }

        this.vpcPeeringConnections = new java.util.ArrayList<VpcPeeringConnection>(vpcPeeringConnections);
    }