Tips of using Sling model in AEM6

Here are some tips of using Sling model in AEM6

1. Config pom in my app bundle

<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Sling-Model-Packages>
au.com.sensis.yp.selcitra.slingmodels
</Sling-Model-Packages>
</instructions>
</configuration>
</plugin>

2. Config debug log
Go to http://localhost:4502/system/console/configMgr, add org.apache.sling.commons.log.LogManager item with org.apache.sling.models
slingmodel-log

3. AEM6 uses slign model 1.0.0, so some features are not avaliable:
1) Collecton/List injection are introduced from 1.0.6, I use code below
2) Can’t inject field like @named(“jcr:name”) etc, So I use AEM Objects Sling Models Injector to achieve this

@Inject
private Resource resource;

public String getName() {
resouce.getName();
}

4. Which injectors are available
http://localhost:4502/system/console/status-slingmodels

5. Great resrouces
https://sling.apache.org/documentation/bundles/models.html
https://docs.adobe.com/docs/en/aem/6-0/develop/platform/sling-adapters.html
http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html

6. Node types resources
https://docs.adobe.com/docs/en/aem/6-0/develop/platform/custom-nodetypes.html
http://jackrabbit.apache.org/jcr/node-type-visualization.html
https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/commons/jcr/JcrConstants.html