@SuppressWarnings("unchecked") public SpringObjectFactory(ApplicationContext applicationContext, String beanName, ClassMetadata classMetadata) { this.beanName = beanName; this.applicationContext = applicationContext; this.classMetadata = classMetadata; this.cls = (Class<Object>)classMetadata.getResourceClass(); }
@Override public Set<MediaType> getConsumes() { Set<MediaType> set = super.getConsumes(); if (set.size() == 0) { set = parent.getConsumes(); } return set; }
public Object getParentInstance() { if (getParentInstances().size() == 0) { return null; } return getParentInstances().get(0); }
private static Set<MediaType> getCollectionProduces(ClassMetadata metadata) { Set<MediaType> produces = new HashSet<MediaType>(); for (MethodMetadata method : metadata.getResourceMethods()) { produces.addAll(method.getProduces()); } for (MethodMetadata method : metadata.getSubResourceMethods()) { produces.addAll(method.getProduces()); } return produces; }
private void logResourceInfo(List<ResourceRecord> resourceRecords) { for (ResourceRecord record : resourceRecords) { try { final String resourceClassName = record.getMetadata().getResourceClass().getName(); final ClassMetadata resourceMetadata = record.getMetadata(); final String resourcePath = resourceMetadata.getPath(); logger.info(Messages.getMessage("serverRegisterJAXRSResourceWithPath", resourceClassName, resourcePath)); } catch (Exception e) { logger.trace("Could not print all of the resource metadata.", e); } } } }
Class<?> resClass = metadata.getResourceClass(); if (resClass != null) { WADLDoc d = resClass.getAnnotation(WADLDoc.class); String path = metadata.getPath(); Class<?> resClass = metadata.getResourceClass(); if (DynamicResource.class.isAssignableFrom(resClass)) { try { List<Param> resourceParams = r.getParam(); List<MethodMetadata> methodMetadata = metadata.getResourceMethods(); List<Injectable> fields = metadata.getInjectableFields(); if (fields != null) { for (Injectable p : metadata.getInjectableFields()) { Param param = null; boolean isUnique = true; methodMetadata = metadata.getSubResourceMethods(); if (methodMetadata != null && !methodMetadata.isEmpty()) { for (MethodMetadata methodMeta : methodMetadata) { methodMetadata = metadata.getSubResourceLocators(); if (methodMetadata != null && !methodMetadata.isEmpty()) { for (MethodMetadata methodMeta : methodMetadata) {
private void parseMethods() { logger.trace("entry"); F1: for (Method method : getMetadata().getResourceClass().getMethods()) { Class<?> declaringClass = method.getDeclaringClass(); if (declaringClass == Object.class) { logger.trace("Was subresource method"); getMetadata().getSubResourceMethods().add(methodMetadata); } else { logger.trace("Was subresource locator"); getMetadata().getSubResourceLocators().add(methodMetadata); getMetadata().getResourceMethods().add(methodMetadata);
String path = dynamicResource.getPath(); if (path != null) { classMetadata.addPath(path); if (logger.isTraceEnabled()) { logger.trace("Adding dispatched path from instance: {}", path); //$NON-NLS-1$ classMetadata.getParentInstances().add(parent); if (logger.isTraceEnabled()) { logger.trace("Adding parent beans from instance: {}", parent); //$NON-NLS-1$ classMetadata.setWorkspaceName(workspaceTitle); classMetadata.setCollectionTitle(collectionTitle);
Set<MediaType> produces = classMetadata.getProduces(); Set<MediaType> consumes = classMetadata.getConsumes(); allMethodMetadata.addAll(classMetadata.getResourceMethods()); allMethodMetadata.addAll(classMetadata.getSubResourceMethods());
for (ResourceRecord record : resourceRecords) { try { final String resourceClassName = record.getMetadata().getResourceClass().getName(); final ClassMetadata resourceMetadata = record.getMetadata(); final String resourcePath = resourceMetadata.getPath(); for (MethodMetadata methodMetadata : resourceMetadata.getResourceMethods()) { ++counter; try { if (isLogForOneResource) { logger .trace("Resource information for {}:{}", resourceMetadata.getResourceClass().getName(), sb); //$NON-NLS-1$ } else { logger.trace(Messages.getMessage("registeredResources", sb)); //$NON-NLS-1$ if (isLogForOneResource) { logger .debug("Resource information for {}:{}", resourceMetadata.getResourceClass().getName(), sb); //$NON-NLS-1$ } else { logger.debug(Messages.getMessage("registeredResources", sb)); //$NON-NLS-1$ if (isLogForOneResource) { logger .trace("Resource information for {}:{}", resourceMetadata.getResourceClass().getName(), sb); //$NON-NLS-1$ } else { logger.trace(Messages.getMessage("registeredResources", sb)); //$NON-NLS-1$ if (isLogForOneResource) { logger
Class<?> resourceClass = metadata.getResourceClass(); logger.trace("Class is {}", resourceClass); List<Injectable> injectableFields = metadata.getInjectableFields(); logger.trace("Injectable fields: {}", injectableFields); PropertyDescriptor[] propertyDescriptors = metadata.getBeanInfo().getPropertyDescriptors(); if(logger.isTraceEnabled()) { logger.trace("Property descriptors are: {}", Arrays.asList(propertyDescriptors));
private void addSubRrcMethodsAndLocators(Resource xmLResource, ResourceRecord record) { List<MethodMetadata> subResourceLocators = record.getMetadata().getSubResourceLocators(); List<MethodMetadata> subResourceMethods = record.getMetadata().getSubResourceMethods(); SubResources subResources = resourcesObjectFactory.createSubResources(); buildSubReasource(record, subResourceLocators, subResources, true); buildSubReasource(record, subResourceMethods, subResources, false); xmLResource.setSubResources(subResources); }
ConstructorMetadata constructorMetadata = new ConstructorMetadata(); List<Injectable> formalParameters = new ArrayList<Injectable>(); Class<?> resourceClass = metadata.getResourceClass(); parameterAnnotations[pos], constructor, getMetadata().isEncoded() || constructorMetadata.isEncoded(), null); metadata.setConstructor(constructorMetadata); logger.trace("parseConstructors() exit");
private boolean parseWorkspace(Class<?> cls) { Workspace workspace = cls.getAnnotation(Workspace.class); if (workspace != null) { getMetadata().setWorkspaceName(workspace.workspaceTitle()); getMetadata().setCollectionTitle(workspace.collectionTitle()); return true; } return false; }
private Resource buildResource(ResourceRecord record) { Resource newResource = resourcesObjectFactory.createResource(); // Add dispatched URIs UriTemplateProcessor uriTemplate = record.getTemplateProcessor(); newResource.setUri(SLASH + uriTemplate.getTemplate()); // Add Collection/Workspace data newResource.setWorkspace(record.getMetadata().getWorkspaceName()); newResource.setCollection(record.getMetadata().getCollectionTitle()); // Add supported HTTP methods List<MethodMetadata> methodRecords = new LinkedList<MethodMetadata>(); methodRecords.addAll(record.getMetadata().getResourceMethods()); org.apache.wink.common.internal.model.admin.Methods methods = resourcesObjectFactory.createMethods(); addResourceMethods(methodRecords, methods); newResource.setMethods(methods); return newResource; }
private Set<SyndLink> build(Set<SyndLink> set, UriBuilder selfUriBuilder, ResourceRecord record) { List<MethodMetadata> methods = null; if (subResourcePath != null && subResourcePath.length() > 0) { // 1) find all the sub-resources that match the sub-resource path List<SubResourceInstance> subResources = record.getMatchingSubResourceMethods(subResourcePath); methods = new LinkedList<MethodMetadata>(); for (SubResourceInstance sub : subResources) { methods.add(sub.getMetadata()); } // 2) add the sub-resource path to the uri builder selfUriBuilder.path(subResourcePath); } else { methods = record.getMetadata().getResourceMethods(); } return build(set, selfUriBuilder, methods); }
/** * create sub-resource records for all sub-resource methods */ private void collectSubResourceMethods() { List<MethodMetadata> subResourceMethods = metadata.getSubResourceMethods(); for (MethodMetadata meta : subResourceMethods) { SubResourceMethodRecord record = new SubResourceMethodRecord(meta); subResources.add(record); } }
/** * create sub-resource records for all sub-resource locators */ private void collectSubResourceLocators() { List<MethodMetadata> subResourceLocators = metadata.getSubResourceLocators(); for (MethodMetadata meta : subResourceLocators) { SubResourceLocatorRecord record = new SubResourceLocatorRecord(meta); subResources.add(record); } }
@Override public Set<MediaType> getProduces() { Set<MediaType> set = super.getProduces(); if (set.size() == 0) { set = parent.getProduces(); } return set; }
private boolean parsePath(Class<?> cls) { Path path = cls.getAnnotation(Path.class); if (path != null) { getMetadata().addPath(path.value()); logger.trace("parseClass() returning true for class direct"); return true; path = superclass.getAnnotation(Path.class); if (path != null) { getMetadata().addPath(path.value()); logger.trace("parseClass() returning true for superclass {}", superclass); return true; path = interfaceClass.getAnnotation(Path.class); if (path != null) { getMetadata().addPath(path.value()); logger.trace("parseClass() returning true for interface {}", interfaceClass); return true;