/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.view.rest;

import java.util.concurrent.ScheduledExecutorService;

import org.fudgemsg.FudgeContext;

import com.opengamma.OpenGammaRuntimeException;
import com.opengamma.engine.view.ViewProcessor;
import com.opengamma.util.SingletonFactoryBean;
import com.opengamma.util.jms.JmsConnector;

/**
 * Spring helper for {@link DataViewProcessorsResource}.
 */
public class RestViewProcessorFactoryBean extends SingletonFactoryBean<DataViewProcessorsResource> {

  private ViewProcessor _viewProcessor;
  private JmsConnector _jmsConnector;
  private FudgeContext _fudgeContext;
  private ScheduledExecutorService _scheduler;

  public ViewProcessor getViewProcessor() {
    return _viewProcessor;
  }

  public void setViewProcessor(ViewProcessor viewProcessor) {
    _viewProcessor = viewProcessor;
  }

  public JmsConnector getJmsConnector() {
    return _jmsConnector;
  }

  public void setJmsConnector(JmsConnector jmsConnector) {
    _jmsConnector = jmsConnector;
  }
  
  public FudgeContext getFudgeContext() {
    return _fudgeContext;
  }
  
  public void setFudgeContext(FudgeContext fudgeContext) {
    _fudgeContext = fudgeContext;
  }
  
  public ScheduledExecutorService getScheduler() {
    return _scheduler;
  }
  
  public void setExecutorService(ScheduledExecutorService scheduler) {
    _scheduler = scheduler;
  }

  //-------------------------------------------------------------------------
  @Override
  protected DataViewProcessorsResource createObject() {
    if (_viewProcessor == null) {
      throw new OpenGammaRuntimeException("The viewProcessor property must be set");
    }
    if (_jmsConnector == null) {
      throw new OpenGammaRuntimeException("The connectionFactory property must be set");
    }
    if (_scheduler == null) {
      throw new OpenGammaRuntimeException("The scheduler property must be set");
    }
    
    DataViewProcessorsResource resource = new DataViewProcessorsResource();
    resource.addViewProcessor(getViewProcessor(), getJmsConnector(), getFudgeContext(), getScheduler());
    return resource;
  }

}

@@ -2022,16 +2022,27 @@
    %0A    
+return new 
 DataView
@@ -2063,83 +2063,8 @@
 urce
- resource = new DataViewProcessorsResource();%0A    resource.addViewProcessor
 (get
@@ -2139,29 +2139,8 @@
 ));%0A
-    return resource;%0A
   %7D%0A

Use the constructor rather than mutating