Rob Sonke 15 Years Ago Ah, really like it . Simple and powerful with some help of Spring. Please sign in to reply. Reply as... Cancel
Michael Young 15 Years Ago Hey Ray,You should be able to write a generic Advice for this that takes a customized entity as a dependency. Also, you actually don't need to implement an interface to implement the advice. Please sign in to reply. Reply as... Cancel Ray Augé Michael Young 15 Years Ago Great! Show us? Please sign in to reply. Reply as... Cancel Jonas Yuan Michael Young 15 Years Ago Thank you, Ray and Michael! Love to see how to implement the advice ... Please sign in to reply. Reply as... Cancel Ray Augé Jonas Yuan 15 Years Ago In addition to the approach above, which is still a good approach for any version of the portal before rev 27426, we now have this as a feature in the core. So we've done most of the heavy lifting for you.I'll blog again about how to use this new feature. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago You stated that this was being done so...how would you override an existing model class in a portlet/plugin in Liferay 6.0 (or 5.2)? Any references would be appreciated. Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago Yeah, what you want to read about is ServiceWrappers:http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+PluginsIt's not the most well documented aspect, but there is an example at least in the "test-hook-portlet".Basically, extend the Wrapper class of the Service in question, and you will also find that you can also extend the entity's Wrapper class and return that. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Jonas Yuan Michael Young 15 Years Ago Thank you, Ray and Michael! Love to see how to implement the advice ... Please sign in to reply. Reply as... Cancel Ray Augé Jonas Yuan 15 Years Ago In addition to the approach above, which is still a good approach for any version of the portal before rev 27426, we now have this as a feature in the core. So we've done most of the heavy lifting for you.I'll blog again about how to use this new feature. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago You stated that this was being done so...how would you override an existing model class in a portlet/plugin in Liferay 6.0 (or 5.2)? Any references would be appreciated. Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago Yeah, what you want to read about is ServiceWrappers:http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+PluginsIt's not the most well documented aspect, but there is an example at least in the "test-hook-portlet".Basically, extend the Wrapper class of the Service in question, and you will also find that you can also extend the entity's Wrapper class and return that. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Ray Augé Jonas Yuan 15 Years Ago In addition to the approach above, which is still a good approach for any version of the portal before rev 27426, we now have this as a feature in the core. So we've done most of the heavy lifting for you.I'll blog again about how to use this new feature. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago You stated that this was being done so...how would you override an existing model class in a portlet/plugin in Liferay 6.0 (or 5.2)? Any references would be appreciated. Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago Yeah, what you want to read about is ServiceWrappers:http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+PluginsIt's not the most well documented aspect, but there is an example at least in the "test-hook-portlet".Basically, extend the Wrapper class of the Service in question, and you will also find that you can also extend the entity's Wrapper class and return that. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Richard Knight Ray Augé 13 Years Ago You stated that this was being done so...how would you override an existing model class in a portlet/plugin in Liferay 6.0 (or 5.2)? Any references would be appreciated. Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago Yeah, what you want to read about is ServiceWrappers:http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+PluginsIt's not the most well documented aspect, but there is an example at least in the "test-hook-portlet".Basically, extend the Wrapper class of the Service in question, and you will also find that you can also extend the entity's Wrapper class and return that. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Ray Augé Richard Knight 13 Years Ago Yeah, what you want to read about is ServiceWrappers:http://www.liferay.com/community/wiki/-/wiki/Main/Wrapper+PluginsIt's not the most well documented aspect, but there is an example at least in the "test-hook-portlet".Basically, extend the Wrapper class of the Service in question, and you will also find that you can also extend the entity's Wrapper class and return that. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Richard Knight Ray Augé 13 Years Ago My goal is to add custom methods to a large number of classes.... any more thoughts that you have would be appreciated.I could do the following:1.) Create a service wrapper class as stated in "Wrapper Plugins"2.) Create a Model class that extends the original model and add a custom method3.) For each method that returns a set of Models, wrap the model in my custom model. This is more of an Adapter/Proxy pattern.This is a fairly heavy-maintenance process (if large numbers of model classes need to be extended) since 2 proxy classes (model and service) that just delegate method calls have to be created along with lots of method overrides. It seems that an easier approach might be to do the following1.) Use AOP to create the extended models2.) Use Service Wrappers to extend the service3.) Each service method returning the model(s) in question should have a slightly different method signature returning the extended class. Each overridden method could then just return the the proxied service call and perform a cast without having to loop over lists of objects (from finders, etc.), wrap them, and return the new list.What are your thoughts, since my real goal is to add custom methods to large numbers of existing models? Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Ray Augé Richard Knight 13 Years Ago You have ServiceWrappers but well we have ModelWrappers where you can add your custom methods. So your ServiceWrapper can return your ModelWrappers for any method you need them.When returning lists, we don't wrap all at once, but rather lazily by creating an extended List object which only wraps entries when the list's getters are called. This eliminates iterating over large sets. It doesn't get around having to cast Models to the new Wrapper impl though. Please sign in to reply. Reply as... Cancel Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Richard Knight Ray Augé 13 Years Ago Thanks for the response...one further question...How do I specify in service.xml (or other mechanism..like spring file) as to what my model wrapper implementation will be for a specific service model class? Or do I need to manually wrap them with my custom model wrapper in my custom service methods? Is there a convention to the Model wrapper that must be followed?Thanks Please sign in to reply. Reply as... Cancel Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Ray Augé Richard Knight 13 Years Ago so, you need to use a ServiceWrapper to output ModelWrappers, but the model wrappers are generated for you (they are in the service jar). You simply pass the original object in the constructor:return new UserWrapper(user);Now to add your customized methods, simply extend the generated ModelWrapper (you have to put that class in your service.jar) and use instances of the extension when wrapping:return new MyCustomUserWrapper(user); Please sign in to reply. Reply as... Cancel Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Mayank Mishra Ray Augé 12 Years Ago Hi experts - I developed a simple service and used AOP on a method. If I put my adivce class in the ROOT/WEB-INF/classes/, the functionality works as expected. But if I dont put the classes there, I get a class not found exception. What is the issue here ? Please sign in to reply. Reply as... Cancel
Barrie Selack 15 Years Ago The aop: syntax does not appear to work in the 5.1.2 ext-spring.xml Please sign in to reply. Reply as... Cancel
(You) 12 Years Ago [...] I think the below post may help. Especially the last few comments by Ray Auge. You could override those methods or add additional methods to your custom model wrapper and return them.... [...] Read More Please sign in to reply. Reply as... Cancel Richard Knight 12 Years Ago I would like to use the liferay Document Library Json service. I could use the standard DL service in ROOT, but I don't want to have to pass in security credentials, I'd rather use the standard portlet security (header-based) auth that generally involves forwarding all http communication through the portlet serveResource method. So I'm not sure what the best way there is to get DL - JSON functionality without passing security credentials??...any thoughts???? Please sign in to reply. Reply as... Cancel
Richard Knight 12 Years Ago I would like to use the liferay Document Library Json service. I could use the standard DL service in ROOT, but I don't want to have to pass in security credentials, I'd rather use the standard portlet security (header-based) auth that generally involves forwarding all http communication through the portlet serveResource method. So I'm not sure what the best way there is to get DL - JSON functionality without passing security credentials??...any thoughts???? Please sign in to reply. Reply as... Cancel