当前位置: 首页>>代码示例>>Java>>正文


Java DefaultPersistenceDelegate类代码示例

本文整理汇总了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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:AbstractTest.java

示例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" }));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:28,代码来源:VirtualFileSystemFile.java

示例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" }));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:24,代码来源:VirtualFileSystemLink.java

示例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;
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:19,代码来源:BeanUserManager.java

示例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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:DefaultPersistenceDelegateTest.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:EncoderTest.java

示例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" }));
}
 
开发者ID:f4bio,项目名称:drftpd3-extended,代码行数:28,代码来源:VirtualFileSystemFile.java

示例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();
}
 
开发者ID:f4bio,项目名称:drftpd3-extended,代码行数:30,代码来源:NukeBeans.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TestPersistenceDelegate.java

示例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]);
                }
            }
    );
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test4936682.java

示例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[] {});
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:Test4679556.java


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