protected Connection createConnection ( Dsn dsn ) { String protocol = dsn . getProtocol ( ) ; Connection connection ; if ( protocol . equalsIgnoreCase ( "http" ) || protocol . equalsIgnoreCase ( "https" ) ) { logger . debug ( "Using an {} connection to Sentry." , protocol . toUpperCase ( ) ) ; connection = createHttpConnection ( dsn ) ; } else if ( protocol . equalsIgnoreCase ( "out" ) ) { logger . debug ( "Using StdOut to send events." ) ; connection = createStdOutConnection ( dsn ) ; } else if ( protocol . equalsIgnoreCase ( "noop" ) ) { logger . debug ( "Using noop to send events." ) ; connection = new NoopConnection ( ) ; } else { throw new IllegalStateException ( "Couldn't create a connection for the protocol '" + protocol + "'" ) ; } BufferedConnection bufferedConnection = null ; if ( getBufferEnabled ( dsn ) ) { Buffer eventBuffer = getBuffer ( dsn ) ; if ( eventBuffer != null ) { long flushtime = getBufferFlushtime ( dsn ) ; boolean gracefulShutdown = getBufferedConnectionGracefulShutdownEnabled ( dsn ) ; Long shutdownTimeout = getBufferedConnectionShutdownTimeout ( dsn ) ; bufferedConnection = new BufferedConnection ( connection , eventBuffer , flushtime , gracefulShutdown , shutdownTimeout ) ; connection = bufferedConnection ; } } // Enable async unless its value is 'false'. if ( getAsyncEnabled ( dsn ) ) { connection = createAsyncConnection ( dsn , connection ) ; } // If buffering is enabled, wrap connection with synchronous disk buffering "connection" if ( bufferedConnection != null ) { connection = bufferedConnection . wrapConnectionWithBufferWriter ( connection ) ; } return connection ; }
Creates a connection to the given DSN by determining the protocol .