/**
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.component.factory.engine;
import java.util.LinkedHashMap;
import java.util.Map;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.component.ComponentInfo;
import com.opengamma.component.ComponentRepository;
import com.opengamma.component.factory.AbstractComponentFactory;
import com.opengamma.livedata.LiveDataClient;
import com.opengamma.livedata.client.RemoteLiveDataClientFactoryBean;
import com.opengamma.util.jms.JmsConnector;
/**
* Component factory to create a {@code LiveDataClient}.
*/
@BeanDefinition
public class LiveDataClientComponentFactory extends AbstractComponentFactory {
/**
* The classifier under which to publish.
*/
@PropertyDefinition(validate = "notNull")
private String _classifier;
/**
* The JMS connector.
*/
@PropertyDefinition(validate = "notNull")
private JmsConnector _jmsConnector;
/**
* The Subscription topic.
*/
@PropertyDefinition(validate = "notNull")
private String _subscriptionTopic;
/**
* The Entitlement topic.
*/
@PropertyDefinition(validate = "notNull")
private String _entitlementTopic;
/**
* The Heartbeat topic.
*/
@PropertyDefinition(validate = "notNull")
private String _heartbeatTopic;
//-------------------------------------------------------------------------
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
RemoteLiveDataClientFactoryBean ldcFb = new RemoteLiveDataClientFactoryBean();
ldcFb.setJmsConnector(getJmsConnector());
ldcFb.setSubscriptionTopic(getSubscriptionTopic());
ldcFb.setEntitlementTopic(getEntitlementTopic());
ldcFb.setHeartbeatTopic(getHeartbeatTopic());
LiveDataClient ldc = ldcFb.getObjectCreating();
ComponentInfo info = new ComponentInfo(LiveDataClient.class, getClassifier());
repo.registerComponent(info, ldc);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code LiveDataClientComponentFactory}.
* @return the meta-bean, not null
*/
public static LiveDataClientComponentFactory.Meta meta() {
return LiveDataClientComponentFactory.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(LiveDataClientComponentFactory.Meta.INSTANCE);
}
@Override
public LiveDataClientComponentFactory.Meta metaBean() {
return LiveDataClientComponentFactory.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the classifier under which to publish.
* @return the value of the property, not null
*/
public String getClassifier() {
return _classifier;
}
/**
* Sets the classifier under which to publish.
* @param classifier the new value of the property, not null
*/
public void setClassifier(String classifier) {
JodaBeanUtils.notNull(classifier, "classifier");
this._classifier = classifier;
}
/**
* Gets the the {@code classifier} property.
* @return the property, not null
*/
public final Property<String> classifier() {
return metaBean().classifier().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the JMS connector.
* @return the value of the property, not null
*/
public JmsConnector getJmsConnector() {
return _jmsConnector;
}
/**
* Sets the JMS connector.
* @param jmsConnector the new value of the property, not null
*/
public void setJmsConnector(JmsConnector jmsConnector) {
JodaBeanUtils.notNull(jmsConnector, "jmsConnector");
this._jmsConnector = jmsConnector;
}
/**
* Gets the the {@code jmsConnector} property.
* @return the property, not null
*/
public final Property<JmsConnector> jmsConnector() {
return metaBean().jmsConnector().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the Subscription topic.
* @return the value of the property, not null
*/
public String getSubscriptionTopic() {
return _subscriptionTopic;
}
/**
* Sets the Subscription topic.
* @param subscriptionTopic the new value of the property, not null
*/
public void setSubscriptionTopic(String subscriptionTopic) {
JodaBeanUtils.notNull(subscriptionTopic, "subscriptionTopic");
this._subscriptionTopic = subscriptionTopic;
}
/**
* Gets the the {@code subscriptionTopic} property.
* @return the property, not null
*/
public final Property<String> subscriptionTopic() {
return metaBean().subscriptionTopic().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the Entitlement topic.
* @return the value of the property, not null
*/
public String getEntitlementTopic() {
return _entitlementTopic;
}
/**
* Sets the Entitlement topic.
* @param entitlementTopic the new value of the property, not null
*/
public void setEntitlementTopic(String entitlementTopic) {
JodaBeanUtils.notNull(entitlementTopic, "entitlementTopic");
this._entitlementTopic = entitlementTopic;
}
/**
* Gets the the {@code entitlementTopic} property.
* @return the property, not null
*/
public final Property<String> entitlementTopic() {
return metaBean().entitlementTopic().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the Heartbeat topic.
* @return the value of the property, not null
*/
public String getHeartbeatTopic() {
return _heartbeatTopic;
}
/**
* Sets the Heartbeat topic.
* @param heartbeatTopic the new value of the property, not null
*/
public void setHeartbeatTopic(String heartbeatTopic) {
JodaBeanUtils.notNull(heartbeatTopic, "heartbeatTopic");
this._heartbeatTopic = heartbeatTopic;
}
/**
* Gets the the {@code heartbeatTopic} property.
* @return the property, not null
*/
public final Property<String> heartbeatTopic() {
return metaBean().heartbeatTopic().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public LiveDataClientComponentFactory clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
LiveDataClientComponentFactory other = (LiveDataClientComponentFactory) obj;
return JodaBeanUtils.equal(getClassifier(), other.getClassifier()) &&
JodaBeanUtils.equal(getJmsConnector(), other.getJmsConnector()) &&
JodaBeanUtils.equal(getSubscriptionTopic(), other.getSubscriptionTopic()) &&
JodaBeanUtils.equal(getEntitlementTopic(), other.getEntitlementTopic()) &&
JodaBeanUtils.equal(getHeartbeatTopic(), other.getHeartbeatTopic()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getClassifier());
hash = hash * 31 + JodaBeanUtils.hashCode(getJmsConnector());
hash = hash * 31 + JodaBeanUtils.hashCode(getSubscriptionTopic());
hash = hash * 31 + JodaBeanUtils.hashCode(getEntitlementTopic());
hash = hash * 31 + JodaBeanUtils.hashCode(getHeartbeatTopic());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(192);
buf.append("LiveDataClientComponentFactory{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
@Override
protected void toString(StringBuilder buf) {
super.toString(buf);
buf.append("classifier").append('=').append(JodaBeanUtils.toString(getClassifier())).append(',').append(' ');
buf.append("jmsConnector").append('=').append(JodaBeanUtils.toString(getJmsConnector())).append(',').append(' ');
buf.append("subscriptionTopic").append('=').append(JodaBeanUtils.toString(getSubscriptionTopic())).append(',').append(' ');
buf.append("entitlementTopic").append('=').append(JodaBeanUtils.toString(getEntitlementTopic())).append(',').append(' ');
buf.append("heartbeatTopic").append('=').append(JodaBeanUtils.toString(getHeartbeatTopic())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code LiveDataClientComponentFactory}.
*/
public static class Meta extends AbstractComponentFactory.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code classifier} property.
*/
private final MetaProperty<String> _classifier = DirectMetaProperty.ofReadWrite(
this, "classifier", LiveDataClientComponentFactory.class, String.class);
/**
* The meta-property for the {@code jmsConnector} property.
*/
private final MetaProperty<JmsConnector> _jmsConnector = DirectMetaProperty.ofReadWrite(
this, "jmsConnector", LiveDataClientComponentFactory.class, JmsConnector.class);
/**
* The meta-property for the {@code subscriptionTopic} property.
*/
private final MetaProperty<String> _subscriptionTopic = DirectMetaProperty.ofReadWrite(
this, "subscriptionTopic", LiveDataClientComponentFactory.class, String.class);
/**
* The meta-property for the {@code entitlementTopic} property.
*/
private final MetaProperty<String> _entitlementTopic = DirectMetaProperty.ofReadWrite(
this, "entitlementTopic", LiveDataClientComponentFactory.class, String.class);
/**
* The meta-property for the {@code heartbeatTopic} property.
*/
private final MetaProperty<String> _heartbeatTopic = DirectMetaProperty.ofReadWrite(
this, "heartbeatTopic", LiveDataClientComponentFactory.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"classifier",
"jmsConnector",
"subscriptionTopic",
"entitlementTopic",
"heartbeatTopic");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
return _classifier;
case -1495762275: // jmsConnector
return _jmsConnector;
case 1191816722: // subscriptionTopic
return _subscriptionTopic;
case 397583362: // entitlementTopic
return _entitlementTopic;
case 1497737619: // heartbeatTopic
return _heartbeatTopic;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends LiveDataClientComponentFactory> builder() {
return new DirectBeanBuilder<LiveDataClientComponentFactory>(new LiveDataClientComponentFactory());
}
@Override
public Class<? extends LiveDataClientComponentFactory> beanType() {
return LiveDataClientComponentFactory.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code classifier} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> classifier() {
return _classifier;
}
/**
* The meta-property for the {@code jmsConnector} property.
* @return the meta-property, not null
*/
public final MetaProperty<JmsConnector> jmsConnector() {
return _jmsConnector;
}
/**
* The meta-property for the {@code subscriptionTopic} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> subscriptionTopic() {
return _subscriptionTopic;
}
/**
* The meta-property for the {@code entitlementTopic} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> entitlementTopic() {
return _entitlementTopic;
}
/**
* The meta-property for the {@code heartbeatTopic} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> heartbeatTopic() {
return _heartbeatTopic;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
return ((LiveDataClientComponentFactory) bean).getClassifier();
case -1495762275: // jmsConnector
return ((LiveDataClientComponentFactory) bean).getJmsConnector();
case 1191816722: // subscriptionTopic
return ((LiveDataClientComponentFactory) bean).getSubscriptionTopic();
case 397583362: // entitlementTopic
return ((LiveDataClientComponentFactory) bean).getEntitlementTopic();
case 1497737619: // heartbeatTopic
return ((LiveDataClientComponentFactory) bean).getHeartbeatTopic();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -281470431: // classifier
((LiveDataClientComponentFactory) bean).setClassifier((String) newValue);
return;
case -1495762275: // jmsConnector
((LiveDataClientComponentFactory) bean).setJmsConnector((JmsConnector) newValue);
return;
case 1191816722: // subscriptionTopic
((LiveDataClientComponentFactory) bean).setSubscriptionTopic((String) newValue);
return;
case 397583362: // entitlementTopic
((LiveDataClientComponentFactory) bean).setEntitlementTopic((String) newValue);
return;
case 1497737619: // heartbeatTopic
((LiveDataClientComponentFactory) bean).setHeartbeatTopic((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
@Override
protected void validate(Bean bean) {
JodaBeanUtils.notNull(((LiveDataClientComponentFactory) bean)._classifier, "classifier");
JodaBeanUtils.notNull(((LiveDataClientComponentFactory) bean)._jmsConnector, "jmsConnector");
JodaBeanUtils.notNull(((LiveDataClientComponentFactory) bean)._subscriptionTopic, "subscriptionTopic");
JodaBeanUtils.notNull(((LiveDataClientComponentFactory) bean)._entitlementTopic, "entitlementTopic");
JodaBeanUtils.notNull(((LiveDataClientComponentFactory) bean)._heartbeatTopic, "heartbeatTopic");
super.validate(bean);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}