serialization - Java: when to serialize non-serializated objects or put them to transient? -


i puzzled non-serialized fields, objects in serialized object @ new work.
should serialized or should marked transient serialization?

here example:

@stateless public class nonserializedthingstateless{ ... }  @requestscoped public class nonserializedthingrequestscoped{ ... }   @named @sessionscoped public class serializedbean implements serializable{   @inject   private nonserializedthingrequestscoped nstrs;    @inject   private nonserializedthingstateless nsts;    private list<something> list; //or else pojo    ... } 

is there , simple way can tell when should serialize injected or used classes or guideline?

is true have choose between serialization , putting things transient, or there other ways?

first, word of warning: want use @inject simple cases (usually singletons). else, autowiring works can confusing fast.

that said, rule transient simple: when read object (deserialize), still have everything need recreate original state?

if object depends on current request, answer no: @ time when bean read stream, request long gone.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -