public EntryImpl ( final ConnectionDescriptor connectionDescriptor, final ConnectionService connectionService, final ServiceRegistration<?> serviceRegistration ) { this.connectionDescriptor = connectionDescriptor; this.connectionService = connectionService; this.serviceRegistration = serviceRegistration; connectionService.getConnection ().addConnectionStateListener ( this ); }
@Override public void startLogin () { notifyStateChange ( this.connectionService, ConnectionState.CLOSED, null, false ); this.connectionService.getConnection ().addConnectionStateListener ( this.connectionStateListener ); this.connectionService.setConnectCallbackHandler ( this.callbackHandler ); // we do call connect for lazy connections since the ConnectionService decides when to connect this.connectionService.connect (); }
@Override public void dispose () { this.connectionService.getConnection ().removeConnectionStateListener ( this ); try { this.serviceRegistration.unregister (); } finally { this.connectionService.dispose (); } } }
final Class<?>[] clazzes = this.connectionService.getSupportedInterfaces (); final String[] str = new String[clazzes.length]; for ( int i = 0; i < clazzes.length; i++ ) properties.put ( ConnectionService.CONNECTION_URI, this.connectionService.getConnection ().getConnectionInformation ().toString () ); properties.put ( Constants.SERVICE_PID, servicePid ); if ( this.loginConnection.getPriority () != null )
public void setConnectCallbackHandler ( final CallbackHandler callbackHandler ) { if ( this.connectionService != null ) { this.connectionService.setConnectCallbackHandler ( callbackHandler ); } }
public synchronized void connect () { if ( this.connectionService != null ) { this.connectionService.connect (); } }
/** * 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 void disconnect () { if ( this.connectionService != null ) { this.connectionService.disconnect (); } }
return String.format ( Messages.PropertySourceWrapper_StateFormat, StringHelper.join ( service.getSupportedInterfaces (), Messages.PropertySourceWrapper_StateFormatDelim ) ); final Connection connection = service.getConnection (); if ( connection == null )
public void setConnectCallbackHandler ( final CallbackHandler callbackHandler ) { if ( this.connectionService != null ) { this.connectionService.setConnectCallbackHandler ( callbackHandler ); } }
public synchronized void connect () { if ( this.connectionService != null ) { this.connectionService.connect (); } }
/** * 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 void disconnect () { if ( this.connectionService != null ) { this.connectionService.disconnect (); } }
public EntryImpl ( final ConnectionDescriptor connectionDescriptor, final ConnectionService connectionService, final ServiceRegistration<?> serviceRegistration ) { this.connectionDescriptor = connectionDescriptor; this.connectionService = connectionService; this.serviceRegistration = serviceRegistration; connectionService.getConnection ().addConnectionStateListener ( this ); }
@Override public void dispose () { this.connectionService.getConnection ().removeConnectionStateListener ( this ); try { this.serviceRegistration.unregister (); } finally { this.connectionService.dispose (); } } }
return String.format ( Messages.PropertySourceWrapper_StateFormat, StringHelper.join ( service.getSupportedInterfaces (), Messages.PropertySourceWrapper_StateFormatDelim ) ); final Connection connection = service.getConnection (); if ( connection == null )
@Override public boolean hasRole ( final String role ) { try { if ( this.sessionPrivileges ) { return this.connectionService.getConnection ().getPrivileges ().contains ( role ); } else { final Map<String, String> properties = this.connectionService.getConnection ().getSessionProperties (); final String value = properties.get ( "session.privilege." + role ); if ( value == null ) { return false; } return Boolean.parseBoolean ( value ); } } catch ( final NullPointerException e ) { return false; } } }
@Override public synchronized void dispose () { if ( this.registrations != null ) { for ( final ServiceRegistration<?> reg : this.registrations ) { reg.unregister (); } this.registrations = null; } if ( this.connectionService != null ) { if ( this.connectionStateListener != null ) { this.connectionService.getConnection ().removeConnectionStateListener ( this.connectionStateListener ); } this.connectionService.dispose (); this.connectionService = null; } }
private Connection getConnection () { if ( this.connectionHolder == null ) { return null; } if ( this.connectionHolder.getConnectionService () == null ) { return null; } return this.connectionHolder.getConnectionService ().getConnection (); }
private void markCompleteOk () { this.complete = true; this.ok = true; this.connectionService.getConnection ().removeConnectionStateListener ( this.connectionStateListener ); checkRegister (); }