• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SerializationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convertXmlToAmf

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Converts XML to an object then serializes it
 */
public static byte[] convertXmlToAmf(String xml) {
	XStream xs = getXStream();
	Amf3Output amf3out = new Amf3Output(SerializationContext.getSerializationContext());

	try {
		Object msg = xs.fromXML(xml);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		amf3out.setOutputStream(baos);
		amf3out.writeObject(msg);

		return baos.toByteArray();
	} catch (Exception ex) {
	}

	return new byte[0];
}
 
开发者ID:nccgroup,项目名称:AMFDSer-ngng,代码行数:21,代码来源:AmfXmlConverter.java


示例2: setup

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
@BeforeClass
public static void setup() {
    serverWrapper = new TestServerWrapper();
    serverPort = serverWrapper.startServer("classpath:/WEB-INF/flex/services-config.xml");
    if (serverPort == -1) {
        Assert.fail("Couldn't start server process");
    }

    AMFConnection.registerAlias(
            "remoting.amfclient.ServerCustomType" /* server type */,
            "remoting.amfclient.ClientCustomType" /* client type */);

    serializationContext = SerializationContext.getSerializationContext();
    ClassDeserializationValidator deserializationValidator =
            (ClassDeserializationValidator) serializationContext.getDeserializationValidator();
    deserializationValidator.addAllowClassPattern("remoting.amfclient.*");
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:18,代码来源:AMFConnectionIT.java


示例3: AmfxInput

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Constructor.
 * Construct an AmfxInput by passing in a <code>SerialziationContext</code> object
 *
 * @param context the <code>SerialziationContext</code> object
 */
public AmfxInput(SerializationContext context)
{
    this.context = context;

    stringTable = new ArrayList(64);
    objectTable = new ArrayList(64);
    traitsTable = new ArrayList(10);

    objectStack = new Stack();
    proxyStack = new Stack();
    arrayPropertyStack = new Stack();
    dictionaryStack = new Stack();
    strictArrayIndexStack = new Stack();
    ecmaArrayIndexStack = new Stack();
    traitsStack = new Stack();

    text = new StringBuffer(32);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:25,代码来源:AmfxInput.java


示例4: convert

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Translate an object to another object of type class.
 * obj types should be ASObject, Boolean, String, Double, Date, ArrayList
 */
public Object convert(Object source, Class desiredClass)
{
    if (source == null && !desiredClass.isPrimitive())
    {
        return null;
    }

    SerializationContext serializationContext = SerializationContext.getSerializationContext();

    ActionScriptDecoder decoder;
    if (serializationContext.restoreReferences)
        decoder = DecoderFactory.getReferenceAwareDecoder(source, desiredClass);
    else
        decoder = DecoderFactory.getDecoder(source, desiredClass);

    if (Trace.remote)
    {
        Trace.trace("Decoder for " + (source == null ? "null" : source.getClass().toString()) +
                " with desired " + desiredClass + " is " + decoder.getClass());
    }

    Object result = decoder.decodeObject(source, desiredClass);
    return result;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:29,代码来源:ASTranslator.java


示例5: decodeObject

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
public Object decodeObject(Object shell, Object encodedObject, Class desiredClass)
{
    Object result = super.decodeObject(shell, encodedObject, desiredClass);

    // Only AMF 3 Dates can be sent by reference so we only
    // need to remember this translation to re-establish pointers
    // to the encodedObject if the incoming type was a Date object.
    if (result != null
            && SerializationContext.getSerializationContext().supportDatesByReference
            && encodedObject instanceof java.util.Date)
    {
        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
        context.getKnownObjects().put(encodedObject, result);
    }

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


示例6: marshal

import flex.messaging.io.SerializationContext; //导入依赖的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: unmarshal

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @see marshalsec.MarshallerBase#unmarshal(java.lang.Object)
 */
@Override
public Object unmarshal ( byte[] data ) throws Exception {
    SerializationContext sc = new SerializationContext();
    AmfxMessageDeserializer amfxMessageDeserializer = new AmfxMessageDeserializer();
    amfxMessageDeserializer.initialize(sc, new ByteArrayInputStream(data), null);
    ActionMessage m = new ActionMessage();
    amfxMessageDeserializer.readMessage(m, null);
    return m.getHeader(0).getData();
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:15,代码来源:BlazeDSAMFX.java


示例8: marshal

import flex.messaging.io.SerializationContext; //导入依赖的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();
    try ( AbstractAmfOutput out = createOutput(sc) ) {
        out.setOutputStream(bos);
        out.writeObject(o);
        return bos.toByteArray();
    }
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:16,代码来源:BlazeDSBase.java


示例9: unmarshal

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @see marshalsec.MarshallerBase#unmarshal(java.lang.Object)
 */
@Override
public Object unmarshal ( byte[] data ) throws Exception {
    SerializationContext sc = new SerializationContext();
    try ( AbstractAmfInput in = createInput(sc) ) {
        in.setInputStream(new ByteArrayInputStream(data));
        return in.readObject();
    }
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:14,代码来源:BlazeDSBase.java


示例10: convertJavaObjToAmf3

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Convert Java Object to AMF3 protocol's byte[]
 *
 * @param msg Java object
 * @return return byte array see: {@link ByteBuf}.
 * @throws IOException          amf3 output exception.
 * @throws NullPointerException where the msg is Null, throw the NullPointerException.
 */
public static ByteBuf convertJavaObjToAmf3(Object msg) throws IOException {
    if (msg == null) {
        throw new NullPointerException("msg");
    }
    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    final Amf3Output op = new Amf3Output(SerializationContext.getSerializationContext());
    op.setOutputStream(bout);
    op.writeObject(msg);
    op.flush();
    op.close();
    return Unpooled.wrappedBuffer(bout.toByteArray());
}
 
开发者ID:ogcs,项目名称:Okra-Ax,代码行数:21,代码来源:Amf3Util.java


示例11: convertXmlToAmfMessage

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Converts XML to a complete AMF message
 */
public static byte[] convertXmlToAmfMessage(String xml) {

	XStream xs = getXStream();
	ActionMessage message = (ActionMessage) xs.fromXML(xml);
	// if (checkAckMessage(message))
	// return null;

	ByteArrayOutputStream baos = new ByteArrayOutputStream();

	ActionContext actionContext = new ActionContext();
	actionContext.setRequestMessage(message);

	AmfMessageSerializer amfMessageSerializer = new AmfMessageSerializer();
	SerializationContext serializationContext = SerializationContext.getSerializationContext();
	amfMessageSerializer.initialize(serializationContext, baos, null);

	try {
		amfMessageSerializer.writeMessage(message);
		return baos.toByteArray();
	} catch (IOException ex) {
		ex.printStackTrace();
		return null;
	} finally {
		baos = null;
	}
}
 
开发者ID:nccgroup,项目名称:AMFDSer-ngng,代码行数:30,代码来源:AmfXmlConverter.java


示例12: convertAmfMessageToXml

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
public static String convertAmfMessageToXml(byte[] amf, boolean useAliasRegistry) {
		XStream xs = getXStream();
		ActionContext actionContext = new ActionContext();
		SerializationContext serializationContext = new SerializationContext();
		// Class aliases for deserialization, mimics registerClassAlias in Flex
		// Generally only used in rendering as it can cause serious problems for
		// proxy sampling
		serializationContext.createASObjectForMissingType = true;
//		serializationContext.supportRemoteClass=true;
		ByteArrayInputStream bin = new ByteArrayInputStream(amf);
		ActionMessage message = new ActionMessage();

		MessageDeserializer deserializer = new AmfMessageDeserializer();
		deserializer.initialize(serializationContext, bin, null);

		try {
			deserializer.readMessage(message, actionContext);
			if (checkAckMessage(message))
				return null;
			String xml = xs.toXML(message);
			return xml;

		} catch (Exception ex) {
			 ex.printStackTrace();
			return null;
		}
	}
 
开发者ID:nccgroup,项目名称:AMFDSer-ngng,代码行数:28,代码来源:AmfXmlConverter.java


示例13: setup

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
@BeforeClass
public static void setup() {
    standardValidationServerWrapper = new TestServerWrapper();
    standardValidationServerPort = standardValidationServerWrapper.startServer("classpath:/WEB-INF/flex/services-config.xml");
    if (standardValidationServerPort == -1) {
        Assert.fail("Couldn't start server (standard validation) process");
    }

    customValidationServerWrapper = new TestServerWrapper();
    customValidationServerPort = customValidationServerWrapper.startServer("classpath:/WEB-INF/flex/services-config-customized-validation.xml");
    if(customValidationServerPort == -1) {
        Assert.fail("Couldn't start server (custom validation) process");
    }

    AMFConnection.registerAlias(
            "remoting.amfclient.ServerCustomType" /* server type */,
            "remoting.amfclient.ClientCustomType" /* client type */);

    serializationContext = SerializationContext.getSerializationContext();
    ClassDeserializationValidator deserializationValidator =
            (ClassDeserializationValidator) serializationContext.getDeserializationValidator();
    deserializationValidator.addAllowClassPattern("remoting.amfclient.*");
    serializationContext.createASObjectForMissingType = true;
    // Make sure collections are written out as Arrays (vs. ArrayCollection),
    // in case the server does not recognize ArrayCollections.
    serializationContext.legacyCollection = true;
    // When legacyMap is true, Java Maps are serialized as ECMA arrays
    // instead of anonymous Object.
    serializationContext.legacyMap = true;
    // Disable serialization of xml documents.
    serializationContext.allowXml = false;
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:33,代码来源:AMFDataTypeIT.java


示例14: createThreadLocals

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
public static void createThreadLocals()
{
    // allocate static thread local objects
    FlexContext.createThreadLocalObjects();
    SerializationContext.createThreadLocalObjects();
    TypeMarshallingContext.createThreadLocalObjects();
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:8,代码来源:MessageBrokerServlet.java


示例15: destroyThreadLocals

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
protected static void destroyThreadLocals()
{
    // clear static member variables
    Log.clear();
    MBeanServerLocatorFactory.clear();

    // Destroy static thread local objects
    FlexContext.releaseThreadLocalObjects();
    SerializationContext.releaseThreadLocalObjects();
    TypeMarshallingContext.releaseThreadLocalObjects();
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:12,代码来源:MessageBrokerServlet.java


示例16: AbstractEndpoint

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Constructs an <code>AbstractEndpoint</code> with the indicated management.
 *
 * @param enableManagement <code>true</code> if the <code>AbstractEndpoint</code>
 * is manageable; <code>false</code> otherwise.
 */
public AbstractEndpoint(boolean enableManagement)
{
    super(enableManagement);
    this.log = Log.getLogger(getLogCategory());
    serializationContext = new SerializationContext();
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:13,代码来源:AbstractEndpoint.java


示例17: setThreadLocals

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 *
 */
public void setThreadLocals()
{
    if (serializationContext != null)
    {
        SerializationContext context = (SerializationContext)serializationContext.clone();
        // Get the latest deserialization validator from the broker.
        MessageBroker broker = getMessageBroker();
        DeserializationValidator validator = broker == null? null : broker.getDeserializationValidator();
        context.setDeserializationValidator(validator);
        SerializationContext.setSerializationContext(context);
    }

    TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:18,代码来源:AbstractEndpoint.java


示例18: initialize

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Establishes the context for reading in data from the given InputStream.
 * A null value can be passed for the trace parameter if a record of the
 * AMFX data should not be made.
 *
 * @param context SerializationContext object
 * @param in InputStream to process
 * @param trace AmfTrace object
 */
public void initialize(SerializationContext context, InputStream in, AmfTrace trace)
{
    amfxIn = new AmfxInput(context);
    this.in = in;

    debugTrace = trace;
    isDebug = debugTrace != null;

    if (debugTrace != null)
        amfxIn.setDebugTrace(debugTrace);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:21,代码来源:AmfxMessageDeserializer.java


示例19: AmfxOutput

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
public AmfxOutput(SerializationContext context)
{
    super(context);

    objectTable = new IdentityHashMap(64);
    traitsTable = new HashMap(10);
    stringTable = new HashMap(64);
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:9,代码来源:AmfxOutput.java


示例20: initialize

import flex.messaging.io.SerializationContext; //导入依赖的package包/类
/**
 * Establishes the context for writing out data to the given OutputStream.
 * A null value can be passed for the trace parameter if a record of the
 * AMFX data should not be made.
 *
 * @param context The SerializationContext specifying the custom options.
 * @param out The OutputStream to write out the AMFX data.
 * @param trace If not null, turns on "trace" debugging for AMFX responses.
 */
public void initialize(SerializationContext context, OutputStream out, AmfTrace trace)
{
    amfxOut = new AmfxOutput(context);
    amfxOut.setOutputStream(out);
    debugTrace = trace;
    isDebug = debugTrace != null;
    amfxOut.setDebugTrace(trace);
    
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:19,代码来源:AmfxMessageSerializer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ShareButton类代码示例发布时间:2022-05-23
下一篇:
Java ByteArrayByteIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap