本文整理汇总了Java中org.restlet.resource.Finder类的典型用法代码示例。如果您正苦于以下问题:Java Finder类的具体用法?Java Finder怎么用?Java Finder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Finder类属于org.restlet.resource包,在下文中一共展示了Finder类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
};
}
开发者ID:restlet,项目名称:restlet-framework,代码行数:27,代码来源:ResourceInjectingApplication.java
示例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;
}
};
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:TestFileTrackerStatusResource.java
示例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;
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:39,代码来源:TestFileTrackerStatusPathResource.java
示例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);
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:24,代码来源:CollectorDI.java
示例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;
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:36,代码来源:AlwaysOKRestlet.java
示例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);
}
}
开发者ID:ontopia,项目名称:ontopia,代码行数:11,代码来源:APIInfoResource.java
示例7: finder
import org.restlet.resource.Finder; //导入依赖的package包/类
public Finder finder(Class<?> cls) {
return new ServerResourceKeyFinder(Key.get(cls));
}
开发者ID:restlet,项目名称:restlet-framework,代码行数:4,代码来源:RestletGuice.java
示例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);
}
开发者ID:restlet,项目名称:restlet-framework,代码行数:6,代码来源:ResourceInjectingApplication.java
示例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;
}
开发者ID:restlet,项目名称:restlet-framework,代码行数:7,代码来源:InternalRouter.java
示例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;
}
开发者ID:apache,项目名称:polygene-java,代码行数:7,代码来源:RestApplication.java
示例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()]));
}
}
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:66,代码来源:SwaggerResource.java
示例12: isFinder
import org.restlet.resource.Finder; //导入依赖的package包/类
public boolean isFinder(Restlet restlet) {
return restlet instanceof Finder;
}
开发者ID:ontopia,项目名称:ontopia,代码行数:4,代码来源:APIInfoResource.java
示例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;
}
开发者ID:restlet,项目名称:restlet-framework,代码行数:18,代码来源:VirtualHost.java
示例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;
}
开发者ID:lathil,项目名称:Ptoceti,代码行数:8,代码来源:GuiceRouter.java
示例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;
}
开发者ID:lathil,项目名称:Ptoceti,代码行数:15,代码来源:GuiceFinderFactory.java
示例16: setupApp
import org.restlet.resource.Finder; //导入依赖的package包/类
protected Application setupApp() throws Exception {
final MapTrackerMemory memory = new MapTrackerMemory();
for(int i = 0; i < totalReady; i++){
memory.updateFile(new FileTrackingStatus(1L, 10L, "test" + i + ".txt",
FileTrackingStatus.STATUS.READY, 3, 4L, "testType" + i, new Date(), new Date()));
}
assertEquals(totalReady, memory.getFileCount(FileTrackingStatus.STATUS.READY));
for(int i = 0; i < totalDone; i++){
memory.updateFile(new FileTrackingStatus(1L, 10L, "test" + (totalReady + i) + ".txt",
FileTrackingStatus.STATUS.DONE, 3, 4L, "testType" + (totalReady + i), new Date(), new Date()));
}
assertEquals(totalDone, memory.getFileCount(FileTrackingStatus.STATUS.DONE));
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;
}
};
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:46,代码来源:TestFileTrackerStatusResourceByStatus.java
示例17: finder
import org.restlet.resource.Finder; //导入依赖的package包/类
/**
* Returns a {@link Finder} that will obtain a dependency-injected instance
* of the ServerResource subtype bound to the type associated with the given
* class.
*
* @param cls
* The class to instantiate.
* @return An instance of {@link Finder}.
* @throws ProvisionException
* if {@code cls} is not bound to {@link ServerResource} or a
* subclass.
*/
Finder finder(Class<?> cls);
开发者ID:restlet,项目名称:restlet-framework,代码行数:14,代码来源:FinderFactory.java
注:本文中的org.restlet.resource.Finder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论