Index: src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationScannerTestCase.java (working copy) @@ -80,10 +80,10 @@ public void shouldRetrieveAllHttpMethodsInProject() throws CoreException { // pre-conditions // operation - final List resourceMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject, + final List httpMethods = JaxrsAnnotationsScanner.findHttpMethodTypes(javaProject, new NullProgressMonitor()); // verifications - assertThat(resourceMethods.size(), equalTo(7)); + assertThat(httpMethods.size(), equalTo(1)); } @Test Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java (working copy) @@ -43,6 +43,7 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase; +import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBuiltinHttpMethod; import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsEndpoint; import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod; import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication; @@ -115,14 +116,14 @@ return resourceMethod; } - private JaxrsHttpMethod createHttpMethod(EnumJaxrsElements element) throws JavaModelException, CoreException { - final IType type = getType(element.qualifiedName, javaProject); + private JaxrsHttpMethod createHttpMethod(String qualifiedName) throws JavaModelException, CoreException { + final IType type = getType(qualifiedName, javaProject); final Annotation httpAnnotation = getAnnotation(type, HTTP_METHOD.qualifiedName); final JaxrsHttpMethod httpMethod = new JaxrsHttpMethod(type, httpAnnotation, metamodel); metamodel.add(httpMethod); return httpMethod; } - + private JaxrsEndpoint createEndpoint(JaxrsMetamodel metamodel, JaxrsHttpMethod httpMethod, JaxrsResourceMethod... resourceMethods) { JaxrsEndpoint endpoint = new JaxrsEndpoint(metamodel, httpMethod, new LinkedList( Arrays.asList(resourceMethods))); @@ -148,7 +149,7 @@ @Test public void shouldConstructSimpleEndpoint() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName)); customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName)); @@ -169,7 +170,7 @@ @Test public void shouldConstructEndpointFromSubresource() throws CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource producLocatorResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productLocatorMethod = createResourceMethod("getProductResourceLocator", producLocatorResource, GET); @@ -189,7 +190,7 @@ @Test public void shouldConstructEndpointWithQueryParams() throws CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource, GET); @@ -203,7 +204,6 @@ @Test public void shoudCreateEndpointWhenAddingResourceMethodInRootResource() throws CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource, GET); @@ -218,7 +218,6 @@ @Test public void shoudCreateEndpointWhenAddingSubresourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -234,7 +233,6 @@ public void shoudCreateEndpointWhenAddingSubresourceLocatorMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"); createResourceMethod("getProduct", bookResource, GET); // createEndpoint(httpMethod, bookResourceMethod); @@ -257,7 +255,6 @@ @Test public void shoudCreateEndpointWhenAddingResourceMethodInSubresource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); createResourceMethod("getProductResourceLocator", productResourceLocator, null); final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"); @@ -274,7 +271,6 @@ public void shoudCreateEndpointWhenChangingSubresourceLocatorMethodIntoSubresourceMethod() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerSubresourceMethod = createResourceMethod("getCustomer", customerResource, null); @@ -293,7 +289,6 @@ @Test public void shoudCreateEndpointWhenAddingSubresourceMethodInSubresource() throws JavaModelException, CoreException { // pre-conditions - createHttpMethod(GET); final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); createResourceMethod("getProductResourceLocator", productResourceLocator, null); final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"); @@ -315,7 +310,7 @@ public void shoudChangeUriPathTemplateWhenAddingApplication() throws JavaModelException, CoreException { // the subresource becomes a root resource ! // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -336,7 +331,7 @@ public void shoudChangeUriPathTemplateWhenAddingResourcePathAnnotation() throws JavaModelException, CoreException { // the subresource becomes a root resource ! // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource, GET); @@ -355,7 +350,7 @@ @Test public void shoudChangeUriPathTemplateWhenAddingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -381,7 +376,7 @@ public void shoudChangeUriPathTemplateWhenChangingApplicationPathAnnotation() throws JavaModelException, CoreException { // pre-conditions final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication"); - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -404,7 +399,7 @@ @Test public void shoudChangeUriPathTemplateWhenChangingResourcePathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -427,7 +422,7 @@ @Test public void shoudChangeUriPathTemplateWhenChangingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -451,7 +446,7 @@ public void shoudChangeUriPathTemplateWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorFound() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; // the subresource locator that will match the resourcemethod when the // rootresource becomes a subresource final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); @@ -480,7 +475,7 @@ @Test public void shoudChangeHttpVerbWhenChangingHttpMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO"); final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -502,7 +497,7 @@ public void shoudChangeUriPathTemplateWhenRemovingMetamodelApplication() throws JavaModelException, CoreException { // pre-conditions final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication"); - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -524,7 +519,7 @@ @Test public void shoudChangeUriPathTemplateWhenRemovingMethodPathAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -547,7 +542,7 @@ @Test public void shoudChangeConsumedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource, POST); @@ -570,7 +565,7 @@ public void shoudChangeConsumedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource, POST); @@ -593,7 +588,7 @@ public void shoudChangeConsumedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource, POST); @@ -618,7 +613,7 @@ @Test public void shoudChangeConsumedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final Annotation annotation = getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName, "application/foo"); @@ -644,7 +639,7 @@ public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), CONSUMES.qualifiedName, "application/xml")); @@ -671,7 +666,7 @@ public void shoudChangeConsumedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource, POST); @@ -695,7 +690,7 @@ @Test public void shoudChangeProducedMediatypesWhenAddingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource, GET); @@ -718,7 +713,7 @@ public void shoudChangeProducedMediatypesWhenAddingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource, GET); @@ -740,7 +735,7 @@ @Test public void shoudChangeProducedMediatypesWhenChangingResourceAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final Annotation annotation = getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName, "application/foo"); @@ -766,7 +761,7 @@ public void shoudChangeProducedMediatypesWhenChangingResourceMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomerAsVCard", customerResource, POST); @@ -792,7 +787,7 @@ public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); customerResource.addOrUpdateAnnotation(getAnnotation(customerResource.getJavaElement(), PRODUCES.qualifiedName, "application/xml")); @@ -819,7 +814,7 @@ public void shoudChangeProducedMediatypesWhenRemovingMethodAnnotationWithoutResourceDefault() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(POST); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.POST; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("createCustomer", customerResource, POST); @@ -843,7 +838,7 @@ @Test public void shoudRemoveEndpointWhenRemovingHttpMethodAnnotation() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = createHttpMethod("org.jboss.tools.ws.jaxrs.sample.services.FOO"); final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -863,7 +858,7 @@ public void shoudRemoveEndpointWhenRemovingResourcePathAnnotationAndMatchingSubresourceLocatorNotFound() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -885,7 +880,7 @@ @Test public void shoudRemoveEndpointsWhenRemovingRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod1 = createResourceMethod("getCustomer", customerResource, GET); @@ -907,7 +902,7 @@ @Test public void shoudRemoveEndpointsWhenRemovingSubresource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); @@ -930,7 +925,7 @@ @Test public void shoudRemoveEndpointsWhenRemovingHttpMethod() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); createResourceMethod("getProductResourceLocator", productResourceLocator, null); final JaxrsResource bookResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.BookResource"); @@ -954,7 +949,7 @@ @Test public void shoudAddEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); @@ -984,7 +979,7 @@ @Test public void shoudRemoveEndpointsWhenChangingSubresourceLocatorReturnType() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); @@ -1014,7 +1009,7 @@ @Test public void shoudRemoveEndpointsWhenRemovingSubresourceLocatorResource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); @@ -1038,7 +1033,7 @@ @Test public void shoudRemoveEndpointWhenRemovingResourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomers", customerResource, GET); @@ -1057,7 +1052,7 @@ public void shoudRemoveEndpointWhenRemovingSubresourceMethodInRootResource() throws JavaModelException, CoreException { // pre-conditions - final JaxrsHttpMethod httpMethod = createHttpMethod(GET); + final JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource"); final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource, GET); @@ -1077,7 +1072,7 @@ @Test public void shoudRemoveEndpointWhenRemovingSubresourceLocatorMethod() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); @@ -1102,7 +1097,7 @@ public void shoudRemoveEndpointWhenSubresourceLocatorRootResourceBecomesSubresource() throws JavaModelException, CoreException { // pre-conditions - JaxrsHttpMethod httpMethod = createHttpMethod(GET); + JaxrsHttpMethod httpMethod = JaxrsBuiltinHttpMethod.GET; final JaxrsResource productResourceLocator = createResource("org.jboss.tools.ws.jaxrs.sample.services.ProductResourceLocator"); final JaxrsResourceMethod productResourceLocatorMethod = createResourceMethod("getProductResourceLocator", productResourceLocator, null); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java (working copy) @@ -171,21 +171,9 @@ return affectedMetamodel.getAffectedElements(); } - /** - * Because sometimes, generics are painful... - * - * @param elements - * @return private List> asList(IJaxrsElement... elements) { final List> result - * = new ArrayList>(); result.addAll(Arrays.asList(elements)); return result; } - */ - @Test public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodel() throws CoreException { // pre-conditions - metamodel.add(createHttpMethod(GET)); - metamodel.add(createHttpMethod(POST)); - metamodel.add(createHttpMethod(PUT)); - metamodel.add(createHttpMethod(DELETE)); // operation final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java", progressMonitor); @@ -196,21 +184,17 @@ assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED)); assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel) metamodel)); final List affectedElements = affectedMetamodel.getAffectedElements(); - // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources + // 1 application + 1 HttpMethod + 7 Resources assertThat(affectedElements.size(), equalTo(9)); assertThat(affectedElements, everyItem(Matchers. hasProperty("deltaKind", equalTo(ADDED)))); - // all HttpMethods, Resources, ResourceMethods and ResourceFields - assertThat(metamodel.getElements(javaProject).size(), equalTo(34)); + // all HttpMethods, Resources, ResourceMethods and ResourceFields. only application is available: the java-based one found in src/main/java + assertThat(metamodel.getElements(javaProject).size(), equalTo(30)); } @Test public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodelWithReset() throws CoreException { // pre-conditions - metamodel.add(createHttpMethod(GET)); - metamodel.add(createHttpMethod(POST)); - metamodel.add(createHttpMethod(PUT)); - metamodel.add(createHttpMethod(DELETE)); // operation final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java", progressMonitor); @@ -222,11 +206,12 @@ metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel(); assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel)); final List affectedElements = affectedMetamodel.getAffectedElements(); - // 1 application + 1 HttpMethod + 4 RootResources + 2 Subresources - assertThat(affectedElements.size(), equalTo(15)); + // 1 application + 1 HttpMethod + 7 Resources + assertThat(affectedElements.size(), equalTo(9)); assertThat(affectedElements, everyItem(Matchers. hasProperty("deltaKind", equalTo(ADDED)))); - // all Applications, HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields - assertThat(metamodel.getElements(javaProject).size(), equalTo(37)); + // all project-specific Applications, HttpMethods, Resources, ResourceMethods and ResourceFields (built-in HttpMethods are not bound to a project) + // 2 applications are available: the java-based and the web.xml since a full build was performed + assertThat(metamodel.getElements(javaProject).size(), equalTo(31)); } /** @@ -255,25 +240,22 @@ metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel(); assertThat(metamodel, notNullValue()); final List affectedElements = affectedMetamodel.getAffectedElements(); - assertThat(affectedElements.size(), equalTo(15)); - // all Applications, HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields - assertThat(metamodel.getElements(javaProject).size(), equalTo(37)); + assertThat(affectedElements.size(), equalTo(9)); + // all Applications, HttpMethods, Resources, ResourceMethods and ResourceFields specific to the project + assertThat(metamodel.getElements(javaProject).size(), equalTo(31)); } @Test - public void shouldAdd6HttpMethodsAnd0ResourceWhenAddingBinaryLib() throws CoreException { + public void shouldNotAddAnythingAddingBinaryLib() throws CoreException { // pre-conditions final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject, "lib/jaxrs-api-2.0.1.GA.jar", progressMonitor); // operation final ResourceDelta event = createEvent(lib.getResource(), ADDED); final List affectedElements = processResourceChanges(event, progressMonitor); - // verifications. Damned : none in the jar... - assertThat(affectedElements.size(), equalTo(6)); - assertThat(affectedElements, everyItem(Matchers. hasProperty("deltaKind", equalTo(ADDED)))); - verify(metamodel, times(6)).add(any(JaxrsHttpMethod.class)); - assertThat(metamodel.getElements(javaProject).size(), equalTo(6)); + // verifications: jar should not be taken into account, even if if it contains matching elements... + assertThat(affectedElements.size(), equalTo(0)); } @Test @@ -574,7 +556,7 @@ } @Test - public void shouldRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException { + public void shouldNotRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException { // pre-conditions final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject, "lib/jaxrs-api-2.0.1.GA.jar", progressMonitor); @@ -587,10 +569,7 @@ final ResourceDelta event = createEvent(lib.getResource(), REMOVED); final List affectedElements = processResourceChanges(event, progressMonitor); // verifications - assertThat(affectedElements.size(), equalTo(1)); - assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.HTTP_METHOD)); - assertThat(affectedElements, everyItem(Matchers. hasProperty("deltaKind", equalTo(REMOVED)))); - assertThat(metamodel.getElements(javaProject).size(), equalTo(0)); + assertThat(affectedElements.size(), equalTo(0)); } @Test Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java (working copy) @@ -118,7 +118,7 @@ @Test public void shouldAssertHTTPMethods() throws CoreException { - // 6 HttpMethods in the jax-rs API (@GET, etc.) + 1 in the project + // 6 fixed HttpMethods as part of the jax-rs API (@GET, etc.) + 1 in the project // (@FOO) Assert.assertEquals(1 * 7, metamodel.getAllHttpMethods().size()); Set jaxrsHttpMethods = new HashSet(); @@ -224,6 +224,7 @@ Collections.sort(httpMethods); assertThat(httpMethods.get(0).getHttpVerb(), equalTo("GET")); assertThat(httpMethods.get(5).getHttpVerb(), equalTo("OPTIONS")); + assertThat(httpMethods.get(6).getHttpVerb(), equalTo("FOO")); } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java (working copy) @@ -62,9 +62,8 @@ // verifications assertNotNull(element); final IJaxrsResource resource = (IJaxrsResource) element; - // only @Path annotation is known by the metamodel, so pure resource - // methods with @GET, etc. are not created here. - assertThat(resource.getAllMethods().size(), equalTo(4)); + // result contains a mix of resource methods and subresource methods since http methods are built-in the metamodel + assertThat(resource.getAllMethods().size(), equalTo(6)); } @Test Index: src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/JaxrsAnnotationsScanner.java (working copy) @@ -140,8 +140,8 @@ throws CoreException { IJavaSearchScope searchScope = null; if (scope instanceof IJavaProject) { - IJavaProject javaProject = (IJavaProject) scope; - searchScope = SearchEngine.createJavaSearchScope(javaProject.getPackageFragmentRoots()); + searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope }, + IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS); } else { searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { scope }); } @@ -195,7 +195,7 @@ List annotations = new ArrayList(httpMethods.size() + 1); annotations.add(PATH.qualifiedName); for (IJaxrsHttpMethod httpMethod : httpMethods) { - annotations.add(httpMethod.getJavaElement().getFullyQualifiedName()); + annotations.add(httpMethod.getFullyQualifiedName()); } return searchForAnnotatedMethods(annotations, searchScope, progressMonitor); } Index: src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/jdt/Annotation.java (working copy) @@ -10,6 +10,7 @@ ******************************************************************************/ package org.jboss.tools.ws.jaxrs.core.jdt; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,16 +33,34 @@ * Full constructor * * @param annotation - * @param name + * @param annotationName * @param annotationElements + * @param sourceRange */ - public Annotation(IAnnotation annotation, String name, Map> annotationElements, + public Annotation(final IAnnotation annotation, final String annotationName, final Map> annotationElements, final ISourceRange sourceRange) { this.javaAnnotation = annotation; - this.javaAnnotationName = name; + this.javaAnnotationName = annotationName; this.javaAnnotationElements = new HashMap>(annotationElements); this.sourceRange = sourceRange; } + + /** + * Full constructor with a single unnamed 'value' + * + * @param annotation + * @param annotationName + * @param annotationValue + * @param sourceRange + */ + public Annotation(final IAnnotation annotation, final String annotationName, final String annotationValue, + final ISourceRange sourceRange) { + this.javaAnnotation = annotation; + this.javaAnnotationName = annotationName; + this.javaAnnotationElements = new HashMap>(); + this.javaAnnotationElements.put("value", Arrays.asList(annotationValue)); + this.sourceRange = sourceRange; + } public boolean update(Annotation annotation) { assert annotation != null; Index: src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java (working copy) @@ -19,7 +19,7 @@ String getHttpVerb(); /** @return the name */ - String getSimpleName(); + String getFullyQualifiedName(); Annotation getHttpMethodAnnotation(); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuilder.java (working copy) @@ -96,20 +96,6 @@ * the progress monitor */ private void build(final int buildKind, final IProject project, final IProgressMonitor progressMonitor) { - /* - * progressMonitor.beginTask("Building JAX-RS Metamodel", 4 * SCALE); - * Logger.debug("Building JAX-RS Metamodel for project {}...", project.getName()); // extract the relevant delta - * bound to this built (some resources or entire project) final List affectedResources = - * extractAffectedResources(project, progressMonitor); progressMonitor.worked(SCALE); // compute changes on the - * JAX-RS Application(s), HttpMethods, Resources, etc. final boolean withReset = (buildKind == FULL_BUILD || - * buildKind == CLEAN_BUILD); final JaxrsMetamodelDelta metamodelDelta = resourceChangedProcessor - * .processAffectedResources(project, withReset, affectedResources, new SubProgressMonitor(progressMonitor, - * SCALE)); progressMonitor.worked(SCALE); new - * JaxrsMetamodelChangedProcessor().processAffectedMetamodel(metamodelDelta, new - * SubProgressMonitor(progressMonitor, SCALE)); progressMonitor.worked(SCALE); new - * JaxrsElementChangedPublisher().publish(metamodelDelta, new SubProgressMonitor(progressMonitor, SCALE)); - * progressMonitor.worked(SCALE); - */ ResourceChangedBuildJob job = new ResourceChangedBuildJob(project, getResourceChangeEvent(project, buildKind)); job.setRule(MutexJobSchedulingRule.getInstance()); job.schedule(); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java (working copy) @@ -30,6 +30,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaCore; @@ -102,18 +103,18 @@ final JaxrsMetamodel metamodel = JaxrsMetamodel.create(JavaCore.create(project)); final JaxrsMetamodelDelta metamodelDelta = new JaxrsMetamodelDelta(metamodel, deltaKind); try { - progressMonitor.beginTask("Processing Project '" + project.getName() + "'...", 1); - Logger.debug("Processing Project '" + project.getName() + "'..."); + progressMonitor.beginTask("Processing project '" + project.getName() + "'...", 1); + Logger.debug("Processing project '" + project.getName() + "'..."); metamodelDelta.addAll(processEvent(new ResourceDelta(project, ADDED, 0), progressMonitor)); if(WtpUtils.hasWebDeploymentDescriptor(project)) { processEvent(new ResourceDelta(WtpUtils.getWebDeploymentDescriptor(project), ADDED, 0), progressMonitor); } progressMonitor.worked(1); } catch (CoreException e) { - Logger.error("Failed while processing Resource results", e); + Logger.error("Failed while processing resource results", e); } finally { progressMonitor.done(); - Logger.debug("Done processing Resource results."); + Logger.debug("Done processing resource results."); } @@ -144,7 +145,6 @@ elementChanges.addAll(processEvent(event, progressMonitor)); progressMonitor.worked(1); } - } catch (CoreException e) { Logger.error("Failed while processing Resource results", e); elementChanges.clear(); @@ -167,7 +167,9 @@ final IJavaElement scope = JavaCore.create(resource); final JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(resource.getProject()); final int deltaKind = event.getDeltaKind(); - if (scope != null) { + if (scope != null && + // ignore changes on binary files (added/removed/changed jars to improve builder performances) + !(scope.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT && ((IPackageFragmentRoot)scope).isArchive())) { switch (deltaKind) { case ADDED: case CHANGED: Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java (working copy) @@ -376,7 +376,7 @@ @Override public IJavaProject getJavaProject() { - return this.httpMethod.getJavaElement().getJavaProject(); + return this.metamodel.getJavaProject(); } } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java (revision 42677) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java (working copy) @@ -96,6 +96,24 @@ */ private JaxrsMetamodel(final IJavaProject javaProject) throws CoreException { this.javaProject = javaProject; + preloadHttpMethods(); + } + + /** + * Preload the HttpMethods collection with 6 items from the specification: + *
    + *
  • @GET
  • + *
  • @POST
  • + *
  • @PUT
  • + *
  • @DELETE
  • + *
  • @OPTIONS
  • + *
  • @HEAD
  • + *
+ */ + private void preloadHttpMethods() { + httpMethods.addAll(Arrays.asList(JaxrsBuiltinHttpMethod.GET, JaxrsBuiltinHttpMethod.POST, + JaxrsBuiltinHttpMethod.PUT, JaxrsBuiltinHttpMethod.DELETE, JaxrsBuiltinHttpMethod.HEAD, + JaxrsBuiltinHttpMethod.OPTIONS)); } /* @@ -454,7 +472,7 @@ public JaxrsHttpMethod getHttpMethod(Annotation httpMethodAnnotation) { if (httpMethodAnnotation != null) { for (IJaxrsHttpMethod httpMethod : httpMethods) { - final String handleIdentifier1 = httpMethod.getJavaElement().getFullyQualifiedName(); + final String handleIdentifier1 = httpMethod.getFullyQualifiedName(); final String handleIdentifier2 = httpMethodAnnotation.getName(); if (handleIdentifier1.equals(handleIdentifier2)) { return (JaxrsHttpMethod) httpMethod; Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java (working copy) @@ -93,9 +93,9 @@ return OTHER; } } - - public JaxrsHttpMethod(IType javaType, Annotation httpMehodAnnotation, JaxrsMetamodel metamodel) { - super(javaType, httpMehodAnnotation, metamodel); + + public JaxrsHttpMethod(IType javaType, Annotation httpMethodAnnotation, JaxrsMetamodel metamodel) { + super(javaType, httpMethodAnnotation, metamodel); } @Override @@ -133,7 +133,7 @@ * () */ @Override - public final String getHttpVerb() { + public String getHttpVerb() { final Annotation httpVerbAnnotation = getHttpMethodAnnotation(); if (httpVerbAnnotation != null) { return httpVerbAnnotation.getValue("value"); @@ -155,8 +155,8 @@ * () */ @Override - public final String getSimpleName() { - return getJavaElement().getElementName(); + public String getFullyQualifiedName() { + return getJavaElement().getFullyQualifiedName(); } /* @@ -166,7 +166,7 @@ */ @Override public final String toString() { - return "HttpMethod [@" + getSimpleName() + ":" + getHttpMethodAnnotation() + "]"; + return "HttpMethod [@" + getFullyQualifiedName() + ":" + getHttpMethodAnnotation() + "]"; } @Override Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java (revision 0) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBuiltinHttpMethod.java (revision 0) @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2012 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain; + +import org.jboss.tools.ws.jaxrs.core.jdt.Annotation; + +/** + * Built-in Http Methods as part of the JAX-RS 1.1 specification + * @author Xavier Coulon + * + */ +public class JaxrsBuiltinHttpMethod extends JaxrsHttpMethod { + + public static final JaxrsHttpMethod GET = new JaxrsBuiltinHttpMethod("javax.ws.rs.GET", "GET"); + public static final JaxrsHttpMethod POST = new JaxrsBuiltinHttpMethod("javax.ws.rs.POST", "POST"); + public static final JaxrsHttpMethod PUT = new JaxrsBuiltinHttpMethod("javax.ws.rs.PUT", "PUT"); + public static final JaxrsHttpMethod DELETE = new JaxrsBuiltinHttpMethod("javax.ws.rs.DELETE", "DELETE"); + public static final JaxrsHttpMethod OPTIONS = new JaxrsBuiltinHttpMethod("javax.ws.rs.OPTIONS", "OPTIONS"); + public static final JaxrsHttpMethod HEAD = new JaxrsBuiltinHttpMethod("javax.ws.rs.HEAD", "HEAD"); + + private final String annotationName; + private final String httpVerb; + + public JaxrsBuiltinHttpMethod(String annotationName, String annotationValue) { + super(null, new Annotation(null, annotationName, annotationValue, null), null); + this.annotationName = annotationName; + this.httpVerb = annotationValue; + } + + @Override + public String getHttpVerb() { + return this.httpVerb; + } + + @Override + public String getFullyQualifiedName() { + return annotationName; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((annotationName == null) ? 0 : annotationName.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + JaxrsBuiltinHttpMethod other = (JaxrsBuiltinHttpMethod) obj; + if (annotationName == null) { + if (other.annotationName != null) { + return false; + } + } else if (!annotationName.equals(other.annotationName)) { + return false; + } + return true; + } + + + +} Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceMethod.java (working copy) @@ -413,7 +413,7 @@ public Annotation getHttpMethodAnnotation() { for (IJaxrsHttpMethod httpMethod : getMetamodel().getAllHttpMethods()) { final Annotation annotation = getAnnotation(httpMethod - .getJavaElement().getFullyQualifiedName()); + .getFullyQualifiedName()); if (annotation != null) { return annotation; } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java (working copy) @@ -213,7 +213,7 @@ JaxrsMetamodel metamodel, JaxrsResource parentResource) throws JavaModelException { final List httpMethodAnnotationNames = new ArrayList(); for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) { - httpMethodAnnotationNames.add(httpMethod.getJavaElement().getFullyQualifiedName()); + httpMethodAnnotationNames.add(httpMethod.getFullyQualifiedName()); } final List annotationNames = new ArrayList(); annotationNames.addAll(Arrays.asList(PATH.qualifiedName, PRODUCES.qualifiedName, CONSUMES.qualifiedName)); Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (revision 42714) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (working copy) @@ -179,7 +179,7 @@ flag = F_PRODUCED_MEDIATYPES_VALUE; } else { for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) { - if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) { + if (httpMethod.getFullyQualifiedName().equals(annotationName)) { flag = F_HTTP_METHOD_VALUE; break; } @@ -224,7 +224,7 @@ flag = F_PRODUCED_MEDIATYPES_VALUE; } else { for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) { - if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) { + if (httpMethod.getFullyQualifiedName().equals(annotationName)) { flag = F_HTTP_METHOD_VALUE; break; }