protected void verifyResultCollectionConsistsOfMessages(Collection<?> elements) {
   Class<?> commonElementType = CollectionUtils.findCommonElementType(elements);
   Assert.isAssignable(
       Message.class,
       commonElementType,
       "The expected collection of Messages contains non-Message element: " + commonElementType);
 }
示例#2
0
 public RawCRUDRepository(Class<T> type, DataOperations persister) {
   super(type, persister);
   Assert.isAssignable(
       Serializable.class,
       type,
       "Items being persisted by Raw repositories must be Serializable. ");
 }
示例#3
0
 public RawFuzzyRepository(Class<T> type) {
   super(type);
   Assert.isAssignable(
       Serializable.class,
       type,
       "Items being persisted by Raw repositories must be Serializable. ");
 }
 @SuppressWarnings("unchecked")
 private ApplicationContextInitializer<ConfigurableApplicationContext> loadInitializer(
     String className, ConfigurableApplicationContext wac) {
   try {
     Class<?> initializerClass = ClassUtils.forName(className, wac.getClassLoader());
     Class<?> initializerContextClass =
         GenericTypeResolver.resolveTypeArgument(
             initializerClass, ApplicationContextInitializer.class);
     if (initializerContextClass != null) {
       Assert.isAssignable(
           initializerContextClass,
           wac.getClass(),
           String.format(
               "Could not add context initializer [%s] since its generic parameter [%s] "
                   + "is not assignable from the type of application context used by this "
                   + "framework servlet [%s]: ",
               initializerClass.getName(),
               initializerContextClass.getName(),
               wac.getClass().getName()));
     }
     return BeanUtils.instantiateClass(initializerClass, ApplicationContextInitializer.class);
   } catch (Exception ex) {
     throw new IllegalArgumentException(
         String.format(
             "Could not instantiate class [%s] specified "
                 + "via 'contextInitializerClasses' init-param",
             className),
         ex);
   }
 }
 @Override
 public void setBeanFactory(BeanFactory beanFactory) {
   Assert.isAssignable(
       ConfigurableListableBeanFactory.class,
       beanFactory.getClass(),
       "a ConfigurableListableBeanFactory is required");
   this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
 }
示例#6
0
  /**
   * setReportClass
   *
   * @param reportClass a {@link java.lang.Class} object.
   */
  public void setReportClass(Class<? extends AttributeStatisticVisitorWithResults> reportClass) {
    /*
     * Even though we are using generics, it's just a compile-time check,
     * so let's do a runtime check, too.
     */
    Assert.isAssignable(
        AttributeStatisticVisitorWithResults.class,
        reportClass,
        "the value of property reportClass does not implement the interface "
            + AttributeStatisticVisitorWithResults.class.getName()
            + "; ");

    m_reportClass = reportClass;
  }
  @Override
  public void afterPropertiesSet() throws Exception {
    // 参数验证
    Assert.notNull(this.triggerRule);
    Assert.notNull(this.mainTableName);
    Class<?> jClass = Class.forName(jobClass);
    Assert.isAssignable(Job.class, jClass);

    if (this.name == null) {
      this.name = this.beanName;
    }
    if (this.group == null) {
      this.group = Scheduler.DEFAULT_GROUP;
    }
    if (this.startDelay > 0 || this.startTime == null) {
      this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
    }
    this.triggerClass = this.triggerRule.getTriggerClass();

    // jobDetail
    JobDetailImpl jdi = new JobDetailImpl();
    jdi.setName(this.name);
    jdi.setGroup(this.group);
    jdi.setJobClass(QuartzJob.class);
    jdi.setJobDataMap(this.jobDataMap);
    //        jdi.setDurability(true);
    jdi.setDescription(this.description);
    this.jobDetail = jdi;

    // jobDataMap
    jobDataMap.put("jobDetail", jdi);
    jobDataMap.put(QuartzJob.JOB_CLASS, jClass);
    jobDataMap.put(QuartzJob.MAIN_TABLE_NAME, mainTableName);
    jobDataMap.put(QuartzJob.THREAD_COUNT, threadCount);
    jobDataMap.put(QuartzJob.TIMEOUT, timeoutMinutesForMultiThread);
    jobDataMap.put(QuartzJob.ALLOW_RETRY, allowRetry);

    // trigger
    this.trigger = triggerRule.initializeTrigger();
    trigger.setName(this.name);
    trigger.setGroup(this.group);
    trigger.setJobKey(this.jobDetail.getKey());
    trigger.setJobDataMap(this.jobDataMap);
    trigger.setStartTime(this.startTime);
    trigger.setPriority(this.priority);
    trigger.setMisfireInstruction(this.misfireInstruction);
    trigger.setDescription(this.description);
  }
 /* (non-Javadoc)
  * @see org.springframework.xd.module.Plugin#processModule(org.springframework.xd.module.Module)
  */
 @Override
 public void processModule(Module module, String group, int index) {
   // TODO: Check if module started?
   Assert.notNull(module, "module cannot be null");
   Assert.isAssignable(IntegrationModule.class, module.getClass());
   String resourcePath = this.integrationModuleBasePath + "/" + module.getName() + ".xml";
   module.addComponents(new ClassPathResource(resourcePath));
   IntegrationModule integrationModule = (IntegrationModule) module;
   integrationModule.initializeModule();
   channelRegistry.inbound(
       integrationModule.getName() + ".input", integrationModule.getInputChannel());
   for (Entry<String, SubscribableChannel> entry :
       integrationModule.getOutputChannels().entrySet()) {
     channelRegistry.outbound(
         integrationModule.getName() + "." + entry.getKey(), entry.getValue());
   }
 }
 private Class<?> getHttpEntityType(MethodParameter methodParam) {
   Assert.isAssignable(HttpEntity.class, methodParam.getParameterType());
   ParameterizedType type = (ParameterizedType) methodParam.getGenericParameterType();
   if (type.getActualTypeArguments().length == 1) {
     Type typeArgument = type.getActualTypeArguments()[0];
     if (typeArgument instanceof Class) {
       return (Class<?>) typeArgument;
     } else if (typeArgument instanceof GenericArrayType) {
       Type componentType = ((GenericArrayType) typeArgument).getGenericComponentType();
       if (componentType instanceof Class) {
         // Surely, there should be a nicer way to do this
         Object array = Array.newInstance((Class<?>) componentType, 0);
         return array.getClass();
       }
     }
   }
   throw new IllegalArgumentException(
       "HttpEntity parameter (" + methodParam.getParameterName() + ") is not parameterized");
 }
 @SuppressWarnings("unchecked")
 private List<ApplicationListener<ApplicationEvent>> getListeners(ConfigurableEnvironment env) {
   String classNames = env.getProperty(PROPERTY_NAME);
   List<ApplicationListener<ApplicationEvent>> listeners =
       new ArrayList<ApplicationListener<ApplicationEvent>>();
   if (StringUtils.hasLength(classNames)) {
     for (String className : StringUtils.commaDelimitedListToSet(classNames)) {
       try {
         Class<?> clazz = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
         Assert.isAssignable(
             ApplicationListener.class,
             clazz,
             "class [" + className + "] must implement ApplicationListener");
         listeners.add((ApplicationListener<ApplicationEvent>) BeanUtils.instantiateClass(clazz));
       } catch (Exception ex) {
         throw new ApplicationContextException(
             "Failed to load context listener class [" + className + "]", ex);
       }
     }
   }
   AnnotationAwareOrderComparator.sort(listeners);
   return listeners;
 }
  @Override
  public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
      throws BeansException {
    LOGGER.info("Loading Management providers {}", Provider.class.getSimpleName());

    Set<String> providers =
        new HashSet<>(
            SpringFactoriesLoader.loadFactoryNames(
                Provider.class, beanFactory.getBeanClassLoader()));

    LOGGER.info(
        "\tFound {} {} implementation(s)", providers.size(), Provider.class.getSimpleName());

    DefaultListableBeanFactory defaultListableBeanFactory =
        (DefaultListableBeanFactory) beanFactory;
    environment = beanFactory.getBean(Environment.class);

    List<String> getSecurityProviders = getSecurityProviders();

    for (String provider : providers) {
      try {
        Class<?> instanceClass = ClassUtils.forName(provider, beanFactory.getBeanClassLoader());
        Assert.isAssignable(Provider.class, instanceClass);

        Provider providerInstance = createInstance((Class<Provider>) instanceClass);

        if (getSecurityProviders.contains(providerInstance.type())) {
          LOGGER.info(
              "Registering a provider {} [{}]",
              instanceClass.getSimpleName(),
              providerInstance.type());

          if (providerInstance.authenticationManager() != null) {
            defaultListableBeanFactory.registerBeanDefinition(
                providerInstance.authenticationManager().getName(),
                new RootBeanDefinition(providerInstance.authenticationManager().getName()));
          }

          if (providerInstance.identityManager() != null) {
            defaultListableBeanFactory.registerBeanDefinition(
                providerInstance.identityManager().getName(),
                new RootBeanDefinition(providerInstance.identityManager().getName()));
          }

          Class<?> extension = providerInstance.configuration();
          if (extension != null) {
            LOGGER.info("\tRegistering provider extension: {}", extension.getName());
            defaultListableBeanFactory.registerBeanDefinition(
                extension.getName(), new RootBeanDefinition(extension.getName()));

            LOGGER.info("\tLoading @Configuration from previous extension {}", extension.getName());
            configurationClassPostProcessor.processConfigBeanDefinitions(
                defaultListableBeanFactory);
          }
        }
      } catch (Exception ex) {
        LOGGER.error("Unable to instantiate provider: {}", ex);
        throw new IllegalStateException("Unable to instantiate provider: " + provider, ex);
      }
    }
  }
 /**
  * Set the Quartz SchedulerFactory implementation to use.
  *
  * <p>Default is {@link StdSchedulerFactory}, reading in the standard {@code quartz.properties}
  * from {@code quartz.jar}. To use custom Quartz properties, specify the "configLocation" or
  * "quartzProperties" bean property on this FactoryBean.
  *
  * @see org.quartz.impl.StdSchedulerFactory
  * @see #setConfigLocation
  * @see #setQuartzProperties
  */
 public void setSchedulerFactoryClass(Class<? extends SchedulerFactory> schedulerFactoryClass) {
   Assert.isAssignable(SchedulerFactory.class, schedulerFactoryClass);
   this.schedulerFactoryClass = schedulerFactoryClass;
 }
 /**
  * Specify the PersistenceManager interface to expose, possibly including vendor extensions.
  *
  * <p>Default is the standard {@code javax.jdo.PersistenceManager} interface.
  */
 public void setPersistenceManagerInterface(
     Class<? extends PersistenceManager> persistenceManagerInterface) {
   this.persistenceManagerInterface = persistenceManagerInterface;
   Assert.notNull(persistenceManagerInterface, "persistenceManagerInterface must not be null");
   Assert.isAssignable(PersistenceManager.class, persistenceManagerInterface);
 }
 @Override
 public void removeModule(Module module, String group, int index) {
   Assert.notNull(module, "module cannot be null");
   Assert.isAssignable(IntegrationModule.class, module.getClass());
   // TODO:
 }