1 17 package org.apache.geronimo.kernel.config.xstream; 18 19 import java.net.URI ; 20 21 import com.thoughtworks.xstream.XStream; 22 import com.thoughtworks.xstream.converters.reflection.ReflectionProvider; 23 import com.thoughtworks.xstream.core.JVM; 24 import org.apache.geronimo.gbean.AbstractName; 25 import org.apache.geronimo.gbean.AbstractNameQuery; 26 import org.apache.geronimo.gbean.GBeanData; 27 import org.apache.geronimo.gbean.GBeanInfo; 28 import org.apache.geronimo.kernel.config.ConfigurationData; 29 import org.apache.geronimo.kernel.config.ConfigurationModuleType; 30 import org.apache.geronimo.kernel.repository.Artifact; 31 import org.apache.geronimo.kernel.repository.Dependency; 32 import org.apache.geronimo.kernel.repository.ImportType; 33 import org.apache.geronimo.kernel.repository.Version; 34 35 38 public final class XStreamUtil { 39 private XStreamUtil() { 40 } 41 42 public static XStream createXStream() { 43 JVM jvm = new JVM(); 44 ReflectionProvider reflectionProvider = jvm.bestReflectionProvider(); 45 XStream xstream = new XStream(reflectionProvider); 46 47 xstream.alias("abstractName", AbstractName.class); 49 xstream.addImmutableType(AbstractName.class); 50 xstream.registerConverter(new AbstractNameConverter()); 51 52 xstream.alias("abstractNameQuery", AbstractNameQuery.class); 54 xstream.addImmutableType(AbstractNameQuery.class); 55 xstream.registerConverter(new AbstractNameQueryConverter()); 56 57 xstream.alias("artifact", Artifact.class); 59 xstream.addImmutableType(Artifact.class); 60 61 xstream.alias("configurationData", ConfigurationData.class); 63 xstream.registerConverter(new ConfigurationDataConverter(reflectionProvider, xstream.getClassMapper())); 64 65 xstream.alias("moduleType", ConfigurationModuleType.class); 67 xstream.addImmutableType(ConfigurationModuleType.class); 68 xstream.registerConverter(new ConfigurationModuleTypeConverter()); 69 70 xstream.alias("dependency", Dependency.class); 72 xstream.addImmutableType(Dependency.class); 73 74 xstream.alias("gbean", GBeanData.class); 76 xstream.registerConverter(new GBeanDataConverter(xstream.getClassMapper())); 77 78 xstream.alias("gbean-info", GBeanInfo.class); 80 81 xstream.registerConverter(new DomConverter()); 83 84 xstream.addImmutableType(ImportType.class); 86 xstream.registerConverter(new ImportTypeConverter()); 87 88 try { 90 xstream.registerConverter(new QNameConverter()); 91 } catch (Exception e) { 92 } 94 95 xstream.alias("version", Version.class); 97 xstream.addImmutableType(Version.class); 98 xstream.registerConverter(new VersionConverter()); 99 100 xstream.alias("uri", URI .class); 102 xstream.addImmutableType(URI .class); 103 xstream.registerConverter(new URIConverter()); 104 105 xstream.registerConverter(new XStreamGBeanStateConverter()); 107 108 return xstream; 109 } 110 } 111 | Popular Tags |