Package org.fudgemsg.mapping

Examples of org.fudgemsg.mapping.FudgeSerializer


    defer.submit(new Publish(msg));
  }

  @Override
  public void rulesAdded(final int modificationCount, final Collection<FunctionBlacklistRule> rules, final ExecutorService defer) {
    final FudgeSerializer fsc = new FudgeSerializer(getFudgeContext());
    final MutableFudgeMsg msg = fsc.newMessage();
    msg.add(MODIFICATION_COUNT_FIELD, modificationCount);
    final MutableFudgeMsg rulesMessage = msg.addSubMessage(RULES_ADDED_FIELD, null);
    for (FunctionBlacklistRule rule : rules) {
      fsc.addToMessage(rulesMessage, null, null, rule);
    }
    defer.submit(new Publish(msg));
  }
View Full Code Here


    defer.submit(new Publish(msg));
  }

  @Override
  public void ruleRemoved(final int modificationCount, final FunctionBlacklistRule rule, final ExecutorService defer) {
    final FudgeSerializer fsc = new FudgeSerializer(getFudgeContext());
    final MutableFudgeMsg msg = fsc.newMessage();
    msg.add(MODIFICATION_COUNT_FIELD, modificationCount);
    final MutableFudgeMsg rulesMessage = msg.addSubMessage(RULES_REMOVED_FIELD, null);
    fsc.addToMessage(rulesMessage, null, null, rule);
    defer.submit(new Publish(msg));
  }
View Full Code Here

    defer.submit(new Publish(msg));
  }

  @Override
  public void rulesRemoved(final int modificationCount, final Collection<FunctionBlacklistRule> rules, final ExecutorService defer) {
    final FudgeSerializer fsc = new FudgeSerializer(getFudgeContext());
    final MutableFudgeMsg msg = fsc.newMessage();
    msg.add(MODIFICATION_COUNT_FIELD, modificationCount);
    final MutableFudgeMsg rulesMessage = msg.addSubMessage(RULES_REMOVED_FIELD, null);
    for (FunctionBlacklistRule rule : rules) {
      fsc.addToMessage(rulesMessage, null, null, rule);
    }
    defer.submit(new Publish(msg));
  }
View Full Code Here

    public Visitor(final FudgeContext context) {
      _context = context;
    }

    private VisitorImpl getUnderlying() {
      return new VisitorImpl(new FudgeSerializer(_context));
    }
View Full Code Here

    CacheMessage response = request.accept(this);
    if (response == null) {
      response = new CacheMessage();
    }
    response.setCorrelationId(request.getCorrelationId());
    final FudgeSerializer ctx = new FudgeSerializer(fudgeContext);
    final MutableFudgeMsg responseMsg = ctx.objectToFudgeMsg(response);
    // We have only one response for each request type, so don't need the headers
    // FudgeSerializer.addClassHeader(responseMsg, response.getClass(), IdentifierMapResponse.class);
    return responseMsg;
  }
View Full Code Here

    //All of these classes must be have consistent sizes
    final ArrayList<Object> templates = Lists.<Object>newArrayList(Double.valueOf(12.0), MissingInput.MISSING_MARKET_DATA);

    final Map<Class<?>, Integer> valueSizeByClass = new HashMap<Class<?>, Integer>(templates.size());
    for (final Object obj : templates) {
      final FudgeSerializer serializer = new FudgeSerializer(getFudgeContext());
      final FudgeMsg data = serializeValue(serializer, obj);
      final int size = FudgeSize.calculateMessageSize(data);
      valueSizeByClass.put(obj.getClass(), size);
    }
    return valueSizeByClass;
View Full Code Here

  }

  protected void putValue(final ComputedValue value, final FudgeMessageStore dataStore) {
    ArgumentChecker.notNull(value, "value");
    final long identifier = getIdentifierMap().getIdentifier(value.getSpecification());
    final FudgeSerializer serializer = new FudgeSerializer(getFudgeContext());
    final Object obj = value.getValue();
    final FudgeMsg data = serializeValue(serializer, obj);
    cacheValueSize(value.getSpecification(), data, obj);
    dataStore.put(identifier, data);
  }
View Full Code Here

    for (final ComputedValue value : values) {
      specifications.add(value.getSpecification());
    }
    final Map<ValueSpecification, Long> identifiers = getIdentifierMap().getIdentifiers(specifications);
    final Map<Long, FudgeMsg> data = new HashMap<Long, FudgeMsg>();
    final FudgeSerializer serializer = new FudgeSerializer(getFudgeContext());
    for (final ComputedValue value : values) {
      final Object obj = value.getValue();
      final FudgeMsg valueData = serializeValue(serializer, obj);
      cacheValueSize(value.getSpecification(), valueData, obj);
      data.put(identifiers.get(value.getSpecification()), valueData);
View Full Code Here

    final Collection<ValueSpecification> specifications = new ArrayList<ValueSpecification>(values.size());
    for (final ComputedValue value : values) {
      specifications.add(value.getSpecification());
    }
    final Map<ValueSpecification, Long> identifiers = getIdentifierMap().getIdentifiers(specifications);
    final FudgeSerializer serializer = new FudgeSerializer(getFudgeContext());
    Map<Long, FudgeMsg> privateData = null;
    Map<Long, FudgeMsg> sharedData = null;
    for (final ComputedValue value : values) {
      final Object obj = value.getValue();
      final FudgeMsg valueData = serializeValue(serializer, obj);
View Full Code Here

  }

  //-------------------------------------------------------------------------
  public void test_fudgeEncoding() {
    FudgeContext context = OpenGammaFudgeContext.getInstance();
    FudgeSerializer serializationContext = new FudgeSerializer(context);
    FudgeDeserializer deserializationContext = new FudgeDeserializer(context);
    ValueRequirement test = new ValueRequirement("DATA", ComputationTargetType.PRIMITIVE, USD);
    MutableFudgeMsg inMsg = serializationContext.objectToFudgeMsg(test);
    assertNotNull(inMsg);
    assertEquals(3, inMsg.getNumFields());
    FudgeMsg outMsg = context.deserialize(context.toByteArray(inMsg)).getMessage();
    ValueRequirement decoded = deserializationContext.fudgeMsgToObject(ValueRequirement.class, outMsg);
    assertEquals(test, decoded);
    test = new ValueRequirement("DATA", ComputationTargetType.PRIMITIVE, USD, ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get());
    inMsg = serializationContext.objectToFudgeMsg(test);
    assertNotNull(inMsg);
    assertEquals(4, inMsg.getNumFields());
    outMsg = context.deserialize(context.toByteArray(inMsg)).getMessage();
    decoded = deserializationContext.fudgeMsgToObject(ValueRequirement.class, outMsg);
    assertEquals(test, decoded);
View Full Code Here

TOP

Related Classes of org.fudgemsg.mapping.FudgeSerializer

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.