Package org.drools.grid.impl

Source Code of org.drools.grid.impl.ConnectionFactoryServiceImpl

package org.drools.grid.impl;

import org.drools.grid.ConnectionFactoryService;
import org.drools.grid.Grid;
import org.drools.grid.GridConnection;
import org.drools.grid.GridNode;
import org.drools.grid.GridServiceDescription;
import org.drools.grid.local.LocalGridNodeConnection;
import org.drools.grid.remote.RemoteGridNodeConnection;

public class ConnectionFactoryServiceImpl
    implements
    ConnectionFactoryService {

    Grid    grid;

    boolean localAllowed;

    public ConnectionFactoryServiceImpl(Grid grid) {
        this.grid = grid;
        this.localAllowed = true;
    }

    public <T> GridConnection<T> createConnection(GridServiceDescription<T> gsd) {
        GridConnection<T> conn = null;

        if ( this.localAllowed ) {
            // internal boolean to disallow local connections
            GridNode gnode = this.grid.getGridNode( gsd.getId() );
            if ( gnode != null ) {
                conn = new LocalGridNodeConnection( gnode );
            }
        }

        if ( conn == null ) {
            conn = new RemoteGridNodeConnection( this.grid,
                                                 gsd );
        }

        return conn;
    }

    public boolean isLocalAllowed() {
        return localAllowed;
    }

    public void setLocalAllowed(boolean localAllowed) {
        this.localAllowed = localAllowed;
    }

}
TOP

Related Classes of org.drools.grid.impl.ConnectionFactoryServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.