List of usage examples for org.springframework.util Assert isInstanceOf
public static void isInstanceOf(Class<?> type, @Nullable Object obj)
From source file:org.cloudfoundry.identity.uaa.web.ForwardAwareInternalResourceViewResolver.java
private MediaType getRequestedMediaType() { RequestAttributes attrs = RequestContextHolder.getRequestAttributes(); Assert.isInstanceOf(ServletRequestAttributes.class, attrs); HttpServletRequest request = ((ServletRequestAttributes) attrs).getRequest(); MediaType requestedMediaType = getMediaTypes(request); return requestedMediaType; }
From source file:jails.http.client.SimpleClientHttpRequestFactory.java
/** * Opens and returns a connection to the given URL. * <p>The default implementation uses the given {@linkplain #setProxy(java.net.Proxy) proxy} - if any - to open a * connection.//from w w w .java 2s .c o m * * @param url the URL to open a connection to * @param proxy the proxy to use, may be {@code null} * @return the opened connection * @throws IOException in case of I/O errors */ protected HttpURLConnection openConnection(URL url, Proxy proxy) throws IOException { URLConnection urlConnection = proxy != null ? url.openConnection(proxy) : url.openConnection(); Assert.isInstanceOf(HttpURLConnection.class, urlConnection); return (HttpURLConnection) urlConnection; }
From source file:grails.plugin.cloudfoundry.GrailsHttpRequestFactory.java
@Override public ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod) throws IOException { URL url = uri.toURL();/*w w w .j a v a2 s . c om*/ URLConnection urlConnection = proxy != null ? url.openConnection(proxy) : url.openConnection(); Assert.isInstanceOf(HttpURLConnection.class, urlConnection); prepareConnection((HttpURLConnection) urlConnection, httpMethod.name()); return new GrailsHttpRequest(wrap((HttpURLConnection) urlConnection)); }
From source file:org.codehaus.grepo.procedure.repository.GrepoProcedureConfiguration.java
/** * {@inheritDoc}/*from w w w . ja v a 2 s. c om*/ */ @Override protected void validateMethodInterceptor() { super.validateMethodInterceptor(); Assert.isInstanceOf(GenericProcedureMethodInterceptor.class, getMethodInterceptor()); }
From source file:org.codehaus.grepo.query.commons.repository.GrepoQueryConfiguration.java
/** * {@inheritDoc}/*from ww w . j a v a 2s . c o m*/ */ @Override protected void validateMethodInterceptor() { super.validateMethodInterceptor(); Assert.isInstanceOf(GenericQueryMethodInterceptor.class, getMethodInterceptor()); }
From source file:ch.rasc.wampspring.config.WampSubProtocolHandler.java
/** * Handle incoming WebSocket messages from clients. */// w ww . ja v a2 s . co m @Override public void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> webSocketMessage, MessageChannel outputChannel) { Assert.isInstanceOf(TextMessage.class, webSocketMessage); WampMessage wampMessage = null; try { wampMessage = WampMessage.fromJson(session, this.jsonFactory, ((TextMessage) webSocketMessage).getPayload()); } catch (Throwable ex) { if (logger.isErrorEnabled()) { logger.error("Failed to parse " + webSocketMessage + " in session " + session.getId() + ".", ex); } return; } try { WampSessionContextHolder.setAttributesFromMessage(wampMessage); outputChannel.send(wampMessage); } catch (Throwable ex) { logger.error("Failed to send client message to application via MessageChannel" + " in session " + session.getId() + ".", ex); if (wampMessage != null && wampMessage instanceof CallMessage) { CallErrorMessage callErrorMessage = new CallErrorMessage((CallMessage) wampMessage, "", ex.toString()); try { String json = callErrorMessage.toJson(this.jsonFactory); session.sendMessage(new TextMessage(json)); } catch (Throwable t) { // Could be part of normal workflow (e.g. browser tab closed) logger.debug("Failed to send error to client.", t); } } } finally { WampSessionContextHolder.resetAttributes(); } }
From source file:io.twipple.springframework.data.clusterpoint.convert.ClusterpointDocumentPropertyAccessor.java
/** * It can always read from those properties. * * @param context the evaluation context. * @param target the target object.//from w w w . java2s . c o m * @param name the name of the property. * @return always true. */ @Override public boolean canRead(@NotNull EvaluationContext context, @NotNull Object target, @NotNull String name) { Assert.notNull(context); Assert.notNull(target); Assert.isInstanceOf(ClusterpointDocument.class, target); Assert.hasText(name); ClusterpointDocument source = (ClusterpointDocument) target; return source.canRead(context, name); }
From source file:org.apache.cxf.fediz.spring.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsFederationService.java
/** * Get a UserDetails object based on the user name contained in the given * token, and the GrantedAuthorities as returned by the * GrantedAuthoritiesContainer implementation as returned by * the token.getDetails() method.//from w w w . j ava 2 s. c o m */ public final UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws AuthenticationException { Assert.notNull(token.getDetails()); Assert.isInstanceOf(GrantedAuthoritiesContainer.class, token.getDetails()); Assert.isInstanceOf(FedizPrincipal.class, token.getPrincipal()); GrantedAuthority[] authorities = ((GrantedAuthoritiesContainer) token.getDetails()).getGrantedAuthorities(); return createuserDetails(token, authorities, ((FedizPrincipal) token.getPrincipal()).getClaims()); }
From source file:org.openregistry.core.domain.jpa.sor.JpaSorLeaveImpl.java
public void setReason(final Type type) { Assert.isInstanceOf(JpaTypeImpl.class, type); this.reason = (JpaTypeImpl) type; }
From source file:io.pivotal.cla.config.DatabaseConfig.java
@Bean public DataSource dataSource() { DataSource service = cloud().getSingletonServiceConnector(DataSource.class, null); Assert.isInstanceOf(org.apache.tomcat.jdbc.pool.DataSource.class, service); org.apache.tomcat.jdbc.pool.DataSource dataSource = (org.apache.tomcat.jdbc.pool.DataSource) service; dataSource.setValidationQuery("/* PING */ SELECT 1"); configureDataSource(dataSource);/*from w w w. j a va 2s. c o m*/ return dataSource; }