本文整理汇总了Java中flex.messaging.io.SerializationContext类的典型用法代码示例。如果您正苦于以下问题:Java SerializationContext类的具体用法?Java SerializationContext怎么用?Java SerializationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializationContext类属于flex.messaging.io包,在下文中一共展示了SerializationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];
}
示例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.*");
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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());
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例14: createThreadLocals
import flex.messaging.io.SerializationContext; //导入依赖的package包/类
public static void createThreadLocals()
{
// allocate static thread local objects
FlexContext.createThreadLocalObjects();
SerializationContext.createThreadLocalObjects();
TypeMarshallingContext.createThreadLocalObjects();
}
示例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();
}