List of usage examples for org.springframework.util Assert isInstanceOf
public static void isInstanceOf(Class<?> type, @Nullable Object obj, Supplier<String> messageSupplier)
From source file:org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.java
protected final HttpServletRequest getHttpServletRequest(ServerHttpRequest request) { Assert.isInstanceOf(ServletServerHttpRequest.class, request, "ServletServerHttpRequest required"); return ((ServletServerHttpRequest) request).getServletRequest(); }
From source file:org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.java
protected final HttpServletResponse getHttpServletResponse(ServerHttpResponse response) { Assert.isInstanceOf(ServletServerHttpResponse.class, response, "ServletServerHttpResponse required"); return ((ServletServerHttpResponse) response).getServletResponse(); }
From source file:org.springframework.web.socket.sockjs.AbstractSockJsSession.java
public final synchronized void sendMessage(WebSocketMessage message) throws IOException { Assert.isTrue(!isClosed(), "Cannot send a message when session is closed"); Assert.isInstanceOf(TextMessage.class, message, "Expected text message: " + message); sendMessageInternal(((TextMessage) message).getPayload()); }
From source file:org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.java
public final void sendMessage(WebSocketMessage<?> message) throws IOException { Assert.state(!isClosed(), "Cannot send a message when session is closed"); Assert.isInstanceOf(TextMessage.class, message, "SockJS supports text messages only"); sendMessageInternal(((TextMessage) message).getPayload()); }
From source file:org.springframework.webflow.engine.impl.FlowExecutionImplFactory.java
public FlowExecution createFlowExecution(FlowDefinition flowDefinition) { Assert.isInstanceOf(Flow.class, flowDefinition, "FlowDefinition is of the wrong type: "); if (logger.isDebugEnabled()) { logger.debug("Creating new execution of '" + flowDefinition.getId() + "'"); }//from w w w .jav a2 s . c om FlowExecutionImpl execution = new FlowExecutionImpl((Flow) flowDefinition); execution.setAttributes(executionAttributes); execution.setListeners(executionListenerLoader.getListeners(execution.getDefinition())); execution.setKeyFactory(executionKeyFactory); return execution; }
From source file:org.springframework.webflow.engine.impl.FlowExecutionImplFactory.java
public FlowExecution restoreFlowExecution(FlowExecution flowExecution, FlowDefinition flowDefinition, FlowExecutionKey flowExecutionKey, MutableAttributeMap<Object> conversationScope, FlowDefinitionLocator subflowDefinitionLocator) { Assert.isInstanceOf(FlowExecutionImpl.class, flowExecution, "FlowExecution is of the wrong type: "); Assert.isInstanceOf(Flow.class, flowDefinition, "FlowDefinition is of the wrong type: "); FlowExecutionImpl execution = (FlowExecutionImpl) flowExecution; Flow flow = (Flow) flowDefinition;/*from www .j a v a 2s. co m*/ execution.setFlow(flow); if (execution.hasSessions()) { FlowSessionImpl rootSession = execution.getRootSession(); rootSession.setFlow(flow); rootSession.setState(flow.getStateInstance(rootSession.getStateId())); if (execution.hasSubflowSessions()) { for (Iterator<FlowSessionImpl> it = execution.getSubflowSessionIterator(); it.hasNext();) { FlowSessionImpl subflowSession = it.next(); Flow subflowDef = (Flow) subflowDefinitionLocator.getFlowDefinition(subflowSession.getFlowId()); subflowSession.setFlow(subflowDef); subflowSession.setState(subflowDef.getStateInstance(subflowSession.getStateId())); } } } execution.setKey(flowExecutionKey); if (conversationScope == null) { conversationScope = new LocalAttributeMap<Object>(); } execution.setConversationScope(conversationScope); execution.setAttributes(executionAttributes); execution.setListeners(executionListenerLoader.getListeners(execution.getDefinition())); execution.setKeyFactory(executionKeyFactory); return execution; }
From source file:org.springframework.ws.soap.axiom.AxiomSoapMessageFactory.java
public AxiomSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { Assert.isInstanceOf(TransportInputStream.class, inputStream, "AxiomSoapMessageFactory requires a TransportInputStream"); TransportInputStream transportInputStream = (TransportInputStream) inputStream; String contentType = getHeaderValue(transportInputStream, TransportConstants.HEADER_CONTENT_TYPE); if (!StringUtils.hasLength(contentType)) { if (logger.isDebugEnabled()) { logger.debug("TransportInputStream has no Content-Type header; defaulting to \"" + SoapVersion.SOAP_11.getContentType() + "\""); }//from www . j a v a2s.com contentType = SoapVersion.SOAP_11.getContentType(); } String soapAction = getHeaderValue(transportInputStream, TransportConstants.HEADER_SOAP_ACTION); if (!StringUtils.hasLength(soapAction)) { soapAction = SoapUtils.extractActionFromContentType(contentType); } try { if (isMultiPartRelated(contentType)) { return createMultiPartAxiomSoapMessage(inputStream, contentType, soapAction); } else { return createAxiomSoapMessage(inputStream, contentType, soapAction); } } catch (XMLStreamException ex) { throw new AxiomSoapMessageCreationException("Could not parse request: " + ex.getMessage(), ex); } catch (OMException ex) { throw new AxiomSoapMessageCreationException("Could not create message: " + ex.getMessage(), ex); } }
From source file:org.springframework.xd.dirt.server.container.ContainerServerApplication.java
@Override public void setEnvironment(Environment environment) { Assert.isInstanceOf(ConfigurableEnvironment.class, environment, "unsupported environment type. " + environment.getClass()); this.environment = (ConfigurableEnvironment) environment; }
From source file:org.springframework.xd.module.core.CompositeModule.java
@Override public void addSource(Object source) { Assert.notNull(source, "source cannot be null"); Assert.isInstanceOf(Resource.class, source, "unsupported source: " + source.getClass().getName()); Resource resource = (Resource) source; XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.context); reader.loadBeanDefinitions(resource); }
From source file:pt.webdetails.browserid.spring.BrowserIdAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { Assert.isInstanceOf(BrowserIdAuthentication.class, authentication, "Only " + BrowserIdAuthentication.class.getName() + " is supported."); BrowserIdAuthentication browserIdAuth = (BrowserIdAuthentication) authentication; BrowserIdResponse response = browserIdAuth.getVerificationResponse(); if (response != null && response.getStatus() == BrowserIdResponse.Status.OK) { String identity = response.getEmail(); //get authorities GrantedAuthority[] grantedAuthorities = getAuthoritiesService().getAuthoritiesForUser(identity); if (grantedAuthorities == null || grantedAuthorities.length == 0) { throw new BrowserIdAuthenticationException("No authorities granted to " + identity); }/*from w w w . j ava 2s . co m*/ BrowserIdAuthenticationToken authenticatedToken = new BrowserIdAuthenticationToken(response, browserIdAuth.getAssertion(), grantedAuthorities); if (log.isDebugEnabled()) { log.debug("Upgraded token with authorities: " + authenticatedToken); } return authenticatedToken; } else { throw new BrowserIdAuthenticationException("User not verified: " + response); } }