当前位置: 首页>>代码示例>>Java>>正文


Java MessageHeader类代码示例

本文整理汇总了Java中flex.messaging.io.amf.MessageHeader的典型用法代码示例。如果您正苦于以下问题:Java MessageHeader类的具体用法?Java MessageHeader怎么用?Java MessageHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessageHeader类属于flex.messaging.io.amf包,在下文中一共展示了MessageHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getXStream

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public static XStream getXStream() {
		if (xstream == null) {
			xstream = new XStream(new DomDriver());

			xstream.alias("ActionMessage", ActionMessage.class);
			xstream.alias("MessageHeader", MessageHeader.class);
			xstream.alias("MessageBody", MessageBody.class);
			xstream.alias("RemotingMessage", RemotingMessage.class);
			xstream.alias("CommandMessage", CommandMessage.class);
			xstream.alias("AcknowledgeMessage", AcknowledgeMessage.class);
			xstream.alias("ErrorMessage", ErrorMessage.class);
			xstream.alias("ASObject", ASObject.class);
			xstream.alias("AsyncMessage", AsyncMessage.class);
			xstream.alias("DSC", CommandMessageExt.class);
//			xstream.alias("DSK", AcknowledgeMessageExt.class);

			// Better ASObject Converter
			Mapper mapper = xstream.getMapper();
		xstream.registerConverter(new ASObjectConverter(mapper));
	}

		return xstream;
	}
 
开发者ID:nccgroup,项目名称:AMFDSer-ngng,代码行数:24,代码来源:AmfXmlConverter.java

示例2: packetCredentials

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
private void packetCredentials(List packetHeaders, Map headers)
{
    if (packetHeaders.size() > 0)
    {
        for (Iterator iter = packetHeaders.iterator(); iter.hasNext();)
        {
            MessageHeader header = (MessageHeader)iter.next();
            if (header.getName().equals(LEGACY_SECURITY_HEADER_NAME))
            {
                Map loginInfo = (Map)header.getData();
                String principal = loginInfo.get(LEGACY_SECURITY_PRINCIPAL).toString();
                Object credentials = loginInfo.get(LEGACY_SECURITY_CREDENTIALS);
                endpoint.getMessageBroker().getLoginManager().login(principal, credentials.toString());
                break;
            }
        }
    }
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:19,代码来源:LegacyFilter.java

示例3: writeHeader

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
protected void writeHeader(MessageHeader h) throws IOException
{
    int buflen = 127; // <header name="..." mustUnderstand="true">
    StringBuffer sb = new StringBuffer(buflen);
    sb.append("<").append(HEADER_TYPE).append(" name=\"");
    sb.append(h.getName());
    sb.append("\"");

    if (h.getMustUnderstand())
    {
        sb.append(" mustUnderstand=\"");
        sb.append(h.getMustUnderstand());
        sb.append("\"");
    }

    sb.append(">");

    amfxOut.writeUTF(sb);

    writeObject(h.getData());

    amfxOut.writeUTF(HEADER_CLOSE_TAG);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:24,代码来源:AmfxMessageSerializer.java

示例4: removeAmfHeader

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
/**
 * Removes any AMF headers found with the name given.
 *
 * @param name The name of the header(s) to remove.
 *
 * @return true if a header existed with the given name.
 */
public boolean removeAmfHeader(String name)
{
    boolean exists = false;
    if (amfHeaders != null)
    {
        for (Iterator<MessageHeader> iterator = amfHeaders.iterator(); iterator.hasNext();)
        {
            MessageHeader header = iterator.next();
            if (name.equals(header.getName()))
            {
                iterator.remove();
                exists = true;
            }
        }
    }
    return exists;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:25,代码来源:AMFConnection.java

示例5: headersMatch

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
protected boolean headersMatch(MessageHeader header1, MessageHeader header2)
{
    if ((header1 == null && header2 != null) || (header1 != null && header2 == null))
        return false;

    if (!header1.getName().equalsIgnoreCase(header2.getName()))
        return false;

    if (header1.getMustUnderstand() != header2.getMustUnderstand())
        return false;

    Object data1 = header1.getData();
    Object data2 = header2.getData();

    if (!headerValuesMatch(data1, data2))
        return false;

    return true;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:20,代码来源:DeserializationConfirmation.java

示例6: marshal

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @see marshalsec.MarshallerBase#marshal(java.lang.Object)
 */
@Override
public byte[] marshal ( Object o ) throws Exception {
    SerializationContext sc = new SerializationContext();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    AmfxMessageSerializer out = new AmfxMessageSerializer();
    out.initialize(sc, bos, null);
    ActionMessage m = new ActionMessage();
    m.addHeader(new MessageHeader("foo", false, o));
    out.writeMessage(m);
    return bos.toByteArray();
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:17,代码来源:BlazeDSAMFX.java

示例7: addAmfHeader

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
/**
 * Adds an AMF packet-level header which is sent with every request for
 * the life of this AMF connection.
 *
 * @param name The name of the header.
 * @param mustUnderstand Whether the header must be processed or not.
 * @param data The value of the header.
 */
public void addAmfHeader(String name, boolean mustUnderstand, Object data)
{
    if (amfHeaders == null)
        amfHeaders = new ArrayList<MessageHeader>();

    MessageHeader header = new MessageHeader(name, mustUnderstand, data);
    amfHeaders.add(header);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:17,代码来源:AMFConnection.java

示例8: processAmfHeaders

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
/**
 * Processes the AMF headers by dispatching them to an AMF header processor,
 * if one exists.
 */
protected void processAmfHeaders(ArrayList<MessageHeader> headers)
{
    // No need to process headers if there's no AMF header processor.
    if (amfHeaderProcessor == null)
        return;

    for (MessageHeader header : headers)
        amfHeaderProcessor.processHeader(header);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:14,代码来源:AMFConnection.java

示例9: messagesMatch

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
protected boolean messagesMatch(ActionMessage m1, ActionMessage m2)
{
    if ((m1 == null && m2 != null) || (m2 == null && m1 != null))
        return false;

    if (m1.getVersion() != m2.getVersion())
        return false;

    int headerCount1 = m1.getHeaderCount();
    int headerCount2 = m2.getHeaderCount();

    if (headerCount1 != headerCount2)
        return false;

    for (int i = 0; i < headerCount1; i++)
    {
        MessageHeader header1 = m1.getHeader(i);
        MessageHeader header2 = m2.getHeader(i);
        if (!headersMatch(header1, header2))
            return false;
    }

    int bodyCount1 = m1.getBodyCount();
    int bodyCount2 = m2.getBodyCount();

    if (bodyCount1 != bodyCount2)
        return false;

    for (int i = 0; i < bodyCount1; i++)
    {
        MessageBody body1 = m1.getBody(i);
        MessageBody body2 = m2.getBody(i);

        if (!bodiesMatch(body1, body2))
            return false;
    }

    return true;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:40,代码来源:DeserializationConfirmation.java

示例10: Confirm1b

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public Confirm1b()
{
    ActionMessage m = new ActionMessage();

    MessageHeader header = new MessageHeader();
    header.setName("Some Header");
    header.setData(new Integer(100));
    m.addHeader(header);

    MessageBody body = new MessageBody();
    body.setData("Sample Value");
    m.addBody(body);

    EXPECTED_VALUE = m;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:16,代码来源:Confirm1b.java

示例11: Confirm7b

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public Confirm7b()
{
    ActionMessage m = new ActionMessage();
    MessageHeader header = new MessageHeader();
    header.setName("Sample Header");
    header.setMustUnderstand(false);
    header.setData("Sample Value");
    m.addHeader(header);
    EXPECTED_VALUE = m;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:11,代码来源:Confirm7b.java

示例12: Confirm7a

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public Confirm7a()
{
    ActionMessage m = new ActionMessage();
    MessageHeader header = new MessageHeader();
    header.setName("Empty");
    m.addHeader(header);
    EXPECTED_VALUE = m;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:9,代码来源:Confirm7a.java

示例13: invoke

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public void invoke(final ActionContext context) throws IOException
{
    next.invoke(context);

    try
    {
        HttpServletRequest request = FlexContext.getHttpRequest();
        HttpServletResponse response = FlexContext.getHttpResponse();

        StringBuffer reqURL = request.getRequestURL();

        if (reqURL != null)
        {
            if (request.getQueryString() != null)
                reqURL.append('?').append(request.getQueryString());

            String oldFullURL = reqURL.toString().trim();
            String encFullURL = response.encodeURL(oldFullURL).trim();

            String sessionSuffix = null;

            // It's ok to lower case here as URLs must be in ASCII
            int pos = encFullURL.toLowerCase().indexOf(";jsessionid");
            if (pos > 0)
            {
                StringBuffer sb = new StringBuffer();
                sb.append(encFullURL.substring(pos));
                sessionSuffix = sb.toString();
            }

            if (sessionSuffix != null && oldFullURL.indexOf(sessionSuffix) < 0)
            {
                context.getResponseMessage().addHeader(new MessageHeader(MessageIOConstants.URL_APPEND_HEADER, true /*mustUnderstand*/, sessionSuffix));
            }
        }
    }
    catch (Throwable t)
    {
        //Nothing more we can do... don't send 'URL Append' AMF header.
    }
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:42,代码来源:SessionFilter.java

示例14: writeMessage

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
public void writeMessage(ActionMessage m) throws IOException
{
    if (isDebug)
        debugTrace.startResponse("Serializing AMFX/HTTP response");

    amfxOut.writeUTF(XML_DIRECTIVE);

    int version = m.getVersion();
    writeOpenAMFX(version);

    if (isDebug)
        debugTrace.version(version);

    // Write out headers
    int headerCount = m.getHeaderCount();
    for (int i = 0; i < headerCount; ++i)
    {
        MessageHeader header = m.getHeader(i);

        if (isDebug)
            debugTrace.startHeader(header.getName(), header.getMustUnderstand(), i);

        writeHeader(header);

        if (isDebug)
            debugTrace.endHeader();
    }

    // Write out the body
    int bodyCount = m.getBodyCount();
    for (int i = 0; i < bodyCount; ++i)
    {
        MessageBody body = m.getBody(i);

        if (isDebug)
            debugTrace.startMessage(body.getTargetURI(), body.getResponseURI(), i);

        writeBody(body);

        if (isDebug)
            debugTrace.endMessage();
    }

    writeCloseAMFX();

    if (isDebug)
        debugTrace.endMessage();
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:49,代码来源:AmfxMessageSerializer.java

示例15: call

import flex.messaging.io.amf.MessageHeader; //导入依赖的package包/类
/**
 * Makes an AMF request to the server. A connection must have been made
 * prior to making a call.
 *
 * @param command The method to call on the server.
 * @param arguments Arguments for the method.
 *
 * @return The result of the call.
 *
 * @throws ClientStatusException If there is a client side exception.
 * @throws ServerStatusException If there is a server side exception.
 */
public Object call(String command, Object ... arguments) throws ClientStatusException , ServerStatusException
{
    if (!connected)
    {
        String message = "AMF connection is not connected";
        ClientStatusException cse = new ClientStatusException(message, ClientStatusException.AMF_CALL_FAILED_CODE);
        throw cse;
    }

    String responseURI = getResponseURI();

    // TODO: Support customizable batching of messages.
    ActionMessage requestMessage = new ActionMessage(getObjectEncoding());

    if (amfHeaders != null)
    {
        for (MessageHeader header : amfHeaders)
            requestMessage.addHeader(header);
    }

    MessageBody amfMessage = new MessageBody(command, responseURI, arguments);
    requestMessage.addBody(amfMessage);

    // Setup for AMF message serializer
    actionContext.setRequestMessage(requestMessage);
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    AmfMessageSerializer amfMessageSerializer = new AmfMessageSerializer();
    amfMessageSerializer.initialize(serializationContext, outBuffer, amfTrace);

    try
    {
        amfMessageSerializer.writeMessage(requestMessage);
        Object result = send(outBuffer);
        return result;
    }
    catch (Exception e)
    {
        if (e instanceof ClientStatusException)
            throw (ClientStatusException)e;
        if (e instanceof ServerStatusException)
            throw (ServerStatusException)e;
        // Otherwise, wrap into a ClientStatusException.
        throw new ClientStatusException(e, ClientStatusException.AMF_CALL_FAILED_CODE, generateHttpResponseInfo());
    }
    finally
    {
        try
        {
            outBuffer.close();
        }
        catch (IOException ignore){}
    }
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:66,代码来源:AMFConnection.java


注:本文中的flex.messaging.io.amf.MessageHeader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。