Hi

Sounds like an interesting proposal (except that we don't use the "I" prefix 
for interfaces).

Am 29.03.2013 um 20:14 schrieb Dan Klco:

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();

What's the difference to something like:

                @SlingProperty(name=”jcr:content/jcr:description”)

would that be like a "search path" ?

Regards
Felix


                /**
                * 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

<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.



--
Felix Meschberger | Principal Scientist | Adobe







Reply via email to