route = router.attach(uriPattern, resourceClass);
} else {
route = router.attachDefault(resourceClass);
}
} else {
Restlet target = null;
try {
// Create a new instance of the application class by
// invoking the constructor with the Context parameter.
target = (Restlet) targetClass.getConstructor(
Context.class).newInstance(
getComponent().getContext()
.createChildContext());
} catch (NoSuchMethodException e) {
getLogger()
.log(Level.FINE,
"Couldn't invoke the constructor of the target class. Please check this class has a constructor with a single parameter of type Context. The empty constructor and the context setter will be used instead: "
+ targetClassName, e);
// The constructor with the Context parameter does not
// exist. Instantiate an application with the default
// constructor then invoke the setContext method.
target = (Restlet) targetClass.getConstructor()
.newInstance();
target.setContext(getComponent().getContext()
.createChildContext());
}
if (target != null) {
if ((uriPattern != null) && !defaultRoute) {