public static Connection findConnection ( final MasterServer master, final String name, final Class<DataAccessConnection> clazz ) { for ( final Connection c : master.getConnections () ) { if ( !clazz.isAssignableFrom ( c.getClass () ) ) { continue; } if ( c.getName ().equals ( name ) ) { return c; } } throw new IllegalStateException ( String.format ( "Unable to find a connection named '%s' of ype %s on %s", name, clazz.getName (), master ) ); }
public static Connection findConnection ( final MasterServer master, final String name, final Class<DataAccessConnection> clazz ) { for ( final Connection c : master.getConnections () ) { if ( !clazz.isAssignableFrom ( c.getClass () ) ) { continue; } if ( c.getName ().equals ( name ) ) { return c; } } throw new IllegalStateException ( String.format ( "Unable to find a connection named '%s' of ype %s on %s", name, clazz.getName (), master ) ); }
private static DataAccessConnection findConnection ( final MasterServer from, final MasterServer to ) { for ( final org.eclipse.scada.configuration.world.osgi.Connection c : from.getConnections () ) { if ( ! ( c instanceof DataAccessConnection ) ) { continue; } for ( final Exporter e : to.getExporter () ) { final Endpoint ep = c.getMatchingEndpoint ( e ); if ( ep != null ) { // this is a common endpoing of the connection and the exporter return (DataAccessConnection)c; } } } return null; }
for ( final Connection con : master.getConnections () )
for ( final Connection con : master.getConnections () )
private void connectMasterToDriver ( final MasterServer master, final org.eclipse.scada.configuration.infrastructure.Driver driver, final Endpoint ep ) { String tt = driver.getProtocolTypeTag (); if ( tt == null || tt.isEmpty () ) { tt = "ngp"; } final DataAccessConnection connection; switch ( tt ) { case "sfp": connection = OsgiFactory.eINSTANCE.createSfpDataAccessConnection (); break; case "ngp": connection = OsgiFactory.eINSTANCE.createDataAccessConnection (); break; default: throw new IllegalStateException ( String.format ( "Protocol type '%s' is unsupported", tt ) ); } connection.setEndpoint ( ep ); connection.setName ( Worlds.makeConnectionName ( driver ) ); connection.setCredentials ( EcoreUtil.copy ( Worlds.findConnectionPassword ( driver ) ) ); final org.eclipse.scada.configuration.world.osgi.MasterServer mappedMaster = this.ctxMap.get ( master ).getImplementation (); mappedMaster.getConnections ().add ( connection ); }
private <T extends Connection> T createConnection ( final EClass connectionClass, final Class<T> clazz, final Global global, final Local local ) { final T connection = clazz.cast ( OsgiFactory.eINSTANCE.create ( connectionClass ) ); final String tag = connection.getTypeTag (); final String cname = String.format ( "global.%s.to.%s.%s", Names.makeName ( global.getGlobal () ), local.getId (), tag ); connection.setName ( cname ); // set credentials connection.setCredentials ( EcoreUtil.copy ( findCredentials ( global, local ) ) ); // add connection to "from" global.getGlobal ().getConnections ().add ( connection ); // point connection to "to" final LinkedList<Endpoint> endpoints = new LinkedList<> (); for ( final Exporter exporter : local.getLocal ().getExporter () ) { endpoints.addAll ( connection.getPossibleEndpoints ( exporter ) ); } if ( endpoints.isEmpty () ) { throw new IllegalStateException ( String.format ( "Unable to find an exporter that could serve as endpoint for connection type %s on master %s", connectionClass.getName (), local.getLocal ().getName () ) ); } final Endpoint endpoint = endpoints.getFirst (); connection.setEndpoint ( endpoint ); // FIXME: adding connection analyzers to "app", in phase 1 return connection; }