Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It's a very common case when you keep a path in some property and you want to build a model based on a resource pointed by this path, e.g. you let authors configure references to some content and this reference is kept in property. To make reading of such referenced models easier, additional annotation @Follow was introduced - it allows mapper to map a resource by following a path stored under given property. It is possible to use this annotation in conjunction with @Children as well.

Thanks to this you can make your code even cleaner. Check the following code snippets and see how Reportit has been simplified by use of the new feature.

Code Block
languagejava
linenumberstrue
// Now - with @Follow annotation
@SliceResource
public class ReportComponent  {
    @Follow
	@JcrProperty(value = "reportPath") 
	private ReportModel report; // this will build ReportModel based on resource path
                                // kept in reportPath property of current resource
	
	public String getReportValue() {
        return report.getValue();
    }
}
// Before
@SliceResource
public class ReportComponent implements InitializableModel {   
    @JcrProperty 
    private String reportPath;
    
    private ReportModel report;
    
    private ModelProvider modelProvider;
    
    @Inject
    public ReportComponent(ModelProvider modelProvider) {
        this.modelProvider = modelProvider
    }
    
    @Override
    public void afterCreated() {
        report = modelProvider.get(ReportModel.class, reportPath);
    }
    
    public String getReportValue() {
        return report.getValue();
    }
}

...

For improved performance it's advised to upgrade AEM/CQ add-ons too. See details below.

Updated add-ons

The AEM60 add-on and CQ56 add-on have been updated to optimize reading of component definition so it's highly advisable to upgrade them too if you're upgrading from previous versions of Slice. The new They use AEM's ComponentManager which provides information about components with some nice caching. The updated add-ons include:

  • AEM60 add-on

...

  • - version 1.1.0

...

  • CQ56 add-on

...

  • - version 2.1.0

...

Throwing exception if fail to create injector

...

Semantic versioning approach

We've introduce introduced full semantic versioning in Slice, so you can be sure that all interfaces are semantically versioned and you can upgrade safely with each minor release of Slice.

...