public static void setSourceConnectionFromEndpoints ( final SourceItem item, final MasterServer master, final Collection<Endpoint> endpoints ) { final Connection connection = Locator.findConnection ( master, endpoints ); if ( connection == null ) { final String nodeName = Nodes.makeName ( Nodes.fromApp ( master ) ); throw new IllegalStateException ( String.format ( "Master '%s' on node '%s' does not have a connection to endpoints %s", master.getName (), nodeName, StringHelper.join ( endpoints, ", " ) ) ); } if ( ! ( connection instanceof DataAccessConnection ) ) { throw new IllegalStateException ( String.format ( "Connection is of type %s but must be of type %s (Endpoints: %s)", connection.getClass ().getName (), DataAccessConnection.class.getName (), StringHelper.join ( endpoints, ", " ) ) ); } item.setConnection ( (DataAccessConnection)connection ); }
public static void setSourceConnectionFromEndpoints ( final SourceItem item, final MasterServer master, final Collection<Endpoint> endpoints ) { final Connection connection = Locator.findConnection ( master, endpoints ); if ( connection == null ) { final String nodeName = Nodes.makeName ( Nodes.fromApp ( master ) ); throw new IllegalStateException ( String.format ( "Master '%s' on node '%s' does not have a connection to endpoints %s", master.getName (), nodeName, StringHelper.join ( endpoints, ", " ) ) ); } if ( ! ( connection instanceof DataAccessConnection ) ) { throw new IllegalStateException ( String.format ( "Connection is of type %s but must be of type %s (Endpoints: %s)", connection.getClass ().getName (), DataAccessConnection.class.getName (), StringHelper.join ( endpoints, ", " ) ) ); } item.setConnection ( (DataAccessConnection)connection ); }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (MasterServer)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_MasterServer_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_MasterServer_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
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; }