<reponame>slusek/OG-Platform
/**
 * Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
 * 
 * Please see distribution for license.
 */
package com.opengamma.component.factory.engine;

import java.util.Map;

import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;

import com.opengamma.component.ComponentInfo;
import com.opengamma.component.ComponentRepository;
import com.opengamma.engine.marketdata.NamedMarketDataSpecificationRepository;
import com.opengamma.financial.view.rest.RemoteNamedMarketDataSpecificationRepository;

/**
 * 
 */
@BeanDefinition
public class RemoteNamedMarketDataSpecificationRepositoryComponentFactory extends AbstractRemoteComponentServerComponentFactory {

  @Override
  protected void initComponent(ComponentRepository repo, ComponentInfo info) {
    if (NamedMarketDataSpecificationRepository.class.isAssignableFrom(info.getType())) {
      NamedMarketDataSpecificationRepository repository = new RemoteNamedMarketDataSpecificationRepository(info.getUri());
      repo.registerComponent(info, repository);
      if (isPublishRest()) {
        repo.getRestComponents().republish(info);
      }
    }   
  }
  
  //------------------------- AUTOGENERATED START -------------------------
  ///CLOVER:OFF
  /**
   * The meta-bean for {@code RemoteNamedMarketDataSpecificationRepositoryComponentFactory}.
   * @return the meta-bean, not null
   */
  public static RemoteNamedMarketDataSpecificationRepositoryComponentFactory.Meta meta() {
    return RemoteNamedMarketDataSpecificationRepositoryComponentFactory.Meta.INSTANCE;
  }

  static {
    JodaBeanUtils.registerMetaBean(RemoteNamedMarketDataSpecificationRepositoryComponentFactory.Meta.INSTANCE);
  }

  @Override
  public RemoteNamedMarketDataSpecificationRepositoryComponentFactory.Meta metaBean() {
    return RemoteNamedMarketDataSpecificationRepositoryComponentFactory.Meta.INSTANCE;
  }

  @Override
  protected Object propertyGet(String propertyName, boolean quiet) {
    return super.propertyGet(propertyName, quiet);
  }

  @Override
  protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    super.propertySet(propertyName, newValue, quiet);
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
      return super.equals(obj);
    }
    return false;
  }

  @Override
  public int hashCode() {
    int hash = 7;
    return hash ^ super.hashCode();
  }

  //-----------------------------------------------------------------------
  /**
   * The meta-bean for {@code RemoteNamedMarketDataSpecificationRepositoryComponentFactory}.
   */
  public static class Meta extends AbstractRemoteComponentServerComponentFactory.Meta {
    /**
     * The singleton instance of the meta-bean.
     */
    static final Meta INSTANCE = new Meta();

    /**
     * The meta-properties.
     */
    private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
        this, (DirectMetaPropertyMap) super.metaPropertyMap());

    /**
     * Restricted constructor.
     */
    protected Meta() {
    }

    @Override
    public BeanBuilder<? extends RemoteNamedMarketDataSpecificationRepositoryComponentFactory> builder() {
      return new DirectBeanBuilder<RemoteNamedMarketDataSpecificationRepositoryComponentFactory>(new RemoteNamedMarketDataSpecificationRepositoryComponentFactory());
    }

    @Override
    public Class<? extends RemoteNamedMarketDataSpecificationRepositoryComponentFactory> beanType() {
      return RemoteNamedMarketDataSpecificationRepositoryComponentFactory.class;
    }

    @Override
    public Map<String, MetaProperty<?>> metaPropertyMap() {
      return _metaPropertyMap$;
    }

    //-----------------------------------------------------------------------
  }

  ///CLOVER:ON
  //-------------------------- AUTOGENERATED END --------------------------
}
