org.springframework.lang.UsesJava7 Java Examples
The following examples show how to use
org.springframework.lang.UsesJava7.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractJaxWsServiceExporter.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create the actual Endpoint instance. * @param bean the service object to wrap * @return the Endpoint instance * @see Endpoint#create(Object) * @see Endpoint#create(String, Object) */ @UsesJava7 // optional use of Endpoint#create with WebServiceFeature[] protected Endpoint createEndpoint(Object bean) { if (this.endpointFeatures != null || this.webServiceFeatures != null) { WebServiceFeature[] endpointFeaturesToUse = this.endpointFeatures; if (endpointFeaturesToUse == null) { endpointFeaturesToUse = new WebServiceFeature[this.webServiceFeatures.length]; for (int i = 0; i < this.webServiceFeatures.length; i++) { endpointFeaturesToUse[i] = convertWebServiceFeature(this.webServiceFeatures[i]); } } return Endpoint.create(this.bindingType, bean, endpointFeaturesToUse); } else { return Endpoint.create(this.bindingType, bean); } }
Example #2
Source File: ThreadPoolTaskScheduler.java From lams with GNU General Public License v2.0 | 6 votes |
@UsesJava7 @Override protected ExecutorService initializeExecutor( ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { this.scheduledExecutor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler); if (this.removeOnCancelPolicy) { if (setRemoveOnCancelPolicyAvailable && this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true); } else { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } } return this.scheduledExecutor; }
Example #3
Source File: LocalJaxWsServiceFactory.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create a JAX-WS Service according to the parameters of this factory. * @see #setServiceName * @see #setWsdlDocumentUrl */ @UsesJava7 // optional use of Service#create with WebServiceFeature[] public Service createJaxWsService() { Assert.notNull(this.serviceName, "No service name specified"); Service service; if (this.serviceFeatures != null) { service = (this.wsdlDocumentUrl != null ? Service.create(this.wsdlDocumentUrl, getQName(this.serviceName), this.serviceFeatures) : Service.create(getQName(this.serviceName), this.serviceFeatures)); } else { service = (this.wsdlDocumentUrl != null ? Service.create(this.wsdlDocumentUrl, getQName(this.serviceName)) : Service.create(getQName(this.serviceName))); } if (this.executor != null) { service.setExecutor(this.executor); } if (this.handlerResolver != null) { service.setHandlerResolver(this.handlerResolver); } return service; }
Example #4
Source File: UserCredentialsDataSourceAdapter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Determine whether there are currently thread-bound credentials, * using them if available, falling back to the statically specified * username and password (i.e. values of the bean properties) else. * <p>Delegates to {@link #doGetConnection(String, String)} with the * determined credentials as parameters. */ @Override @UsesJava7 public Connection getConnection() throws SQLException { JdbcUserCredentials threadCredentials = this.threadBoundCredentials.get(); Connection con = (threadCredentials != null ? doGetConnection(threadCredentials.username, threadCredentials.password) : doGetConnection(this.username, this.password)); if (this.catalog != null) { con.setCatalog(this.catalog); } if (this.schema != null) { con.setSchema(this.schema); } return con; }
Example #5
Source File: AbstractDriverBasedDataSource.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Build properties for the Driver, including the given username and password (if any), * and obtain a corresponding Connection. * @param username the name of the user * @param password the password to use * @return the obtained Connection * @throws SQLException in case of failure * @see java.sql.Driver#connect(String, java.util.Properties) */ @UsesJava7 protected Connection getConnectionFromDriver(String username, String password) throws SQLException { Properties mergedProps = new Properties(); Properties connProps = getConnectionProperties(); if (connProps != null) { mergedProps.putAll(connProps); } if (username != null) { mergedProps.setProperty("user", username); } if (password != null) { mergedProps.setProperty("password", password); } Connection con = getConnectionFromDriver(mergedProps); if (this.catalog != null) { con.setCatalog(this.catalog); } if (this.schema != null) { con.setSchema(this.schema); } return con; }
Example #6
Source File: ThreadPoolTaskScheduler.java From spring4-understanding with Apache License 2.0 | 6 votes |
@UsesJava7 @Override protected ExecutorService initializeExecutor( ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { this.scheduledExecutor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler); if (this.removeOnCancelPolicy) { if (setRemoveOnCancelPolicyAvailable && this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(true); } else { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } } return this.scheduledExecutor; }
Example #7
Source File: LocalJaxWsServiceFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a JAX-WS Service according to the parameters of this factory. * @see #setServiceName * @see #setWsdlDocumentUrl */ @UsesJava7 // optional use of Service#create with WebServiceFeature[] public Service createJaxWsService() { Assert.notNull(this.serviceName, "No service name specified"); Service service; if (this.serviceFeatures != null) { service = (this.wsdlDocumentUrl != null ? Service.create(this.wsdlDocumentUrl, getQName(this.serviceName), this.serviceFeatures) : Service.create(getQName(this.serviceName), this.serviceFeatures)); } else { service = (this.wsdlDocumentUrl != null ? Service.create(this.wsdlDocumentUrl, getQName(this.serviceName)) : Service.create(getQName(this.serviceName))); } if (this.executor != null) { service.setExecutor(this.executor); } if (this.handlerResolver != null) { service.setHandlerResolver(this.handlerResolver); } return service; }
Example #8
Source File: AbstractJaxWsServiceExporter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create the actual Endpoint instance. * @param bean the service object to wrap * @return the Endpoint instance * @see Endpoint#create(Object) * @see Endpoint#create(String, Object) */ @UsesJava7 // optional use of Endpoint#create with WebServiceFeature[] protected Endpoint createEndpoint(Object bean) { if (this.endpointFeatures != null || this.webServiceFeatures != null) { WebServiceFeature[] endpointFeaturesToUse = this.endpointFeatures; if (endpointFeaturesToUse == null) { endpointFeaturesToUse = new WebServiceFeature[this.webServiceFeatures.length]; for (int i = 0; i < this.webServiceFeatures.length; i++) { endpointFeaturesToUse[i] = convertWebServiceFeature(this.webServiceFeatures[i]); } } return Endpoint.create(this.bindingType, bean, endpointFeaturesToUse); } else { return Endpoint.create(this.bindingType, bean); } }
Example #9
Source File: ThreadPoolTaskScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Set the remove-on-cancel mode on {@link ScheduledThreadPoolExecutor} (JDK 7+). * <p>Default is {@code false}. If set to {@code true}, the target executor will be * switched into remove-on-cancel mode (if possible, with a soft fallback otherwise). * <p><b>This setting can be modified at runtime, for example through JMX.</b> */ @UsesJava7 public void setRemoveOnCancelPolicy(boolean removeOnCancelPolicy) { this.removeOnCancelPolicy = removeOnCancelPolicy; if (setRemoveOnCancelPolicyAvailable && this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy); } else if (removeOnCancelPolicy && this.scheduledExecutor != null) { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } }
Example #10
Source File: StandardWebSocketClient.java From spring4-understanding with Apache License 2.0 | 5 votes |
@UsesJava7 // fallback to InetAddress.getLoopbackAddress() private InetAddress getLocalHost() { try { return InetAddress.getLocalHost(); } catch (UnknownHostException ex) { return InetAddress.getLoopbackAddress(); } }
Example #11
Source File: ResultSetWrappingSqlRowSet.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * @see java.sql.ResultSet#getObject(int, Class) */ @UsesJava7 @Override public <T> T getObject(int columnIndex, Class<T> type) throws InvalidResultSetAccessException { try { return this.resultSet.getObject(columnIndex, type); } catch (SQLException se) { throw new InvalidResultSetAccessException(se); } }
Example #12
Source File: ThreadPoolTaskScheduler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return the current setting for the remove-on-cancel mode. * <p>Requires an underlying {@link ScheduledThreadPoolExecutor}. */ @UsesJava7 public boolean isRemoveOnCancelPolicy() { if (!setRemoveOnCancelPolicyAvailable) { return false; } if (this.scheduledExecutor == null) { // Not initialized yet: return our setting for the time being. return this.removeOnCancelPolicy; } return getScheduledThreadPoolExecutor().getRemoveOnCancelPolicy(); }
Example #13
Source File: ThreadPoolTaskScheduler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Set the remove-on-cancel mode on {@link ScheduledThreadPoolExecutor} (JDK 7+). * <p>Default is {@code false}. If set to {@code true}, the target executor will be * switched into remove-on-cancel mode (if possible, with a soft fallback otherwise). * <p><b>This setting can be modified at runtime, for example through JMX.</b> */ @UsesJava7 public void setRemoveOnCancelPolicy(boolean removeOnCancelPolicy) { this.removeOnCancelPolicy = removeOnCancelPolicy; if (setRemoveOnCancelPolicyAvailable && this.scheduledExecutor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) this.scheduledExecutor).setRemoveOnCancelPolicy(removeOnCancelPolicy); } else if (removeOnCancelPolicy && this.scheduledExecutor != null) { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } }
Example #14
Source File: ScheduledExecutorFactoryBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override @UsesJava7 protected ExecutorService initializeExecutor( ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { ScheduledExecutorService executor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler); if (this.removeOnCancelPolicy) { if (setRemoveOnCancelPolicyAvailable && executor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true); } else { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } } // Register specified ScheduledExecutorTasks, if necessary. if (!ObjectUtils.isEmpty(this.scheduledExecutorTasks)) { registerTasks(this.scheduledExecutorTasks, executor); } // Wrap executor with an unconfigurable decorator. this.exposedExecutor = (this.exposeUnconfigurableExecutor ? Executors.unconfigurableScheduledExecutorService(executor) : executor); return executor; }
Example #15
Source File: ResultSetWrappingSqlRowSet.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @see java.sql.ResultSet#getObject(int, Class) */ @UsesJava7 @Override public <T> T getObject(int columnIndex, Class<T> type) throws InvalidResultSetAccessException { try { return this.resultSet.getObject(columnIndex, type); } catch (SQLException se) { throw new InvalidResultSetAccessException(se); } }
Example #16
Source File: ThreadPoolTaskScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Return the current setting for the remove-on-cancel mode. * <p>Requires an underlying {@link ScheduledThreadPoolExecutor}. */ @UsesJava7 public boolean isRemoveOnCancelPolicy() { if (!setRemoveOnCancelPolicyAvailable) { return false; } if (this.scheduledExecutor == null) { // Not initialized yet: return our setting for the time being. return this.removeOnCancelPolicy; } return getScheduledThreadPoolExecutor().getRemoveOnCancelPolicy(); }
Example #17
Source File: ScheduledExecutorFactoryBean.java From lams with GNU General Public License v2.0 | 5 votes |
@Override @UsesJava7 protected ExecutorService initializeExecutor( ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler) { ScheduledExecutorService executor = createExecutor(this.poolSize, threadFactory, rejectedExecutionHandler); if (this.removeOnCancelPolicy) { if (setRemoveOnCancelPolicyAvailable && executor instanceof ScheduledThreadPoolExecutor) { ((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true); } else { logger.info("Could not apply remove-on-cancel policy - not a Java 7+ ScheduledThreadPoolExecutor"); } } // Register specified ScheduledExecutorTasks, if necessary. if (!ObjectUtils.isEmpty(this.scheduledExecutorTasks)) { registerTasks(this.scheduledExecutorTasks, executor); } // Wrap executor with an unconfigurable decorator. this.exposedExecutor = (this.exposeUnconfigurableExecutor ? Executors.unconfigurableScheduledExecutorService(executor) : executor); return executor; }
Example #18
Source File: JdbcUtils.java From effectivejava with Apache License 2.0 | 4 votes |
/** * Retrieve a JDBC column value from a ResultSet, using the specified value type. * <p>Uses the specifically typed ResultSet accessor methods, falling back to * {@link #getResultSetValue(java.sql.ResultSet, int)} for unknown types. * <p>Note that the returned value may not be assignable to the specified * required type, in case of an unknown type. Calling code needs to deal * with this case appropriately, e.g. throwing a corresponding exception. * @param rs is the ResultSet holding the data * @param index is the column index * @param requiredType the required value type (may be {@code null}) * @return the value object * @throws SQLException if thrown by the JDBC API */ @UsesJava7 // guard optional use of JDBC 4.1 (safe with 1.6 due to getObjectWithTypeAvailable check) public static Object getResultSetValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException { if (requiredType == null) { return getResultSetValue(rs, index); } Object value; // Explicitly extract typed value, as far as possible. if (String.class.equals(requiredType)) { return rs.getString(index); } else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) { value = rs.getBoolean(index); } else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) { value = rs.getByte(index); } else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) { value = rs.getShort(index); } else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) { value = rs.getInt(index); } else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) { value = rs.getLong(index); } else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) { value = rs.getFloat(index); } else if (double.class.equals(requiredType) || Double.class.equals(requiredType) || Number.class.equals(requiredType)) { value = rs.getDouble(index); } else if (BigDecimal.class.equals(requiredType)) { return rs.getBigDecimal(index); } else if (java.sql.Date.class.equals(requiredType)) { return rs.getDate(index); } else if (java.sql.Time.class.equals(requiredType)) { return rs.getTime(index); } else if (java.sql.Timestamp.class.equals(requiredType) || java.util.Date.class.equals(requiredType)) { return rs.getTimestamp(index); } else if (byte[].class.equals(requiredType)) { return rs.getBytes(index); } else if (Blob.class.equals(requiredType)) { return rs.getBlob(index); } else if (Clob.class.equals(requiredType)) { return rs.getClob(index); } else { // Some unknown type desired -> rely on getObject. if (getObjectWithTypeAvailable) { try { return rs.getObject(index, requiredType); } catch (SQLFeatureNotSupportedException ex) { logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex); } catch (AbstractMethodError err) { logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err); } } // Fall back to getObject without type specification... return getResultSetValue(rs, index); } // Perform was-null check if necessary (for results that the JDBC driver returns as primitives). return (rs.wasNull() ? null : value); }
Example #19
Source File: LocaleChangeInterceptor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Parse the given locale value as coming from a request parameter. * <p>The default implementation calls {@link StringUtils#parseLocaleString(String)} * or JDK 7's {@link Locale#forLanguageTag(String)}, depending on the * {@link #setLanguageTagCompliant "languageTagCompliant"} configuration property. * @param locale the locale value to parse * @return the corresponding {@code Locale} instance * @since 4.3 */ @UsesJava7 protected Locale parseLocaleValue(String locale) { return (isLanguageTagCompliant() ? Locale.forLanguageTag(locale) : StringUtils.parseLocaleString(locale)); }
Example #20
Source File: CookieLocaleResolver.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Render the given locale as a text value for inclusion in a cookie. * <p>The default implementation calls {@link Locale#toString()} * or JDK 7's {@link Locale#toLanguageTag()}, depending on the * {@link #setLanguageTagCompliant "languageTagCompliant"} configuration property. * @param locale the locale to stringify * @return a String representation for the given locale * @since 4.3 */ @UsesJava7 protected String toLocaleValue(Locale locale) { return (isLanguageTagCompliant() ? locale.toLanguageTag() : locale.toString()); }
Example #21
Source File: CookieLocaleResolver.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Parse the given locale value coming from an incoming cookie. * <p>The default implementation calls {@link StringUtils#parseLocaleString(String)} * or JDK 7's {@link Locale#forLanguageTag(String)}, depending on the * {@link #setLanguageTagCompliant "languageTagCompliant"} configuration property. * @param locale the locale value to parse * @return the corresponding {@code Locale} instance * @since 4.3 */ @UsesJava7 protected Locale parseLocaleValue(String locale) { return (isLanguageTagCompliant() ? Locale.forLanguageTag(locale) : StringUtils.parseLocaleString(locale)); }