/** * Create a new instance from an existing AbstractResource but * defining a new path. * * @param path the path. * @param ar the existing abstract resource. */ public AbstractResource(String path, AbstractResource ar) { this.uriPath = new PathValue(path); this.resourceClass = ar.resourceClass; this.constructors = ar.constructors; this.fields = ar.fields; this.setterMethods = ar.setterMethods; this.resourceMethods = ar.resourceMethods; this.subResourceMethods = ar.subResourceMethods; this.subResourceLocators = ar.subResourceLocators; this.postConstructMethods = ar.postConstructMethods; this.preDestroyMethods = ar.preDestroyMethods; }
private static void workOutSubResourceLocatorsList( AbstractResource resource, MethodList methodList, boolean isEncoded) { for (AnnotatedMethod m : methodList.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class)) { final Path mPathAnnotation = m.getAnnotation(Path.class); final AbstractSubResourceLocator subResourceLocator = new AbstractSubResourceLocator( resource, m.getMethod(), new PathValue( mPathAnnotation.value()), m.getAnnotations()); processParameters( subResourceLocator.getResource().getResourceClass(), subResourceLocator.getMethod().getDeclaringClass(), subResourceLocator, m, isEncoded); resource.getSubResourceLocators().add(subResourceLocator); } }
public ContainerRequest filter(ContainerRequest request) { LOGGER.log(Level.INFO, "Sub-Resource Locator matched. " + "\n Path: " + asrl.getPath().getValue() + (context != null ? "\n Matched Result: " + context.getUriInfo().getMatchedResults().get(0) : "") + "\n Resource: " + asrl.getResource().getResourceClass().getName() + "\n Method: " + asrl.getMethod().toGenericString()); return request; } }
new PathValue(rPathAnnotation.value())); } else { // just a subresource class resource = new AbstractResource(resourceClass);
@Override public String toString() { return "AbstractResource(" + ((null == getPath()) ? "" : ("\"" + getPath().getValue() + "\", - ")) + getResourceClass().getSimpleName() + ": " + getConstructors().size() + " constructors, " + getFields().size() + " fields, " + getSetterMethods().size() + " setter methods, " + getResourceMethods().size() + " res methods, " + getSubResourceMethods().size() + " subres methods, " + getSubResourceLocators().size() + " subres locators " + ")"; }
/** * Create a new instance from an existing AbstractResource but * defining a new path. * * @param path the path. * @param ar the existing abstract resource. */ public AbstractResource(String path, AbstractResource ar) { this.uriPath = new PathValue(path); this.resourceClass = ar.resourceClass; this.constructors = ar.constructors; this.fields = ar.fields; this.setterMethods = ar.setterMethods; this.resourceMethods = ar.resourceMethods; this.subResourceMethods = ar.subResourceMethods; this.subResourceLocators = ar.subResourceLocators; this.postConstructMethods = ar.postConstructMethods; this.preDestroyMethods = ar.preDestroyMethods; }
private Resource generateSubResource(AbstractResource r, String path) { Resource wadlResource = new Resource(); if (r.isRootResource()) { StringBuilder b = new StringBuilder(r.getPath().getValue()); if (!(r.getPath().getValue().endsWith("/") || path.startsWith("/"))) { b.append("/"); } b.append(path); wadlResource.setPath(b.toString()); } // for each sub-resource method Map<String, Param> wadlSubResourceParams = new HashMap<String, Param>(); for (AbstractSubResourceMethod m : r.getSubResourceMethods()) { // find or create sub resource for uri template String template = m.getPath().getValue(); if (!template.equals(path) && !template.equals('/' + path)) { continue; } com.sun.research.ws.wadl.Method wadlMethod = generateMethod(r, wadlSubResourceParams, m); wadlResource.getMethodOrResource().add(wadlMethod); } // add parameters that are associated with each sub-resource method PATH template for (Param wadlParam : wadlSubResourceParams.values()) { wadlResource.getParam().add(wadlParam); } return wadlResource; }
/** * Create a new instance from an existing AbstractResource but * defining a new path. * * @param path the path. * @param ar the existing abstract resource. */ public AbstractResource(String path, AbstractResource ar) { this.uriPath = new PathValue(path); this.resourceClass = ar.resourceClass; this.constructors = ar.constructors; this.fields = ar.fields; this.setterMethods = ar.setterMethods; this.resourceMethods = ar.resourceMethods; this.subResourceMethods = ar.subResourceMethods; this.subResourceLocators = ar.subResourceLocators; this.postConstructMethods = ar.postConstructMethods; this.preDestroyMethods = ar.preDestroyMethods; }
public ContainerRequest filter(ContainerRequest request) { LOGGER.log(Level.INFO, "Sub-Resource Method matched." + "\n Path: " + asrm.getPath().getValue() + (context != null ? "\n Matched Result: " + context.getUriInfo().getMatchedResults().get(0) : "") + "\n HttpMethod: " + asrm.getHttpMethod() + "\n Resource: " + asrm.getDeclaringResource().getResourceClass().getName() + "\n Method: " + asrm.getMethod().toGenericString()); return request; } }
private static void workOutSubResourceLocatorsList( AbstractResource resource, MethodList methodList, boolean isEncoded) { for (AnnotatedMethod m : methodList.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class)) { final Path mPathAnnotation = m.getAnnotation(Path.class); final AbstractSubResourceLocator subResourceLocator = new AbstractSubResourceLocator( resource, m.getMethod(), new PathValue( mPathAnnotation.value()), m.getAnnotations()); processParameters( subResourceLocator.getResource().getResourceClass(), subResourceLocator.getMethod().getDeclaringClass(), subResourceLocator, m, isEncoded); resource.getSubResourceLocators().add(subResourceLocator); } }
@Override public void visitAbstractSubResourceMethod(AbstractSubResourceMethod method) { // check the same things that are being checked for resource methods visitAbstractResourceMethod(method); // and make sure the Path is not null if ((null == method.getPath()) || (null == method.getPath().getValue()) || (method.getPath().getValue().length() == 0)) { issueList.add(new ResourceModelIssue( method, ImplMessages.ERROR_SUBRES_METHOD_URI_PATH_INVALID(method.getMethod(), method.getPath()), true)); } }
private static void workOutSubResourceLocatorsList( AbstractResource resource, MethodList methodList, boolean isEncoded) { for (AnnotatedMethod m : methodList.hasNotMetaAnnotation(HttpMethod.class). hasAnnotation(Path.class)) { final Path mPathAnnotation = m.getAnnotation(Path.class); final AbstractSubResourceLocator subResourceLocator = new AbstractSubResourceLocator( resource, m.getMethod(), new PathValue( mPathAnnotation.value()), m.getAnnotations()); processParameters( subResourceLocator.getResource().getResourceClass(), subResourceLocator.getMethod().getDeclaringClass(), subResourceLocator, m, isEncoded); resource.getSubResourceLocators().add(subResourceLocator); } }
@Override public Resource createResource( AbstractResource r, String path ) { Resource wadlResource = new Resource(); if (path != null) wadlResource.setPath(path); else if (r.isRootResource()) wadlResource.setPath(r.getPath().getValue()); return wadlResource; }
new PathValue(rPathAnnotation.value())); } else { // just a subresource class resource = new AbstractResource(resourceClass);
@Override public void visitAbstractResource(AbstractResource resource) { // uri template of the resource, if present should not contain null value if (resource.isRootResource() && ((null == resource.getPath()) || (null == resource.getPath().getValue()))) { issueList.add(new ResourceModelIssue( resource, ImplMessages.ERROR_RES_URI_PATH_INVALID(resource.getResourceClass(), resource.getPath()), true)); // TODO: is it really a fatal issue? } checkNonPublicMethods(resource); }
new PathValue(rPathAnnotation.value())); } else { // just a subresource class resource = new AbstractResource(resourceClass);