static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
java类java.beans.DefaultPersistenceDelegate的实例源码
AbstractTest.java 文件源码
项目:jdk8u-jdk
阅读 28
收藏 0
点赞 0
评论 0
AbstractTest.java 文件源码
项目:openjdk-jdk10
阅读 21
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:openjdk9
阅读 28
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:jdk8u_jdk
阅读 31
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 22
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
VirtualFileSystemFile.java 文件源码
项目:drftpd3
阅读 18
收藏 0
点赞 0
评论 0
/**
* Configure the serialization of the File.
*/
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (PropertyDescriptor pd : pdArr) {
// logger.debug("PropertyDescriptor - VirtualFileSystemFile - "
// + pd.getDisplayName());
if (transientListFile.contains(pd.getName())) {
pd.setValue("transient", Boolean.TRUE);
}
}
// needed to create a VFSFile object during unserialization
enc.setPersistenceDelegate(VirtualFileSystemFile.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "size", "slaves" }));
}
VirtualFileSystemLink.java 文件源码
项目:drftpd3
阅读 18
收藏 0
点赞 0
评论 0
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (int x = 0; x < pdArr.length; x++) {
// logger.debug("PropertyDescriptor - VirtualFileSystemLink - "
// + pdArr[x].getDisplayName());
if (transientListLink.contains(pdArr[x].getName())) {
pdArr[x].setValue("transient", Boolean.TRUE);
}
}
enc.setPersistenceDelegate(VirtualFileSystemLink.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "linkPath" }));
}
BeanUserManager.java 文件源码
项目:drftpd3
阅读 18
收藏 0
点赞 0
评论 0
/**
* Sets up the XMLEnconder.
*/
public XMLEncoder getXMLEncoder(OutputStream out) {
XMLEncoder e = new XMLEncoder(out);
e.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e1) {
logger.error("", e1);
}
});
e.setPersistenceDelegate(BeanUser.class,
new DefaultPersistenceDelegate(new String[] { "name" }));
e.setPersistenceDelegate(Key.class, new DefaultPersistenceDelegate(
new String[] { "owner", "key" }));
e.setPersistenceDelegate(HostMask.class,
new DefaultPersistenceDelegate(new String[] { "mask" }));
return e;
}
VirtualFileSystemFile.java 文件源码
项目:drftpd3
阅读 21
收藏 0
点赞 0
评论 0
/**
* Configure the serialization of the File.
*/
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (PropertyDescriptor pd : pdArr) {
// logger.debug("PropertyDescriptor - VirtualFileSystemFile - "
// + pd.getDisplayName());
if (transientListFile.contains(pd.getName())) {
pd.setValue("transient", Boolean.TRUE);
}
}
// needed to create a VFSFile object during unserialization
enc.setPersistenceDelegate(VirtualFileSystemFile.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "size", "slaves" }));
}
VirtualFileSystemLink.java 文件源码
项目:drftpd3
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (int x = 0; x < pdArr.length; x++) {
// logger.debug("PropertyDescriptor - VirtualFileSystemLink - "
// + pdArr[x].getDisplayName());
if (transientListLink.contains(pdArr[x].getName())) {
pdArr[x].setValue("transient", Boolean.TRUE);
}
}
enc.setPersistenceDelegate(VirtualFileSystemLink.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "linkPath" }));
}
BeanUserManager.java 文件源码
项目:drftpd3
阅读 18
收藏 0
点赞 0
评论 0
/**
* Sets up the XMLEnconder.
*/
public XMLEncoder getXMLEncoder(OutputStream out) {
XMLEncoder e = new XMLEncoder(out);
e.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e1) {
logger.error("", e1);
}
});
e.setPersistenceDelegate(BeanUser.class,
new DefaultPersistenceDelegate(new String[] { "name" }));
e.setPersistenceDelegate(Key.class, new DefaultPersistenceDelegate(
new String[] { "owner", "key" }));
e.setPersistenceDelegate(HostMask.class,
new DefaultPersistenceDelegate(new String[] { "mask" }));
return e;
}
AbstractTest.java 文件源码
项目:infobip-open-jdk-8
阅读 27
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:jdk8u-dev-jdk
阅读 22
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:jdk7-jdk
阅读 19
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:openjdk-source-code-learn
阅读 21
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:OLD-OpenJDK8
阅读 19
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
DefaultPersistenceDelegateTest.java 文件源码
项目:cn1
阅读 23
收藏 0
点赞 0
评论 0
private void recordCall(Object param) {
StackTraceElement[] eles = (new Throwable()).getStackTrace();
int i = 0;
// skip Throwable.init()
while (eles[i].getClassName().equals("java.lang.Throwable")) {
i++;
}
// skip calls from MockEncoder
while (eles[i].getClassName().equals(MockEncoder.class.getName())) {
i++;
}
// skip calls from DefaultPersistenceDelegate & PersistenceDelegate
while (eles[i].getClassName().equals(
DefaultPersistenceDelegate.class.getName())
|| eles[i].getClassName().equals(
PersistenceDelegate.class.getName())) {
i++;
}
if (i > 2
&& eles[++i].getClassName().equals(
DefaultPersistenceDelegateTest.class.getName())) {
CallVerificationStack.getInstance().push(param);
}
}
EncoderTest.java 文件源码
项目:cn1
阅读 24
收藏 0
点赞 0
评论 0
public void testGetPersistenceDelegate_Default() {
Encoder enc = new Encoder();
Encoder enc2 = new Encoder();
PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd1 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd2 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd3 = enc2
.getPersistenceDelegate(MockBean4Codec.class);
assertTrue(pd3 instanceof DefaultPersistenceDelegate);
assertSame(pd1, pd2);
assertSame(pd1, pd3);
}
AbstractTest.java 文件源码
项目:JAVA_UNIT
阅读 26
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
AbstractTest.java 文件源码
项目:openjdk-jdk7u-jdk
阅读 17
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
DefaultPersistenceDelegateTest.java 文件源码
项目:freeVM
阅读 23
收藏 0
点赞 0
评论 0
private void recordCall(Object param) {
StackTraceElement[] eles = (new Throwable()).getStackTrace();
int i = 0;
// skip Throwable.init()
while (eles[i].getClassName().equals("java.lang.Throwable")) {
i++;
}
// skip calls from MockEncoder
while (eles[i].getClassName().equals(MockEncoder.class.getName())) {
i++;
}
// skip calls from DefaultPersistenceDelegate & PersistenceDelegate
while (eles[i].getClassName().equals(
DefaultPersistenceDelegate.class.getName())
|| eles[i].getClassName().equals(
PersistenceDelegate.class.getName())) {
i++;
}
if (i > 2
&& eles[++i].getClassName().equals(
DefaultPersistenceDelegateTest.class.getName())) {
CallVerificationStack.getInstance().push(param);
}
}
EncoderTest.java 文件源码
项目:freeVM
阅读 23
收藏 0
点赞 0
评论 0
public void testGetPersistenceDelegate_Default() {
Encoder enc = new Encoder();
Encoder enc2 = new Encoder();
PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd1 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd2 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd3 = enc2
.getPersistenceDelegate(MockBean4Codec.class);
assertTrue(pd3 instanceof DefaultPersistenceDelegate);
assertSame(pd1, pd2);
assertSame(pd1, pd3);
}
DefaultPersistenceDelegateTest.java 文件源码
项目:freeVM
阅读 20
收藏 0
点赞 0
评论 0
private void recordCall(Object param) {
StackTraceElement[] eles = (new Throwable()).getStackTrace();
int i = 0;
// skip Throwable.init()
while (eles[i].getClassName().equals("java.lang.Throwable")) {
i++;
}
// skip calls from MockEncoder
while (eles[i].getClassName().equals(MockEncoder.class.getName())) {
i++;
}
// skip calls from DefaultPersistenceDelegate & PersistenceDelegate
while (eles[i].getClassName().equals(
DefaultPersistenceDelegate.class.getName())
|| eles[i].getClassName().equals(
PersistenceDelegate.class.getName())) {
i++;
}
if (i > 2
&& eles[++i].getClassName().equals(
DefaultPersistenceDelegateTest.class.getName())) {
CallVerificationStack.getInstance().push(param);
}
}
EncoderTest.java 文件源码
项目:freeVM
阅读 24
收藏 0
点赞 0
评论 0
public void testGetPersistenceDelegate_Default() {
Encoder enc = new Encoder();
Encoder enc2 = new Encoder();
PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd1 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class);
assertTrue(pd2 instanceof DefaultPersistenceDelegate);
PersistenceDelegate pd3 = enc2
.getPersistenceDelegate(MockBean4Codec.class);
assertTrue(pd3 instanceof DefaultPersistenceDelegate);
assertSame(pd1, pd2);
assertSame(pd1, pd3);
}
AbstractTest.java 文件源码
项目:openjdk-icedtea7
阅读 68
收藏 0
点赞 0
评论 0
static void test(AbstractTest object) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(output);
encoder.setPersistenceDelegate(
object.getClass(),
new DefaultPersistenceDelegate(new String[] {"value"}));
encoder.writeObject(object);
encoder.close();
System.out.print(output);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
XMLDecoder decoder = new XMLDecoder(input);
AbstractTest result = (AbstractTest) decoder.readObject();
decoder.close();
if (object.getValue() != result.getValue())
throw new Error("Should be " + object);
}
VirtualFileSystemFile.java 文件源码
项目:drftpd3-extended
阅读 24
收藏 0
点赞 0
评论 0
/**
* Configure the serialization of the File.
*/
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (int x = 0; x < pdArr.length; x++) {
// logger.debug("PropertyDescriptor - VirtualFileSystemFile - "
// + pdArr[x].getDisplayName());
if (transientListFile.contains(pdArr[x].getName())) {
pdArr[x].setValue("transient", Boolean.TRUE);
}
}
// needed to create a VFSFile object during unserialization
enc.setPersistenceDelegate(VirtualFileSystemFile.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "size", "slaves" }));
}
VirtualFileSystemLink.java 文件源码
项目:drftpd3-extended
阅读 19
收藏 0
点赞 0
评论 0
@Override
protected void setupXML(XMLEncoder enc) {
super.setupXML(enc);
PropertyDescriptor[] pdArr;
try {
pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class)
.getPropertyDescriptors();
} catch (IntrospectionException e) {
logger.error("I don't know what to do here", e);
throw new RuntimeException(e);
}
for (int x = 0; x < pdArr.length; x++) {
// logger.debug("PropertyDescriptor - VirtualFileSystemLink - "
// + pdArr[x].getDisplayName());
if (transientListLink.contains(pdArr[x].getName())) {
pdArr[x].setValue("transient", Boolean.TRUE);
}
}
enc.setPersistenceDelegate(VirtualFileSystemLink.class,
new DefaultPersistenceDelegate(new String[] { "username",
"group", "linkPath" }));
}
BeanUserManager.java 文件源码
项目:drftpd3-extended
阅读 21
收藏 0
点赞 0
评论 0
/**
* Sets up the XMLEnconder.
*/
public XMLEncoder getXMLEncoder(OutputStream out) {
XMLEncoder e = new XMLEncoder(out);
e.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e1) {
logger.error("", e1);
}
});
e.setPersistenceDelegate(BeanUser.class,
new DefaultPersistenceDelegate(new String[] { "name" }));
e.setPersistenceDelegate(Key.class, new DefaultPersistenceDelegate(
new String[] { "owner", "key" }));
e.setPersistenceDelegate(HostMask.class,
new DefaultPersistenceDelegate(new String[] { "mask" }));
return e;
}
NukeBeans.java 文件源码
项目:drftpd3-extended
阅读 14
收藏 0
点赞 0
评论 0
/**
* Serializes the TreeMap.
*
* @throws IOException
*/
public void commit() throws IOException {
saveClassLoader();
XMLEncoder enc = null;
try {
switchClassLoaders();
enc = new XMLEncoder(new SafeFileOutputStream(nukeFile));
enc.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e) {
logger.error(e, e);
}
});
enc.setPersistenceDelegate(LRUMap.class, new DefaultPersistenceDelegate(new String[] { "maxSize" } ));
enc.writeObject(_nukes);
} catch (IOException ex) {
throw new IOException(ex.getMessage());
} finally {
if (enc != null)
enc.close();
}
setPreviousClassLoader();
}
TestPersistenceDelegate.java 文件源码
项目:jdk8u-jdk
阅读 24
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws InterruptedException {
Class<?> type = TestPersistenceDelegate.class;
test(type, DefaultPersistenceDelegate.class);
ENCODER.setPersistenceDelegate(type, new BeanPersistenceDelegate());
test(type, BeanPersistenceDelegate.class);
ENCODER.setPersistenceDelegate(type, null);
test(type, DefaultPersistenceDelegate.class);
// the following tests fails on previous build
test(Bean.class, BeanPersistenceDelegate.class);
test(BeanPersistenceDelegate.class, BeanPersistenceDelegate.class);
}