Skip to main content

Home/ Java Development/ Group items tagged serialization

Rss Feed Group items tagged

Hendy Irawan

XStream - a simple library to serialize objects to XML and back again. - 0 views

  •  
    XStream is a simple library to serialize objects to XML and back again. Features Ease of use. A high level facade is supplied that simplifies common use cases. No mappings required. Most objects can be serialized without need for specifying mappings. Performance. Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput. Clean XML. No information is duplicated that can be obtained via reflection. This results in XML that is easier to read for humans and more compact than native Java serialization. Requires no modifications to objects. Serializes internal fields, including private and final. Supports non-public and inner classes. Classes are not required to have default constructor. Full object graph support. Duplicate references encountered in the object-model will be maintained. Supports circular references. Integrates with other XML APIs. By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML). Customizable conversion strategies. Strategies can be registered allowing customization of how particular types are represented as XML. Error messages. When an exception occurs due to malformed XML, detailed diagnostics are provided to help isolate and fix the problem. Alternative output format. The modular design allows other output formats. XStream ships currently with JSON support and morphing.
Rinav G

JavaBlogging » What is serialVersionUID? - 2 views

  • private static final long serialVersionUID = 1L
  • and it is still there even after the program finished. Let’s see if we can read that file once again, this time without creating it first.
  • Now, let’s see what happens, when we change the serialVersionUID value and try to deserialize once again our file. Change the line 2 in the class SerializeMe so that serialVersionUID contains now 2 instead of 1:
  • ...13 more annotations...
  • serialVersionUID = 2L;
  • static final
  • Exception in thread "main" java.io.InvalidClassException:
  • As you can see, this time the deserialization didn’t go well. ObjectInputStream complained about the serialVersionUID being changed.
  • How does he know that it changed? If serialVersinUID is static, then it should not have been serialized in the first place, and there should be no information about the previous value 1 during the deserialization, right? Well, serialVersionUID is an exception to the rule that “static fields don’t get serialized”.
  • Moreover, if there is no serialVersionUID officially declared in the class to be serialized, compiler automatically adds it with a value generated based on the fields declared in the class.
  • The deserialization of that object does not necessarily have to occur exactly after serialization. It can occur after a few months or on a completely different JVM
  • there is a chance that the class declaration has changed between serialization and deserialization.
  • It checks if the data read from the input stream is compatible with the current definition of the class.
  • when the visibility of a field changes, the serialVersionUID changes too.
  • sometimes you just want for some reason to forbid deserialization of old serialized objects,
  • you might tend to write it once for every serializable class ( or have it generated by the IDE ) and forget about it. WRONG !!!
  • If you write it once and don’t take care to update it when necessary, you loose all the merits of serialVersionUID.
  •  
    What is serialVersionUID? What is it Used For???
Hendy Irawan

snakeyaml - YAML parser and emitter for Java - Google Project Hosting - 0 views

  •  
    YAML is a data serialization format designed for human readability and interaction with scripting languages. SnakeYAML is a YAML parser and emitter for the Java programming language. SnakeYAML features a complete YAML 1.1 parser. In particular, SnakeYAML can parse all examples from the specification. Unicode support including UTF-8/UTF-16 input/output. high-level API for serializing and deserializing native Java objects. support for all types from the YAML types repository. relatively sensible error messages.
Hendy Irawan

Jettison - Home - 0 views

  •  
    Jettison is a collection of Java APIs (like STaX and DOM) which read and write JSON. This allows nearly transparent enablement of JSON based web services in services frameworks like CXF or XML serialization frameworks like XStream. There are currently two included conventions for mapping JSON to XML. The first, is BadgerFish which implements the full XML infoset in JSON using various techniques. The second, is called the "mapped" convention. It allows you to manually map XML namespaces to JSON element prefixes. Jettison was developed for usage in XFire and CXF to enable JSON based services. Later it also found its place in Java object serialization with XStream To learn more, see the User's Guide.
Paul Sydney Orozco

http://www.adobocode.com/spring/marshallingunmarshalling-java-objects-into-xml-file-usi... - 0 views

  •  
    The release 3.0 of Spring Framework added the Spring Module OXM which supports the marshalling and unmarshalling of Java objects and XML documents.In this post, we will be using Spring OXM to take a Java object, convert it to a XML-format and save it in the hard-disk as an XML file containing information of that Java object. We will also cover how to retrieve back the serialized state of that XML file and reconstruct it back to it's original state as a Java object.
Hendy Irawan

Apache Commons Daemon : Java based daemons or services - 0 views

  •  
    "Since 1994, the Java programming language evolved and became a valid tool to develop reliable and performant server applications as opposed to just applets and client applications. The major disadvantage of the Java platform is that still today the only portable way to start a Java application relies on a single point of entry: the public static void main(String[]) method. Having a single-point of entry is a valid solution for client applications, where interactively a user can command to the application to quit (which can terminate the Virtual Machine process at calling the System.exit(int) method), but in those cases where the application is not interactive (server applications) there is currently no portable way to notify the Virtual Machine of its imminent shutdown. A server application written in Java might have to perform several tasks before being able to shutdown the Virtual Machine process. For example in the case of a Servlet container, before the VM process is shut down, sessions might need to be serialized to disk, and web applications need to be destroyed. One common solution to this problem is to create (for example) a ServerSocket and wait for a particular message to be issued. When the message is received, all operations required to shut down the server applications are performed and at the end the System.exit method is called to terminate the Virtual Machine process. This method however, has several disadvantages and risks: In case of a system-wide shutdown, the Virtual Machine process may be shut down directly by the operating system without notifying the running server application. If an attacker finds out the shutdown message to send to the server and discovers a way to send this message, he can easily interrupt the server's operation, bypassing all the security restrictions implemented in the operating system. Most multi-user operating systems already have a way in which server applications are started and stopped. Under Unix based
Hendy Irawan

Shrinkwrap - JBoss Community - 0 views

  • Shrinkwrap provides a simple mechanism to assemble archives like JARs, WARs, and EARs with a friendly, fluent API.
  •  
    Shrinkwrap provides a simple mechanism to assemble archives like JARs, WARs, and EARs with a friendly, fluent API. JavaArchive archive = ShrinkWrap.create(JavaArchive.class,"archive.jar")    .addClasses(MyClass.class,MyOtherClass.class)    .addResource("mystuff.properties"); From there you may deploy directly into any supported integration container like JBoss EmbeddedAS, GlassFish v3 Embedded, Jetty, or OpenEJB.  Or perhaps you'd like to export the archive to a file or exploded directory structure.  Maybe you'd prefer to serialize it over the network to a remote host.  The possibilities are limitless. To boot, ShrinkWrap is the supported deployment mechanism of the Arquillian project, and together we render the testing of true enterprise components amiable as a puppy.  Where Java EE brought a POJO programming model to application development, we've brought it to testing.  You handle your business logic; we'll do the rest. To foster community participation, the majority of documentation and examples are available through our Wiki. Releases are available either via our Downloads section, or through the JBoss Maven Repository, which we recommend is configured in ${userHomeDir}/.m2/settings.xml:
1 - 7 of 7
Showing 20 items per page