|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wicketstuff.annotation.scan.AnnotatedMountScanner
public class AnnotatedMountScanner
Looks for mount information by scanning for classes annotated with MountPath. You can
specify a package to scan (e.g., "org.mycompany.wicket.pages"). Wildcards also work (e.g.,
"org.mycompany.*.pages" or "org.mycompany.**.pages").
You can also go more advanced, using any pattern supported by MatchingResources. For
example, the first package example above is turned into
"classpath*:/org/mycompany/wicket/pages/**/*.class".
For each class that is annotated, an appropriate IRequestMapper implementing class is
created using the information in the MountPath annotation and any supplemental
annotations. Each instance is added to the list to return. Each item in the returned list can
then be mounted.
Typical usage is in your Application.init() method and utilizes the
AnnotatedMountList.mount(org.apache.wicket.protocol.http.WebApplication) convenience method.
protected void init()
{
new AnnotatedMountScanner().scanPackage("org.mycompany.wicket.pages").mount(this);
}
You could scan the entire classpath if you wanted by passing in null, but that might require more time to run than limiting it to known packages which have annotated classes.
Page classes annotation usage is as follows:
@MountPath
private class HelloPage extends Page
{
}
@MountPath("hello")
private class HelloPage extends Page
{
}
@MountPath(value = "dogs", alt = { "canines", "k9s" })
private class DogsPage extends Page
{
}
The first example will mount HelloPage to /HelloPage using the default mapper (as returned by
getRequestMapper(java.lang.String, java.lang.Class extends org.apache.wicket.request.component.IRequestablePage>) which is MountedMapper.
The second example will mount HelloPage to /hello using the default mapper (as returned by
getRequestMapper(java.lang.String, java.lang.Class extends org.apache.wicket.request.component.IRequestablePage>) which is MountedMapper.
The third example will mount DogsPage at "/dogs" (as the primary) and as "/canines" and "/k9s" as
alternates using the MountedMapper.
| Constructor Summary | |
|---|---|
AnnotatedMountScanner()
|
|
| Method Summary | |
|---|---|
String |
getDefaultMountPath(Class<? extends IRequestablePage> pageClass)
Returns the default mount path for a given class (used if the path has not been specified in the @MountPath annotation). |
List<Class<?>> |
getPackageMatches(String pattern)
Scan given a package name or part of a package name and return list of classes with MountPath annotation. |
String |
getPatternForPackage(String packageName)
Get the Spring search pattern given a package name or part of a package name |
List<Class<?>> |
getPatternMatches(String pattern)
Scan given a Spring search pattern and return list of classes with MountPath annotation. |
IRequestMapper |
getRequestMapper(String mountPath,
Class<? extends IRequestablePage> pageClass)
Returns the default mapper given a mount path and class. |
AnnotatedMountList |
scanClass(Class<? extends Page> pageClass)
Scan given a class that is a sublass of Page. |
protected AnnotatedMountList |
scanList(List<Class<?>> mounts)
Scan a list of classes which are annotated with MountPath |
AnnotatedMountList |
scanPackage(String packageName)
Scan given package name or part of a package name |
AnnotatedMountList |
scanPattern(String pattern)
Scan given a Spring search pattern. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AnnotatedMountScanner()
| Method Detail |
|---|
public String getPatternForPackage(String packageName)
packageName - a package name
public List<Class<?>> getPackageMatches(String pattern)
public List<Class<?>> getPatternMatches(String pattern)
public AnnotatedMountList scanPackage(String packageName)
packageName - a package to scan (e.g., "org.mycompany.pages)
AnnotatedMountListpublic AnnotatedMountList scanPattern(String pattern)
pattern -
AnnotatedMountListprotected AnnotatedMountList scanList(List<Class<?>> mounts)
mounts -
AnnotatedMountListpublic AnnotatedMountList scanClass(Class<? extends Page> pageClass)
Page.
pageClass - Page subclass to scan
AnnotatedMountList containing the primary and alternate strategies created
for the class.
public IRequestMapper getRequestMapper(String mountPath,
Class<? extends IRequestablePage> pageClass)
mountPath - pageClass -
MountedMapperpublic String getDefaultMountPath(Class<? extends IRequestablePage> pageClass)
@MountPath annotation). By default, this method returns the
pageClass.getSimpleName().
pageClass -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||