Hi,

i am posting this message again, because first posting was included in another thread and not a new one .... And i am still waiting for answer :-)


As described we are using sling with an object mapper.

------------------------------------------------
wall (sling:resourceType = "wall")
|
|--> brickgroup1 (sling:resourceType = "brickgroup")
|         |
|         |--> brick11 (sling:resourceType = "statichtmlbrick")
|         |--> brick12 (sling:resourceType = "contentbrick")
|         |--> brick13 (sling:resourceType = "contentbrick")
|
|--> brickgroup2 (sling:resourceType = "brickgroup")
        |
        |--> brick21 (sling:resourceType = "contentbrick")
        |--> brick22 (sling:resourceType = "contentbrick")
        |--> brick23 (sling:resourceType = "statichtmlbrick")
------------------------------------------------

If we include other scripts to a script, we always use
----
sling.include(brickgroup.getPath());
----

inside the script, we adapt resource to our class with an AdapterFactory.


This means, the node has always to be retrieved and mapped again by the OR mapper.


So i am wondering if it could be useful to have a new include method on SlingHelper to handle

public void include(Resource resource, RequestDispatcherOptions options) {
// doing similar than other includes, but with resource
}


And than i could create a PojoSyntheticResource and include directly in the script. Benefit its already resolved and mapped....
example:

sling.include(new PojoSyntheticResource(brickgroup));

-------------------------
public class PojoSyntheticResource extends SyntheticResource {


  Base base;

public PojoSyntheticResource(ResourceResolver resourceResolver, Base base) {
      this(resourceResolver, base.getPath(), base.getResourceType());
      this.base = base;
  }

  /**
   * Creates a synthetic resource with the given <code>path</code> and
   * <code>resourceType</code>.
   */
protected PojoSyntheticResource(ResourceResolver resourceResolver, String path, String resourceType) {
      super(resourceResolver, path, resourceType);
  }

  @Override
  public <Type> Type adaptTo(Class<Type> type) {
      if (Base.class.isAssignableFrom(type)) {
          return (Type) base;
      }
      return null;
  }
}

-------------------------------------


Do you like to have an scriptHelper method like this ? than i would open an jira issue. Or do you any other suggestions ?



Markus

Reply via email to