本文整理汇总了Java中org.restlet.resource.Finder类的典型用法代码示例。如果您正苦于以下问题:Java Finder类的具体用法?Java Finder怎么用?Java Finder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Finder类属于org.restlet.resource包,在下文中一共展示了Finder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapFinderWithMemberInjection
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Wraps a {@link Finder} returned by {@link #createFinder(Class)} to do
* member injection using the passed in {@link MembersInjector}.
*
* @param finder
* The finder.
* @param membersInjector
* The instance of {@link MembersInjector}.
* @return A wrapped {@link Finder}.
*/
public static Finder wrapFinderWithMemberInjection(final Finder finder,
final SelfInjectingServerResource.MembersInjector membersInjector) {
return new Finder(finder.getContext(), finder.getTargetClass()) {
@Override
public ServerResource find(Request request, Response response) {
ServerResource res = finder.find(request, response);
if (res instanceof SelfInjectingServerResource) {
SelfInjectingServerResource tmp = (SelfInjectingServerResource) res;
tmp.ensureInjected(membersInjector);
} else {
membersInjector.injectMembers(res);
}
return res;
}
};
}
示例2: setupApp
import org.restlet.resource.Finder; //导入依赖的package包/类
protected Application setupApp() throws Exception {
final MapTrackerMemory memory = new MapTrackerMemory();
memory.updateFile(new FileTrackingStatus(1L, 10L, "test1.txt",
FileTrackingStatus.STATUS.READY, 3, 4L, "testType1", new Date(), new Date()));
memory.updateFile(new FileTrackingStatus(1L, 10L, "test2.txt",
FileTrackingStatus.STATUS.READING, 3, 4L, "testType2", new Date(), new Date()));
memory.updateFile(new FileTrackingStatus(1L, 10L, "test3.txt",
FileTrackingStatus.STATUS.DONE, 3, 4L, "testType3", new Date(), new Date()));
this.memory = memory;
Finder finder = new Finder() {
@Override
public ServerResource find(Request request, Response response) {
return fileTrackingStatusResource(memory);
}
};
final Router router = new Router();
router.attach("/files/list", finder);
router.attach("/files/list/", finder);
router.attach("/files/list/{status}", finder);
return new Application() {
@Override
public Restlet createInboundRoot() {
return router;
}
};
}
示例3: setupApp
import org.restlet.resource.Finder; //导入依赖的package包/类
protected Application setupApp() throws Exception {
final MapTrackerMemory memory = new MapTrackerMemory();
memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test1.txt")
.getAbsolutePath(), FileTrackingStatus.STATUS.READY, 3, 4L,
"testType1", new Date(), new Date()));
memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test2.txt")
.getAbsolutePath(), FileTrackingStatus.STATUS.READING, 3, 4L,
"testType2", new Date(), new Date()));
memory.updateFile(new FileTrackingStatus(1L, 10L, new File("test3.txt")
.getAbsolutePath(), FileTrackingStatus.STATUS.DONE, 3, 4L,
"testType3", new Date(), new Date()));
this.memory = memory;
Finder finder = new Finder() {
@Override
public ServerResource find(Request request, Response response) {
return fileTrackingStatusPathResource(memory);
}
};
final Router router = new Router();
router.attach("/files/status", finder, Template.MODE_STARTS_WITH);
Application app = new Application() {
@Override
public Restlet createInboundRoot() {
return router;
}
};
return app;
}
示例4: attachFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Helper method to attch the server resource to the router.
*
* @param router
* @param pathTemplate
* @param resourceClass
* @param matchingMode
*/
private final void attachFinder(Router router, String pathTemplate,
final Class<? extends ServerResource> resourceClass,
int matchingMode) {
Finder finder = new Finder() {
@Override
public ServerResource find(Request request, Response response) {
return beanFactory.getBean(resourceClass);
}
};
router.attach(pathTemplate, finder, matchingMode);
}
示例5: createComponent
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Creates a Component that will used this reasource to always return ok.
*
* @param port
* @return
*/
public static Component createComponent(int port) {
Finder finder = new Finder() {
@Override
public ServerResource find(Request request, Response response) {
return new AlwaysOKRestlet();
}
};
final Router router = new Router();
router.attach("/", finder, Template.MODE_STARTS_WITH);
Application app = new Application() {
@Override
public Restlet createInboundRoot() {
return router;
}
};
Component component = new Component();
component.getServers().add(org.restlet.data.Protocol.HTTP, port);
component.getDefaultHost().attach(app);
return component;
}
示例6: describe
import org.restlet.resource.Finder; //导入依赖的package包/类
private void describe(StringBuilder b, Restlet restlet, String path) {
if (restlet instanceof Router) {
describeRoutes(b, (Router) restlet, path);
} else if (restlet instanceof Finder) {
Finder f = (Finder) restlet;
b.append(path).append(" = ").append(ClassUtils.collapsedName(f.getTargetClass())).append("\n");
} else if (restlet instanceof Filter) {
describe(b, ((Filter)restlet).getNext(), path);
}
}
示例7: finder
import org.restlet.resource.Finder; //导入依赖的package包/类
public Finder finder(Class<?> cls) {
return new ServerResourceKeyFinder(Key.get(cls));
}
示例8: createFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
@Override
public Finder createFinder(Class<? extends ServerResource> targetClass) {
Finder finder = super.createFinder(targetClass);
return wrapFinderWithMemberInjection(finder, membersInjector);
}
示例9: createFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
@Override
public Finder createFinder(Class<? extends ServerResource> targetClass) {
Finder result = super.createFinder(targetClass);
result.setContext(getContext().createChildContext());
return result;
}
示例10: newFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
private Finder newFinder( Class<? extends ServerResource> resource )
{
Finder finder = objectFactory.newObject( Finder.class );
finder.setTargetClass( resource );
return finder;
}
示例11: generateSwaggerForFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
private void generateSwaggerForFinder(JSONObject pathObject, String routePath, Finder finder)
throws JSONException {
Class<? extends ServerResource> targetClass = finder.getTargetClass();
for (Method method : targetClass.getDeclaredMethods()) {
String httpVerb = null;
Annotation annotationInstance = method.getAnnotation(HttpVerb.class);
if (annotationInstance != null) {
httpVerb = ((HttpVerb) annotationInstance).value().toLowerCase();
}
HashSet<String> methodPaths = new HashSet<String>();
annotationInstance = method.getAnnotation(Paths.class);
if (annotationInstance != null) {
methodPaths.addAll(Arrays.asList(((Paths) annotationInstance).value()));
}
if (httpVerb != null && methodPaths.contains(routePath) && !routePath.endsWith("/")) {
JSONObject operation = new JSONObject();
pathObject.put(httpVerb, operation);
annotationInstance = method.getAnnotation(Summary.class);
if (annotationInstance != null) {
operation.put(Summary.class.getSimpleName().toLowerCase(), ((Summary) annotationInstance).value());
}
annotationInstance = method.getAnnotation(Description.class);
if (annotationInstance != null) {
operation.put(Description.class.getSimpleName().toLowerCase(), ((Description) annotationInstance).value());
}
annotationInstance = method.getAnnotation(Tags.class);
if (annotationInstance != null) {
operation.put(Tags.class.getSimpleName().toLowerCase(), ((Tags) annotationInstance).value());
}
operation.put("operationId", method.getName());
ArrayList<JSONObject> parameters = new ArrayList<JSONObject>();
for (Annotation[] annotations : method.getParameterAnnotations()) {
if (annotations.length != 0) {
JSONObject parameter = new JSONObject();
for (Annotation annotation : annotations) {
if (annotation instanceof Parameter) {
Parameter parameterAnnotation = (Parameter) annotation;
parameter.put("name", parameterAnnotation.name());
parameter.put("in", parameterAnnotation.in());
if (parameterAnnotation.description() != null) {
parameter.put("description", parameterAnnotation.description());
}
parameter.put("type", "string");
parameter.put("required", parameterAnnotation.required());
}
}
if(parameter.keys().hasNext()) {
parameters.add(parameter);
}
}
}
operation.put("parameters", parameters.toArray(new JSONObject[parameters.size()]));
}
}
}
示例12: isFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
public boolean isFinder(Restlet restlet) {
return restlet instanceof Finder;
}
示例13: createFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Creates a new finder instance based on the "targetClass" property.
*
* In addition to super class behavior, this method will set the context of
* the finder by creating a protected context via the
* {@link Context#createChildContext()} method.
*
* @param targetClass
* The target Resource class to attach.
* @return The new finder instance.
*/
@Override
public Finder createFinder(Class<? extends ServerResource> targetClass) {
Finder result = super.createFinder(targetClass);
result.setContext(getContext().createChildContext());
return result;
}
示例14: createFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
@Override
public Finder createFinder(Class<? extends org.restlet.resource.ServerResource> targetClass) {
Finder finder = finderFactory.getFinder(targetClass, getContext(), getLogger());
return finder;
}
示例15: getFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Create a GuiceFinder for the provided server resource.
*
* @param targetClass the server resource class to be injected by guice
* @param context the restlet current context
* @param logger current logger
* @return a configured finder.
*/
public Finder getFinder(Class<? extends ServerResource> targetClass, Context context, Logger logger){
GuiceFinder finder = GuiceFinder.createGuiceFinder(targetClass, context, logger);
finder.setInjector(GuiceContext.Instance.getInjector());
return finder;
}