本文整理汇总了Java中com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider类的典型用法代码示例。如果您正苦于以下问题:Java PureJavaReflectionProvider类的具体用法?Java PureJavaReflectionProvider怎么用?Java PureJavaReflectionProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PureJavaReflectionProvider类属于com.thoughtworks.xstream.converters.reflection包,在下文中一共展示了PureJavaReflectionProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public static void load( File folder ) {
if (!folder.isDirectory())
folder = folder.getParentFile();
TweedSettings.folder = folder;
try {
File def = new File( folder, "tweed.xml" );
if (!def.exists())
settings = new TweedSettings();
else
settings = (TweedSettings) new XStream(new PureJavaReflectionProvider()).fromXML( def );
TweedFrame.instance.tweed.initFrom( folder.toString() );
} catch ( Throwable th ) {
settings = new TweedSettings();
save(true);
th.printStackTrace();
}
writeRecentFiles();
}
示例2: testSortsFieldOrderWithArray
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testSortsFieldOrderWithArray() {
SortableFieldKeySorter sorter = new SortableFieldKeySorter();
sorter.registerFieldOrder(MommyBear.class,
new String[] { "b", "c", "a" });
xstream = new XStream(new PureJavaReflectionProvider(new FieldDictionary(sorter)));
setupSecurity(xstream);
xstream.alias("mommy", MommyBear.class);
MommyBear root = new MommyBear();
root.c = "ccc";
root.b = "bbb";
root.a = "aaa";
assertBothWays(root, "<mommy>\n" + " <b>bbb</b>\n" + " <c>ccc</c>\n"
+ " <a>aaa</a>\n" + "</mommy>");
}
示例3: testSortsFieldOrderWhileUsingInheritance
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testSortsFieldOrderWhileUsingInheritance() {
SortableFieldKeySorter sorter = new SortableFieldKeySorter();
sorter.registerFieldOrder(BabyBear.class,
new String[] { "b", "d", "c", "a" });
xstream = new XStream(new PureJavaReflectionProvider(new FieldDictionary(sorter)));
setupSecurity(xstream);
xstream.alias("baby", BabyBear.class);
BabyBear root = new BabyBear();
root.c = "ccc";
root.b = "bbb";
root.a = "aaa";
root.d = "ddd";
assertBothWays(root, "<baby>\n" + " <b>bbb</b>\n" + " <d>ddd</d>\n"
+ " <c>ccc</c>\n" + " <a>aaa</a>\n" + "</baby>");
}
示例4: initXStream
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
/**
* @return
*/
private XStream initXStream(final Session session, final boolean nullifyPk)
{
final XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(final MapperWrapper next)
{
return new HibernateMapper(new HibernateCollectionsMapper(next));
}
};
// Converter für die Hibernate-Collections
xstream.registerConverter(new HibernateCollectionConverter(xstream.getConverterLookup()));
xstream.registerConverter(
new HibernateProxyConverter(xstream.getMapper(), new PureJavaReflectionProvider(), xstream.getConverterLookup()),
XStream.PRIORITY_VERY_HIGH);
xstream.setMarshallingStrategy(new XStreamMarshallingStrategy(XStreamMarshallingStrategy.RELATIVE));
init(xstream);
return xstream;
}
示例5: BeanXStreamConverter
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
@Inject
public BeanXStreamConverter(XStreamConfiguration configuration) {
rp = new PureJavaReflectionProvider();
Mapper dmapper = new DefaultMapper(this.getClass().getClassLoader());
/*
* Putting this here means only one conversion per thread may be active at
* any one time, but since the conversion process is atomic this will not
* matter unless the class is extended.
*/
writerStack = new ThreadSafeWriterStack();
/*
* create a driver that wires into a standard driver, and updates the stack
* position.
*/
driver = new StackDriver(new XppDriver(), writerStack, configuration.getNameSpaces());
/*
* Create an interface class mapper that understands class hierarchy for
* single items
*/
for (XStreamConfiguration.ConverterSet c : MAPPER_SCOPES) {
converterMap.put(c, configuration.getConverterConfig(c,rp,dmapper,driver,writerStack));
}
}
示例6: testOwnMapperChainCanBeRegistered
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testOwnMapperChainCanBeRegistered() {
ClassLoaderReference classLoaderReference = new ClassLoaderReference(getClass().getClassLoader());
Mapper mapper = new DefaultMapper(classLoaderReference);
xstream = new XStream(new PureJavaReflectionProvider(), new DomDriver(), getClass().getClassLoader(), mapper);
String expected = "" +
"<com.thoughtworks.acceptance.objects.Software>\n" +
" <vendor>ms</vendor>\n" +
" <name>word</name>\n" +
"</com.thoughtworks.acceptance.objects.Software>";
assertEquals(expected, xstream.toXML(new Software("ms", "word")));
}
示例7: testExceptionThrownUponSerializationIfNotSupport
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testExceptionThrownUponSerializationIfNotSupport() {
xstream = new XStream(new PureJavaReflectionProvider());
xstream.alias("thing", ThingWithFinalField.class);
try {
xstream.toXML(new ThingWithFinalField());
} catch (ObjectAccessException expectedException) {
assertEquals("Invalid final field " + ThingWithFinalField.class.getName() + ".number",
expectedException.getMessage());
}
}
示例8: testSerializeWithXppDriverAndPureJavaReflectionProviderAndActiveSecurityManager
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testSerializeWithXppDriverAndPureJavaReflectionProviderAndActiveSecurityManager() {
sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.misc"));
sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
sm.addPermission(source, new RuntimePermission("createClassLoader"));
sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
sm.addPermission(source, new PropertyPermission("java.home", "read"));
sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
sm.addPermission(source, new PropertyPermission("sun.io.serialization.extendedDebugInfo", "read"));
sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
sm.addPermission(source, new PropertyPermission("user.country", "read"));
sm.addPermission(source, new PropertyPermission("user.dir", "read"));
sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
sm.addPermission(source, new NetPermission("specifyStreamHandler"));
sm.setReadOnly();
System.setSecurityManager(sm);
xstream = new XStream(new PureJavaReflectionProvider());
xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName()+".*objects.**");
xstream.allowTypesByWildcard(this.getClass().getName()+"$*");
assertBothWays();
}
示例9: testCanWriteInheritanceHierarchiesInOldOrder
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testCanWriteInheritanceHierarchiesInOldOrder() {
xstream = new XStream(new PureJavaReflectionProvider(new FieldDictionary(new XStream12FieldKeySorter())));
OpenSourceSoftware openSourceSoftware = new OpenSourceSoftware("apache", "geronimo", "license");
String xml =
"<oss>\n" +
" <license>license</license>\n" +
" <vendor>apache</vendor>\n" +
" <name>geronimo</name>\n" +
"</oss>";
xstream.alias("oss", OpenSourceSoftware.class);
assertEquals(xml, xstream.toXML(openSourceSoftware));
}
示例10: setUp
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
// fonts should be serializable also with pure Java
xstream = new XStream(new PureJavaReflectionProvider());
xstream.allowTypes(Font.class, TextAttribute.class);
in = new Font("Arial", Font.BOLD, 20);
}
示例11: saveXML
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public static void saveXML( Object o , String fileName ) {
BoofcvClassLoader loader = new BoofcvClassLoader();
XStreamAppletVersion xstream = new XStreamAppletVersion(new PureJavaReflectionProvider(),new DomDriver(),loader,null,new DefaultConverterLookup(), null);
// XStream xstream = new XStream(new PureJavaReflectionProvider(),new DomDriver(),loader,null,new DefaultConverterLookup(), null);
xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
try {
xstream.toXML(o,new FileOutputStream(fileName));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
示例12: loadXML
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public static <T> T loadXML( String fileName ) {
BoofcvClassLoader loader = new BoofcvClassLoader();
XStreamAppletVersion xstream = new XStreamAppletVersion(new PureJavaReflectionProvider(),new DomDriver(),loader,null,new DefaultConverterLookup(), null);
xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
try {
return (T)xstream.fromXML(new FileReader(fileName));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
示例13: VRaptorXStream
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public VRaptorXStream(TypeNameExtractor extractor, HierarchicalStreamDriver hierarchicalStreamDriver,
Serializee serializee, ReflectionProvider reflectionProvider) {
super(new PureJavaReflectionProvider(),hierarchicalStreamDriver);
this.extractor = extractor;
this.serializee = serializee;
this.reflectionProvider = reflectionProvider;
}
示例14: createXStream
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
protected XStream createXStream() {
XStream xstream = new XStream(new PureJavaReflectionProvider(new FieldDictionary(
new AlphabeticalFieldkeySorter())));
setupSecurity(xstream);
return xstream;
}
示例15: testSerializeWithDomDriverAndPureJavaReflectionProviderAndActiveSecurityManager
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; //导入依赖的package包/类
public void testSerializeWithDomDriverAndPureJavaReflectionProviderAndActiveSecurityManager() {
sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.text.resources"));
sm.addPermission(source, new RuntimePermission("accessClassInPackage.sun.util.resources"));
sm.addPermission(source, new RuntimePermission("accessDeclaredMembers"));
sm.addPermission(source, new RuntimePermission("createClassLoader"));
sm.addPermission(source, new RuntimePermission("fileSystemProvider"));
sm.addPermission(source, new RuntimePermission("loadLibrary.nio"));
sm.addPermission(source, new RuntimePermission("modifyThreadGroup"));
sm.addPermission(source, new RuntimePermission("reflectionFactoryAccess"));
sm.addPermission(source, new PropertyPermission("com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration", "read"));
sm.addPermission(source, new PropertyPermission("elementAttributeLimit", "read"));
sm.addPermission(source, new PropertyPermission("entityExpansionLimit", "read"));
sm.addPermission(source, new PropertyPermission("http://java.sun.com/xml/dom/properties/ancestor-check", "read"));
sm.addPermission(source, new PropertyPermission("ibm.dst.compatibility", "read"));
sm.addPermission(source, new PropertyPermission("java.home", "read"));
sm.addPermission(source, new PropertyPermission("java.nio.file.spi.DefaultFileSystemProvider", "read"));
sm.addPermission(source, new PropertyPermission("java.security.debug", "read"));
sm.addPermission(source, new PropertyPermission("javax.xml.datatype.DatatypeFactory", "read"));
sm.addPermission(source, new PropertyPermission("javax.xml.parsers.DocumentBuilderFactory", "read"));
sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalDTD", "read"));
sm.addPermission(source, new PropertyPermission("javax.xml.accessExternalSchema", "read"));
sm.addPermission(source, new PropertyPermission("jaxp.debug", "read"));
sm.addPermission(source, new PropertyPermission("jdk.util.TimeZone.allowSetDefault", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.elementAttributeLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.entityExpansionLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.entityReplacementLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.maxElementDepth", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.maxGeneralEntitySizeLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.maxParameterEntitySizeLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.maxOccurLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.maxXMLNameLimit", "read"));
sm.addPermission(source, new PropertyPermission("jdk.xml.totalEntitySizeLimit", "read"));
sm.addPermission(source, new PropertyPermission("maxOccurLimit", "read"));
sm.addPermission(source, new PropertyPermission("sun.boot.class.path", "read"));
sm.addPermission(source, new PropertyPermission("sun.nio.fs.chdirAllowed", "read"));
sm.addPermission(source, new PropertyPermission("sun.timezone.ids.oldmapping", "read"));
sm.addPermission(source, new PropertyPermission("user.country", "read"));
sm.addPermission(source, new PropertyPermission("user.dir", "read"));
sm.addPermission(source, new PropertyPermission("user.timezone", "read,write"));
sm.addPermission(source, new NetPermission("specifyStreamHandler"));
sm.addPermission(source, new ReflectPermission("suppressAccessChecks"));
sm.setReadOnly();
System.setSecurityManager(sm);
xstream = new XStream(new PureJavaReflectionProvider(), new DomDriver());
xstream.allowTypesByWildcard(AbstractAcceptanceTest.class.getPackage().getName()+".*objects.**");
xstream.allowTypesByWildcard(this.getClass().getName()+"$*");
assertBothWays();
}