Package org.springframework.integration.support.channel

Examples of org.springframework.integration.support.channel.BeanFactoryChannelResolver


    private DirectChannel inputChannel;
    private MessageChannel outputChannel;

    public SpringIntegrationProducer(SpringCamelContext context, SpringIntegrationEndpoint endpoint) {
        super(endpoint);
        this.channelResolver = new BeanFactoryChannelResolver(context.getApplicationContext());
    }
View Full Code Here


  public static void main(String[] args) {
    log.info("Starting notification system...");
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/notification.xml");

    ChannelResolver channelResolver = new BeanFactoryChannelResolver(context);
    NotificationUtils notificationUtils = new NotificationUtils();

    File propsPath = new File(".", "notification.properties");
    Properties props = new Properties();
    try {
      props.load(new FileReader(propsPath));

      CompositeFileListFilter statusFilter = (CompositeFileListFilter) context.getBean("statusFilter");

      Map<String, Set<File>> allDataPaths = new HashMap<String, Set<File>>();

      for (String platformType : PlatformType.getKeys()) {
        platformType = platformType.toLowerCase();

        if (props.containsKey(platformType + ".splitterBatchSize")) {
          notificationUtils.setSplitterBatchSize(Integer.parseInt(props.getProperty(platformType + ".splitterBatchSize")));
        }

        if (props.containsKey(platformType + ".dataPaths")) {
          log.debug("Resolving " + platformType + ".dataPaths ...");
          String dataPaths = props.getProperty(platformType + ".dataPaths");
          Set<File> paths = new HashSet<File>();
          for (String path : dataPaths.split(",")) {
            File f = new File(path);
            if (f.exists() && f.canRead() && f.isDirectory()) {
              paths.add(f);
              log.debug("Added " + path);
            }
          }

          allDataPaths.put(platformType, paths);

          if (platformType.equals("solid")) {
            for (String key : props.stringPropertyNames()) {
              if (key.startsWith("solid.wsdl.url.")) {
                String serviceName = key.substring(key.lastIndexOf(".") + 1);
                log.debug("Creating service: " + serviceName);
                SolidServiceWrapper ssw = new SolidServiceWrapper(serviceName, URI.create(props.getProperty(key)).toURL());
                context.getBeanFactory().registerSingleton(serviceName, ssw);
              }
            }
          }

          if (platformType.equals("pacbio")) {
            for (String key : props.stringPropertyNames()) {
              if (key.startsWith("pacbio.ws.url.")) {
                String serviceName = key.substring(key.lastIndexOf(".") + 1);
                log.debug("Creating service: " + serviceName);
                PacBioServiceWrapper psw = new PacBioServiceWrapper(serviceName, URI.create(props.getProperty(key)));
                context.getBeanFactory().registerSingleton(serviceName, psw);
              }
            }
          }

          RunFolderScanner rfs = (RunFolderScanner) context.getBean(platformType + "StatusRecursiveScanner");

          MultiFileQueueMessageSource mfqms = new MultiFileQueueMessageSource();
          mfqms.setBeanName(platformType + "MultiFileQueueMessageSource");
          mfqms.setBeanFactory(context.getBeanFactory());
          mfqms.setScanner(rfs);
          mfqms.setFilter(statusFilter);
          mfqms.setDirectories(paths);
          //make sure all the directories are rescanned each poll
          mfqms.setScanEachPoll(false);
          mfqms.afterPropertiesSet();

          SourcePollingChannelAdapter spca = new SourcePollingChannelAdapter();
          spca.setBeanName(platformType + "StatusFileSource");
          spca.setBeanFactory(context.getBeanFactory());
          spca.setMaxMessagesPerPoll(1);

          DynamicTrigger trigger;
          if (props.containsKey(platformType + ".scanRate")) {
            trigger = new DynamicTrigger(Integer.parseInt(props.getProperty(platformType + ".scanRate")), TimeUnit.MILLISECONDS);
          }
          else {
            trigger = new DynamicTrigger(600000, TimeUnit.MILLISECONDS);
          }
          trigger.setFixedRate(false);
          spca.setTrigger(trigger);

          spca.setSource(mfqms);
          spca.setOutputChannel(channelResolver.resolveChannelName(platformType + "StatusFileInputChannel"));
          spca.setAutoStartup(false);
          spca.afterPropertiesSet();

          DirectChannel outputChannel = (DirectChannel) channelResolver.resolveChannelName(platformType + "StatusChannel");
          outputChannel.setBeanName(platformType + "StatusChannel");
          outputChannel.setBeanFactory(context.getBeanFactory());

          if (props.containsKey("wiretap.enabled") && "true".equals(props.get("wiretap.enabled"))) {
            //set up wire tap
            DirectChannel wireTapChannel = (DirectChannel) channelResolver.resolveChannelName("wireTapChannel");
            wireTapChannel.setBeanName("wireTapChannel");
            wireTapChannel.setBeanFactory(context.getBeanFactory());

            LoggingHandler wireTapLogger = new LoggingHandler("TRACE");
            wireTapLogger.setBeanName("OutputWireTapper");
            wireTapLogger.setBeanFactory(context.getBeanFactory());
            wireTapLogger.setLoggerName("wiretap");
            wireTapLogger.setShouldLogFullMessage(true);
            wireTapLogger.afterPropertiesSet();
            wireTapChannel.subscribe(wireTapLogger);

            List<ChannelInterceptor> ints = new ArrayList<ChannelInterceptor>();
            WireTap wt = new WireTap(wireTapChannel);
            ints.add(wt);
            outputChannel.setInterceptors(ints);
          }

          DirectChannel signChannel = (DirectChannel)channelResolver.resolveChannelName(platformType+"MessageSignerChannel");
          signChannel.setBeanFactory(context.getBeanFactory());

          DirectChannel splitterChannel = (DirectChannel)channelResolver.resolveChannelName(platformType+"SplitterChannel");
          splitterChannel.setBeanFactory(context.getBeanFactory());

          if (props.containsKey(platformType + ".http.statusEndpointURIs")) {
            log.debug("Resolving " + platformType + ".http.statusEndpointURIs ...");
            String statusEndpointURIs = props.getProperty(platformType + ".http.statusEndpointURIs");
View Full Code Here

            endpoint.getEndpointConfiguration().setChannelName(resourcePath);
        }

        if (context.getApplicationContext() != null) {
            endpoint.getEndpointConfiguration().setBeanFactory(context.getApplicationContext());
            endpoint.getEndpointConfiguration().setChannelResolver(new BeanFactoryChannelResolver(context.getApplicationContext()));
        }

        enrichEndpointConfiguration(endpoint.getEndpointConfiguration(), parameters, context);

        return endpoint;
View Full Code Here

     * @param channelName the name to resolve
     * @return the MessageChannel object
     */
    protected MessageChannel resolveChannelName(String channelName) {
        if (endpointConfiguration.getChannelResolver() == null) {
            endpointConfiguration.setChannelResolver(new BeanFactoryChannelResolver(endpointConfiguration.getBeanFactory()));
        }

        return endpointConfiguration.getChannelResolver().resolveDestination(channelName);
    }
View Full Code Here

    /**
     * Checks if channel resolver is set before using channel names.
     */
    private void checkChannelResolver() {
        if (action.getChannelResolver() == null) {
            action.setChannelResolver(new BeanFactoryChannelResolver(applicationContext));
        }
    }
View Full Code Here

     * @param channelName the name to resolve
     * @return the MessageChannel object
     */
    protected MessageChannel resolveChannelName(String channelName) {
        if (channelResolver == null) {
            channelResolver = new BeanFactoryChannelResolver(beanFactory);
        }
       
        return channelResolver.resolveDestination(channelName);
    }
View Full Code Here

     * @param channelName the name to resolve
     * @return the MessageChannel object
     */
    protected MessageChannel resolveChannelName(String channelName) {
        if (endpointConfiguration.getChannelResolver() == null) {
            endpointConfiguration.setChannelResolver(new BeanFactoryChannelResolver(endpointConfiguration.getBeanFactory()));
        }

        return endpointConfiguration.getChannelResolver().resolveDestination(channelName);
    }
View Full Code Here

TOP

Related Classes of org.springframework.integration.support.channel.BeanFactoryChannelResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.