private URI getUri(String jdbcUrl) { if (Strings.isNullOrEmpty(jdbcUrl)) { throw new MinnalException("Invalid jdbc url"); } String cleanURI = jdbcUrl.substring(5); try { return new URI(cleanURI); } catch (Exception e) { throw new MinnalException("Invalid jdbc url"); } }
@Override public int getActiveConnections() { try { return dataSource.getNumBusyConnectionsAllUsers(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public long getFailedCheckins() { try { return dataSource.getNumFailedCheckinsDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public void writeResponseContent(String content) { try { context.getEntityStream().write(content.getBytes(Charsets.UTF_8)); } catch (IOException e) { logger.error("Failed while writing the response content", e); throw new MinnalException("Failed while writing the response content", e); } }
@Override public int getCachedStatements() { try { return dataSource.getStatementCacheNumStatementsAllUsers(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public long getFailedCheckouts() { try { return dataSource.getNumFailedCheckoutsDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public long getFailedIdleTests() { try { return dataSource.getNumFailedIdleTestsDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public long getUpTime() { try { return dataSource.getUpTimeMillisDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
/** * @param configuration * @param router */ public HttpsConnector(ConnectorConfiguration configuration, Router router) { super(configuration, router); if (configuration.getSslConfiguration() == null) { logger.error("SSL configuration is missing for https connector"); throw new MinnalException("SSL configuration is missing for https scheme"); } }
public <T extends Configuration> T provide(Class<T> clazz, String path) { InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); try { return Serializer.DEFAULT_YAML_SERIALIZER.deserialize(is, clazz); } catch (Exception e) { logger.error("Failed while reading the config file - " + path, e); throw new MinnalException(e); } }
@Override public int getIdleConnections() { try { return dataSource.getNumIdleConnectionsAllUsers(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public int getAwaitingCheckout() { try { return dataSource.getNumThreadsAwaitingCheckoutDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public int getTotalConnections() { try { return dataSource.getNumConnectionsAllUsers(); } catch (SQLException e) { throw new MinnalException(e); } }
@Override public long getStartTime() { try { return dataSource.getStartTimeMillisDefaultUser(); } catch (SQLException e) { throw new MinnalException(e); } }
protected void loadPermissions() { Properties properties = new Properties(); permissions = new HashMap<String, List<String>>(); InputStream is = null; try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream(mappingFile); if (is == null) { return; } properties.load(is); for (Entry<Object, Object> entry : properties.entrySet()) { Iterable<String> perms = Splitter.on(",").omitEmptyStrings().split((String) entry.getValue()); permissions.put((String) entry.getKey(), Lists.newArrayList(perms)); } } catch (IOException e) { logger.error("Failed while loading the property file - " + mappingFile, e); throw new MinnalException("Failed while loading the property file - " + mappingFile, e); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } }
protected void loadRoles() { Properties properties = new Properties(); roles = new HashMap<String, List<String>>(); InputStream is = null; try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream(mappingFile); if (is == null) { return; } properties.load(is); for (Entry<Object, Object> entry : properties.entrySet()) { Iterable<String> rols = Splitter.on(",").omitEmptyStrings().split((String) entry.getValue()); roles.put((String) entry.getKey(), Lists.newArrayList(rols)); } } catch (IOException e) { logger.error("Failed while loading the property file - " + mappingFile, e); throw new MinnalException("Failed while loading the property file - " + mappingFile, e); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } }
/** * @param object */ public ByteBuf serialize(Object object, MediaType mediaType) { ByteBuf byteBuf = Unpooled.buffer(); OutputStream stream = new ByteBufOutputStream(byteBuf); try { writeTo(object, object.getClass(), object.getClass(), null, mediaType, new MultivaluedHashMap<String, Object>(), stream); } catch (IOException e) { throw new MinnalException(e); } return byteBuf; }
bundleConfig = (BundleConfiguration) configClass.newInstance(); } catch (Exception e) { throw new MinnalException(e);
/** * @param object */ public <T> T deserializeCollection(ByteBuf byteBuf, Class<T> type, Class<T> genericType, MediaType mediaType) { InputStream stream = new ByteBufInputStream(byteBuf); try { return (T) readFrom((Class<Object>) genericType, (Class<Object>) type, null, mediaType, new MultivaluedHashMap<String, String>(), stream); } catch (IOException e) { throw new MinnalException(e); } }
/** * @param object */ public <T> T deserialize(ByteBuf byteBuf, Class<T> type, MediaType mediaType) { InputStream stream = new ByteBufInputStream(byteBuf); try { return (T) readFrom((Class<Object>) type, type, null, mediaType, new MultivaluedHashMap<String, String>(), stream); } catch (IOException e) { throw new MinnalException(e); } }