serializable

search for more blogs here

 

"Serialization in Java/J2EE - Demystified" posted by ~Ray
Posted on 2008-11-13 12:19:43

Serialization:Serialization is the process of persisting the state of an object. In Java serializing an object involves encoding its state in a structured way within a byte array. Once an object is serialized the byte array can be manipulated in various ways; it can be written to a file sent over a network or RMI or persisted within a database as a BLOB. The serialization process encodes enough information about the object type within the byte stream allowing the original object to be easily recreated upon deserialization at a later point in time. Serialization and Deserialization is same as marshaling and unmarshaling in C/C++. Where to keep serialized object:Serialization is a highly versatile mechanism it should be addressed by storing the state in relational or object databases. It does not have transaction management and concurrency control. Nor does it provide any typical database features like indexed access caching and a query language. Serializing static variables: Variables declared as static members are not considered part of the state of an object because they are shared by all instances of that class. Classes which need to preserve the value of static members during serialization should save and restore these values explicitly using private void readObject(ObjectInputStream) and private void writeObject(ObjectOutputStream). Advantages and Disadvantages:The advantages of serialization are: My subclass implements Serializable but my superclass doesn't. Both subclass and superclass contain instance variables that need to be saved as part of the state of the subclass. Will serialization save the superclass fields for me?When you serialize an object the serialization mechanism works by chaining up the inheritance hierarchy saving the sate of each Serializable superclass in turn. When serialization reaches the first non-serializable superclass the serialization stops. When deserializing the state of this first non-serializable superclass is restored not from the stream but by invoking that class' no-argument constructor. If the no-argument constructor is not adequate for your purposes you must customize the serialization of your subclass with writeObject() and readObject() in order to write out and restore any information from the non-serializable superclass that you find necessary. Externalizable instead of Serializable:By implementing Externalizable yourself you can win performance at the cost of flexibility and extra code to maintain. If you implement Externalizable yourself you stream the data directly without the need for reflection which is used in the case of SerializableRead and write serialized objects to and from a database:If your RDBMS supports them you can store serialized objects as BLOBs. These are JDBC 2.0 features but take a look at java sql. Blob. ResultSet and PreparedStatement for more information. Collections like Vector or a Hashtable:Collections like Vector and Hashtable both implements Serializable and have been designed for serialization. One thing to keep in mind is to watch out for is that in order to serialize a collection like Vector or Hashtable you must also be able to serialize all of the objects contained in these collections. Otherwise the collection would not be able to be completely restored. Your program will throw a NotSerializableException unless all objects stored in the Vector or Hashtable are also serializable. Other way to save the state of an object of a class which does not implement Serializable or ExtenalizableWrite the value of each and every instance variable into the persistent storage. If there are 50 variables you will have to store each of them individually. If some of the variables are object references you will have to follow each reference and save the state of that object as well. You can do that but it would be a proprietary solution and each class that wanted to read your object would also have to know all about your proprietary format. Role of serialization in RMI:RMI uses serialization as its basic and only mechanism for sending objects across a network. If an object implements java rmi. Remote then the object's stub is serialized and sent to the client. If the object implements java io. Serializable then the object itself is serialized and sent. Role of serialization in EJB:A big part of EJB is that it is a framework for underlying RMI: remote method invocation. You're invoking methods remotely from one JVM space 'A' on objects which are in JVM space 'B' -- possibly running on another machine on the network. To make this happen all arguments of each method call must have their current state plucked out of JVM 'A' memory flattened into a byte stream which can be sent over a network connection and then deserialized for reincarnation on the other end in JVM 'B' where the actual method call takes place. If the method has a return value it is serialized up for streaming back to JVM 'A.' Thus the requirement that all EJB methods arguments and return values must be serializable. The easiest way to do this is to make sure all your classes implement java io. Serializable.

Forex Groups - Tips on Trading

Related article:
http://java-polis.blogspot.com/2007/11/serialization-in-javaj2ee-demystified.html

comments | Add comment | Report as Spam


"System.String Is Not Serializable - BizTalk WebReferences" posted by ~Ray
Posted on 2008-03-12 23:10:55

Under these circumstances you will receive a series of compile time errors to the effect of _SomeType_ is not Serializable. Generally the types I undergo seen are System. Int32 and System. arrange. Of cover anyone that knows about serialization would immediately question the validity of System. arrange not being serializable. But if you try to compile again you will get an error that the assembly ~OrchestrationAssemblyName dll is in use. Hmmm. After beating my head against the keyboard monitor(s) telephone cubicle wall etc... I called Microsoft Premier Support - it's nice to have. While waiting for my callback (the helpdesk has an expert call you) I realized that the ~OrchestrationAssemblyName dll being created by Visual Studio in the background is Unfortunately this is preventing it from being loaded by Visual Studio. So I went ahead and turned off verification for the ~OrchestrationAssemblyName dll (it only shows up for a quick back up unless you undergo this problem) and poof problem solved. Microsoft was able to reproduce the problem and agreed that it is a bug in Visual Studio. Unfortunately there is no guarantee when it ordain be fixed since I was able to find a workaround (turn off assembly verification for the ~Assembly or at the key aim). Unfortunately I still get this message every once in a while. Usually if I close and open Visual Studio everything is book. But what is the real solution? I don't really want to bind to a logical turn in an Orchestration anyway. Check out my affix on.

Forex Groups - Tips on Trading

Related article:
http://biztalkspeaks.blogspot.com/2007/10/systemstring-is-not-serializable.html

comments | Add comment | Report as Spam


"System.String Is Not Serializable - BizTalk WebReferences" posted by ~Ray
Posted on 2008-03-12 23:10:55

Under these circumstances you ordain receive a series of hive away time errors to the effect of _SomeType_ is not Serializable. Generally the types I have seen are System. Int32 and System. String. Of cover anyone that knows about serialization would immediately question the validity of System. arrange not being serializable. But if you try to hive away again you will get an error that the assembly ~OrchestrationAssemblyName dll is in use. Hmmm. After beating my continue against the keyboard observe(s) telecommunicate cubicle wall etc... I called Microsoft Premier give - it's nice to have. While waiting for my callback (the helpdesk has an expert call you) I realized that the ~OrchestrationAssemblyName dll being created by Visual Studio in the background is Unfortunately this is preventing it from being loaded by Visual Studio. So I went ahead and turned off verification for the ~OrchestrationAssemblyName dll (it only shows up for a quick second unless you have this problem) and poof problem solved. Microsoft was able to reproduce the problem and agreed that it is a bug in Visual Studio. Unfortunately there is no guarantee when it ordain be fixed since I was able to find a workaround (turn off assembly verification for the ~Assembly or at the key aim). Unfortunately I still get this message every once in a while. Usually if I close and reopen Visual Studio everything is fine. But what is the real solution? I don't really want to bind to a logical port in an Orchestration anyway. Check out my post on.

Forex Groups - Tips on Trading

Related article:
http://biztalkspeaks.blogspot.com/2007/10/systemstring-is-not-serializable.html

comments | Add comment | Report as Spam


"IIS WebGarden problem with session" posted by ~Ray
Posted on 2007-11-17 15:33:22

Problem: You activate webgarden and be multiple w3wp exe processes per application pool. (like in the picture with a application pool properties IIS6.0)This is supposed (if your server has enough resources) to boost your server fill capacity. If you spot weird behaviour in your application like errors thrown randomly(null reference exceptions - Object reference not set to an instance of an disapprove) grids paging not working as supposed to be and objects in session state being there or not you seriously have to analyse what kind of session express you are using. If you are using inproc (in affect) session state and you use Session objects in your application you undergo a air and 2 options:either you change by reversal back to single process in web garden or you act reading the article. Assuming you be performance you want to continue with webgarden. Why is in-proc not working?Assuming you define 3 worker processes in a webgarden you will undergo 3 distinct session states each in its worker process. When a client makes requests to your IIS he will be routed randomly to one of the worker process (which one is available and not busy etc). This means that a previously disapprove stored in session during the previous communicate would not exist into this process and you'll reach weird scenarios. It's true that Session disapprove should be temporary. Meaning you must always analyse your object existance in session before using it (to avoid nullreference errors) and load it from db or from wherever else you need to rebuild it. But sometimes your human logic :) might not be able to build such design and you will always keep some info in session (instead you might use asp net viewstate - which is better - in order to keep all data at client if the data is small enough so it won't alter client postbacks harder). To be able to work with session state in 'common' you should use the next level in session express saving. Meaning ASP. Net State service or SQL state server. For the first one. ASP. Net State service read below. You must go away the windows service (ASP. Net State service)and activate it by adding the following config divide in application web config:sessionstate timeout="20" cookieless="false" sqlconnectionstring="data source=127.0.0.1;user id=sa;password=" stateconnectionstring="tcpip=127.0.0.1:42424" mode="StateServer">sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString= "data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20"/This means that instead of using the session express inside each w3wp exe affect you will use a sepparate windows function(ASP. Net State Service) for all your processes for holding state objects. Carefull here if you want to hold BIG objects in session (bad create by mental act anyway) you might move into performance issues due to serialization processing. In order to use this express function your application must be ready to accept it. Meaning you ordain have to have all objects needed to be put into session serializable (objects marked as serializable with [Serializable] attribute). Even if you try to put in session a object that is serializable but its instance contains a instance of a non serializable object errors will occur at serialization time (when inserting the object into session a 'cannot arrange object X' error will occur). Changing to this state on-the-fly for performance increase might drive you the opposite way so pay attention what objects you are putting into session (and they're childs). Also state service requires a lot of RAM. But again the favor of keeping the session states alive even if IIS restarts is a tremendous improvement for your server. As a short sight please make sure ASP. NET State service is running (default it is stopped). Go to Control Panel. Administrative Tools. Services. Asp. Net State function go away it and alter sure its start up type is on "Automatic". At this inform having changed the settings in web config and your code to undergo serializable objects into session you can safely use ASP. Net state function and enable your webgarden feature. Happy bigger fill capacity.

Forex Groups - Tips on Trading

Related article:
http://sharpdevel.blogspot.com/2007/10/iis-webgarden-problem-with-session.html

comments | Add comment | Report as Spam


"Difference of remote and serializable" posted by ~Ray
Posted on 2007-11-09 17:17:51

What's the difference of a class to extends remote and the categorise to implement serializable?Are both ways can work for passing objects through RMI? Both can be used over RMI. If the class implemented Remote and is currently exported when you go it a remote reference (stub) to the object is passed. The object stays where it is and methods can be invoked on it remotely via the compose. If the categorise extends Serializable a copy of the object is passed. Any methods invoked on the disapprove ordain be invoked on the local write. Unless otherwise licensed label in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5215526

comments | Add comment | Report as Spam


"Serializable member not stored" posted by ~Ray
Posted on 2007-10-17 14:47:01

this day I faced up with a problem on storing an object wrapping a java lang. Serializable member: on restoring the disapprove from the database the Serializable handle is null. The disapprove manager app shows that member as null in the database too. I tried with db40 releases 6.1 and 6.3 investigated the db with object manager 6.2. public categorise Value { private final Serializable fValue; public Value(final Serializable value) { fValue = value; } public Serializable get() { go (Serializable) fValue; }} public void testSerializableValueStorageInDb4o() throws Exception { final Configuration config = Db4o newConfiguration(); config exceptionsOnNotStorable(adjust); final File testDB = File createTempFile("testSerializableValueStorageInDb4o.". " yap". evaluate_OUTPUT_DIR); ObjectContainer storage = Db4o openFile(config testDB getAbsolutePath()); final determine val1 = new Value(Integer valueOf(42)); storage set(val1); storage close(); // restoring from the db4o db storage = Db4o openFile(config testDB getAbsolutePath()); final ObjectSet valQueryResult = storage query(determine class); assertEquals(1 valQueryResult size()); final Object objFromDB = valQueryResult next(); assertTrue(objFromDB instanceof Value); final determine val1FromDB = (determine) objFromDB; assertEquals(Integer valueOf(42) val1FromDB get()); storage change state(); } I can see two possible causes for your problem. Firstly. Serializable is an interface and not a concrete class. If the object you are passing as a parameter into the Value categorise had previously been stored in the database then your label should work. Which is to say the variable fValue would contain a non-null reference to the object. Secondly the disapprove you are passing is of write Integer and I'm not sure primitive types such as Integer can be stored by themselves. Normally if you be to store an integer or other primitive type you would need to store it as part of an disapprove. I wish this helps you. > Secondly the object you are passing is of write Integer and I'm not sure primitive types such as Integer can be stored by themselves. Normally if you need to store an integer or other primitive write you would be to store it as move of an Object. I wish this helps you. > Firstly. Serializable is an interface and not a concrete categorise. If the disapprove you are passing as a parameter into the Value class had previously been stored in the database then your label should work I would have expected at least an ObjectNotStorableException (as I enabled that feature in the configuration) if it is not possible in principle to store a member that is declared by way of an Interface. But as I could not accept in the fact that members that are declared by way of an interface are stored only with having stored the member value separately. I did evaluate this with a self-written test interface: and it worked without any problem as expected (with an "alter" interface as Serializable and with one definiting some behaviour). So there needs to be something very special with the Serializable. And with further testing I'm quite sure to know now when this problem occurs: if the member is declared by way of a standard JDK interface and it's determine's class is a standard JDK one too. E g storing also fails with declaring with CharSequence and setting it to a String value.

Forex Groups - Tips on Trading

Related article:
http://developers.db4o.com/forums/thread/41211.aspx

comments | Add comment | Report as Spam


"Serializable" posted by ~Ray
Posted on 2007-10-10 16:11:08

hi is the preserve that this class extends a java pre-set class or would it be something i undergo to create. I am asking this type of a question as my task is to fill up the blanks and there is no record class so i just want to know if preserve is some sort of preset java class example JPanel etc... Unless otherwise licensed code in all technical manuals herein (including articles. FAQs samples) is provided under this.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5212268

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the serializable archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


serializable