Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.XStream$InitializationException


    assertNull(serializableFactory.makeSerializableIfNecessary(null));
  }

  public void testMakeSerializableIfNecessaryWithNotSerializableArgument()
      throws Exception {
    XStream xstream = new XStream();
    ObjectWrapper expected = new ObjectWrapper(xstream.toXML(puppy));

    Object actual = serializableFactory.makeSerializableIfNecessary(puppy);

    assertEquals(expected, actual);
    SerializationAssert.assertIsSerializable(actual);
View Full Code Here


     */
    public SessionRecorderImpl(final PluginManager pm, CreateRecorderOption... options) {
        this.infoBroker = pm.getPlugin(InformationBroker.class);

        try {
            this.xstream = new XStream();
        } catch (Exception e) {
            this.logger.warning("Error creating xstream! No logging available!.");
            e.printStackTrace();
            this.xstream = null;
        }
View Full Code Here

    long stddev;
  }

  private XStream getXStream()
  {
    XStream xstream = new XStream();
    xstream.alias("entry", Entry.class);
    return xstream;
  }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    private void read(InputStream input) {
        m_roles.clear();
        // We use DomDriver because the standard XPP driver has issues with attributes.
        XStream xstream = new XStream(/*new DomDriver()*/);
        xstream.registerConverter(ROLEMAPCONVERTER);
        xstream.registerConverter(ROLECONVERTER);
        xstream.registerConverter(DICTCONVERTER);
        xstream.aliasType("roles", Map.class);
        try {
            Map<String, RoleImpl> fromXML = (Map<String, RoleImpl>) xstream.fromXML(input);
            m_roles.putAll(fromXML);
        }
        catch (StreamException e) {
            // no problem: this means that the remote repository is empty.
        }
View Full Code Here

     * @param out An output stream to write to. It will be closed by the this method.
     * @throws java.io.IOException When there is a problem creating the stream, or
     * the other end of the stream fails.
     */
    private void write(OutputStream out) throws IOException {
        XStream xstream = new XStream(new DomDriver());
        xstream.registerConverter(ROLEMAPCONVERTER);
        xstream.registerConverter(ROLECONVERTER);
        xstream.registerConverter(DICTCONVERTER);
        xstream.aliasType("roles", Map.class);
        xstream.toXML(m_roles, out);
        try {
            out.close();
        }
        catch (IOException e) {
            m_log.log(LogService.LOG_ERROR, "Error closing XStream output stream.", e);
View Full Code Here

        // if this is a serialized config, fallback to the serialization marshaler
        if (SERIALIZED_MAGIC[0] == streamHeader[0] && SERIALIZED_MAGIC[1] == streamHeader[1]) {
            return new SerializedConfigurationMarshaler().readConfigurationData(pushbackInputStream);
        }

        XStream xstream = XStreamUtil.createXStream();
        Reader reader = new InputStreamReader(pushbackInputStream);
        ConfigurationData configurationData = (ConfigurationData)xstream.fromXML(reader);
        return configurationData;
    }
View Full Code Here

        ConfigurationData configurationData = (ConfigurationData)xstream.fromXML(reader);
        return configurationData;
    }

    public void writeConfigurationData(ConfigurationData configurationData, OutputStream out) throws IOException {
        XStream xstream = XStreamUtil.createXStream();
        String xml = xstream.toXML(configurationData);

        out.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "\n" +
                "<!-- ======================================================== -->\n" +
                "<!-- Warning - Modification of this file may cause server     -->\n" +
View Full Code Here

            ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(classLoader);

                DomReader reader = new DomReader(element);
                XStream xstream = XStreamUtil.createXStream();
                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to load gbeans", e);
            } finally {
View Full Code Here

            throw (IOException)new IOException("Cannot instantiate " + Document.class.getName()).initCause(e);
        }
        Document document = documentBuilder.newDocument();
        DomWriter writer = new DomWriter(document);

        XStream xstream = XStreamUtil.createXStream();
        xstream.marshal(gbeanDatas, writer);

//        FileWriter w = new FileWriter("target/foo.xml");
//        xstream.toXML(gbeanDatas, w);
//        w.close();
View Full Code Here

    }

    public static XStream createXStream() {
        JVM jvm = new JVM();
        ReflectionProvider reflectionProvider = jvm.bestReflectionProvider();
        XStream xstream = new XStream(reflectionProvider);

        // AbstractName
        xstream.alias("abstractName", AbstractName.class);
        xstream.addImmutableType(AbstractName.class);
        xstream.registerConverter(new AbstractNameConverter());

        // AbstractNameQuery
        xstream.alias("abstractNameQuery", AbstractNameQuery.class);
        xstream.addImmutableType(AbstractNameQuery.class);
        xstream.registerConverter(new AbstractNameQueryConverter());

        // Artifact
        xstream.alias("artifact", Artifact.class);
        xstream.addImmutableType(Artifact.class);

        // ConfigurationData
        xstream.alias("configurationData", ConfigurationData.class);
        xstream.registerConverter(new ConfigurationDataConverter(reflectionProvider, xstream.getClassMapper()));

        // ConfigurationModuleTypeConverter
        xstream.alias("moduleType", ConfigurationModuleType.class);
        xstream.addImmutableType(ConfigurationModuleType.class);
        xstream.registerConverter(new ConfigurationModuleTypeConverter());

        // Dependency
        xstream.alias("dependency", Dependency.class);
        xstream.addImmutableType(Dependency.class);

        // GBeanData
        xstream.alias("gbean", GBeanData.class);
        xstream.registerConverter(new GBeanDataConverter(xstream.getClassMapper()));

        // GBeanInfo
        xstream.alias("gbean-info", GBeanInfo.class);

        // w3c Dom
        xstream.registerConverter(new DomConverter());

        // ImportType
        xstream.addImmutableType(ImportType.class);
        xstream.registerConverter(new ImportTypeConverter());

        // QName
        try {
            xstream.registerConverter(new QNameConverter());
        } catch (Exception e) {
            // cl can't see QName class so we don't need to register a converter for it
        }

        // Version
        xstream.alias("version", Version.class);
        xstream.addImmutableType(Version.class);
        xstream.registerConverter(new VersionConverter());

        // URI
        xstream.alias("uri", URI.class);
        xstream.addImmutableType(URI.class);
        xstream.registerConverter(new URIConverter());

        // XStreamGBeanState
        xstream.registerConverter(new XStreamGBeanStateConverter());

        return xstream;
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.XStream$InitializationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.