本文整理汇总了Java中java.rmi.MarshalledObject.get方法的典型用法代码示例。如果您正苦于以下问题:Java MarshalledObject.get方法的具体用法?Java MarshalledObject.get怎么用?Java MarshalledObject.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.MarshalledObject
的用法示例。
在下文中一共展示了MarshalledObject.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkHistory
import java.rmi.MarshalledObject; //导入方法依赖的package包/类
private boolean checkHistory (TransformHistory history, int xi, int ti, String xml, String xsl, String output) {
// modify history
history.setOverwriteOutput (!history.isOverwriteOutput()); // negate
history.setProcessOutput ((history.getProcessOutput()+1)%3); // rotate
if ( xml != null ) {
history.addXML (xml, output);
}
if ( xsl != null ) {
history.addXSL (xsl, output);
}
// test number of XMLs
if ( history.getXMLs().length != xi ) {
System.out.println(" history.getXMLs().length: " + history.getXMLs().length);
return false;
}
// test number of XSLs
if ( history.getXSLs().length != ti ) {
System.out.println(" history.getXSLs().length: " + history.getXSLs().length);
return false;
}
// (de)marshal
TransformHistory newHistory = null;
try {
MarshalledObject marshalled = new MarshalledObject (history);
newHistory = (TransformHistory) marshalled.get();
} catch (Exception exc) {
System.err.println("!!! " + exc);
return false;
}
// test if equals
return (history.equals (newHistory));
}
示例2: delegatesToMO
import java.rmi.MarshalledObject; //导入方法依赖的package包/类
/**
* Test that MarshalledObject inherits the ObjectInputFilter from
* the stream it was deserialized from.
*/
@Test(dataProvider="FilterCases")
static void delegatesToMO(boolean withFilter) {
try {
Serializable testobj = Integer.valueOf(5);
MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");
byte[] bytes = writeObjects(mo);
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais)) {
CountingFilter filter1 = new CountingFilter();
ObjectInputFilter.Config.setObjectInputFilter(ois, withFilter ? filter1 : null);
MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject();
int count = filter1.getCount();
actualMO.get();
int expectedCount = withFilter ? count + 2 : count;
int actualCount = filter1.getCount();
Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
}
} catch (IOException ioe) {
Assert.fail("Unexpected IOException", ioe);
} catch (ClassNotFoundException cnf) {
Assert.fail("Deserializing", cnf);
}
}
示例3: delegatesToMO
import java.rmi.MarshalledObject; //导入方法依赖的package包/类
/**
* Test that MarshalledObject inherits the ObjectInputFilter from
* the stream it was deserialized from.
*/
@Test(dataProvider="FilterCases")
static void delegatesToMO(boolean withFilter) {
try {
Serializable testobj = Integer.valueOf(5);
MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");
byte[] bytes = writeObjects(mo);
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bais)) {
CountingFilter filter1 = new CountingFilter();
ois.setObjectInputFilter(withFilter ? filter1 : null);
MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject();
int count = filter1.getCount();
actualMO.get();
int expectedCount = withFilter ? count + 2 : count;
int actualCount = filter1.getCount();
Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
}
} catch (IOException ioe) {
Assert.fail("Unexpected IOException", ioe);
} catch (ClassNotFoundException cnf) {
Assert.fail("Deserializing", cnf);
}
}
示例4: unmarshal
import java.rmi.MarshalledObject; //导入方法依赖的package包/类
public Object unmarshal(MarshalledObject mobj)
throws IOException, ClassNotFoundException
{
return mobj.get();
}