Any command that extends CacheableCommand can be cached; in other words, both the TaskCommand and ControllerCommand can be cached.
IllegalStateException is thrown when a cached command cannot be serialized. This can happen if any of the variables/objects (class level) are not serializable.
sample command definition:
public class LearnerTestCmdImpl extends ControllerCommandImpl implements
LearnerTestCmd {
String name;
MyBean bean;
.................................
.................................
sample bean definition:
public class MyBean {
This can be resolved in two ways:
1. Make the object (Eg: MyBean Object in above sample) serializable
i.e;
public class MyBean implements Serializable {
2. Make the MyBean object transient variable in the command. But any variable/object defined as transient will not be a part of the cache content.
i.e;
public class LearnerTestCmdImpl extends ControllerCommandImpl implements
LearnerTestCmd {
String name;
transient MyBean bean;
.................................
.................................
IllegalStateException is thrown when a cached command cannot be serialized. This can happen if any of the variables/objects (class level) are not serializable.
sample command definition:
public class LearnerTestCmdImpl extends ControllerCommandImpl implements
LearnerTestCmd {
String name;
MyBean bean;
.................................
.................................
sample bean definition:
public class MyBean {
Let's say the command LearnerTestCmdImpl is cached but throws IllegalStateException while it is executed.
This can be resolved in two ways:
1. Make the object (Eg: MyBean Object in above sample) serializable
i.e;
public class MyBean implements Serializable {
2. Make the MyBean object transient variable in the command. But any variable/object defined as transient will not be a part of the cache content.
i.e;
public class LearnerTestCmdImpl extends ControllerCommandImpl implements
LearnerTestCmd {
String name;
transient MyBean bean;
.................................
.................................
No comments:
Post a Comment