Justin,

I total agree, however I didn't see a way to inject adaptables into the Sling 
Adapter Manager without knowing the exact class to be adapted ahead of time.  I 
would imagine there would be a way to change this, but I can't see one which 
would not require changing the Sling Adapter Manager.  

If we could add a hook where you could specify an AdapterFactory to handle 
requests for a subclass of a particular class, assuming the exact class is not 
matched then we should be able to support adapting to proxy instances without 
further code for implementers.

 At the moment, there is an abstract class included in the Sling Proxy project 
which will make it easier for implementers to implement an AdapterFactory for 
their interfaces.

Thanks for the feedback and please let me know if I missed something,

-Dan

-----Original Message-----
From: justinedel...@gmail.com [mailto:justinedel...@gmail.com] On Behalf Of 
Justin Edelson
Sent: Friday, March 29, 2013 3:36 PM
To: dev@sling.apache.org
Subject: Re: Sling Dynamic Proxy

Hi Dan,
This looks very interesting, but I'm curious why this code:

ISlingProxyService slingProxyService;****

{...}****

Page page = slingProxyService.getProxy(resource, Page.class);

Is not just

Page page = resource.adaptTo(Page.class);


Regards,

Justin


On Fri, Mar 29, 2013 at 3:14 PM, Dan Klco <dan.k...@sixdimensions.com>wrote:

>  Hello Everyone,****
>
>  ****
>
> A colleague (Michael Kelleher) and I have built an extension we would 
> be interested in incorporating into Sling, as a contributed module. 
> ****
>
>  ****
>
> A short synopsis of this is, it functions as a far simpler, read-only 
> ORM for Sling.  It allows a developer to define an Interface, and with 
> the use of Annotations, and a Service, create an instance backed by 
> resource(s) within JCR.  The mapping of method names to JCR properties 
> is configured with annotations and interpreted by the Java Proxy 
> InvocationHandler to map back to Sling Resources and properties.****
>
>  ****
>
> Here's an example usage of the Sling Dynamic Proxy:****
>
>  ****
>
> public interface Page extends ISlingProxy {****
>
>  ****
>
>                 /******
>
>                 * Gets the property jcr:created****
>
>                 */****
>
>                 @SlingProperty(name="jcr:created")****
>
>                 public Date getCreationDate();****
>
>  ****
>
>                 /******
>
>                 * Gets the property jcr:description at the sub path 
> jcr:content, the path is not required and can be absolute****
>
>                 */****
>
>                 @SlingProperty(name="jcr:description", 
> path="jcr:content")
> ****
>
>                 public String getDescription();****
>
>  ****
>
>                 /******
>
>                 * Gets the property jcr:title at the sub path 
> jcr:content, the path is not required and can be absolute****
>
>                 */****
>
>                 @SlingProperty(name="jcr:title", 
> path="jcr:content")****
>
>                 public String getTitle();****
>
>  ****
>
>                 /******
>
>                 * Gets the content resource, this could also return a 
> class which can be adapted from a resource or another proxy 
> instance.****
>
>                 */****
>
>                 @SlingReference(path="jcr:content")****
>
>                 public Resource getContentResource();****
>
>  ****
>
>                 /******
>
>                 * Gets the children of the current resource, the 
> return type should match the return type in the generic of the return 
> Iterator.**
> **
>
>                 */****
>
>                 @SlingChildren(returnType=Resource.class, path="")****
>
>                 public Iterator<Resource> getChildren();****
>
> }****
>
>  ****
>
> You could then retrieve an instance of the proxy as such:****
>
>  ****
>
> Resource resource;****
>
> ISlingProxyService slingProxyService;****
>
> {...}****
>
> Page page = slingProxyService.getProxy(resource, Page.class);****
>
>  ****
>
> You can check out the code, including some basic tests on GitHub:****
>
> https://github.com/sixdimensions/sling-proxy****
>
>  ****
>
> We both hope this project will be of interest to the Sling developers 
> and the Sling community.****
>
>  ****
>
> Thanks,****
>
> ** **
>
> Dan Klco****
>
> Senior Staff Engineer, Adobe WEM / Day CQ5****
>
> San Ramon, CA / Dayton, OH****
>
> ** **
>
> [image: Description: Description: Description:
> cid:image003.gif@01CCF856.90108760] 
> <http://www.sixdimensions.com/>****
>
> Cell (937) 231-3050****
>
> Office (937) 343-1326****
>
> Fax (877) 510-5082****
>
> LinkedIn <http://www.linkedin.com/in/klcodanr> | 
> @KlcoDanR<https://twitter.com/klcodanr>
> ****
>
> ** **
>
> *People. Deliver. Progress.*
>
> ** **
>

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2904 / Virus Database: 2641/6211 - Release Date: 03/28/13

Reply via email to