/** * Register the current connection as an OSGi service */ private EntryImpl registerConnection ( final ConnectionDescriptor connectionDescriptor, final ConnectionService connectionService ) { final Class<?>[] interfaces = connectionService.getSupportedInterfaces (); final String[] clazzes = new String[interfaces.length]; int i = 0; for ( final Class<?> iface : interfaces ) { clazzes[i] = iface.getName (); i++; } final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( ConnectionService.CONNECTION_URI, connectionDescriptor.getConnectionInformation ().toString () ); if ( connectionDescriptor.getServiceId () != null ) { properties.put ( Constants.SERVICE_PID, connectionDescriptor.getServiceId () ); } final ServiceRegistration<?> serviceRegistration = this.context.registerService ( clazzes, connectionService, properties ); return new EntryImpl ( connectionDescriptor, connectionService, serviceRegistration ); }
if ( tok.length == 1 ) cd = new ConnectionDescriptor ( ConnectionInformation.fromURI ( tok[0] ) ); cd = new ConnectionDescriptor ( ConnectionInformation.fromURI ( tok[1] ), tok[0], null ); if ( cd.getConnectionInformation () == null )
@Override public List<String> getGroups ( final ConnectionDescriptor connectionDescriptor ) { return Arrays.asList ( connectionDescriptor.getConnectionInformation ().getTarget () ); }
public void update () { String errorMessage = null; try { String id = this.idText.getText (); if ( id.isEmpty () ) { id = null; } final ConnectionInformation ci = ConnectionInformation.fromURI ( this.uriText.getText () ); if ( ci == null ) { throw new IllegalArgumentException ( "Invalid syntax of URI" ); } this.connectionInformation = new ConnectionDescriptor ( ci, id, null ); } catch ( final Throwable e ) { errorMessage = ExceptionHelper.getMessage ( e ); } setState ( errorMessage ); }
@Override public String getDescription ( final Object element ) { if ( element instanceof ConnectionDiscovererBean ) { return ( (ConnectionDiscovererBean)element ).getDescription (); } else if ( element instanceof ConnectionHolder ) { return ( (ConnectionHolder)element ).getConnectionInformation ().getDescription (); } return super.getDescription ( element ); }
@Override public List<String> getGroups ( final ConnectionDescriptor connectionDescriptor ) { return Arrays.asList ( connectionDescriptor.getConnectionInformation ().getTarget () ); }
public void update () { String errorMessage = null; try { String id = this.idText.getText (); if ( id.isEmpty () ) { id = null; } final ConnectionInformation ci = ConnectionInformation.fromURI ( this.uriText.getText () ); if ( ci == null ) { throw new IllegalArgumentException ( "Invalid syntax of URI" ); } this.connectionInformation = new ConnectionDescriptor ( ci, id, null ); } catch ( final Throwable e ) { errorMessage = ExceptionHelper.getMessage ( e ); } setState ( errorMessage ); }
@Override public String getDescription ( final Object element ) { if ( element instanceof ConnectionDiscovererBean ) { return ( (ConnectionDiscovererBean)element ).getDescription (); } else if ( element instanceof ConnectionHolder ) { return ( (ConnectionHolder)element ).getConnectionInformation ().getDescription (); } return super.getDescription ( element ); }
private void store () throws CoreException { PrintWriter printer = null; try { printer = new PrintWriter ( getFile () ); for ( final ConnectionDescriptor descriptor : getConnections () ) { if ( descriptor.getServiceId () != null ) { printer.println ( descriptor.getServiceId () + STORE_ID_DELIM + descriptor.getConnectionInformation () ); } else { printer.println ( descriptor.getConnectionInformation ().toString () ); } } } catch ( final IOException e ) { throw new CoreException ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.DefaultFileResourceDiscoverer_ErrorStore, e ) ); } finally { if ( printer != null ) { printer.close (); } } }
public synchronized Entry getConnection ( final ConnectionDescriptor connectionDescriptor ) { final Set<EntryWrapper> entries = this.entryMap.get ( connectionDescriptor ); if ( !entries.isEmpty () ) { return wrapConnection ( entries.iterator ().next ().getEntry () ); } final ConnectionService connectionService = ConnectionCreatorHelper.createConnection ( connectionDescriptor.getConnectionInformation (), null, false ); if ( connectionService == null ) { return null; } return wrapConnection ( registerConnection ( connectionDescriptor, connectionService ) ); }
protected void createInitialFile () { try { add ( new ConnectionDescriptor ( ConnectionInformation.fromURI ( "da:ngp://scada.eclipse.org:2101" ) ) ); //$NON-NLS-1$ } catch ( final CoreException e ) { Activator.getDefault ().getLog ().log ( new Status ( IStatus.INFO, Activator.PLUGIN_ID, "Failed to create initial file", e ) ); } }
/** * Register the current connection as an OSGi service */ private EntryImpl registerConnection ( final ConnectionDescriptor connectionDescriptor, final ConnectionService connectionService ) { final Class<?>[] interfaces = connectionService.getSupportedInterfaces (); final String[] clazzes = new String[interfaces.length]; int i = 0; for ( final Class<?> iface : interfaces ) { clazzes[i] = iface.getName (); i++; } final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( ConnectionService.CONNECTION_URI, connectionDescriptor.getConnectionInformation ().toString () ); if ( connectionDescriptor.getServiceId () != null ) { properties.put ( Constants.SERVICE_PID, connectionDescriptor.getServiceId () ); } final ServiceRegistration<?> serviceRegistration = this.context.registerService ( clazzes, connectionService, properties ); return new EntryImpl ( connectionDescriptor, connectionService, serviceRegistration ); }
public synchronized Entry getConnection ( final ConnectionDescriptor connectionDescriptor ) { final Set<EntryWrapper> entries = this.entryMap.get ( connectionDescriptor ); if ( !entries.isEmpty () ) { return wrapConnection ( entries.iterator ().next ().getEntry () ); } final ConnectionService connectionService = ConnectionCreatorHelper.createConnection ( connectionDescriptor.getConnectionInformation (), null, false ); if ( connectionService == null ) { return null; } return wrapConnection ( registerConnection ( connectionDescriptor, connectionService ) ); }
this.idText.setLayoutData ( new GridData ( SWT.FILL, SWT.CENTER, true, false ) ); if ( this.connectionInformation != null && this.connectionInformation.getConnectionInformation () != null ) this.uriText.setText ( this.connectionInformation.getConnectionInformation ().toMaskedString () ); if ( this.connectionInformation.getServiceId () != null ) this.idText.setText ( this.connectionInformation.getServiceId () );
@Override public List<String> getGroups ( final ConnectionDescriptor connectionDescriptor ) { final ConnectionInformation info = connectionDescriptor.getConnectionInformation (); final ArrayList<String> list = new ArrayList<String> (); if ( info.getInterface () != null ) { list.add ( info.getInterface () ); } if ( info.getDriver () != null ) { list.add ( info.getDriver () ); } if ( info.getTarget () != null ) { list.add ( info.getTarget () ); } if ( info.getSecondaryTarget () != null ) { list.add ( "" + info.getSecondaryTarget () ); } return list; }
this.idText.setLayoutData ( new GridData ( SWT.FILL, SWT.CENTER, true, false ) ); if ( this.connectionInformation != null && this.connectionInformation.getConnectionInformation () != null ) this.uriText.setText ( this.connectionInformation.getConnectionInformation ().toMaskedString () ); if ( this.connectionInformation.getServiceId () != null ) this.idText.setText ( this.connectionInformation.getServiceId () );
@Override public List<String> getGroups ( final ConnectionDescriptor connectionDescriptor ) { final ConnectionInformation info = connectionDescriptor.getConnectionInformation (); final ArrayList<String> list = new ArrayList<String> (); if ( info.getInterface () != null ) { list.add ( info.getInterface () ); } if ( info.getDriver () != null ) { list.add ( info.getDriver () ); } if ( info.getTarget () != null ) { list.add ( info.getTarget () ); } if ( info.getSecondaryTarget () != null ) { list.add ( "" + info.getSecondaryTarget () ); } return list; }
private StyledString getConnectionString ( final ConnectionHolder holder ) { final ConnectionService service = holder.getConnectionService (); final ConnectionDescriptor desc = holder.getConnectionInformation (); final StyledString str = new StyledString ( makeLabel ( desc.getConnectionInformation () ) ); if ( service != null ) { str.append ( " [", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ final Connection connection = service.getConnection (); if ( connection != null ) { str.append ( String.format ( "%s", holder.getConnectionState () ), StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ } str.append ( "]", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ } if ( desc.getServiceId () != null ) { str.append ( String.format ( " (%s)", desc.getServiceId () ), StyledString.QUALIFIER_STYLER ); //$NON-NLS-1$ } return str; }
@Override @SuppressWarnings ( "rawtypes" ) public Object getAdapter ( final Class adapter ) { logger.debug ( "Adapt to: {}", adapter ); if ( adapter == FolderEntry.class && this.entry instanceof FolderEntry ) { return this.entry; } if ( adapter == DataItemEntry.class && this.entry instanceof DataItemEntry ) { return this.entry; } if ( adapter == Item.class && this.entry instanceof DataItemEntry ) { final DataItemEntry entry = (DataItemEntry)this.entry; return new Item ( getHolder ().getConnectionInformation ().getConnectionInformation ().toString (), entry.getId (), Type.URI ); } return null; }
private StyledString getConnectionString ( final ConnectionHolder holder ) { final ConnectionService service = holder.getConnectionService (); final ConnectionDescriptor desc = holder.getConnectionInformation (); final StyledString str = new StyledString ( makeLabel ( desc.getConnectionInformation () ) ); if ( service != null ) { str.append ( " [", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ final Connection connection = service.getConnection (); if ( connection != null ) { str.append ( String.format ( "%s", holder.getConnectionState () ), StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ } str.append ( "]", StyledString.DECORATIONS_STYLER ); //$NON-NLS-1$ } if ( desc.getServiceId () != null ) { str.append ( String.format ( " (%s)", desc.getServiceId () ), StyledString.QUALIFIER_STYLER ); //$NON-NLS-1$ } return str; }