本文整理汇总了Java中java.beans.DefaultPersistenceDelegate类的典型用法代码示例。如果您正苦于以下问题:Java DefaultPersistenceDelegate类的具体用法?Java DefaultPersistenceDelegate怎么用?Java DefaultPersistenceDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultPersistenceDelegate类属于java.beans包,在下文中一共展示了DefaultPersistenceDelegate类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
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);
}
示例2: setupXML
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
/**
* 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" }));
}
示例3: setupXML
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
@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" }));
}
示例4: getXMLEncoder
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
/**
* 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;
}
示例5: recordCall
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
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);
}
}
示例6: testGetPersistenceDelegate_Default
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
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);
}
示例7: setupXML
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
/**
* 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" }));
}
示例8: commit
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
/**
* 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();
}
示例9: main
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
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);
}
示例10: initialize
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(
OuterClass.InnerClass.class,
new DefaultPersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
OuterClass.InnerClass inner = (OuterClass.InnerClass) oldInstance;
OuterClass outer = inner.getOuter();
return new Expression(inner, outer, "getInner", new Object[0]);
}
}
);
}
示例11: initialize
import java.beans.DefaultPersistenceDelegate; //导入依赖的package包/类
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
C c = (C) oldInstance;
return new Expression(c, c.getX(), "createC", new Object[] {});
}
});
}