Example usage for org.springframework.util Assert isInstanceOf

List of usage examples for org.springframework.util Assert isInstanceOf

Introduction

In this page you can find the example usage for org.springframework.util Assert isInstanceOf.

Prototype

public static void isInstanceOf(Class<?> type, @Nullable Object obj) 

Source Link

Document

Assert that the provided object is an instance of the provided class.

Usage

From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java

@PostMapping(path = "/genericUser")
public Generic<User> testGenericUser(@RequestBody Generic<User> input) {
    Assert.isInstanceOf(Generic.class, input);
    Assert.isInstanceOf(User.class, input.value);
    return input;
}

From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java

@PostMapping(path = "/genericLong")
public Generic<Long> testGenericLong(@RequestBody Generic<Long> input) {
    Assert.isInstanceOf(Generic.class, input);
    Assert.isInstanceOf(Long.class, input.value);
    return input;
}

From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java

@PostMapping(path = "/genericDate")
public Generic<Date> testGenericDate(@RequestBody Generic<Date> input) {
    Assert.isInstanceOf(Generic.class, input);
    Assert.isInstanceOf(Date.class, input.value);
    System.out.println(input.value);
    return input;
}

From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java

@PostMapping(path = "/genericEnum")
public Generic<HttpStatus> testGenericEnum(@RequestBody Generic<HttpStatus> input) {
    Assert.isInstanceOf(Generic.class, input);
    Assert.isInstanceOf(HttpStatus.class, input.value);
    return input;
}

From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java

@PostMapping(path = "/genericGenericUser")
public Generic<Generic<User>> testGenericGenericUser(@RequestBody Generic<Generic<User>> input) {
    Assert.isInstanceOf(Generic.class, input);
    Assert.isInstanceOf(Generic.class, input.value);
    Assert.isInstanceOf(User.class, input.value.value);
    return input;
}

From source file:org.beadle.framework.view.ReturnTypeViewResolver.java

public View resolveViewName(String viewName, Locale locale) throws Exception {
    RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
    HttpServletRequest request = ((ServletRequestAttributes) attrs).getRequest();
    Assert.isInstanceOf(ServletRequestAttributes.class, attrs);
    List<MediaType> requestedMediaTypes = getMediaTypes(request);
    if (requestedMediaTypes != null) {
        List<View> candidateViews = getCandidateViews(viewName, locale, requestedMediaTypes);
        View bestView = getBestView(candidateViews, requestedMediaTypes, attrs);
        if (bestView != null) {
            return bestView;
        }/*from   ww w .j  a v a 2 s .c  o  m*/
    }
    if (this.useNotAcceptableStatusCode) {
        if (logger.isDebugEnabled()) {
            logger.debug("No acceptable view found; returning 406 (Not Acceptable) status code");
        }
        return NOT_ACCEPTABLE_VIEW;
    } else {
        logger.debug("No acceptable view found; returning null");
        return null;
    }
}

From source file:org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration.java

protected void addDefaultDependencyFactories() {
    boolean debug = log.isDebugEnabled();

    // default JDK 1.4 processor
    dependencyFactories.add(0, new MandatoryImporterDependencyFactory());

    // load through reflection the dependency and injection processors if running on JDK 1.5 and annotation
    // processing is enabled
    if (processAnnotation) {
        // dependency processor
        Class<?> annotationProcessor = null;
        try {//w ww .java 2s  .  com
            annotationProcessor = Class.forName(ANNOTATION_DEPENDENCY_FACTORY, false,
                    ExtenderConfiguration.class.getClassLoader());
        } catch (ClassNotFoundException cnfe) {
            log.warn("Spring DM annotation package not found, annotation processing disabled.");
            log.debug("Spring DM annotation package not found, annotation processing disabled.", cnfe);
            return;
        }
        Object processor = BeanUtils.instantiateClass(annotationProcessor);
        Assert.isInstanceOf(OsgiServiceDependencyFactory.class, processor);
        dependencyFactories.add(1, (OsgiServiceDependencyFactory) processor);

        if (debug)
            log.debug("Succesfully loaded annotation dependency processor [" + ANNOTATION_DEPENDENCY_FACTORY
                    + "]");

        // add injection processor (first in line)
        postProcessors.add(0, new OsgiAnnotationPostProcessor());
        log.info("Spring-DM annotation processing enabled");
    } else {
        if (debug) {
            log.debug("Spring-DM annotation processing disabled; [" + ANNOTATION_DEPENDENCY_FACTORY
                    + "] not loaded");
        }
    }

}

From source file:org.eclipse.gemini.blueprint.service.dependency.internal.DefaultMandatoryDependencyManager.java

public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory);
    this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}

From source file:org.springframework.batch.core.configuration.support.AbstractApplicationContextFactory.java

/**
 * Setter for the parent application context.
 *
 * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
 *///  www  .  ja  va  2s .  c  om
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    if (applicationContext == null) {
        return;
    }
    Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext);
    parent = (ConfigurableApplicationContext) applicationContext;
}

From source file:org.springframework.batch.core.configuration.support.ClassPathXmlApplicationContextFactory.java

/**
 * Setter for the parent application context.
 * /*from   ww w .j  a  va  2 s .  co  m*/
 * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
 */
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    if (applicationContext == null) {
        return;
    }
    Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext);
    parent = (ConfigurableApplicationContext) applicationContext;
}