Java 类org.glassfish.jersey.server.model.ResourceModel 实例源码

项目:CredentialStorageService-dw-hibernate    文件:UnitOfWorkApplicationListenerTest.java   
private void prepareAppEvent(final String resourceMethodName) throws NoSuchMethodException {
    final Resource.Builder builder = Resource.builder();
    final MockResource mockResource = new MockResource();
    final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName);

    Method definitionMethod = handlingMethod;
    final Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0];
    if (this.methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) {
        definitionMethod = interfaceClass.getMethod(resourceMethodName);
    }

    final ResourceMethod resourceMethod = builder.addMethod()
            .handlingMethod(handlingMethod)
            .handledBy(mockResource, definitionMethod).build();
    final Resource resource = builder.build();
    final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build();

    when(this.appEvent.getResourceModel()).thenReturn(model);
    when(this.uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod);
}
项目:dropwizard-entitymanager    文件:UnitOfWorkApplicationListenerTest.java   
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException {
    final Resource.Builder builder = Resource.builder();
    final MockResource mockResource = new MockResource();
    final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName);

    Method definitionMethod = handlingMethod;
    Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0];
    if (methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) {
        definitionMethod = interfaceClass.getMethod(resourceMethodName);
    }

    final ResourceMethod resourceMethod = builder.addMethod()
            .handlingMethod(handlingMethod)
            .handledBy(mockResource, definitionMethod).build();
    final Resource resource = builder.build();
    final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build();

    when(appEvent.getResourceModel()).thenReturn(model);
    when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod);
}
项目:dropwizard-routing    文件:RoutingUnitOfWorkApplicationListenerTest.java   
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException {
    final Resource.Builder builder = Resource.builder();
    final MockResource mockResource = new MockResource();
    final Method handlingMethod = mockResource.getClass().getMethod(resourceMethodName);

    Method definitionMethod = handlingMethod;
    Class<?> interfaceClass = mockResource.getClass().getInterfaces()[0];
    if (methodDefinedOnInterface(resourceMethodName, interfaceClass.getMethods())) {
        definitionMethod = interfaceClass.getMethod(resourceMethodName);
    }

    final ResourceMethod resourceMethod = builder.addMethod().handlingMethod(handlingMethod)
            .handledBy(mockResource, definitionMethod).build();
    final Resource resource = builder.build();
    final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build();

    when(appEvent.getResourceModel()).thenReturn(model);
    when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod);
}
项目:biblebot    文件:JerseyEndpointLoggingListener.java   
@Override
public void onEvent(ApplicationEvent event) {
    if (event.getType() == ApplicationEvent.Type.INITIALIZATION_APP_FINISHED) {
        final ResourceModel resourceModel = event.getResourceModel();
        final ResourceLogDetails logDetails = new ResourceLogDetails();
        resourceModel.getResources().stream().forEach((resource) -> {
            logDetails.addEndpointLogLines(getLinesFromResource(resource));
        });
        logDetails.log();
    }
}
项目:ozark    文件:OzarkModelProcessor.java   
@Override
public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {
    ResourceModel.Builder rmb = new ResourceModel.Builder(false);
    resourceModel.getResources().forEach(r -> {
        rmb.addResource(processResource(r));
    });
    return rmb.build();
}
项目:ozark    文件:OzarkModelProcessorTest.java   
@Test
public void processResourceModel() {
    ResourceModel.Builder rmb = new ResourceModel.Builder(false);
    Resource resource = Resource.builder(SomeController.class).build();
    rmb.addResource(resource);
    ResourceModel processedModel = new OzarkModelProcessor().processResourceModel(rmb.build(), null);
    Resource processedResource = processedModel.getResources().get(0);
    processedResource.getResourceMethods().forEach(m -> assertTrue(m.getProducedTypes().contains(MediaType.TEXT_HTML_TYPE)));
}
项目:dropwizard-jooq    文件:JooqTransactionalApplicationListenerTest.java   
private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException {
    final Resource.Builder builder = Resource.builder();

    final Method method = mockResource.getClass().getMethod(resourceMethodName);
    final ResourceMethod resourceMethod = builder.addMethod().handlingMethod(method).handledBy(mockResource, method).build();
    final Resource resource = builder.build();
    final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build();

    when(appEvent.getResourceModel()).thenReturn(model);
    when(uriInfo.getMatchedResourceMethod()).thenReturn(resourceMethod);
}
项目:bootique-jersey    文件:ResourceModelDebugger.java   
@Override
public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {

    if (LOGGER.isDebugEnabled()) {
        resourceModel.getRootResources().forEach(r -> {
            debugResource(r);
        });
    }

    return resourceModel;
}
项目:SensorSafe    文件:SensorSafeOAuth1ServerFeature.java   
@Override
public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {
    final ResourceModel.Builder builder = new ResourceModel.Builder(resourceModel, false);
    for (Resource resource : resources) {
        builder.addResource(resource);
    }

    return builder.build();
}
项目:ozark    文件:OzarkModelProcessor.java   
@Override
public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) {
    return subResourceModel;
}
项目:bootique-jersey    文件:ResourceModelDebugger.java   
@Override
public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) {
    return subResourceModel;
}
项目:ameba    文件:OptionsMethodProcessor.java   
/**
 * {@inheritDoc}
 */
@Override
public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {
    return ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true).build();
}
项目:ameba    文件:OptionsMethodProcessor.java   
/**
 * {@inheritDoc}
 */
@Override
public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) {
    return ModelProcessorUtil.enhanceResourceModel(subResourceModel, true, methodList, true).build();
}
项目:SensorSafe    文件:SensorSafeOAuth1ServerFeature.java   
@Override
public ResourceModel processSubResource(ResourceModel subResourceModel, Configuration configuration) {
    return subResourceModel;
}
项目:ameba    文件:ApplicationEvent.java   
/**
 * <p>getResourceModel.</p>
 *
 * @return a {@link org.glassfish.jersey.server.model.ResourceModel} object.
 */
public ResourceModel getResourceModel() {
    return event.getResourceModel();
}