JBoss Tools SVN: r37732 - in trunk/ws: plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core and 12 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-01-09 17:16:52 -0500 (Mon, 09 Jan 2012)
New Revision: 37732
Added:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBaseElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsWebxmlApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtils.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/wtp/
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/webapp/WEB-INF/web.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-with-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-without-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-with-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-without-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-with-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-without-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-with-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-without-servlet-mapping.xml
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/IJaxrsResourceElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsAnnotatedTypeApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElement.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDelta.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDeltaScanner.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsParamBeanProperty.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsProvider.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceElement.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/EnumKind.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsApplication.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsProvider.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AllTests.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
Log:
Working on JBIDE-10425
Sometimes, the 'JAX-RS REST Web Services' node remains in a 'Building..' state (https://issues.jboss.org/browse/JBIDE-10425)
Working on JBIDE-10287
Add support for JAX-RS Application (https://issues.jboss.org/browse/JBIDE-10287)
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/META-INF/MANIFEST.MF 2012-01-09 22:16:52 UTC (rev 37732)
@@ -15,13 +15,19 @@
org.eclipse.jface.text;bundle-version="3.7.0";visibility:=reexport,
org.eclipse.jst.j2ee.ejb;bundle-version="1.1.502",
org.eclipse.ui.workbench;bundle-version="3.7.0";visibility:=reexport,
- org.eclipse.jdt.ui;bundle-version="3.7.0";visibility:=reexport,
org.eclipse.jdt.core.manipulation;bundle-version="1.3.0";visibility:=reexport,
org.eclipse.ui.editors;bundle-version="3.7.0";visibility:=reexport,
org.eclipse.core.commands;bundle-version="3.6.0";visibility:=reexport,
org.eclipse.ui;bundle-version="3.7.0";visibility:=reexport,
org.eclipse.ltk.core.refactoring;bundle-version="3.5.200";visibility:=reexport,
- org.eclipse.wst.validation;bundle-version="1.2.300";visibility:=reexport
+ org.eclipse.wst.validation;bundle-version="1.2.300";visibility:=reexport,
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.301";visibility:=reexport,
+ org.eclipse.jst.j2ee.core;bundle-version="1.1.301";visibility:=reexport,
+ org.eclipse.core.resources;bundle-version="3.5.1";visibility:=reexport,
+ org.eclipse.jst.j2ee;bundle-version="1.1.301";visibility:=reexport,
+ org.eclipse.emf.ecore;bundle-version="2.5.0";visibility:=reexport,
+ org.eclipse.wst.common.frameworks.ui;bundle-version="1.1.301",
+ org.eclipse.jface.text;bundle-version="3.7.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: javax.ws.rs,
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessor.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -41,10 +41,11 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElementFactory;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceElement;
@@ -212,7 +213,7 @@
progressMonitor);
for (IType matchingType : matchingApplicationTypes) {
final CompilationUnit ast = JdtUtils.parse(matchingType, progressMonitor);
- final JaxrsApplication createdApplication = factory.createApplication(matchingType, ast, metamodel);
+ final JaxrsJavaApplication createdApplication = factory.createApplication(matchingType, ast, metamodel);
if (createdApplication != null) {
metamodel.add(createdApplication);
changes.add(new JaxrsElementDelta(createdApplication, ADDED));
@@ -255,7 +256,7 @@
changes.add(new JaxrsElementDelta(resource, ADDED));
}
// now,let's see if the given type can be an Application
- final JaxrsApplication application = factory.createApplication(javaType, ast, metamodel);
+ final JaxrsJavaApplication application = factory.createApplication(javaType, ast, metamodel);
if (application != null) {
metamodel.add(application);
changes.add(new JaxrsElementDelta(application, ADDED));
@@ -308,9 +309,9 @@
private List<JaxrsElementDelta> processAddition(final IAnnotation javaAnnotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final JaxrsElement<?> existingElement = metamodel.getElement(javaAnnotation.getParent());
+ final JaxrsJavaElement<?> existingElement = (JaxrsJavaElement<?>) metamodel.getElement(javaAnnotation.getParent());
if (existingElement == null) {
- final JaxrsElement<?> createdElement = factory.createElement(javaAnnotation, ast, metamodel);
+ final JaxrsJavaElement<?> createdElement = factory.createElement(javaAnnotation, ast, metamodel);
if (createdElement != null) {
metamodel.add(createdElement);
changes.add(new JaxrsElementDelta(createdElement, ADDED));
@@ -345,9 +346,9 @@
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
Annotation annotation = JdtUtils.resolveAnnotation(javaAnnotation, ast);
if (annotation != null) {
- final JaxrsElement<?> existingElement = metamodel.getElement(annotation);
+ final JaxrsJavaElement<?> existingElement = (JaxrsJavaElement<?>) metamodel.getElement(annotation);
if (existingElement == null) {
- final JaxrsElement<?> createdElement = factory.createElement(javaAnnotation, ast, metamodel);
+ final JaxrsJavaElement<?> createdElement = factory.createElement(javaAnnotation, ast, metamodel);
if (createdElement != null) {
metamodel.add(createdElement);
changes.add(new JaxrsElementDelta(createdElement, ADDED));
@@ -374,7 +375,7 @@
private List<JaxrsElementDelta> processChange(IMethod javaMethod, CompilationUnit ast,
JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final JaxrsElement<?> jaxrsElement = metamodel.getElement(javaMethod);
+ final JaxrsBaseElement jaxrsElement = metamodel.getElement(javaMethod);
if (jaxrsElement != null && jaxrsElement.getElementKind() == EnumElementKind.RESOURCE_METHOD) {
final int flag = ((JaxrsResourceMethod) jaxrsElement).update(CompilationUnitsRepository.getInstance()
.getMethodSignature(javaMethod));
@@ -394,8 +395,8 @@
private List<JaxrsElementDelta> processRemoval(IPackageFragmentRoot packageFragmentRoot,
final JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final List<JaxrsElement<?>> elements = metamodel.getElements(packageFragmentRoot);
- for (JaxrsElement<?> element : elements) {
+ final List<JaxrsBaseElement> elements = metamodel.getElements(packageFragmentRoot);
+ for (JaxrsBaseElement element : elements) {
metamodel.remove(element);
changes.add(new JaxrsElementDelta(element, REMOVED));
}
@@ -412,8 +413,8 @@
private List<JaxrsElementDelta> processRemoval(ICompilationUnit compilationUnit, CompilationUnit ast,
final JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final List<JaxrsElement<?>> elements = metamodel.getElements(compilationUnit);
- for (JaxrsElement<?> element : elements) {
+ final List<JaxrsBaseElement> elements = metamodel.getElements(compilationUnit);
+ for (JaxrsBaseElement element : elements) {
metamodel.remove(element);
CompilationUnitsRepository.getInstance().removeAST(compilationUnit);
changes.add(new JaxrsElementDelta(element, REMOVED));
@@ -429,7 +430,7 @@
private List<JaxrsElementDelta> processRemoval(final IType javaType, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final JaxrsElement<?> element = metamodel.getElement(javaType);
+ final JaxrsBaseElement element = metamodel.getElement(javaType);
// if item does not exist yet, then don't care about the removed type
if (element != null) {
metamodel.remove(element);
@@ -446,7 +447,7 @@
private List<JaxrsElementDelta> processRemoval(final IAnnotation javaAnnotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel, final IProgressMonitor progressMonitor) throws CoreException {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final JaxrsElement<?> element = metamodel.getElement(javaAnnotation);
+ final JaxrsJavaElement<?> element = (JaxrsJavaElement<?>) metamodel.getElement(javaAnnotation);
if (element != null) {
// The logic is the same for all the kinds of elements
final int flag = element.removeAnnotation(javaAnnotation.getHandleIdentifier());
@@ -463,8 +464,8 @@
private List<JaxrsElementDelta> processRemoval(IField field, CompilationUnit ast, JaxrsMetamodel metamodel,
IProgressMonitor progressMonitor) {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final List<JaxrsElement<?>> elements = metamodel.getElements(field);
- for (JaxrsElement<?> element : elements) {
+ final List<JaxrsBaseElement> elements = metamodel.getElements(field);
+ for (JaxrsBaseElement element : elements) {
metamodel.remove(element);
changes.add(new JaxrsElementDelta(element, REMOVED));
}
@@ -474,8 +475,8 @@
private List<JaxrsElementDelta> processRemoval(IMethod method, CompilationUnit ast,
JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) {
final List<JaxrsElementDelta> changes = new ArrayList<JaxrsElementDelta>();
- final List<JaxrsElement<?>> elements = metamodel.getElements(method);
- for (JaxrsElement<?> element : elements) {
+ final List<JaxrsBaseElement> elements = metamodel.getElements(method);
+ for (JaxrsBaseElement element : elements) {
if (element.getElementKind() == EnumElementKind.RESOURCE_METHOD) {
metamodel.remove(element);
changes.add(new JaxrsElementDelta(element, REMOVED));
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsElementDelta.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -18,14 +18,14 @@
import java.util.List;
import org.eclipse.jdt.core.IJavaElementDelta;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
public class JaxrsElementDelta implements Comparable<JaxrsElementDelta> {
- private final JaxrsElement<?> element;
+ private final JaxrsBaseElement element;
private final int deltaKind;
@@ -67,7 +67,7 @@
* @param element
* @param deltaKind
*/
- public JaxrsElementDelta(JaxrsElement<?> element, int deltaKind) {
+ public JaxrsElementDelta(JaxrsBaseElement element, int deltaKind) {
this(element, deltaKind, 0);
}
@@ -78,7 +78,7 @@
* @param deltaKind
* @param flags
*/
- public JaxrsElementDelta(JaxrsElement<?> element, int deltaKind, int flags) {
+ public JaxrsElementDelta(JaxrsBaseElement element, int deltaKind, int flags) {
this.element = element;
this.deltaKind = deltaKind;
this.flags = flags;
@@ -88,7 +88,7 @@
}
/** @return the element */
- public JaxrsElement<?> getElement() {
+ public JaxrsBaseElement getElement() {
return element;
}
@@ -112,7 +112,7 @@
StringBuilder s = new StringBuilder();
s.append("JaxrsElementChange: [").append(ConstantUtils.toCamelCase(element.getElementKind().toString()))
.append(" ").append(ConstantUtils.getStaticFieldName(IJavaElementDelta.class, deltaKind)).append("] ")
- .append(element.getJavaElement().getElementName());
+ .append(element.getName());
try {
if (flags != F_NONE) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessor.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -28,8 +28,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
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.JaxrsMetamodel;
@@ -39,6 +38,7 @@
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResource;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.JaxrsEndpointDelta;
@@ -87,14 +87,14 @@
}
private List<JaxrsEndpointDelta> processEvent(final JaxrsElementDelta event) throws CoreException {
- final JaxrsElement<?> element = event.getElement();
+ final JaxrsBaseElement element = event.getElement();
final EnumElementKind elementKind = element.getElementKind();
final int flags = event.getFlags();
switch (event.getDeltaKind()) {
case ADDED:
switch (elementKind) {
case APPLICATION:
- return processAddition((JaxrsApplication) element);
+ return processAddition((IJaxrsApplication) element);
case HTTP_METHOD:
return processAddition((JaxrsHttpMethod) element);
case RESOURCE:
@@ -105,7 +105,7 @@
case CHANGED:
switch (elementKind) {
case APPLICATION:
- return processChange((JaxrsApplication) element, flags);
+ return processChange((IJaxrsApplication) element, flags);
case HTTP_METHOD:
return processChange((JaxrsHttpMethod) element, flags);
case RESOURCE:
@@ -116,7 +116,7 @@
case REMOVED:
switch (elementKind) {
case APPLICATION:
- return processRemoval((JaxrsApplication) element);
+ return processRemoval((IJaxrsApplication) element);
case HTTP_METHOD:
return processRemoval((JaxrsHttpMethod) element);
case RESOURCE:
@@ -135,9 +135,9 @@
* @param application
* @return
*/
- private List<JaxrsEndpointDelta> processAddition(final JaxrsApplication application) {
+ private List<JaxrsEndpointDelta> processAddition(final IJaxrsApplication application) {
final List<JaxrsEndpointDelta> changes = new ArrayList<JaxrsEndpointDelta>();
- final JaxrsMetamodel metamodel = application.getMetamodel();
+ final JaxrsMetamodel metamodel = (JaxrsMetamodel) application.getMetamodel();
// if the given application becomes the used application in the metamodel
if (application.equals(metamodel.getApplication())) {
for (Iterator<JaxrsEndpoint> iterator = metamodel.getEndpoints().iterator(); iterator.hasNext();) {
@@ -285,9 +285,9 @@
return supertypesHandlers;
}
- private List<JaxrsEndpointDelta> processChange(final JaxrsApplication application, int flags) {
+ private List<JaxrsEndpointDelta> processChange(final IJaxrsApplication application, int flags) {
final List<JaxrsEndpointDelta> changes = new ArrayList<JaxrsEndpointDelta>();
- final JaxrsMetamodel metamodel = application.getMetamodel();
+ final JaxrsMetamodel metamodel = (JaxrsMetamodel) application.getMetamodel();
if (application.equals(metamodel.getApplication())) {
for (Iterator<JaxrsEndpoint> iterator = metamodel.getEndpoints().iterator(); iterator.hasNext();) {
JaxrsEndpoint endpoint = iterator.next();
@@ -408,9 +408,9 @@
return changes;
}
- private List<JaxrsEndpointDelta> processRemoval(final JaxrsApplication application) {
+ private List<JaxrsEndpointDelta> processRemoval(final IJaxrsApplication application) {
final List<JaxrsEndpointDelta> changes = new ArrayList<JaxrsEndpointDelta>();
- final JaxrsMetamodel metamodel = application.getMetamodel();
+ final JaxrsMetamodel metamodel = (JaxrsMetamodel) application.getMetamodel();
for (Iterator<JaxrsEndpoint> iterator = metamodel.getEndpoints().iterator(); iterator.hasNext();) {
JaxrsEndpoint endpoint = iterator.next();
if (endpoint.refresh(metamodel.getApplication())) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessor.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -18,31 +18,38 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.ws.rs.core.Application;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElementFactory;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceField;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsWebxmlApplication;
import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.WtpUtils;
import org.jboss.tools.ws.jaxrs.core.jdt.JaxrsAnnotationsScanner;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.metamodel.JaxrsMetamodelDelta;
import org.jboss.tools.ws.jaxrs.core.metamodel.JaxrsMetamodelLocator;
@@ -69,7 +76,7 @@
JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(project);
if (metamodel == null) {
return processEntireProject(project, ADDED, progressMonitor);
- } else if(withReset) {
+ } else if (withReset) {
return processEntireProject(project, CHANGED, progressMonitor);
} else {
return processAffectedResources(events, metamodel, progressMonitor);
@@ -81,7 +88,7 @@
*
* @param project
* the project
- * @param deltaKind
+ * @param deltaKind
* @param progressMonitor
* the progress monitor
* @return the metamodel along with all the JAX-RS elements.
@@ -89,15 +96,17 @@
*/
private JaxrsMetamodelDelta processEntireProject(IProject project, int deltaKind, IProgressMonitor progressMonitor)
throws CoreException {
-
+
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() + "'...");
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);
} finally {
@@ -150,10 +159,13 @@
Logger.debug("Processing {}", event);
final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
final IResource resource = event.getResource();
+ if (resource == null) {
+ return results;
+ }
final IJavaElement scope = JavaCore.create(resource);
+ final JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(resource.getProject());
+ final int deltaKind = event.getDeltaKind();
if (scope != null) {
- final JaxrsMetamodel metamodel = JaxrsMetamodelLocator.get(scope.getJavaProject());
- final int deltaKind = event.getDeltaKind();
switch (deltaKind) {
case ADDED:
case CHANGED:
@@ -168,11 +180,76 @@
results.addAll(processResourceChangesOnScopeRemoval(scope, metamodel, progressMonitor));
break;
}
+ } else if (WtpUtils.isWebDeploymentDescriptor(resource)) {
+ switch (deltaKind) {
+ case ADDED:
+ case CHANGED:
+ results.addAll(processApplicationChangesOnWebxmlAdditionOrChange(resource, metamodel, progressMonitor));
+ break;
+ case REMOVED:
+ results.addAll(processApplicationChangesOnWebxmlRemoval(resource, metamodel, progressMonitor));
+ break;
+ }
}
return results;
}
+ private List<JaxrsElementDelta> processApplicationChangesOnWebxmlAdditionOrChange(IResource resource,
+ JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws CoreException {
+ final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
+ final IType applicationType = JdtUtils.resolveType(Application.class.getName(), metamodel.getJavaProject(),
+ progressMonitor);
+ final ITypeHierarchy applicationTypeHierarchy = JdtUtils.resolveTypeHierarchy(applicationType, false,
+ progressMonitor);
+ final IType[] applicationSubclasses = applicationTypeHierarchy.getSubclasses(applicationType);
+ // add the standard Application type in last position in the hierarchy
+ final IType[] applicationClasses = new IType[applicationSubclasses.length + 1];
+ System.arraycopy(applicationSubclasses, 0, applicationClasses, 0, applicationSubclasses.length);
+ applicationClasses[applicationClasses.length -1] = applicationType;
+ String resolvedApplicationPath = null;
+ for (IType applicationClass : applicationClasses) {
+ final String applicationPath = WtpUtils.getApplicationPath(resource.getProject(),
+ applicationClass.getFullyQualifiedName());
+ if (applicationPath != null) {
+ resolvedApplicationPath = applicationPath;
+ break;
+ }
+ }
+ final IJaxrsApplication application = metamodel.getApplication();
+ if (resolvedApplicationPath != null) {
+ final JaxrsWebxmlApplication webxmlApplication = factory.createApplication(resolvedApplicationPath, resource, metamodel);
+ if (application == null || application.getKind() == EnumKind.APPLICATION_JAVA) {
+ metamodel.add(webxmlApplication);
+ results.add(new JaxrsElementDelta(webxmlApplication, ADDED));
+ } else if (application != null && application.getKind() == EnumKind.APPLICATION_WEBXML) {
+ int flags = webxmlApplication.update(webxmlApplication);
+ results.add(new JaxrsElementDelta(webxmlApplication, CHANGED, flags));
+ }
+ } else if(application != null && application.getKind() == EnumKind.APPLICATION_WEBXML){
+ final JaxrsWebxmlApplication webxmlApplication = (JaxrsWebxmlApplication) application;
+ metamodel.remove(webxmlApplication);
+ results.add(new JaxrsElementDelta(webxmlApplication, REMOVED));
+ }
+ // otherwise, do nothing (application path not declared in web.xml, or not valid but can't be discovered)
+ return results;
+ }
+
+ private List<JaxrsElementDelta> processApplicationChangesOnWebxmlRemoval(IResource resource,
+ JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) {
+ final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
+ for (Iterator<IJaxrsApplication> iterator = metamodel.getAllApplications().iterator(); iterator.hasNext();) {
+ IJaxrsApplication application = (IJaxrsApplication) iterator.next();
+ if(application instanceof JaxrsWebxmlApplication) {
+ Logger.debug("Removing {}", application);
+ final JaxrsWebxmlApplication webxmlApplication = (JaxrsWebxmlApplication)application;
+ metamodel.remove(webxmlApplication);
+ results.add(new JaxrsElementDelta(webxmlApplication, REMOVED));
+ }
+ }
+ return results;
+ }
+
private List<JaxrsElementDelta> processApplicationChangesOnScopeAdditionOrChange(IJavaElement scope,
JaxrsMetamodel metamodel, IProgressMonitor progressMonitor) throws JavaModelException, CoreException {
final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
@@ -201,34 +278,35 @@
JavaModelException {
final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
// see if there may be elements to add/change from the given scope
- final List<JaxrsApplication> matchingApplications = new ArrayList<JaxrsApplication>();
+ final List<JaxrsJavaApplication> matchingApplications = new ArrayList<JaxrsJavaApplication>();
final List<IType> matchingApplicationTypes = JaxrsAnnotationsScanner.findApplicationTypes(scope,
progressMonitor);
for (IType matchingApplicationType : matchingApplicationTypes) {
final CompilationUnit ast = JdtUtils.parse(matchingApplicationType, progressMonitor);
- final JaxrsApplication matchingApplication = factory.createApplication(matchingApplicationType, ast,
+ final JaxrsJavaApplication matchingApplication = factory.createApplication(matchingApplicationType, ast,
metamodel);
if (matchingApplication != null) {
matchingApplications.add(matchingApplication);
}
}
// retrieve the existing elements from the Metamodel
- final List<JaxrsApplication> existingApplications = metamodel.getElements(scope, JaxrsApplication.class);
+ final List<JaxrsJavaApplication> existingApplications = metamodel
+ .getElements(scope, JaxrsJavaApplication.class);
// compute the differences, with a 'fuzzy' case when the kind is
// 'changed'
- final Collection<JaxrsApplication> addedApplications = CollectionUtils.difference(matchingApplications,
+ final Collection<JaxrsJavaApplication> addedApplications = CollectionUtils.difference(matchingApplications,
existingApplications);
- for (JaxrsApplication application : addedApplications) {
+ for (JaxrsJavaApplication application : addedApplications) {
results.add(new JaxrsElementDelta(application, ADDED));
}
- final Collection<JaxrsApplication> changedApplications = CollectionUtils.intersection(matchingApplications,
+ final Collection<JaxrsJavaApplication> changedApplications = CollectionUtils.intersection(matchingApplications,
existingApplications);
- for (JaxrsApplication application : changedApplications) {
+ for (JaxrsJavaApplication application : changedApplications) {
results.add(new JaxrsElementDelta(application, CHANGED, F_FINE_GRAINED));
}
- final Collection<JaxrsApplication> removedApplications = CollectionUtils.difference(existingApplications,
+ final Collection<JaxrsJavaApplication> removedApplications = CollectionUtils.difference(existingApplications,
matchingApplications);
- for (JaxrsApplication application : removedApplications) {
+ for (JaxrsJavaApplication application : removedApplications) {
results.add(new JaxrsElementDelta(application, REMOVED));
}
return results;
@@ -260,8 +338,9 @@
JavaModelException {
final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
// retrieve the existing elements from the Metamodel
- final List<JaxrsApplication> existingApplications = metamodel.getElements(scope, JaxrsApplication.class);
- for (JaxrsApplication application : existingApplications) {
+ final List<JaxrsJavaApplication> existingApplications = metamodel
+ .getElements(scope, JaxrsJavaApplication.class);
+ for (JaxrsJavaApplication application : existingApplications) {
results.add(new JaxrsElementDelta(application, REMOVED));
}
return results;
@@ -269,7 +348,7 @@
private List<JaxrsElementDelta> postProcessApplication(JaxrsElementDelta event, IProgressMonitor progressMonitor) {
final List<JaxrsElementDelta> results = new ArrayList<JaxrsElementDelta>();
- final JaxrsApplication eventApplication = (JaxrsApplication) event.getElement();
+ final JaxrsJavaApplication eventApplication = (JaxrsJavaApplication) event.getElement();
final JaxrsMetamodel metamodel = eventApplication.getMetamodel();
switch (event.getDeltaKind()) {
case ADDED:
@@ -281,8 +360,8 @@
results.add(event);
break;
case CHANGED:
- final JaxrsApplication existingApplication = metamodel.getElement(eventApplication.getJavaElement(),
- JaxrsApplication.class);
+ final JaxrsJavaApplication existingApplication = metamodel.getElement(eventApplication.getJavaElement(),
+ JaxrsJavaApplication.class);
final int flags = existingApplication.update(eventApplication);
if (flags != 0) {
results.add(new JaxrsElementDelta(existingApplication, CHANGED, flags));
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDelta.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDelta.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDelta.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder;
-import java.util.EventObject;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.jdt.core.IJavaElementDelta;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDeltaScanner.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDeltaScanner.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceDeltaScanner.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -27,11 +27,11 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.WtpUtils;
/**
- * Scans and filters the IJavaElementDelta and IResourceDelta (including their
- * children and annotations) and returns a list of JavaElementChangedEvents that
- * match with the JavaElementChangedEventFilter rules.
+ * Scans and filters the IJavaElementDelta and IResourceDelta (including their children and annotations) and returns a
+ * list of JavaElementChangedEvents that match with the JavaElementChangedEventFilter rules.
*
* @author xcoulon
* @see @{IJavaElementDelta}
@@ -43,8 +43,8 @@
private final ResourceDeltaFilter filter = new ResourceDeltaFilter();
- public List<ResourceDelta> scanAndFilterEvent(final IResourceDelta delta,
- final IProgressMonitor progressMonitor) throws CoreException {
+ public List<ResourceDelta> scanAndFilterEvent(final IResourceDelta delta, final IProgressMonitor progressMonitor)
+ throws CoreException {
try {
progressMonitor.beginTask("Analysing changes", 1);
Logger.debug("Some resources changed...");
@@ -55,11 +55,9 @@
}
/**
- * Analyses the given ResourceDelta and its children and returns a list of
- * relevant events for further processing. These events may be
- * {@link JavaElementDelta} or {@link ResourceDelta} depending
- * on the nature of the affected resource (ie: a resource of a compilation
- * unit or a web deployement descriptor/web fragment, respectively).
+ * Analyses the given ResourceDelta and its children and returns a list of relevant events for further processing.
+ * These events may be {@link JavaElementDelta} or {@link ResourceDelta} depending on the nature of the affected
+ * resource (ie: a resource of a compilation unit or a web deployement descriptor/web fragment, respectively).
*
* @param delta
* the delta to analyse
@@ -77,47 +75,54 @@
// FIXME: duplicate code: testing that the resouce if a java file here,
// and in the filter too.
final int flags = delta.getFlags();
- final boolean isJavaFile = resource.getType() == IResource.FILE && ("java").equals(resource.getFileExtension());
- final boolean javaFileAdded = isJavaFile && delta.getKind() == ADDED;
- final boolean javaFileChanged = isJavaFile && delta.getKind() == CHANGED;
- final boolean javaFileRemoved = isJavaFile && delta.getKind() == REMOVED;
- final boolean javaFileMarkersChanged = javaFileChanged && (delta.getFlags() & IResourceDelta.MARKERS) != 0;
- if ((javaFileAdded || javaFileRemoved)) {
- Logger.debug("File {} {}", resource,
- ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
- ResourceDelta event = new ResourceDelta(resource, delta.getKind(), flags);
- if (filter.applyRules(event)) {
- events.add(event);
- }
- } else if (javaFileChanged && !javaFileMarkersChanged) {
- Logger.debug("File {} {}", resource,
- ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
- ResourceDelta event = new ResourceDelta(resource, delta.getKind(), flags);
- if (filter.applyRules(event)) {
- events.add(event);
- }
- } else if (javaFileChanged && javaFileMarkersChanged) {
- IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
- for (IMarkerDelta markerDelta : markerDeltas) {
- int severity = markerDelta.getAttribute(IMarker.SEVERITY, 0);
- String type = markerDelta.getType();
- String message = markerDelta.getAttribute(IMarker.MESSAGE, "");
- if (severity == IMarker.SEVERITY_ERROR && type.equals("org.eclipse.jdt.core.problem")) {
- Logger.debug("Marker delta: {} [{}] {}: \"{}\" at line {} (id={})", markerDelta.getResource()
- .getName(), ConstantUtils.getStaticFieldName(IResourceDelta.class, markerDelta.getKind()),
- ConstantUtils.getStaticFieldName(IMarker.class, severity, "SEVERITY_"), message,
- markerDelta.getAttribute(IMarker.LINE_NUMBER), markerDelta.getId());
- int flag = markerDelta.getKind() == IResourceDelta.ADDED ? IJavaElementDeltaFlag.F_MARKER_ADDED
- : IJavaElementDeltaFlag.F_MARKER_REMOVED;
- ResourceDelta event = new ResourceDelta(resource, CHANGED, flag);
- if (filter.applyRules(event)) {
- events.add(event);
+ if (WtpUtils.isWebDeploymentDescriptor(resource)) {
+ events.add(new ResourceDelta(resource, delta.getKind(), 0));
+ } else {
+
+ final boolean isJavaFile = resource.getType() == IResource.FILE
+ && ("java").equals(resource.getFileExtension());
+ final boolean javaFileAdded = isJavaFile && delta.getKind() == ADDED;
+ final boolean javaFileChanged = isJavaFile && delta.getKind() == CHANGED;
+ final boolean javaFileRemoved = isJavaFile && delta.getKind() == REMOVED;
+ final boolean javaFileMarkersChanged = javaFileChanged && (delta.getFlags() & IResourceDelta.MARKERS) != 0;
+ if ((javaFileAdded || javaFileRemoved)) {
+ Logger.debug("File {} {}", resource,
+ ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
+ ResourceDelta event = new ResourceDelta(resource, delta.getKind(), flags);
+ if (filter.applyRules(event)) {
+ events.add(event);
+ }
+ } else if (javaFileChanged && !javaFileMarkersChanged) {
+ Logger.debug("File {} {}", resource,
+ ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
+ ResourceDelta event = new ResourceDelta(resource, delta.getKind(), flags);
+ if (filter.applyRules(event)) {
+ events.add(event);
+ }
+ } else if (javaFileChanged && javaFileMarkersChanged) {
+ IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
+ for (IMarkerDelta markerDelta : markerDeltas) {
+ int severity = markerDelta.getAttribute(IMarker.SEVERITY, 0);
+ String type = markerDelta.getType();
+ String message = markerDelta.getAttribute(IMarker.MESSAGE, "");
+ if (severity == IMarker.SEVERITY_ERROR && type.equals("org.eclipse.jdt.core.problem")) {
+ Logger.debug("Marker delta: {} [{}] {}: \"{}\" at line {} (id={})", markerDelta.getResource()
+ .getName(), ConstantUtils.getStaticFieldName(IResourceDelta.class,
+ markerDelta.getKind()), ConstantUtils.getStaticFieldName(IMarker.class, severity,
+ "SEVERITY_"), message, markerDelta.getAttribute(IMarker.LINE_NUMBER), markerDelta
+ .getId());
+ int flag = markerDelta.getKind() == IResourceDelta.ADDED ? IJavaElementDeltaFlag.F_MARKER_ADDED
+ : IJavaElementDeltaFlag.F_MARKER_REMOVED;
+ ResourceDelta event = new ResourceDelta(resource, CHANGED, flag);
+ if (filter.applyRules(event)) {
+ events.add(event);
+ }
}
}
+ } else {
+ Logger.trace("**ignored** Delta {} [{}]", delta.getResource().getFullPath(),
+ ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
}
- } else {
- Logger.trace("**ignored** Delta {} [{}]", delta.getResource().getFullPath(),
- ConstantUtils.getStaticFieldName(IResourceDelta.class, delta.getKind()));
}
for (IResourceDelta childDelta : delta.getAffectedChildren()) {
events.addAll(scanDelta(childDelta));
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/IJaxrsResourceElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/IJaxrsResourceElement.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/IJaxrsResourceElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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:
- * Xavier Coulon - Initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
-
-public interface IJaxrsResourceElement {
-
- JaxrsResource getParentResource();
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsAnnotatedTypeApplication.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsAnnotatedTypeApplication.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsAnnotatedTypeApplication.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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:
- * Xavier Coulon - Initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
-
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.ApplicationPath;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.wst.validation.ValidatorMessage;
-import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
-import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
-import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
-
-/**
- * This domain element describes a subtype of {@link jvax.ws.rs.Application} annotated with
- * {@link jvax.ws.rs.ApplicationPath}.
- *
- * @author xcoulon
- */
-public class JaxrsAnnotatedTypeApplication extends JaxrsApplication {
-
- /**
- * Full constructor.
- *
- * @param javaType
- * @param applicationPathAnnocation
- * @param metamodel
- */
- public JaxrsAnnotatedTypeApplication(IType javaType, Annotation applicationPathAnnocation, JaxrsMetamodel metamodel) {
- super(javaType, applicationPathAnnocation, metamodel);
- }
-
- @Override
- public EnumElementKind getElementKind() {
- return EnumElementKind.APPLICATION;
- }
-
- @Override
- public EnumKind getKind() {
- if (getAnnotation(ApplicationPath.class.getName()) != null) {
- return EnumKind.APPLICATION;
- }
- return EnumKind.UNDEFINED;
- }
-
- @Override
- public List<ValidatorMessage> validate() {
- List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
- return messages;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getApplicationPath() {
- final Annotation applicationPathAnnotation = getAnnotation(ApplicationPath.class.getName());
- if (applicationPathAnnotation != null) {
- return applicationPathAnnotation.getValue("value");
- }
- return null;
- }
-
- /**
- * Update this Application with the elements of the given Application
- *
- * @param application
- * @return the flags indicating the kind of changes that occurred during the
- * update.
- */
- @Override
- public int update(JaxrsApplication application) {
- int flags = 0;
- final Annotation annotation = this.getAnnotation(ApplicationPath.class.getName());
- final Annotation otherAnnotation = application.getAnnotation(ApplicationPath.class.getName());
- if (annotation != null && otherAnnotation != null && !annotation.equals(otherAnnotation)
- && annotation.update(otherAnnotation)) {
- flags += F_APPLICATION_PATH_VALUE;
- }
- return flags;
- }
-
- @Override
- public String toString() {
- return ("Application '" + getJavaElement().getElementName() + "': " + getApplicationPath());
- }
-
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsApplication.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsApplication.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsApplication.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -1,27 +0,0 @@
-package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.IType;
-import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
-import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
-
-public abstract class JaxrsApplication extends JaxrsElement<IType> implements IJaxrsApplication {
-
-
- public JaxrsApplication(IType element, Annotation annotation, JaxrsMetamodel metamodel) {
- super(element, annotation, metamodel);
- }
-
- public JaxrsApplication(IType element, List<Annotation> annotations, JaxrsMetamodel metamodel) {
- super(element, annotations, metamodel);
- }
-
- /**
- * @return the value of the {@link javax.ws.rs.ApplicationPath} annotation or null if it does not exist in te
- * associated java type.
- */
- public abstract String getApplicationPath();
-
- public abstract int update(JaxrsApplication eventApplication);
-}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBaseElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBaseElement.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBaseElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,59 @@
+package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsElement;
+
+public abstract class JaxrsBaseElement implements IJaxrsElement {
+
+ /** The associated metamodel. */
+ final JaxrsMetamodel metamodel;
+
+ /** Indicates if the underlying java element has compiltation errors. */
+ private boolean hasErrors;
+
+ /**
+ * Full constructor.
+ *
+ * @param metamodel
+ */
+ public JaxrsBaseElement(JaxrsMetamodel metamodel) {
+ this.metamodel = metamodel;
+ }
+
+ /**
+ * Sets a flag of whether the underlying java element has compilation errors or not.
+ *
+ * @param h
+ * : true if the java element has errors, false otherwise
+ */
+ public void hasErrors(final boolean h) {
+ this.hasErrors = h;
+ }
+
+ /** @return true if the java element has errors, false otherwise. */
+ public final boolean hasErrors() {
+ return hasErrors;
+ }
+
+ /** @return the metamodel */
+ public final JaxrsMetamodel getMetamodel() {
+ return metamodel;
+ }
+
+ public abstract EnumElementKind getElementKind();
+
+ public abstract EnumKind getKind();
+
+ public abstract IResource getResource();
+
+ public abstract List<ValidatorMessage> validate();
+
+ public abstract String getName();
+
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsBaseElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElement.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -1,337 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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:
- * Xavier Coulon - Initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
-
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_CONSUMED_MEDIATYPES_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_DEFAULT_VALUE_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_ELEMENT_KIND;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_HTTP_METHOD_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_MATRIX_PARAM_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_NONE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_PARAM_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PRODUCED_MEDIATYPES_VALUE;
-import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_QUERY_PARAM_VALUE;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.wst.validation.ValidatorMessage;
-import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtils;
-import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
-import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
-import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
-import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
-import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
-
-/**
- * Base class for all elements in the JAX-RS Metamodel.
- *
- * @author xcoulon
- *
- * @param <T>
- * the underlying Java type managed by the JAX-RS ElementKind.
- */
-public abstract class JaxrsElement<T extends IMember> {
-
- /** The associated metamodel. */
- private final JaxrsMetamodel metamodel;
-
- /** The underlying java element. */
- private final T javaElement;
-
- /** Indicates if the underlying java element has compiltation errors. */
- private boolean hasErrors;
-
- /**
- * Map of Annotations on the associated Java Element, indexed by the
- * annotation class name.
- */
- private final Map<String, Annotation> annotations = new HashMap<String, Annotation>();
-
- /**
- * Full constructor.
- *
- * @param model
- * the associated metamodel
- * @param element
- * the underlying java element
- */
- public JaxrsElement(final T element, final Annotation annotation, final JaxrsMetamodel metamodel) {
- this(element, Arrays.asList(annotation), metamodel);
- }
-
- /**
- * Full constructor.
- *
- * @param model
- * the associated metamodel
- * @param element
- * the underlying java element
- **/
- public JaxrsElement(final T element, final List<Annotation> annotations, final JaxrsMetamodel metamodel) {
- this.metamodel = metamodel;
- this.javaElement = element;
- if (annotations != null) {
- for (Annotation annotation : annotations) {
- this.annotations.put(annotation.getName(), annotation);
- }
- }
- }
-
- public abstract EnumElementKind getElementKind();
-
- public abstract EnumKind getKind();
-
- Annotation getAnnotation(String className) {
- return annotations.get(className);
- }
-
- /** @return the underlying java element */
- public final T getJavaElement() {
- return javaElement;
- }
-
- /**
- * Sets a flag of whether the underlying java element has compilation errors
- * or not.
- *
- * @param h
- * : true if the java element has errors, false otherwise
- */
- public void hasErrors(final boolean h) {
- this.hasErrors = h;
- }
-
- /** @return true if the java element has errors, false otherwise. */
- public final boolean hasErrors() {
- return hasErrors;
- }
-
- /**
- * Returns the CompilationUnit (AST3/DOM) of the given java element.
- *
- * @param element
- * the java element
- * @param progressMonitor
- * the progress monitor
- * @return the compilation unit or null
- * @throws JavaModelException
- * in case of underlying exception
- */
- final CompilationUnit getCompilationUnit(final IProgressMonitor progressMonitor) throws JavaModelException {
- return JdtUtils.parse(javaElement, progressMonitor);
- }
-
- /** @return the metamodel */
- public final JaxrsMetamodel getMetamodel() {
- return metamodel;
- }
-
- public Map<String, Annotation> getAnnotations() {
- return annotations;
- }
-
- IResource getResource() {
- return this.javaElement.getResource();
- }
-
- public int addOrUpdateAnnotation(final Annotation annotation) {
- if (annotation == null) {
- return 0;
- }
- boolean changed = false;
- final EnumKind previousKind = getKind();
- final String annotationName = annotation.getName();
- if (annotations.containsKey(annotation.getName())) {
- changed = annotations.get(annotation.getName()).update(annotation);
- } else {
- annotations.put(annotation.getName(), annotation);
- changed = true;
- }
- if (changed) {
- getMetamodel().indexElement(this, annotation);
- return qualifyChange(annotationName, previousKind);
- }
- return F_NONE;
- }
-
- public int mergeAnnotations(Map<String, Annotation> otherAnnotations) {
- int flags = 0;
- // keep values in the 'otherAnnotations' map
- final Map<String, Annotation> addedAnnotations = CollectionUtils.difference(otherAnnotations, this.annotations);
- // keep values in the 'this.annotations' map
- final Map<String, Annotation> removedAnnotations = CollectionUtils.difference(this.annotations,
- otherAnnotations);
- // keep values in the 'otherAnnotations' map
- final Map<String, Annotation> changedAnnotations = CollectionUtils.intersection(otherAnnotations,
- this.annotations);
-
- for (Entry<String, Annotation> entry : addedAnnotations.entrySet()) {
- flags += this.addOrUpdateAnnotation(entry.getValue());
- }
- for (Entry<String, Annotation> entry : changedAnnotations.entrySet()) {
- flags += this.addOrUpdateAnnotation(entry.getValue());
- }
- for (Entry<String, Annotation> entry : removedAnnotations.entrySet()) {
- flags += this.removeAnnotation(entry.getValue());
- }
- return flags;
- }
-
- private int qualifyChange(final String annotationName, EnumKind previousKind) {
- int flag = F_NONE;
- final EnumKind currentKind = getKind();
- if (annotationName.equals(Path.class.getName())) {
- flag = F_PATH_VALUE;
- } else if (annotationName.equals(ApplicationPath.class.getName())) {
- flag = F_APPLICATION_PATH_VALUE;
- } else if (annotationName.equals(HttpMethod.class.getName())) {
- flag = F_HTTP_METHOD_VALUE;
- } else if (annotationName.equals(PathParam.class.getName())) {
- flag = F_PATH_PARAM_VALUE;
- } else if (annotationName.equals(QueryParam.class.getName())) {
- flag = F_QUERY_PARAM_VALUE;
- } else if (annotationName.equals(MatrixParam.class.getName())) {
- flag = F_MATRIX_PARAM_VALUE;
- } else if (annotationName.equals(DefaultValue.class.getName())) {
- flag = F_DEFAULT_VALUE_VALUE;
- } else if (annotationName.equals(Consumes.class.getName())) {
- flag = F_CONSUMED_MEDIATYPES_VALUE;
- } else if (annotationName.equals(Produces.class.getName())) {
- flag = F_PRODUCED_MEDIATYPES_VALUE;
- } else {
- for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
- flag = F_HTTP_METHOD_VALUE;
- break;
- }
- }
- }
-
- if (currentKind != previousKind) {
- flag += F_ELEMENT_KIND;
- }
- return flag;
- }
-
- public int removeAnnotation(Annotation annotation) {
- return removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
- }
-
- public int removeAnnotation(final String handleIdentifier) {
- int flag = F_NONE;
- for (Iterator<Entry<String, Annotation>> iterator = annotations.entrySet().iterator(); iterator.hasNext();) {
- Entry<String, Annotation> entry = iterator.next();
- Annotation annotation = entry.getValue();
- if (annotation.getJavaAnnotation().getHandleIdentifier().equals(handleIdentifier)) {
- this.metamodel.unindexElement(this, handleIdentifier);
- final EnumKind previousKind = getKind();
- final String annotationName = entry.getKey();
- iterator.remove();
- if (annotationName.equals(Path.class.getName())) {
- flag = F_PATH_VALUE;
- }else if (annotationName.equals(ApplicationPath.class.getName())) {
- flag = F_APPLICATION_PATH_VALUE;
- } else if (annotationName.equals(HttpMethod.class.getName())) {
- flag = F_HTTP_METHOD_VALUE;
- } else if (annotationName.equals(PathParam.class.getName())) {
- flag = F_PATH_PARAM_VALUE;
- } else if (annotationName.equals(QueryParam.class.getName())) {
- flag = F_QUERY_PARAM_VALUE;
- } else if (annotationName.equals(MatrixParam.class.getName())) {
- flag = F_MATRIX_PARAM_VALUE;
- } else if (annotationName.equals(Consumes.class.getName())) {
- flag = F_CONSUMED_MEDIATYPES_VALUE;
- } else if (annotationName.equals(Produces.class.getName())) {
- flag = F_PRODUCED_MEDIATYPES_VALUE;
- } else {
- for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
- if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
- flag = F_HTTP_METHOD_VALUE;
- break;
- }
- }
- }
- final EnumKind currentKind = getKind();
- if (currentKind != previousKind) {
- flag += F_ELEMENT_KIND;
- }
- break;
- }
- }
- return flag;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((javaElement == null) ? 0 : javaElement.getHandleIdentifier().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 (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- JaxrsElement<?> other = (JaxrsElement<?>) obj;
- if (javaElement == null) {
- if (other.javaElement != null) {
- return false;
- }
- } else if (!javaElement.getHandleIdentifier().equals(other.javaElement.getHandleIdentifier())) {
- return false;
- }
- return true;
- }
-
- public abstract List<ValidatorMessage> validate();
-
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactory.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -31,6 +31,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IAnnotation;
@@ -63,7 +64,7 @@
* @return the created JAX-RS element or null if the given Java annotation is not a valid one.
* @throws CoreException
*/
- public JaxrsElement<?> createElement(IAnnotation javaAnnotation, CompilationUnit ast, JaxrsMetamodel metamodel)
+ public JaxrsJavaElement<?> createElement(IAnnotation javaAnnotation, CompilationUnit ast, JaxrsMetamodel metamodel)
throws CoreException {
Annotation annotation = JdtUtils.resolveAnnotation(javaAnnotation, ast);
final String annotationName = annotation.getName();
@@ -71,7 +72,7 @@
final JaxrsHttpMethod httpMethod = createHttpMethod(annotation, ast, metamodel);
return httpMethod;
} else if (annotationName.equals(ApplicationPath.class.getName())) {
- final JaxrsApplication application = createApplication(annotation, ast, metamodel);
+ final JaxrsJavaApplication application = createApplication(annotation, ast, metamodel);
return application;
} else {
switch (javaAnnotation.getParent().getElementType()) {
@@ -81,7 +82,7 @@
}
break;
case METHOD:
- final IJaxrsHttpMethod httpMethod = metamodel.getHttpMethod(annotationName);
+ final JaxrsHttpMethod httpMethod = (JaxrsHttpMethod) metamodel.getHttpMethod(annotationName);
if (annotationName.equals(Path.class.getName())) {
return createResourceMethod(annotation, ast, metamodel);
} else if (httpMethod != null) {
@@ -293,13 +294,13 @@
* @return
* @throws CoreException
*/
- public JaxrsApplication createApplication(final IType javaType, final CompilationUnit ast,
+ public JaxrsJavaApplication createApplication(final IType javaType, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
Annotation applicationPathAnnotation = JdtUtils.resolveAnnotation(javaType, ast, ApplicationPath.class);
if (applicationPathAnnotation == null) {
return null;
}
- return new JaxrsAnnotatedTypeApplication(javaType, applicationPathAnnotation, metamodel);
+ return new JaxrsJavaApplication(javaType, applicationPathAnnotation, metamodel);
}
/**
@@ -312,11 +313,11 @@
* @return
* @throws CoreException
*/
- public JaxrsApplication createApplication(final Annotation annotation, final CompilationUnit ast,
+ public JaxrsJavaApplication createApplication(final Annotation annotation, final CompilationUnit ast,
final JaxrsMetamodel metamodel) throws CoreException {
if (annotation.getJavaParent() != null && annotation.getJavaParent().getElementType() == IJavaElement.TYPE
&& annotation.getName().equals(ApplicationPath.class.getName())) {
- return new JaxrsAnnotatedTypeApplication((IType) annotation.getJavaParent(), annotation, metamodel);
+ return new JaxrsJavaApplication((IType) annotation.getJavaParent(), annotation, metamodel);
}
return null;
}
@@ -340,7 +341,7 @@
public JaxrsResourceField createField(IField javaField, CompilationUnit ast, JaxrsMetamodel metamodel)
throws JavaModelException {
final IType parentType = (IType) javaField.getParent();
- JaxrsElement<?> parentResource = metamodel.getElement(parentType);
+ JaxrsBaseElement parentResource = metamodel.getElement(parentType);
if (parentResource == null) {
// creating the parent resource but not adding it to the metamodel
// yet..
@@ -370,4 +371,7 @@
return null;
}
+ public JaxrsWebxmlApplication createApplication(String applicationPath, IResource resource, JaxrsMetamodel metamodel) {
+ return new JaxrsWebxmlApplication(applicationPath, resource, metamodel);
+ }
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsEndpoint.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -28,6 +28,7 @@
import org.eclipse.jdt.core.IMethod;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JavaMethodParameter;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResourceMethod;
@@ -38,7 +39,7 @@
private final LinkedList<JaxrsResourceMethod> resourceMethods;
- private JaxrsApplication application = null;
+ private IJaxrsApplication application = null;
private String uriPathTemplate = null;
@@ -46,11 +47,11 @@
private List<String> producedMediaTypes = null;
- public JaxrsEndpoint(final JaxrsApplication application, final JaxrsHttpMethod httpMethod, final JaxrsResourceMethod resourceMethod) {
+ public JaxrsEndpoint(final IJaxrsApplication application, final JaxrsHttpMethod httpMethod, final JaxrsResourceMethod resourceMethod) {
this(application, httpMethod, new LinkedList<JaxrsResourceMethod>(Arrays.asList(resourceMethod)));
}
- public JaxrsEndpoint(final JaxrsApplication application, final JaxrsHttpMethod httpMethod, final LinkedList<JaxrsResourceMethod> resourceMethods) {
+ public JaxrsEndpoint(final IJaxrsApplication application, final JaxrsHttpMethod httpMethod, final LinkedList<JaxrsResourceMethod> resourceMethods) {
this.application = application;
this.httpMethod = httpMethod;
this.resourceMethods = resourceMethods;
@@ -150,7 +151,7 @@
* @return true if the endpoint is still valid, false otherwise (it should
* be removed from the metamodel)
*/
- public boolean refresh(JaxrsApplication application) {
+ public boolean refresh(IJaxrsApplication application) {
this.application = application;
refreshUriPathTemplate();
return true;
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsHttpMethod.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -37,7 +37,7 @@
*
* @author xcoulon
*/
-public class JaxrsHttpMethod extends JaxrsElement<IType> implements IJaxrsHttpMethod {
+public class JaxrsHttpMethod extends JaxrsJavaElement<IType> implements IJaxrsHttpMethod {
/**
* A Simple sorter for HTTP Verbs: the preferred order is
Copied: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java (from rev 37698, trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsAnnotatedTypeApplication.java)
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Xavier Coulon - Initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.ApplicationPath;
+
+import org.eclipse.jdt.core.IType;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
+
+/**
+ * This domain element describes a subtype of {@link jvax.ws.rs.Application} annotated with
+ * {@link jvax.ws.rs.ApplicationPath}.
+ *
+ * @author xcoulon
+ */
+public class JaxrsJavaApplication extends JaxrsJavaElement<IType> implements IJaxrsApplication {
+
+ /**
+ * Full constructor.
+ *
+ * @param javaType
+ * @param applicationPathAnnocation
+ * @param metamodel
+ */
+ public JaxrsJavaApplication(IType javaType, Annotation applicationPathAnnocation, JaxrsMetamodel metamodel) {
+ super(javaType, applicationPathAnnocation, metamodel);
+ }
+
+ @Override
+ public EnumElementKind getElementKind() {
+ return EnumElementKind.APPLICATION;
+ }
+
+ @Override
+ public EnumKind getKind() {
+ if (getAnnotation(ApplicationPath.class.getName()) != null) {
+ return EnumKind.APPLICATION_JAVA;
+ }
+ return EnumKind.UNDEFINED;
+ }
+
+ @Override
+ public List<ValidatorMessage> validate() {
+ List<ValidatorMessage> messages = new ArrayList<ValidatorMessage>();
+ return messages;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getApplicationPath() {
+ final Annotation applicationPathAnnotation = getAnnotation(ApplicationPath.class.getName());
+ if (applicationPathAnnotation != null) {
+ return applicationPathAnnotation.getValue("value");
+ }
+ return null;
+ }
+
+ /**
+ * Update this Application with the elements of the given Application
+ *
+ * @param application
+ * @return the flags indicating the kind of changes that occurred during the
+ * update.
+ */
+ public int update(JaxrsJavaApplication application) {
+ int flags = 0;
+ final Annotation annotation = this.getAnnotation(ApplicationPath.class.getName());
+ final Annotation otherAnnotation = application.getAnnotation(ApplicationPath.class.getName());
+ if (annotation != null && otherAnnotation != null && !annotation.equals(otherAnnotation)
+ && annotation.update(otherAnnotation)) {
+ flags += F_APPLICATION_PATH_VALUE;
+ }
+ return flags;
+ }
+
+ @Override
+ public String toString() {
+ return ("Application '" + getJavaElement().getElementName() + "': " + getApplicationPath());
+ }
+
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaApplication.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (from rev 37698, trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElement.java)
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Xavier Coulon - Initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_CONSUMED_MEDIATYPES_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_DEFAULT_VALUE_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_ELEMENT_KIND;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_HTTP_METHOD_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_MATRIX_PARAM_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_NONE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_PARAM_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PATH_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_PRODUCED_MEDIATYPES_VALUE;
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_QUERY_PARAM_VALUE;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.MatrixParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtils;
+import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
+import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
+
+/**
+ * Base class for all elements in the JAX-RS Metamodel.
+ *
+ * @author xcoulon
+ *
+ * @param <T>
+ * the underlying Java type managed by the JAX-RS ElementKind.
+ */
+public abstract class JaxrsJavaElement<T extends IMember> extends JaxrsBaseElement {
+
+ /** The underlying java element. */
+ private final T javaElement;
+
+ /**
+ * Map of Annotations on the associated Java Element, indexed by the
+ * annotation class name.
+ */
+ private final Map<String, Annotation> annotations = new HashMap<String, Annotation>();
+
+ /**
+ * Full constructor.
+ *
+ * @param model
+ * the associated metamodel
+ * @param element
+ * the underlying java element
+ */
+ public JaxrsJavaElement(final T element, final Annotation annotation, final JaxrsMetamodel metamodel) {
+ this(element, Arrays.asList(annotation), metamodel);
+ }
+
+ /**
+ * Full constructor.
+ *
+ * @param model
+ * the associated metamodel
+ * @param element
+ * the underlying java element
+ **/
+ public JaxrsJavaElement(final T element, final List<Annotation> annotations, final JaxrsMetamodel metamodel) {
+ super(metamodel);
+ this.javaElement = element;
+ if (annotations != null) {
+ for (Annotation annotation : annotations) {
+ this.annotations.put(annotation.getName(), annotation);
+ }
+ }
+ }
+
+ Annotation getAnnotation(String className) {
+ return annotations.get(className);
+ }
+
+ /** @return the underlying java element */
+ public final T getJavaElement() {
+ return javaElement;
+ }
+
+ @Override
+ public String getName() {
+ return javaElement != null ? javaElement.getElementName() : "*unknown java element*";
+ }
+
+ /**
+ * Returns the CompilationUnit (AST3/DOM) of the given java element.
+ *
+ * @param element
+ * the java element
+ * @param progressMonitor
+ * the progress monitor
+ * @return the compilation unit or null
+ * @throws JavaModelException
+ * in case of underlying exception
+ */
+ final CompilationUnit getCompilationUnit(final IProgressMonitor progressMonitor) throws JavaModelException {
+ return JdtUtils.parse(javaElement, progressMonitor);
+ }
+
+ public Map<String, Annotation> getAnnotations() {
+ return annotations;
+ }
+
+ public int addOrUpdateAnnotation(final Annotation annotation) {
+ if (annotation == null) {
+ return 0;
+ }
+ boolean changed = false;
+ final EnumKind previousKind = getKind();
+ final String annotationName = annotation.getName();
+ if (annotations.containsKey(annotation.getName())) {
+ changed = annotations.get(annotation.getName()).update(annotation);
+ } else {
+ annotations.put(annotation.getName(), annotation);
+ changed = true;
+ }
+ if (changed) {
+ getMetamodel().indexElement(this, annotation);
+ return qualifyChange(annotationName, previousKind);
+ }
+ return F_NONE;
+ }
+
+ public int mergeAnnotations(Map<String, Annotation> otherAnnotations) {
+ int flags = 0;
+ // keep values in the 'otherAnnotations' map
+ final Map<String, Annotation> addedAnnotations = CollectionUtils.difference(otherAnnotations, this.annotations);
+ // keep values in the 'this.annotations' map
+ final Map<String, Annotation> removedAnnotations = CollectionUtils.difference(this.annotations,
+ otherAnnotations);
+ // keep values in the 'otherAnnotations' map
+ final Map<String, Annotation> changedAnnotations = CollectionUtils.intersection(otherAnnotations,
+ this.annotations);
+
+ for (Entry<String, Annotation> entry : addedAnnotations.entrySet()) {
+ flags += this.addOrUpdateAnnotation(entry.getValue());
+ }
+ for (Entry<String, Annotation> entry : changedAnnotations.entrySet()) {
+ flags += this.addOrUpdateAnnotation(entry.getValue());
+ }
+ for (Entry<String, Annotation> entry : removedAnnotations.entrySet()) {
+ flags += this.removeAnnotation(entry.getValue());
+ }
+ return flags;
+ }
+
+ private int qualifyChange(final String annotationName, EnumKind previousKind) {
+ int flag = F_NONE;
+ final EnumKind currentKind = getKind();
+ if (annotationName.equals(Path.class.getName())) {
+ flag = F_PATH_VALUE;
+ } else if (annotationName.equals(ApplicationPath.class.getName())) {
+ flag = F_APPLICATION_PATH_VALUE;
+ } else if (annotationName.equals(HttpMethod.class.getName())) {
+ flag = F_HTTP_METHOD_VALUE;
+ } else if (annotationName.equals(PathParam.class.getName())) {
+ flag = F_PATH_PARAM_VALUE;
+ } else if (annotationName.equals(QueryParam.class.getName())) {
+ flag = F_QUERY_PARAM_VALUE;
+ } else if (annotationName.equals(MatrixParam.class.getName())) {
+ flag = F_MATRIX_PARAM_VALUE;
+ } else if (annotationName.equals(DefaultValue.class.getName())) {
+ flag = F_DEFAULT_VALUE_VALUE;
+ } else if (annotationName.equals(Consumes.class.getName())) {
+ flag = F_CONSUMED_MEDIATYPES_VALUE;
+ } else if (annotationName.equals(Produces.class.getName())) {
+ flag = F_PRODUCED_MEDIATYPES_VALUE;
+ } else {
+ for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
+ if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ flag = F_HTTP_METHOD_VALUE;
+ break;
+ }
+ }
+ }
+
+ if (currentKind != previousKind) {
+ flag += F_ELEMENT_KIND;
+ }
+ return flag;
+ }
+
+ public int removeAnnotation(Annotation annotation) {
+ return removeAnnotation(annotation.getJavaAnnotation().getHandleIdentifier());
+ }
+
+ public int removeAnnotation(final String handleIdentifier) {
+ int flag = F_NONE;
+ for (Iterator<Entry<String, Annotation>> iterator = annotations.entrySet().iterator(); iterator.hasNext();) {
+ Entry<String, Annotation> entry = iterator.next();
+ Annotation annotation = entry.getValue();
+ if (annotation.getJavaAnnotation().getHandleIdentifier().equals(handleIdentifier)) {
+ this.metamodel.unindexElement(this, handleIdentifier);
+ final EnumKind previousKind = getKind();
+ final String annotationName = entry.getKey();
+ iterator.remove();
+ if (annotationName.equals(Path.class.getName())) {
+ flag = F_PATH_VALUE;
+ }else if (annotationName.equals(ApplicationPath.class.getName())) {
+ flag = F_APPLICATION_PATH_VALUE;
+ } else if (annotationName.equals(HttpMethod.class.getName())) {
+ flag = F_HTTP_METHOD_VALUE;
+ } else if (annotationName.equals(PathParam.class.getName())) {
+ flag = F_PATH_PARAM_VALUE;
+ } else if (annotationName.equals(QueryParam.class.getName())) {
+ flag = F_QUERY_PARAM_VALUE;
+ } else if (annotationName.equals(MatrixParam.class.getName())) {
+ flag = F_MATRIX_PARAM_VALUE;
+ } else if (annotationName.equals(Consumes.class.getName())) {
+ flag = F_CONSUMED_MEDIATYPES_VALUE;
+ } else if (annotationName.equals(Produces.class.getName())) {
+ flag = F_PRODUCED_MEDIATYPES_VALUE;
+ } else {
+ for (IJaxrsHttpMethod httpMethod : metamodel.getAllHttpMethods()) {
+ if (httpMethod.getJavaElement().getFullyQualifiedName().equals(annotationName)) {
+ flag = F_HTTP_METHOD_VALUE;
+ break;
+ }
+ }
+ }
+ final EnumKind currentKind = getKind();
+ if (currentKind != previousKind) {
+ flag += F_ELEMENT_KIND;
+ }
+ break;
+ }
+ }
+ return flag;
+ }
+
+ public IResource getResource() {
+ return this.javaElement.getResource();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((javaElement == null) ? 0 : javaElement.getHandleIdentifier().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 (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ JaxrsJavaElement<?> other = (JaxrsJavaElement<?>) obj;
+ if (javaElement == null) {
+ if (other.javaElement != null) {
+ return false;
+ }
+ } else if (!javaElement.getHandleIdentifier().equals(other.javaElement.getHandleIdentifier())) {
+ return false;
+ }
+ return true;
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsJavaElement.java
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodel.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -37,6 +38,7 @@
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsMetamodel;
@@ -66,7 +68,7 @@
/**
* All the subclasses of <code>javax.ws.rs.core.Application</code>, although there should be only one.
*/
- private final List<JaxrsApplication> applications = new ArrayList<JaxrsApplication>();
+ private final List<IJaxrsApplication> applications = new ArrayList<IJaxrsApplication>();
/**
* All the resources (both rootresources and subresources) available in the service , indexed by their associated
@@ -84,7 +86,7 @@
private final List<JaxrsHttpMethod> httpMethods = new ArrayList<JaxrsHttpMethod>();
/** Internal index of all the elements of this metamodel. */
- private final Map<String, Set<JaxrsElement<?>>> elementsIndex = new HashMap<String, Set<JaxrsElement<?>>>();
+ private final Map<String, Set<JaxrsBaseElement>> elementsIndex = new HashMap<String, Set<JaxrsBaseElement>>();
/** the endpoints, built from the resource methods. */
private final List<JaxrsEndpoint> endpoints = new ArrayList<JaxrsEndpoint>();
@@ -137,10 +139,10 @@
javaProject.getProject().setSessionProperty(METAMODEL_QUALIFIED_NAME, null);
}
- public void add(JaxrsElement<?> element) {
+ public void add(JaxrsJavaElement<?> element) {
switch (element.getElementKind()) {
case APPLICATION:
- this.applications.add((JaxrsApplication) element);
+ this.applications.add((JaxrsJavaApplication) element);
break;
case HTTP_METHOD:
this.httpMethods.add((JaxrsHttpMethod) element);
@@ -156,8 +158,20 @@
indexElement(element);
}
+ public void add(JaxrsWebxmlApplication application) {
+ this.applications.add(application);
+ Collections.sort(this.applications, new Comparator<IJaxrsApplication>() {
+ @Override
+ public int compare(IJaxrsApplication app1, IJaxrsApplication app2) {
+ return app1.getKind().compareTo(app2.getKind());
+ }
+ });
+ indexElement(application, javaProject);
+ }
+
/** @param jaxrsElement */
- protected void indexElement(final JaxrsElement<?> jaxrsElement) {
+ protected void indexElement(final JaxrsJavaElement<?> jaxrsElement) {
+ Logger.trace("Indexing {}", jaxrsElement);
final IJavaElement javaElement = jaxrsElement.getJavaElement();
// first, unindex element to clear previous state
unindexElement(jaxrsElement);
@@ -184,7 +198,7 @@
}
- protected void indexElement(final JaxrsElement<?> element, final Annotation annotation) {
+ protected void indexElement(final JaxrsJavaElement<?> element, final Annotation annotation) {
if (annotation != null) {
indexElement(element, annotation.getJavaAnnotation());
}
@@ -194,21 +208,20 @@
* @param jaxrsElement
* @param javaElement
*/
- @SuppressWarnings("unchecked")
- private void indexElement(final JaxrsElement<?> jaxrsElement, final IJavaElement javaElement) {
+ private void indexElement(final JaxrsBaseElement jaxrsElement, final IJavaElement javaElement) {
if (javaElement == null) {
return;
}
final String key = javaElement.getHandleIdentifier();
if (!elementsIndex.containsKey(key)) {
- elementsIndex.put(key, new HashSet<JaxrsElement<?>>(Arrays.asList(jaxrsElement)));
+ elementsIndex.put(key, new HashSet<JaxrsBaseElement>(Arrays.asList(jaxrsElement)));
} else {
elementsIndex.get(key).add(jaxrsElement);
}
}
/** @param jaxrsElement */
- protected void unindexElement(final JaxrsElement<?> jaxrsElement) {
+ protected void unindexElement(final JaxrsBaseElement jaxrsElement) {
// if the given element is a JAX-RS Resource, also unindex its children
// ResourceMethod
if (jaxrsElement.getElementKind() == EnumElementKind.RESOURCE) {
@@ -221,16 +234,17 @@
}
}
// unindex the given element, whatever its kind
- for (Iterator<Entry<String, Set<JaxrsElement<?>>>> iterator = elementsIndex.entrySet().iterator(); iterator
+ for (Iterator<Entry<String, Set<JaxrsBaseElement>>> iterator = elementsIndex.entrySet().iterator(); iterator
.hasNext();) {
- final Entry<String, Set<JaxrsElement<?>>> entry = iterator.next();
- final Set<JaxrsElement<?>> elements = entry.getValue();
+ final Entry<String, Set<JaxrsBaseElement>> entry = iterator.next();
+ final Set<JaxrsBaseElement> elements = entry.getValue();
// because the elements.remove(jaxrsElement); does not work here
// (hashcode has changed between the time the jaxrsElement was added
// and now !)
- for (Iterator<JaxrsElement<?>> elementIterator = elements.iterator(); elementIterator.hasNext();) {
- JaxrsElement<?> element = elementIterator.next();
+ for (Iterator<JaxrsBaseElement> elementIterator = elements.iterator(); elementIterator.hasNext();) {
+ JaxrsBaseElement element = elementIterator.next();
if (element.equals(jaxrsElement)) {
+ Logger.trace(" Removing {} from index", element);
elementIterator.remove();
}
}
@@ -248,8 +262,8 @@
* @param jaxrsElement
* @param handleIdentifier
*/
- protected void unindexElement(final JaxrsElement<?> jaxrsElement, final String handleIdentifier) {
- Set<JaxrsElement<?>> jaxrsElements = elementsIndex.get(handleIdentifier);
+ protected void unindexElement(final JaxrsBaseElement jaxrsElement, final String handleIdentifier) {
+ Set<JaxrsBaseElement> jaxrsElements = elementsIndex.get(handleIdentifier);
if (jaxrsElements != null) {
jaxrsElements.remove(jaxrsElement);
}
@@ -260,15 +274,15 @@
* specified in the code. An invalid application may be returned, though (ie, a Type annotated with
* {@link javax.ws.rs.ApplicationPath} but not extending the {@link javax.ws.rs.Application} type).
*/
- public final JaxrsApplication getApplication() {
+ public final IJaxrsApplication getApplication() {
if (applications.isEmpty()) {
return null;
}
return applications.get(0);
}
- public final List<JaxrsApplication> getAllApplications() {
- return Collections.unmodifiableList(new ArrayList<JaxrsApplication>(applications));
+ public final List<IJaxrsApplication> getAllApplications() {
+ return Collections.unmodifiableList(new ArrayList<IJaxrsApplication>(applications));
}
public final List<IJaxrsProvider> getAllProviders() {
@@ -311,7 +325,7 @@
* @throws JavaModelException
* in case of underlying exception
*/
- public final JaxrsElement<?> find(final IJavaElement element) throws JavaModelException {
+ public final JaxrsJavaElement<?> find(final IJavaElement element) throws JavaModelException {
switch (element.getElementType()) {
case IJavaElement.TYPE:
// return findElement((IType) element);
@@ -342,7 +356,7 @@
continue;
}
Logger.debug("Error found: " + marker.getAttribute(IMarker.MESSAGE, ""));
- JaxrsElement<?> element = (JaxrsElement<?>) find(compilationUnit.getElementAt(marker.getAttribute(
+ JaxrsJavaElement<?> element = (JaxrsJavaElement<?>) find(compilationUnit.getElementAt(marker.getAttribute(
IMarker.CHAR_START, 0)));
if (element != null) {
element.hasErrors(true);
@@ -378,7 +392,7 @@
public IJaxrsHttpMethod getHttpMethod(final String annotationName) throws CoreException {
IType annotationType = JdtUtils.resolveType(annotationName, javaProject, new NullProgressMonitor());
if (annotationType != null) {
- final JaxrsElement<?> element = getElement(annotationType);
+ final JaxrsBaseElement element = getElement(annotationType);
if (element != null && element.getElementKind() == EnumElementKind.HTTP_METHOD) {
return (IJaxrsHttpMethod) element;
}
@@ -392,54 +406,53 @@
* @param element
* @return
*/
- public boolean containsElement(JaxrsElement<?> element) {
+ public boolean containsElement(JaxrsJavaElement<?> element) {
return (getElement(element.getJavaElement()) != null);
}
- public JaxrsElement<?> getElement(IJavaElement element) {
+ public JaxrsBaseElement getElement(IJavaElement element) {
if (element == null) {
return null;
}
final String handleIdentifier = element.getHandleIdentifier();
- final Set<JaxrsElement<?>> elements = elementsIndex.get(handleIdentifier);
+ final Set<JaxrsBaseElement> elements = elementsIndex.get(handleIdentifier);
if (elements == null || elements.isEmpty()) {
return null;
}
return elements.iterator().next();
}
- public JaxrsElement<?> getElement(Annotation annotation) {
+ public JaxrsBaseElement getElement(Annotation annotation) {
return getElement(annotation.getJavaAnnotation());
}
@Override
@SuppressWarnings("unchecked")
public <T> T getElement(IJavaElement element, Class<T> clazz) {
- final JaxrsElement<?> jaxrsElement = getElement(element);
+ final JaxrsBaseElement jaxrsElement = getElement(element);
if (jaxrsElement != null && clazz.isAssignableFrom(jaxrsElement.getClass())) {
return (T) jaxrsElement;
}
return null;
}
- public List<JaxrsElement<?>> getElements(final IJavaElement javaElement) {
+ public List<JaxrsBaseElement> getElements(final IJavaElement javaElement) {
final String key = javaElement.getHandleIdentifier();
- final List<JaxrsElement<?>> elements = new ArrayList<JaxrsElement<?>>();
+ final List<JaxrsBaseElement> result = new ArrayList<JaxrsBaseElement>();
if (elementsIndex.containsKey(key)) {
- for (JaxrsElement<?> element : elementsIndex.get(key)) {
- elements.add(element);
- }
+ final Set<JaxrsBaseElement> indexedElements = elementsIndex.get(key);
+ result.addAll(indexedElements);
}
- return elements;
+ return result;
}
@SuppressWarnings("unchecked")
- public <T extends JaxrsElement<?>> List<T> getElements(final IJavaElement javaElement,
- Class<? extends JaxrsElement<?>> T) {
+ public <T extends JaxrsBaseElement> List<T> getElements(final IJavaElement javaElement,
+ Class<? extends JaxrsBaseElement> T) {
final String key = javaElement.getHandleIdentifier();
final List<T> elements = new ArrayList<T>();
if (elementsIndex.containsKey(key)) {
- for (JaxrsElement<?> element : elementsIndex.get(key)) {
+ for (JaxrsBaseElement element : elementsIndex.get(key)) {
if (element.getClass().isAssignableFrom(T) || T.isAssignableFrom(element.getClass())) {
elements.add((T) element);
}
@@ -448,13 +461,24 @@
return elements;
}
+ public void remove(JaxrsBaseElement element) {
+ switch (element.getKind()) {
+ case APPLICATION_WEBXML:
+ remove((JaxrsWebxmlApplication) element);
+ break;
+ default:
+ remove((JaxrsJavaElement<?>)element);
+ break;
+ }
+ }
+
/**
- * Remove the given JAX-RS Resource from the metamodel.
+ * Remove the given JAX-RS Element from the metamodel.
*
* @param resource
* @return true if the resource was actually removed, false otherwise.
*/
- public void remove(JaxrsElement<?> element) {
+ public void remove(JaxrsJavaElement<?> element) {
if (element == null) {
return;
}
@@ -480,6 +504,11 @@
unindexElement(element);
}
+ public void remove(JaxrsWebxmlApplication application) {
+ this.applications.remove(application);
+ unindexElement(application);
+ }
+
public JaxrsHttpMethod getHttpMethod(Annotation httpMethodAnnotation) {
if (httpMethodAnnotation != null) {
for (IJaxrsHttpMethod httpMethod : httpMethods) {
@@ -550,10 +579,11 @@
@Override
public IProject getProject() {
- if(javaProject == null) {
+ if (javaProject == null) {
return null;
}
return javaProject.getProject();
}
+
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsParamBeanProperty.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsParamBeanProperty.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsParamBeanProperty.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -24,7 +24,7 @@
* @author xcoulon
*
*/
-public class JaxrsParamBeanProperty extends JaxrsElement<IMethod> implements IJaxrsParamBeanProperty {
+public class JaxrsParamBeanProperty extends JaxrsJavaElement<IMethod> implements IJaxrsParamBeanProperty {
public JaxrsParamBeanProperty(IMethod element, Annotation annotation, JaxrsMetamodel metamodel) {
super(element, annotation, metamodel);
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsProvider.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsProvider.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -30,7 +30,7 @@
*
* @author xcoulon
*/
-public class JaxrsProvider extends JaxrsElement<IType> implements IJaxrsProvider {
+public class JaxrsProvider extends JaxrsJavaElement<IType> implements IJaxrsProvider {
/**
* Internal 'Provider' element builder.
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResource.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -39,10 +39,10 @@
*
* @author xcoulon
*/
-public class JaxrsResource extends JaxrsElement<IType> implements IJaxrsResource {
+public class JaxrsResource extends JaxrsJavaElement<IType> implements IJaxrsResource {
/** Optional Application. */
- private final JaxrsAnnotatedTypeApplication application = null;
+ private final JaxrsJavaApplication application = null;
private final Map<String, JaxrsResourceField> resourceFields = new HashMap<String, JaxrsResourceField>();
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceElement.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsResourceElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -19,7 +19,7 @@
* @author Xavier Coulon
*
*/
-public abstract class JaxrsResourceElement<T extends IMember> extends JaxrsElement<T> {
+public abstract class JaxrsResourceElement<T extends IMember> extends JaxrsJavaElement<T> {
private final JaxrsResource parentResource;
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsWebxmlApplication.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsWebxmlApplication.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsWebxmlApplication.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,118 @@
+package org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain;
+
+import static org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsElementDelta.F_APPLICATION_PATH_VALUE;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.wst.validation.ValidatorMessage;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
+
+public class JaxrsWebxmlApplication extends JaxrsBaseElement implements IJaxrsApplication {
+
+ private String applicationPath;
+
+ private final IResource webxmlResource;
+
+ /**
+ * Full constructor.
+ *
+ * @param metamodel
+ */
+ public JaxrsWebxmlApplication(String applicationPath, IResource webxmlResource, JaxrsMetamodel metamodel) {
+ super(metamodel);
+ this.applicationPath = formatApplicationPath(applicationPath);
+ this.webxmlResource = webxmlResource;
+ }
+
+ @Override
+ public String getApplicationPath() {
+ return applicationPath;
+ }
+
+ public int update(JaxrsWebxmlApplication eventApplication) {
+ if (eventApplication != null) {
+ String eventApplicationPath = formatApplicationPath(eventApplication.getApplicationPath());
+ if ((eventApplicationPath.equals(this.applicationPath))) {
+ this.applicationPath = eventApplicationPath;
+ return F_APPLICATION_PATH_VALUE;
+ }
+ }
+ return 0;
+ }
+
+ private String formatApplicationPath(final String eventApplicationPath) {
+ String path = eventApplicationPath.replace("/*", "/");
+ if (path.length() > 1 && path.endsWith("/")) {
+ path = path.substring(0, path.length() - 1);
+ }
+ return path;
+ }
+
+ @Override
+ public EnumElementKind getElementKind() {
+ return EnumElementKind.APPLICATION;
+ }
+
+ @Override
+ public EnumKind getKind() {
+ return EnumKind.APPLICATION_WEBXML;
+ }
+
+ @Override
+ public IResource getResource() {
+ return webxmlResource;
+ }
+
+ @Override
+ public String getName() {
+ return webxmlResource != null ? webxmlResource.getName() : "*unknown resource*";
+ }
+
+ @Override
+ public List<ValidatorMessage> validate() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((webxmlResource == null) ? 0 : webxmlResource.getFullPath().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 (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ JaxrsWebxmlApplication other = (JaxrsWebxmlApplication) obj;
+ if (webxmlResource == null && other.webxmlResource != null) {
+ return false;
+ } else if (webxmlResource != null && other.webxmlResource == null) {
+ return false;
+ } else if (webxmlResource != null && other.webxmlResource != null && !webxmlResource.getFullPath().equals(other.webxmlResource.getFullPath())) {
+ return false;
+ }
+ return true;
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsWebxmlApplication.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidator.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -23,7 +23,7 @@
import org.eclipse.wst.validation.ValidationState;
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilder;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils;
import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger;
@@ -52,7 +52,7 @@
if (jaxrsMetamodel == null) {
return validationResult;
}
- JaxrsElement<?> element = jaxrsMetamodel.getElement(JdtUtils.getCompilationUnit(resource));
+ JaxrsBaseElement element = jaxrsMetamodel.getElement(JdtUtils.getCompilationUnit(resource));
if (element != null) {
Logger.debug("Validating the JAX-RS Metamodel after {} was {}", resource.getName(),
ConstantUtils.getStaticFieldName(IResourceDelta.class, kind));
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtils.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtils.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,155 @@
+package org.jboss.tools.ws.jaxrs.core.internal.utils;
+
+import java.io.FileInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public class WtpUtils {
+
+ public static IFolder getWebInfFolder(IProject project) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component == null) {
+ return null;
+ }
+ IVirtualFolder contentFolder = component.getRootFolder();
+ final IFolder underlyingFolder = (IFolder) contentFolder.getFolder(WebArtifactEdit.WEB_INF)
+ .getUnderlyingFolder();
+ return underlyingFolder;
+ }
+
+ /**
+ * Attempts to find the applicationPath configured in the application's web deployment description. The
+ * applicationPath is expected to be configured as below: <code>
+ * <servlet-mapping>
+ * <servlet-name>com.acme.MyApplication</servlet-name>
+ * <url-pattern>/hello/*</url-pattern>
+ * </servlet-mapping>
+ * </code> where
+ * <code>com.acme.MyApplication</code> is a subtype of <code>javax.ws.rs.Application</code> and is the given
+ * 'applicationType' parameter of this method. If the webapp does not provide its own subtype of
+ * <code>javax.ws.rs.Application</code>, then the applicationType parameter can be
+ * <code>javax.ws.rs.Application</code> itself.
+ *
+ * @param javaProject
+ * the current java project
+ * @param applicationTypeName
+ * the name of the type/subtype to match in the servlet-mapping
+ * @return the applicationPath or null if it is not configured.
+ * @throws CoreException
+ */
+ public static String getApplicationPath(IProject project, String applicationTypeName) throws CoreException {
+ IFolder webInfFolder = getWebInfFolder(project);
+ if(webInfFolder == null) {
+ return null;
+ }
+ IResource webxmlResource = webInfFolder.findMember("web.xml");
+ if (webxmlResource == null || !webxmlResource.exists()) {
+ Logger.debug("No deployment descriptor found in project '{}'", project.getName());
+ return null;
+ }
+ /*if (webxmlResource.isSynchronized(IResource.DEPTH_INFINITE)) {
+ Logger.debug("Resource is not in sync'");
+ webxmlResource.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
+ }*/
+ // cannot use the WebTools WebArtifact Edit APIs because the web.xml configuration does not require a servlet,
+ // but just a servlet-mapping element.
+ /*
+ * WebArtifactEdit webArtifactEdit = WebArtifactEdit.getWebArtifactEditForRead(javaProject.getProject()); //
+ * webArtifactEdit.getDeploymentDescriptorRoot().eResource().unload(); if (!webArtifactEdit.isValid()) { return
+ * null; } webArtifactEdit.getDeploymentDescriptorRoot(); WebApp webApp = webArtifactEdit.getWebApp();
+ * EList<ServletMapping> servletMappings = webApp.getServletMappings(); for (ServletMapping servletMapping :
+ * servletMappings) { if (servletMapping.getName().equals(applicationTypeName)) { return
+ * servletMapping.getUrlPattern(); } }
+ */
+ // using a good old xpath expression to scan the file.
+ try {
+ DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
+ domFactory.setNamespaceAware(false); // never forget this!
+ domFactory.setValidating(false);
+ DocumentBuilder builder = domFactory.newDocumentBuilder();
+ final FileInputStream fileInputStream = new FileInputStream(webxmlResource.getLocation().toFile());
+ InputSource inputSource = new InputSource(fileInputStream);
+ Document doc = builder.parse(inputSource);
+
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ String expression = "//servlet-mapping[servlet-name=\"" + applicationTypeName + "\"]/url-pattern/text()";
+
+ XPathExpression expr = xpath.compile(expression);
+ Node urlPattern = (Node) expr.evaluate(doc, XPathConstants.NODE);
+ if (urlPattern != null) {
+ Logger.debug("Found matching url-pattern: {}", urlPattern);
+ return urlPattern.getTextContent();
+ }
+ } catch (Exception e) {
+ Logger.error("Unable to parse file '" + webxmlResource.getProjectRelativePath().toOSString()
+ + "' to find <servlet-mapping> elements", e);
+ }
+
+ Logger.debug("No servlet mapping found for {} in {}", applicationTypeName,
+ webxmlResource.getProjectRelativePath());
+ return null;
+ }
+
+ /**
+ * Indicates if the given resource is the web deployment descriptor (or not).
+ *
+ * @param resource
+ * @return
+ */
+ public static boolean isWebDeploymentDescriptor(IResource resource) {
+ final IFolder webinfFolder = getWebInfFolder(resource.getProject());
+ if(webinfFolder == null) {
+ return false;
+ }
+ final IFile file = webinfFolder.getFile("web.xml");
+ if (file == null) {
+ return false;
+ }
+ return resource.getFullPath().equals(file.getFullPath());
+ }
+
+ /**
+ * Returns true if the given project has a web deployment descriptor, false otherwise.
+ *
+ * @param project
+ * @return
+ */
+ public static boolean hasWebDeploymentDescriptor(IProject project) {
+ final IFolder webinfFolder = getWebInfFolder(project);
+ if(webinfFolder == null) {
+ return false;
+ }
+ final IFile file = webinfFolder.getFile("web.xml");
+ return (file != null && file.exists());
+ }
+
+ public static IResource getWebDeploymentDescriptor(IProject project) {
+ final IFolder webinfFolder = getWebInfFolder(project);
+ final IFile file = webinfFolder.getFile("web.xml");
+ if(file != null && file.exists()) {
+ return project.findMember(file.getProjectRelativePath());
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/EnumKind.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/EnumKind.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/EnumKind.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -20,8 +20,11 @@
* UNDEFINED KIND (when no annotation nor any other java element can define precisely what the element is.
*/
UNDEFINED,
- /** An application */
- APPLICATION,
+ /** A JAX-RS Application declared in the web deployment descriptor.*/
+ // must be declared *before* APPLICATION_JAVA constant to enable comparison !
+ APPLICATION_WEBXML,
+ /** A java annotated type based JAX-RS Application */
+ APPLICATION_JAVA,
/** An HTTP method. */
HTTP_METHOD,
/** A message producer. */
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsApplication.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsApplication.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsApplication.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.metamodel;
-public interface IJaxrsApplication {
+public interface IJaxrsApplication extends IJaxrsElement {
+ public abstract String getApplicationPath();
+
+ public abstract EnumKind getKind();
+
}
Added: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,7 @@
+package org.jboss.tools.ws.jaxrs.core.metamodel;
+
+public interface IJaxrsElement {
+
+ IJaxrsMetamodel getMetamodel();
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsElement.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsHttpMethod.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -13,7 +13,7 @@
import org.eclipse.jdt.core.IType;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
-public interface IJaxrsHttpMethod extends Comparable<IJaxrsHttpMethod> {
+public interface IJaxrsHttpMethod extends IJaxrsElement, Comparable<IJaxrsHttpMethod> {
/** @return the httpVerb */
String getHttpVerb();
Modified: trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsProvider.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/metamodel/IJaxrsProvider.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -10,6 +10,6 @@
******************************************************************************/
package org.jboss.tools.ws.jaxrs.core.metamodel;
-public interface IJaxrsProvider {
+public interface IJaxrsProvider extends IJaxrsElement{
}
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/webapp/WEB-INF/web.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/hello/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/projects/org.jboss.tools.ws.jaxrs.tests.sampleproject/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-with-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-with-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-with-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<!-- A sample web.xml file validated by the web-app DTD in version 2.3 -->
+<web-app>
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/hello/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-with-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-without-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-without-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-without-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<!-- A sample web.xml file validated by the web-app DTD in version 2.3 -->
+<web-app>
+</web-app>
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_3-without-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-with-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-with-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-with-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/hello/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-with-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-without-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-without-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-without-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+</web-app>
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_4-without-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-with-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-with-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-with-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/hello/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-with-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-without-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-without-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-without-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+</web-app>
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-2_5-without-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-with-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-with-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-with-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <servlet-mapping>
+ <servlet-name>javax.ws.rs.core.Application</servlet-name>
+ <url-pattern>/hello/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-with-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-without-servlet-mapping.xml
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-without-servlet-mapping.xml (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-without-servlet-mapping.xml 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+</web-app>
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/resources/web-3_0-without-servlet-mapping.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AllTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AllTests.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/AllTests.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -12,17 +12,18 @@
import org.jboss.tools.ws.jaxrs.core.internal.configuration.ProjectBuilderUtilsTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.configuration.ProjectNatureUtilsTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JavaElementChangedProcessorTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JavaElementDeltaFilterTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JavaElementDeltaScannerTestCase;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JavaElementDeltaFilterTestCase;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JavaElementChangedProcessorTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilderTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelChangedProcessorTestCase;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.JaxrsMetamodelBuilderTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.ResourceChangedListenerTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.ResourceChangedProcessorTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElementFactoryTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodelTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.validation.JaxrsMetamodelValidatorTestCase;
import org.jboss.tools.ws.jaxrs.core.internal.utils.CollectionUtilsTestCase;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.WtpUtilsTestCase;
import org.jboss.tools.ws.jaxrs.core.jdt.CompilationUnitsRepositoryTestCase;
import org.jboss.tools.ws.jaxrs.core.jdt.JaxrsAnnotationScannerTestCase;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtilsTestCase;
@@ -39,7 +40,7 @@
JaxrsElementFactoryTestCase.class, JaxrsMetamodelBuilderTestCase.class, CollectionUtilsTestCase.class,
PubSubServiceTestCase.class, JaxrsMetamodelValidatorTestCase.class,
ResourceChangedProcessorTestCase.class, ResourceChangedListenerTestCase.class,
- JaxrsAnnotationScannerTestCase.class})
+ JaxrsAnnotationScannerTestCase.class, WtpUtilsTestCase.class})
public class AllTests {
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/WorkbenchUtils.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -11,6 +11,8 @@
package org.jboss.tools.ws.jaxrs.core;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
@@ -18,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
@@ -29,6 +32,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -65,6 +69,7 @@
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
+import org.jboss.tools.ws.jaxrs.core.internal.utils.WtpUtils;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.junit.Assert;
@@ -113,8 +118,10 @@
}
- /** @return
- * @throws JavaModelException */
+ /**
+ * @return
+ * @throws JavaModelException
+ */
public static IPackageFragment createPackage(IJavaProject javaProject, String pkgName) throws JavaModelException {
IFolder folder = javaProject.getProject().getFolder("src/main/java");
IPackageFragmentRoot packageFragmentRoot = javaProject.getPackageFragmentRoot(folder);
@@ -178,19 +185,19 @@
return null;
}
- /** Create a compilation unit from the given filename content, in the given
- * package, with the given name
+ /**
+ * Create a compilation unit from the given filename content, in the given package, with the given name
*
* @param fileName
- * the filename containing the source code, in the /resources
- * folder of the test bundle, or null if the created compilation
- * unit must remain empty after its creation
+ * the filename containing the source code, in the /resources folder of the test bundle, or null if the
+ * created compilation unit must remain empty after its creation
* @param pkg
* the target package
* @param unitName
* the target compilation unit name
* @return the created compilation unit
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static ICompilationUnit createCompilationUnit(IJavaProject javaProject, String fileName, String pkg,
String unitName, Bundle bundle) throws JavaModelException {
String contents = "";
@@ -237,11 +244,13 @@
Assert.assertEquals("Content was not inserted", content, subSource);
}
- /** Removes the first occurrence of the given content (not a regexp)
+ /**
+ * Removes the first occurrence of the given content (not a regexp)
*
* @param type
* @param content
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static void removeFirstOccurrenceOfCode(IType type, String content, boolean useWorkingCopy)
throws JavaModelException {
replaceFirstOccurrenceOfCode(type, content, "", useWorkingCopy);
@@ -257,10 +266,12 @@
saveAndClose(unit);
}
- /** @param compilationUnit
+ /**
+ * @param compilationUnit
* @param useWorkingCopy
* @return
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static ICompilationUnit getCompilationUnit(ICompilationUnit compilationUnit, boolean useWorkingCopy)
throws JavaModelException {
return useWorkingCopy ? createWorkingCopy(compilationUnit) : compilationUnit;
@@ -420,9 +431,11 @@
}
- /** @param type
+ /**
+ * @param type
* @return
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static IMethod getMethod(IType type, String name) throws JavaModelException {
for (IMethod method : type.getMethods()) {
if (method.getElementName().equals(name)) {
@@ -554,9 +567,11 @@
return (IMethod) method.getCompilationUnit().getElementAt(sourceRange.getOffset());
}
- /** @param compilationUnit
+ /**
+ * @param compilationUnit
* @return
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static ICompilationUnit createWorkingCopy(ICompilationUnit compilationUnit) throws JavaModelException {
LOGGER.debug("Creating working copy...");
// ICompilationUnit workingCopy = compilationUnit.getWorkingCopy(new
@@ -565,10 +580,7 @@
/*
* (non-Javadoc)
- *
- * @see
- * org.eclipse.jdt.core.WorkingCopyOwner#getProblemRequestor(org
- * .eclipse.jdt.core.ICompilationUnit)
+ * @see org.eclipse.jdt.core.WorkingCopyOwner#getProblemRequestor(org .eclipse.jdt.core.ICompilationUnit)
*/
@Override
public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) {
@@ -595,7 +607,8 @@
@Override
public void acceptProblem(IProblem problem) {
- //LOGGER.debug("Reporting problem: {} on {}", problem, new String(problem.getOriginatingFileName()));
+ // LOGGER.debug("Reporting problem: {} on {}", problem, new
+ // String(problem.getOriginatingFileName()));
}
};
@@ -608,8 +621,10 @@
return workingCopy;
}
- /** @param unit
- * @throws JavaModelException */
+ /**
+ * @param unit
+ * @throws JavaModelException
+ */
public static void saveAndClose(ICompilationUnit unit) throws JavaModelException {
try {
if (unit.isWorkingCopy()) {
@@ -637,12 +652,10 @@
public static void move(ICompilationUnit compilationUnit, String targetPackageName, Bundle bundle)
throws CoreException {
/*
- * ICompilationUnit destContainer =
- * createCompilationUnit(compilationUnit.getJavaProject(), null,
- * targetPackageName, compilationUnit.getElementName(), bundle);
- * MoveElementsOperation operation = new MoveElementsOperation( new
- * IJavaElement[] { compilationUnit }, new IJavaElement[] {
- * destContainer }, true); operation.run(new NullProgressMonitor());
+ * ICompilationUnit destContainer = createCompilationUnit(compilationUnit.getJavaProject(), null,
+ * targetPackageName, compilationUnit.getElementName(), bundle); MoveElementsOperation operation = new
+ * MoveElementsOperation( new IJavaElement[] { compilationUnit }, new IJavaElement[] { destContainer }, true);
+ * operation.run(new NullProgressMonitor());
*/
IPackageFragment packageFragment = WorkbenchUtils.createPackage(compilationUnit.getJavaProject(),
"org.jboss.tools.ws.jaxrs.sample");
@@ -662,18 +675,15 @@
ICompilationUnit unit = getCompilationUnit(parent.getCompilationUnit(), useWorkingCopy);
IBuffer buffer = ((IOpenable) unit).getBuffer();
final ISourceRange sourceRange = annotation.getSourceRange();
- buffer.replace(sourceRange.getOffset(), sourceRange.getLength(), "");
+ buffer.replace(sourceRange.getOffset(), sourceRange.getLength(), "");
saveAndClose(unit);
}
+
/*
- * public static CompilationUnitEditor getCompilationUnitEditor(IFile file)
- * throws PartInitException { IEditorPart editorPart = null;
- * PlatformUI.isWorkbenchRunning(); PlatformUI.getWorkbench().isStarting();
- * IWorkbenchPage page =
- * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- * editorPart = page.openEditor(new FileEditorInput(file),
- * IDE.getEditorDescriptor(file).getId()); return (CompilationUnitEditor)
- * editorPart; }
+ * public static CompilationUnitEditor getCompilationUnitEditor(IFile file) throws PartInitException { IEditorPart
+ * editorPart = null; PlatformUI.isWorkbenchRunning(); PlatformUI.getWorkbench().isStarting(); IWorkbenchPage page =
+ * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); editorPart = page.openEditor(new
+ * FileEditorInput(file), IDE.getEditorDescriptor(file).getId()); return (CompilationUnitEditor) editorPart; }
*/
public static void delete(IMember element) throws JavaModelException {
@@ -715,14 +725,16 @@
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), progressMonitor);
}
- /** Iterates through the project's package fragment roots and returns the one
- * (source or binary) which project relative path matches the given path.
+ /**
+ * Iterates through the project's package fragment roots and returns the one (source or binary) which project
+ * relative path matches the given path.
*
* @param project
* @param path
* @param progressMonitor
* @return
- * @throws JavaModelException */
+ * @throws JavaModelException
+ */
public static IPackageFragmentRoot getPackageFragmentRoot(IJavaProject project, String path,
IProgressMonitor progressMonitor) throws JavaModelException {
for (IPackageFragmentRoot packageFragmentRoot : project.getAllPackageFragmentRoots()) {
@@ -736,12 +748,14 @@
return null;
}
- /** @param monitor
+ /**
+ * @param monitor
* @param description
* @param projectName
* @param workspace
* @param project
- * @throws InvocationTargetException */
+ * @throws InvocationTargetException
+ */
static void createProject(IProgressMonitor monitor, IProjectDescription description, String projectName,
IWorkspace workspace, IProject project) throws InvocationTargetException {
// import from file system
@@ -769,15 +783,16 @@
}
}
- /** Remove the first referenced library those absolute path contains the
- * given name.
+ /**
+ * Remove the first referenced library those absolute path contains the given name.
*
* @param javaProject
* @param name
* @param progressMonitor
* @throws CoreException
* @throws InterruptedException
- * @throws OperationCanceledException */
+ * @throws OperationCanceledException
+ */
public static List<IPackageFragmentRoot> removeClasspathEntry(IJavaProject javaProject, String name,
IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException, InterruptedException {
IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
@@ -825,8 +840,9 @@
return found;
}
- public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass) throws JavaModelException {
- if(annotationClass == null) {
+ public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass)
+ throws JavaModelException {
+ if (annotationClass == null) {
return null;
}
return JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationClass);
@@ -834,9 +850,8 @@
public static Annotation getAnnotation(final IMember member, final Class<?> annotationClass, String... values)
throws JavaModelException {
- Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null),
- annotationClass);
-
+ Annotation annotation = JdtUtils.resolveAnnotation(member, JdtUtils.parse(member, null), annotationClass);
+
Map<String, List<String>> elements = new HashMap<String, List<String>>();
elements.put("value", Arrays.asList(values));
annotation.update(new Annotation(annotation.getJavaAnnotation(), annotation.getName(), elements, null));
@@ -847,5 +862,96 @@
return JdtUtils.resolveType(typeName, javaProject, null);
}
+ /**
+ * Creates a file with the given name and the given content in the given folder.
+ *
+ * @param folder
+ * @param fileName
+ * @param stream
+ * @throws CoreException
+ * @throws IOException
+ */
+ public static IResource createContent(IFolder folder, String fileName, InputStream stream) throws CoreException,
+ IOException {
+ if (!folder.exists()) {
+ folder.create(true, true, new NullProgressMonitor());
+ }
+ folder.getFile(fileName).create(stream, true, null);
+ LOGGER.debug("Content of {}", folder.getFile(fileName).getProjectRelativePath().toPortableString());
+ final InputStream contents = folder.getFile(fileName).getContents();
+ final char[] buffer = new char[0x10000];
+ StringBuilder out = new StringBuilder();
+ Reader in = new InputStreamReader(contents, "UTF-8");
+ int read;
+ do {
+ read = in.read(buffer, 0, buffer.length);
+ if (read > 0) {
+ out.append(buffer, 0, read);
+ }
+ } while (read >= 0);
+ LOGGER.debug(out.toString());
+ return folder.findMember(fileName);
+ }
+ /**
+ * Replaces the content of the given resource with the given stream.
+ *
+ * @param webxmlResource
+ * @param stream
+ * @throws CoreException
+ * @throws IOException
+ */
+ public static void replaceContent(IResource resource, InputStream stream) throws CoreException, IOException {
+ final IProject project = resource.getProject();
+ final IFile file = project.getFile(resource.getProjectRelativePath());
+ if (file.exists()) {
+ file.delete(true, new NullProgressMonitor());
+ }
+ file.create(stream, true, null);
+ LOGGER.debug("Content:");
+ final InputStream contents = file.getContents();
+ final char[] buffer = new char[0x10000];
+ StringBuilder out = new StringBuilder();
+ Reader in = new InputStreamReader(contents, "UTF-8");
+ int read;
+ do {
+ read = in.read(buffer, 0, buffer.length);
+ if (read > 0) {
+ out.append(buffer, 0, read);
+ }
+ } while (read >= 0);
+ LOGGER.debug(out.toString());
+ }
+
+ /**
+ * @return
+ * @throws CoreException
+ * @throws IOException
+ * @throws InterruptedException
+ * @throws OperationCanceledException
+ * @throws InvocationTargetException
+ */
+ public static IResource replaceDeploymentDescriptorWith(IJavaProject javaProject, String webxmlReplacementName,
+ Bundle bundle) throws Exception {
+ IFolder webInfFolder = WtpUtils.getWebInfFolder(javaProject.getProject());
+ IResource webxmlResource = webInfFolder.findMember("web.xml");
+ if (webxmlResource != null && webxmlReplacementName == null) {
+ webxmlResource.delete(true, new NullProgressMonitor());
+ } else if (webxmlResource == null && webxmlReplacementName == null) {
+ // nothing to do: file does not exist and should be removed ;-)
+ return null;
+ }
+ if (webxmlReplacementName == null) {
+ return null;
+ }
+ InputStream stream = FileLocator.openStream(bundle, new Path("resources").append(webxmlReplacementName), false);
+ assertThat(stream, notNullValue());
+ if (webxmlResource != null) {
+ replaceContent(webxmlResource, stream);
+ return webxmlResource;
+ } else {
+ return createContent(webInfFolder, "web.xml", stream);
+ }
+ }
+
}
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementChangedProcessorTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -78,9 +78,8 @@
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
import org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsAnnotatedTypeApplication;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceField;
@@ -228,8 +227,8 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -245,8 +244,8 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -263,8 +262,8 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -273,7 +272,7 @@
// pre-conditions
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, getAnnotation(type, ApplicationPath.class), metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, getAnnotation(type, ApplicationPath.class), metamodel);
metamodel.add(application);
final Annotation annotation = getAnnotation(type, SuppressWarnings.class);
// operation
@@ -281,7 +280,7 @@
final List<JaxrsElementDelta> impacts = processEvent(event, progressMonitor);
// verifications
assertThat(impacts.size(), equalTo(0));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class)); // one call, during pre-conditions
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class)); // one call, during pre-conditions
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -291,7 +290,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class, "/bar");
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(annotation, CHANGED);
@@ -300,7 +299,7 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@@ -310,7 +309,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(annotation, CHANGED);
@@ -326,7 +325,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
final Annotation suppressWarningsAnnotation = getAnnotation(type, SuppressWarnings.class);
// operation
@@ -343,7 +342,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(type.getCompilationUnit(), REMOVED);
@@ -352,7 +351,7 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()), equalTo(application));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()), equalTo(application));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
@@ -362,7 +361,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(type, REMOVED);
@@ -371,7 +370,7 @@
assertThat(impacts.size(), equalTo(1));
assertThat(impacts.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(impacts.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ assertThat(((JaxrsJavaApplication) impacts.get(0).getElement()).getApplicationPath(), equalTo("/app"));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
@@ -381,7 +380,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(annotation, REMOVED);
@@ -400,7 +399,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
// operation
final JavaElementDelta event = createEvent(getAnnotation(type, SuppressWarnings.class), REMOVED);
@@ -416,7 +415,7 @@
final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(type, annotation, metamodel);
metamodel.add(application);
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -430,7 +429,7 @@
assertThat(impacts.get(0).getDeltaKind(), equalTo(REMOVED));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
-
+
@Test
public void shouldAddHttpMethodWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelChangedProcessorTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -44,10 +44,9 @@
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.JaxrsAnnotatedTypeApplication;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
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;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
@@ -78,9 +77,9 @@
metamodel = spy(JaxrsMetamodel.create(javaProject));
}
- private JaxrsApplication createApplication(String typeName) throws CoreException, JavaModelException {
+ private JaxrsJavaApplication createApplication(String typeName) throws CoreException, JavaModelException {
final IType applicationType = getType(typeName, javaProject);
- final JaxrsApplication application = new JaxrsAnnotatedTypeApplication(applicationType,
+ final JaxrsJavaApplication application = new JaxrsJavaApplication(applicationType,
getAnnotation(applicationType, ApplicationPath.class), metamodel);
metamodel.add(application);
return application;
@@ -121,7 +120,7 @@
return httpMethod;
}
- private JaxrsEndpoint createEndpoint(JaxrsApplication application, JaxrsHttpMethod httpMethod, JaxrsResourceMethod... resourceMethods) {
+ private JaxrsEndpoint createEndpoint(JaxrsJavaApplication application, JaxrsHttpMethod httpMethod, JaxrsResourceMethod... resourceMethods) {
JaxrsEndpoint endpoint = new JaxrsEndpoint(application, httpMethod, new LinkedList<JaxrsResourceMethod>(
Arrays.asList(resourceMethods)));
metamodel.add(endpoint);
@@ -320,7 +319,7 @@
final JaxrsEndpoint endpoint = createEndpoint(httpMethod, customerResourceMethod);
assertThat(endpoint.getUriPathTemplate(), equalTo("/customers/{id}"));
// operation
- final JaxrsApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
+ final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
final JaxrsElementDelta event = new JaxrsElementDelta(application, ADDED);
final List<JaxrsEndpointDelta> changes = processEvent(event, progressMonitor);
// verifications
@@ -378,7 +377,7 @@
@Test
public void shoudChangeUriPathTemplateWhenChangingApplicationPathAnnotation() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
+ final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
@@ -499,7 +498,7 @@
@Test
public void shoudChangeUriPathTemplateWhenRemovingMetamodelApplication() throws JavaModelException, CoreException {
// pre-conditions
- final JaxrsApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
+ final JaxrsJavaApplication application = createApplication("org.jboss.tools.ws.jaxrs.sample.services.RestApplication");
final JaxrsHttpMethod httpMethod = createHttpMethod(GET.class);
final JaxrsResource customerResource = createResource("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final JaxrsResourceMethod customerResourceMethod = createResourceMethod("getCustomer", customerResource,
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ResourceChangedProcessorTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -37,6 +37,7 @@
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -49,18 +50,19 @@
import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
import org.jboss.tools.ws.jaxrs.core.JBossJaxrsCorePlugin;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsAnnotatedTypeApplication;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElementFactory;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsJavaApplication;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceField;
import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsWebxmlApplication;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumElementKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
+import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsApplication;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsMetamodel;
import org.jboss.tools.ws.jaxrs.core.metamodel.JaxrsMetamodelDelta;
@@ -90,16 +92,39 @@
javaProject.getProject().setSessionProperty(JaxrsMetamodel.METAMODEL_QUALIFIED_NAME, metamodel);
}
- private JaxrsApplication createApplication(IType type) throws JavaModelException {
+ /**
+ * Creates a java annotated type based JAX-RS Application element
+ * @param type
+ * @return
+ * @throws JavaModelException
+ */
+ private JaxrsJavaApplication createApplication(IType type) throws JavaModelException {
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
- return new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ return new JaxrsJavaApplication(type, annotation, metamodel);
}
- private JaxrsApplication createApplication(IType type, String applicationPath) throws JavaModelException {
+ /**
+ * Creates a java annotated type based JAX-RS Application element
+ * @param type
+ * @param applicationPath
+ * @return
+ * @throws JavaModelException
+ */
+ private JaxrsJavaApplication createApplication(IType type, String applicationPath) throws JavaModelException {
final Annotation annotation = getAnnotation(type, ApplicationPath.class, applicationPath);
- return new JaxrsAnnotatedTypeApplication(type, annotation, metamodel);
+ return new JaxrsJavaApplication(type, annotation, metamodel);
}
+ /**
+ * Creates a web.xml based JAX-RS Application element
+ *
+ * @param applicationPath
+ * @return
+ * @throws JavaModelException
+ */
+ private JaxrsWebxmlApplication createApplication(String applicationPath) throws JavaModelException {
+ return new JaxrsWebxmlApplication(applicationPath, null, metamodel);
+ }
/**
* @return
@@ -136,8 +161,10 @@
return new ResourceDelta(resource, deltaKind, NO_FLAG);
}
- private List<JaxrsElementDelta> processResourceChanges(ResourceDelta event, IProgressMonitor progressmonitor) throws CoreException {
- final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false, Arrays.asList(event), progressmonitor);
+ private List<JaxrsElementDelta> processResourceChanges(ResourceDelta event, IProgressMonitor progressmonitor)
+ throws CoreException {
+ final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false,
+ Arrays.asList(event), progressmonitor);
return affectedMetamodel.getAffectedElements();
}
@@ -145,10 +172,8 @@
* Because sometimes, generics are painful...
*
* @param elements
- * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>...
- * elements) { final List<IJaxrsElement<?>> result = new
- * ArrayList<IJaxrsElement<?>>();
- * result.addAll(Arrays.asList(elements)); return result; }
+ * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>... elements) { final List<IJaxrsElement<?>> result
+ * = new ArrayList<IJaxrsElement<?>>(); result.addAll(Arrays.asList(elements)); return result; }
*/
@Test
@@ -162,10 +187,11 @@
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
final ResourceDelta event = createEvent(sourceFolder.getResource(), ADDED);
- final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false, Arrays.asList(event), progressMonitor);
+ final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false,
+ Arrays.asList(event), progressMonitor);
// verifications
assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED));
- assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel)metamodel));
+ assertThat(affectedMetamodel.getMetamodel(), equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
// 1 application + 1 HttpMethod + 3 RootResources + 2 Subresources
assertThat(affectedElements.size(), equalTo(7));
@@ -175,7 +201,8 @@
}
@Test
- public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodelWithReset() throws CoreException {
+ public void shouldAddHttpMethodsAndResourcesWhenAddingSourceFolderWithExistingMetamodelWithReset()
+ throws CoreException {
// pre-conditions
metamodel.add(createHttpMethod(GET.class));
metamodel.add(createHttpMethod(POST.class));
@@ -185,26 +212,26 @@
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
final ResourceDelta event = createEvent(sourceFolder.getResource(), ADDED);
- final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, true, Arrays.asList(event), progressMonitor);
+ final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, true,
+ Arrays.asList(event), progressMonitor);
// verifications
assertThat(affectedMetamodel.getDeltaKind(), equalTo(CHANGED));
metamodel = (JaxrsMetamodel) affectedMetamodel.getMetamodel();
- assertThat(metamodel, equalTo((IJaxrsMetamodel)metamodel));
+ assertThat(metamodel, equalTo((IJaxrsMetamodel) metamodel));
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
// 1 application + 1 HttpMethod + 3 RootResources + 2 Subresources
assertThat(affectedElements.size(), equalTo(13));
assertThat(affectedElements, everyItem(Matchers.<JaxrsElementDelta> hasProperty("deltaKind", equalTo(ADDED))));
- // all HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(29));
+ // all Applications, HttpMethods (including @OPTIONS and @HEAD), Resources, ResourceMethods and ResourceFields
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
}
+
/**
* Because sometimes, generics are painful...
*
* @param elements
- * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>...
- * elements) { final List<IJaxrsElement<?>> result = new
- * ArrayList<IJaxrsElement<?>>();
- * result.addAll(Arrays.asList(elements)); return result; }
+ * @return private List<IJaxrsElement<?>> asList(IJaxrsElement<?>... elements) { final List<IJaxrsElement<?>> result
+ * = new ArrayList<IJaxrsElement<?>>(); result.addAll(Arrays.asList(elements)); return result; }
*/
@Test
@@ -212,12 +239,13 @@
// pre-conditions
// remove the metamodel
this.metamodel.remove();
- this.metamodel = null;
+ this.metamodel = null;
// operation
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
final ResourceDelta event = createEvent(sourceFolder.getResource(), ADDED);
- final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false, Arrays.asList(event), progressMonitor);
+ final JaxrsMetamodelDelta affectedMetamodel = processor.processAffectedResources(project, false,
+ Arrays.asList(event), progressMonitor);
// verifications
// 1 application + 1 HttpMethod + 3 RootResources + 2 Subresources
assertThat(affectedMetamodel.getDeltaKind(), equalTo(ADDED));
@@ -225,9 +253,9 @@
assertThat(metamodel, notNullValue());
final List<JaxrsElementDelta> affectedElements = affectedMetamodel.getAffectedElements();
assertThat(affectedElements.size(), equalTo(13));
- // all HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields
- assertThat(metamodel.getElements(javaProject).size(), equalTo(29));
-
+ // all Applications, HttpMethods (including @OPTIONS and @HEAD), project Resources, ResourceMethods and ResourceFields
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(30));
+
}
@Test
@@ -263,8 +291,8 @@
@Test
public void shouldAddApplicationWhenChangingResource() throws CoreException {
// pre-conditions
- final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", javaProject,
- progressMonitor);
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
// operation
final ResourceDelta event = createEvent(annotation.getJavaParent().getResource(), CHANGED);
@@ -273,16 +301,16 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
- assertThat(((JaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class));
+ assertThat(((IJaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@Test
public void shouldChangeApplicationWhenChangingResource() throws CoreException {
// pre-conditions
- final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", javaProject,
- progressMonitor);
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
metamodel.add(createApplication(type, "/bar"));
// operation
final ResourceDelta event = createEvent(type.getResource(), CHANGED);
@@ -291,16 +319,16 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(CHANGED));
- assertThat(((JaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
- verify(metamodel, times(1)).add(any(JaxrsApplication.class));
+ assertThat(((IJaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ verify(metamodel, times(1)).add(any(JaxrsJavaApplication.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
}
@Test
public void shouldRemoveApplicationWhenChangingResource() throws CoreException {
// pre-conditions
- final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", javaProject,
- progressMonitor);
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
metamodel.add(createApplication(type));
final Annotation annotation = getAnnotation(type, ApplicationPath.class);
// operation
@@ -311,7 +339,7 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
+ assertThat(((IJaxrsApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/app"));
verify(metamodel, times(1)).add(any(JaxrsHttpMethod.class));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
@@ -320,9 +348,9 @@
public void shouldRemoveApplicationWhenRemovingCompilationUnit() throws CoreException {
// pre-conditions
// JaxrsMetamodel metamodel = new JaxrsMetamodel(javaProject);
- final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", javaProject,
- progressMonitor);
- final JaxrsApplication application = createApplication(type);
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ final JaxrsJavaApplication application = createApplication(type);
metamodel.add(application);
// operation
final ResourceDelta event = createEvent(type.getResource(), REMOVED);
@@ -331,7 +359,7 @@
assertThat(affectedElements.size(), equalTo(1));
assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
- assertThat(((JaxrsApplication) affectedElements.get(0).getElement()), equalTo(application));
+ assertThat(((JaxrsJavaApplication) affectedElements.get(0).getElement()), equalTo(application));
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
@@ -358,9 +386,9 @@
@Test
public void shouldRemoveApplicationWhenRemovingSourceFolder() throws CoreException {
// pre-conditions
- final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication", javaProject,
- progressMonitor);
- final JaxrsApplication application = createApplication(type);
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ final JaxrsJavaApplication application = createApplication(type);
metamodel.add(application);
final IPackageFragmentRoot sourceFolder = WorkbenchUtils.getPackageFragmentRoot(javaProject, "src/main/java",
progressMonitor);
@@ -376,6 +404,156 @@
}
@Test
+ public void shouldAddApplicationWhenAddingWebxml() throws Exception {
+ // pre-conditions
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, ADDED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
+ }
+
+ @Test
+ public void shouldNotAddApplicationWhenAddingEmptyWebxml() throws Exception {
+ // pre-conditions
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-without-servlet-mapping.xml", bundle);
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, ADDED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(0));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldAddApplicationWhenChangingWebxml() throws Exception {
+ // pre-conditions
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
+ }
+
+ @Test
+ public void shouldOverrideApplicationWhenChangingWebxml() throws Exception {
+ // pre-conditions
+ final IType type = JdtUtils.resolveType("org.jboss.tools.ws.jaxrs.sample.services.RestApplication",
+ javaProject, progressMonitor);
+ final JaxrsJavaApplication application = createApplication(type);
+ metamodel.add(application);
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ final JaxrsWebxmlApplication webxmlApplication = (JaxrsWebxmlApplication) affectedElements.get(0).getElement();
+ assertThat(webxmlApplication.getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(ADDED));
+ assertThat(webxmlApplication.getApplicationPath(), equalTo("/hello"));
+ verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(2)); // old application (java) + new one (web.xml)
+ assertThat(metamodel.getApplication(), equalTo((IJaxrsApplication)webxmlApplication)); // web.xml based application precedes any other java based JAX-RS Application element
+
+ }
+
+ @Test
+ public void shouldChangeApplicationWhenChangingWebxml() throws Exception {
+ // pre-conditions
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ metamodel.add(createApplication("/foo"));
+ // operation
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(CHANGED));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ verify(metamodel, times(1)).add(any(JaxrsWebxmlApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(1));
+ }
+
+ @Test
+ public void shouldRemoveApplicationWhenChangingWebxml() throws Exception {
+ // pre-conditions
+ metamodel.add(createApplication("/hello"));
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-without-servlet-mapping.xml", bundle);
+ // operation
+ final ResourceDelta event = createEvent(webxmlResource, CHANGED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()).getApplicationPath(), equalTo("/hello"));
+ verify(metamodel, times(1)).remove(any(JaxrsWebxmlApplication.class));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
+ public void shouldRemoveApplicationWhenRemovingWebxml() throws Exception {
+ // pre-conditions
+ // JaxrsMetamodel metamodel = new JaxrsMetamodel(javaProject);
+ final JaxrsWebxmlApplication application = createApplication("/hello");
+ metamodel.add(application);
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ // operation
+ webxmlResource.delete(true, progressMonitor);
+ final ResourceDelta event = createEvent(webxmlResource, REMOVED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
+ assertThat(((JaxrsWebxmlApplication) affectedElements.get(0).getElement()), equalTo(application));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
+ @Ignore()
+ public void shouldRemoveApplicationWhenRemovingWebInfFolder() throws Exception {
+ // pre-conditions
+ final IResource webxmlResource = WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject,
+ "web-3_0-with-servlet-mapping.xml", bundle);
+ final JaxrsWebxmlApplication application = createApplication("/hello");
+ metamodel.add(application);
+
+ // operation
+ final IContainer webInfFolder = webxmlResource.getParent();
+ webInfFolder.delete(IResource.FORCE, progressMonitor);
+ final ResourceDelta event = createEvent(webInfFolder, REMOVED);
+ final List<JaxrsElementDelta> affectedElements = processResourceChanges(event, progressMonitor);
+ // verifications
+ assertThat(affectedElements.size(), equalTo(1));
+ assertThat(affectedElements.get(0).getElement().getElementKind(), equalTo(EnumElementKind.APPLICATION));
+ assertThat(affectedElements.get(0).getElement(), is(notNullValue()));
+ assertThat(affectedElements.get(0).getDeltaKind(), equalTo(REMOVED));
+ assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
+ }
+
+ @Test
public void shouldRemoveHttpMethodWhenRemovingBinaryLib() throws CoreException {
// pre-conditions
final IPackageFragmentRoot lib = WorkbenchUtils.getPackageFragmentRoot(javaProject,
@@ -512,7 +690,6 @@
assertThat(metamodel.getElements(javaProject).size(), equalTo(0));
}
-
@Test
public void shouldAddResourceWhenAddingSourceCompilationUnit() throws CoreException {
// pre-conditions
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsElementFactoryTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -70,7 +70,7 @@
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource");
final Annotation annotation = getAnnotation(type, Path.class);
// operation
- final JaxrsElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
+ final JaxrsJavaElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
assertNotNull(element);
@@ -106,7 +106,7 @@
final IType type = getType("org.jboss.tools.ws.jaxrs.sample.services.FOO");
final Annotation annotation = getAnnotation(type, HttpMethod.class);
// operation
- final JaxrsElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
+ final JaxrsJavaElement<?> element = factory.createElement(annotation.getJavaAnnotation(),
JdtUtils.parse(type, progressMonitor), metamodel);
// verifications
assertNotNull(element);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/domain/JaxrsMetamodelTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -36,6 +36,7 @@
import org.jboss.tools.ws.jaxrs.core.builder.AbstractMetamodelBuilderTestCase;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils;
+import org.jboss.tools.ws.jaxrs.core.metamodel.EnumKind;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsEndpoint;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsHttpMethod;
import org.jboss.tools.ws.jaxrs.core.metamodel.IJaxrsResource;
@@ -154,8 +155,13 @@
Assert.assertFalse("No produced media types", endpoint.getProducedMediaTypes().isEmpty());
}
}
-
@Test
+ public void shouldRetrieveApplicationPath() throws CoreException {
+ assertThat(metamodel.getApplication().getKind(), equalTo(EnumKind.APPLICATION_WEBXML));
+ assertThat(metamodel.getApplication().getApplicationPath(), equalTo("/hello"));
+ }
+
+ @Test
public void shouldRetrieveCustomerResource() throws CoreException {
IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
final IJaxrsResource customerResource = (IJaxrsResource) metamodel.getElement(customerType);
@@ -191,7 +197,7 @@
}
@Test
- public void shouldRetrieveBooksubresourceMethodProposals() throws CoreException {
+ public void shouldRetrieveBookSubresourceMethodProposals() throws CoreException {
IType customerType = getType("org.jboss.tools.ws.jaxrs.sample.services.BookResource", javaProject);
IMethod customerMethod = getMethod(customerType, "getProduct");
final IJaxrsResourceMethod customerResourceMethod = (IJaxrsResourceMethod) metamodel.getElement(customerMethod);
Modified: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-01-09 21:41:51 UTC (rev 37731)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/validation/JaxrsMetamodelValidatorTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -24,7 +24,9 @@
import org.eclipse.wst.validation.ValidatorMessage;
import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
import org.jboss.tools.ws.jaxrs.core.builder.AbstractMetamodelBuilderTestCase;
-import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsBaseElement;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsHttpMethod;
+import org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResourceMethod;
import org.jboss.tools.ws.jaxrs.core.jdt.Annotation;
import org.junit.Test;
@@ -38,7 +40,7 @@
public void shouldValidateHttpMethod() throws CoreException {
// preconditions
IType fooType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject);
- final JaxrsElement<?> httpMethod = metamodel.getElement(fooType);
+ final JaxrsBaseElement httpMethod = metamodel.getElement(fooType);
// operation
final List<ValidatorMessage> validationMessages = httpMethod.validate();
// validation
@@ -49,7 +51,7 @@
public void shouldNotValidateHttpMethod() throws CoreException {
// preconditions
IType fooType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.FOO", javaProject);
- final JaxrsElement<?> httpMethod = metamodel.getElement(fooType);
+ final JaxrsHttpMethod httpMethod = metamodel.getElement(fooType, JaxrsHttpMethod.class);
Annotation httpAnnotation = WorkbenchUtils.getAnnotation(fooType, HttpMethod.class, new String[0]);
httpMethod.addOrUpdateAnnotation(httpAnnotation);
// operation
@@ -62,7 +64,7 @@
public void shouldValidateResourceMethod() throws CoreException {
// preconditions
IType customerJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final JaxrsElement<?> customerResource = metamodel.getElement(customerJavaType);
+ final JaxrsBaseElement customerResource = metamodel.getElement(customerJavaType);
// operation
final List<ValidatorMessage> validationMessages = customerResource.validate();
// validation
@@ -73,9 +75,9 @@
public void shouldNotValidateResourceMethod() throws CoreException {
// preconditions
IType customerJavaType = WorkbenchUtils.getType("org.jboss.tools.ws.jaxrs.sample.services.CustomerResource", javaProject);
- final JaxrsElement<?> customerResource = metamodel.getElement(customerJavaType);
+ final JaxrsBaseElement customerResource = metamodel.getElement(customerJavaType);
IMethod customerJavaMethod = WorkbenchUtils.getMethod(customerJavaType, "getCustomer");
- final JaxrsElement<?> customerResourceMethod = metamodel.getElement(customerJavaMethod);
+ final JaxrsResourceMethod customerResourceMethod = metamodel.getElement(customerJavaMethod, JaxrsResourceMethod.class);
Annotation pathAnnotation = WorkbenchUtils.getAnnotation(customerJavaMethod, Path.class, "/{foo}");
customerResourceMethod.addOrUpdateAnnotation(pathAnnotation);
// operation
Added: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java 2012-01-09 22:16:52 UTC (rev 37732)
@@ -0,0 +1,127 @@
+package org.jboss.tools.ws.jaxrs.core.internal.utils;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Application;
+
+import org.eclipse.core.resources.IResource;
+import org.jboss.tools.ws.jaxrs.core.AbstractCommonTestCase;
+import org.jboss.tools.ws.jaxrs.core.WorkbenchUtils;
+import org.junit.Test;
+
+public class WtpUtilsTestCase extends AbstractCommonTestCase {
+
+ @Test
+ public void shouldRetrieveWebDeploymentDescriptor() throws Exception {
+ // pre-conditions
+ // operation
+ final IResource webxml= WtpUtils.getWebDeploymentDescriptor(project);
+ // verifications
+ assertThat(webxml, notNullValue());
+ }
+
+ @Test
+ public void shouldVerifyProjectHasWebDeploymentDescriptor() throws Exception {
+ // pre-conditions
+ // operation
+ final boolean hasWebxml= WtpUtils.hasWebDeploymentDescriptor(project);
+ // verifications
+ assertThat(hasWebxml, equalTo(true));
+ }
+
+
+ @Test
+ public void shouldRetrieveApplicationPathFromInWeb23xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_3-with-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, equalTo("/hello/*"));
+ }
+
+ @Test
+ public void shouldNotRetrieveApplicationPathInWeb23xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_3-without-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, nullValue());
+ }
+
+ @Test
+ public void shouldRetrieveApplicationPathInWeb24xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_4-with-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, equalTo("/hello/*"));
+ }
+
+ @Test
+ public void shouldNotRetrieveApplicationPathInWeb24xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_4-without-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, nullValue());
+ }
+
+ @Test
+ public void shouldRetrieveApplicationPathInWeb25xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_5-with-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, equalTo("/hello/*"));
+ }
+
+ @Test
+ public void shouldNotRetrieveApplicationPathInWeb25xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-2_5-without-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, nullValue());
+ }
+
+ @Test
+ public void shouldRetrieveApplicationPathInWeb30xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-3_0-with-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, equalTo("/hello/*"));
+
+ }
+
+ @Test
+ public void shouldNotRetrieveApplicationPathInWeb30xml() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, "web-3_0-without-servlet-mapping.xml", bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, nullValue());
+ }
+
+ @Test
+ public void shouldNotRetrieveApplicationPathWhenWebXmlMissing() throws Exception {
+ // pre-conditions
+ WorkbenchUtils.replaceDeploymentDescriptorWith(javaProject, null, bundle);
+ // operation
+ final String applicationPath = WtpUtils.getApplicationPath(project, Application.class.getName());
+ // verifications
+ assertThat(applicationPath, nullValue());
+ }
+
+}
Property changes on: trunk/ws/tests/org.jboss.tools.ws.jaxrs.core.test/src/org/jboss/tools/ws/jaxrs/core/internal/utils/WtpUtilsTestCase.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
12 years, 11 months
JBoss Tools SVN: r37731 - in trunk/common/tests/org.jboss.tools.common.el.core.test: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-01-09 16:41:51 -0500 (Mon, 09 Jan 2012)
New Revision: 37731
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath
trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
Log:
fixed compilation errors
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath 2012-01-09 20:30:09 UTC (rev 37730)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/.classpath 2012-01-09 21:41:51 UTC (rev 37731)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF 2012-01-09 20:30:09 UTC (rev 37730)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF 2012-01-09 21:41:51 UTC (rev 37731)
@@ -20,4 +20,4 @@
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
org.jboss.tools.common
Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
12 years, 11 months
JBoss Tools SVN: r37730 - trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-09 15:30:09 -0500 (Mon, 09 Jan 2012)
New Revision: 37730
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ResolverProjectNature1.java
Log:
Ctrl+Shift+G on a java element doesn't work for complex ELs https://issues.jboss.org/browse/JBIDE-10593
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ResolverProjectNature1.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ResolverProjectNature1.java 2012-01-09 20:16:29 UTC (rev 37729)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/resolver/ResolverProjectNature1.java 2012-01-09 20:30:09 UTC (rev 37730)
@@ -41,7 +41,12 @@
public IRelevanceCheck createRelevanceCheck(IJavaElement element) {
// TODO Auto-generated method stub
- return null;
+ return new IRelevanceCheck(){
+
+ @Override
+ public boolean isRelevant(String content) {
+ return false;
+ }};
}
}
12 years, 11 months
JBoss Tools SVN: r37729 - in trunk/ws/plugins/org.jboss.tools.ws.ui: src/org/jboss/tools/ws/ui and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: bfitzpat
Date: 2012-01-09 15:16:29 -0500 (Mon, 09 Jan 2012)
New Revision: 37729
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
Log:
JBIDE-10485 - Initial integration on context menu for WSDL files to launch the WS Tester
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2012-01-09 19:24:00 UTC (rev 37728)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.properties 2012-01-09 20:16:29 UTC (rev 37729)
@@ -11,4 +11,5 @@
ws_bottom_up.wizard.name = Simple Web Service
ws_bottom_up.wizard.description = Create a Web Service from existing class
jbossws.page.name = JBossWS Runtime
-jaxrs.annotation.category=JAX-RS
\ No newline at end of file
+jaxrs.annotation.category=JAX-RS
+RunWSTesterAction.label = Test in JBoss Web Service Tester
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2012-01-09 19:24:00 UTC (rev 37728)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2012-01-09 20:16:29 UTC (rev 37729)
@@ -241,5 +241,20 @@
class="javax.ws.rs.ext.Provider"
name="Provider">
</annotation>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.jboss.tools.ws.tester.enablement"
+ nameFilter="*.wsdl"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ class="org.jboss.tools.ws.ui.actions.RunWSTesterAction"
+ id="org.jboss.tools.ws.tester.enablement.action"
+ label="%RunWSTesterAction.label"
+ menubarPath="org.eclipse.wst.ws.ui.webservice.category.popupMenu/popupActions">
+ </action>
+ </objectContribution>
</extension>
</plugin>
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java 2012-01-09 20:16:29 UTC (rev 37729)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.ui.actions;
+
+import java.net.MalformedURLException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+import org.jboss.tools.ws.ui.views.JAXRSWSTestView2;
+
+/**
+ * Action to fire up the WS Tester from a WSDL in a navigator view
+ * @author bfitzpat
+ *
+ */
+public class RunWSTesterAction implements IObjectActionDelegate {
+
+ private ISelection selection = null;
+
+ public RunWSTesterAction() {
+ // empty
+ }
+
+ @Override
+ public void run(final IAction action) {
+ if (this.selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) this.selection;
+ if (ssel.getFirstElement() instanceof IFile) {
+ IFile wsdlFile = (IFile) ssel.getFirstElement();
+ IWorkbench wb = PlatformUI.getWorkbench();
+ IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+ IWorkbenchPage page = win.getActivePage();
+ String id = JAXRSWSTestView2.ID;
+ try {
+ IViewPart part = page.showView(id);
+ if (part instanceof JAXRSWSTestView2) {
+ JAXRSWSTestView2 testerView = (JAXRSWSTestView2) part;
+ String url = wsdlFile.getRawLocationURI().toURL().toExternalForm();
+ testerView.setWSDLURL(url);
+ }
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ JBossWSUIPlugin.log(e);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ JBossWSUIPlugin.log(e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ // empty
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2012-01-09 19:24:00 UTC (rev 37728)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2012-01-09 20:16:29 UTC (rev 37729)
@@ -193,6 +193,32 @@
*/
public JAXRSWSTestView2() {
}
+
+ public void setWSDLURL( String url ) {
+ this.urlCombo.setText(url);
+ this.methodCombo.setText(JAX_WS);
+ setControlsForWSType(JAX_WS);
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
+ }
+
+ public void setJAXRS ( String url, String method ) {
+ this.urlCombo.setText(url);
+ String uCaseMethod = method.toUpperCase();
+ if (uCaseMethod.equalsIgnoreCase(GET))
+ this.methodCombo.setText(GET);
+ else if (uCaseMethod.equalsIgnoreCase(POST))
+ this.methodCombo.setText(POST);
+ else if (uCaseMethod.equalsIgnoreCase(PUT))
+ this.methodCombo.setText(PUT);
+ else if (uCaseMethod.equalsIgnoreCase(DELETE))
+ this.methodCombo.setText(DELETE);
+ else if (uCaseMethod.equalsIgnoreCase(OPTIONS))
+ this.methodCombo.setText(OPTIONS);
+ setControlsForWSType(JAX_RS);
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
+ }
private void getImages() {
mImageRegistry = new ImageRegistry();
12 years, 11 months
JBoss Tools SVN: r37728 - in trunk/jsf: tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-09 14:24:00 -0500 (Mon, 09 Jan 2012)
New Revision: 37728
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MessagePropertyRefactoringTest.java
Log:
Ctrl+Shift+G on a java element doesn't work for complex ELs https://issues.jboss.org/browse/JBIDE-10593
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java 2012-01-09 18:08:56 UTC (rev 37727)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java 2012-01-09 19:24:00 UTC (rev 37728)
@@ -150,7 +150,7 @@
}
- private ELSegment findELSegment(IFile file, TextSelection selection){
+ public static ELSegment findELSegment(IFile file, TextSelection selection){
ELContext context = PageContextFactory.createPageContext(file);
if(context == null)
@@ -179,7 +179,7 @@
return null;
}
- private ELSegment getSegment(ELResolver[] resolvers, ELContext context, TextSelection selection, ELReference reference, ELExpression operand){
+ private static ELSegment getSegment(ELResolver[] resolvers, ELContext context, TextSelection selection, ELReference reference, ELExpression operand){
for (ELResolver resolver : resolvers) {
ELResolution resolution = resolver.resolve(context, operand, selection.getOffset());
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MessagePropertyRefactoringTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MessagePropertyRefactoringTest.java 2012-01-09 18:08:56 UTC (rev 37727)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MessagePropertyRefactoringTest.java 2012-01-09 19:24:00 UTC (rev 37728)
@@ -7,11 +7,13 @@
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.TextSelection;
import org.jboss.tools.common.base.test.AbstractRefactorTest;
-import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.MessagePropertyELSegment;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.el.refactoring.RenameMessagePropertyProcessor;
-import org.jboss.tools.jst.web.kb.el.MessagePropertyELSegmentImpl;
+import org.jboss.tools.jsf.ui.el.refactoring.ELRefactorContributionFactory;
import org.jboss.tools.test.util.ProjectImportTestSetup;
public class MessagePropertyRefactoringTest extends AbstractRefactorTest{
@@ -58,14 +60,19 @@
structure.addTextChange(change);
list.add(structure);
- MessagePropertyELSegmentImpl segment = new MessagePropertyELSegmentImpl(new LexicalToken(position,13,"hello_message",-1000));
- segment.setMessageBundleResource(propertyFile);
- segment.setBaseName("demo.Messages");
- segment.setMessagePropertySourceReference(0,10);
- RenameMessagePropertyProcessor processor = new RenameMessagePropertyProcessor(sourceFile, segment);
- processor.setNewName(NEW_NAME);
+ //MessagePropertyELSegmentImpl segment = new MessagePropertyELSegmentImpl(new LexicalToken(position,13,"hello_message",-1000));
+ //segment.setMessageBundleResource(propertyFile);
+ //segment.setBaseName("demo.Messages");
+ //segment.setMessagePropertySourceReference(0,10);
+ ELSegment segment = ELRefactorContributionFactory.findELSegment(sourceFile, new TextSelection(position, 13));
+ if(segment instanceof MessagePropertyELSegment){
+ RenameMessagePropertyProcessor processor = new RenameMessagePropertyProcessor(sourceFile, (MessagePropertyELSegment)segment);
+ processor.setNewName(NEW_NAME);
- checkRename(processor, list);
+ checkRename(processor, list);
+ }else{
+ fail("segment must be instance of MessagePropertyELSegment");
+ }
}
}
12 years, 11 months
JBoss Tools SVN: r37727 - in trunk/seam/tests/org.jboss.tools.seam.ui.test: src/org/jboss/tools/seam/ui/test/el and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2012-01-09 13:08:56 -0500 (Mon, 09 Jan 2012)
New Revision: 37727
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/numberguess/web/giveup.jspx
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELExprPartitionerTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java
Log:
Ctrl+Shift+G on a java element doesn't work for complex ELs https://issues.jboss.org/browse/JBIDE-10593
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/numberguess/web/giveup.jspx
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/numberguess/web/giveup.jspx 2012-01-09 16:52:10 UTC (rev 37726)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/projects/numberguess/web/giveup.jspx 2012-01-09 18:08:56 UTC (rev 37727)
@@ -18,6 +18,7 @@
<h1><h:outputText value="#{Message.question}" /></h1>
<f:view>
<h:form styleClass="niceform">
+ <h:outputText value="#{numberGuess.possibilities + numberGuess.remainingGuesses}"/>
<h:outputText value="#{Message.info_start}" /><h:outputText value="#{numberGuess.remainingGuesses}"/><h:outputText value="#{Message.info_finish}" />
<h:commandButton value="#{Message.button_yes}" action="yes"/>
<h:commandButton value="#{Message.button_no}" action="no"/>
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELExprPartitionerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELExprPartitionerTest.java 2012-01-09 16:52:10 UTC (rev 37726)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELExprPartitionerTest.java 2012-01-09 18:08:56 UTC (rev 37727)
@@ -93,42 +93,50 @@
public void testELExprPartitioner() throws Exception{
ArrayList<TestRegion> regionList = new ArrayList<TestRegion>();
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(673, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(681, 7/*"question"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'question' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(756, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(764, 7/*"question"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'question' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("questio", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'question' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(863, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(871, 9/*"info_start"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'info_start' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("questio", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'question' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(909, 10/*"numberGuess"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
- regionList.add(new TestRegion(921, 15/*"remainingGuesses"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getRemainingGuesses() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("numberGues", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("possibilitie", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getPossibilities() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(964, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(972, 10/*"info_finish"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'info_finish' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("numberGues", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("remainingGuesse", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getRemainingGuesses() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(1022, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(1030, 9/*"button_yes"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'button_yes' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("info_star", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'info_start' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(1091, 6/*"Message"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
- regionList.add(new TestRegion(1099, 8/*"button_no"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'button_no' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("numberGues", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("remainingGuesse", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getRemainingGuesses() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(1157, 10/*"numberGuess"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
- regionList.add(new TestRegion(1169, 12/*"possibilities"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getPossibilities() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("info_finis", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'info_finish' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
- //regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
- regionList.add(new TestRegion(1237, 13/*"_localVariable"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Iterator.next() - java.util'")}));
- regionList.add(new TestRegion(1252, 7/*"intValue"*/, new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Integer.intValue() - java.lang'")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("button_ye", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'button_yes' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("Messag", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open bundle 'demo.bundle.Messages'", "Messages.properties")}));
+ regionList.add(new TestRegion("button_n", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open property 'button_no' of bundle 'demo.bundle.Messages'", "Messages.properties")}));
+
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("numberGues", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+ regionList.add(new TestRegion("possibilitie", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'NumberGuess.getPossibilities() - org.jboss.seam.example.numberguess'", "NumberGuess.java")}));
+
+ regionList.add(new TestRegion("#{", new TestHyperlink[]{}));
+ regionList.add(new TestRegion("_localVariabl", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Iterator.next() - java.util'")}));
+ regionList.add(new TestRegion("intValu", new TestHyperlink[]{new TestHyperlink(ELHyperlink.class, "Open 'Integer.intValue() - java.lang'")}));
+
HyperlinkTestUtil.checkRegions(project, PAGE_NAME, regionList, new ELHyperlinkDetector());
}
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java 2012-01-09 16:52:10 UTC (rev 37726)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/el/ELReferencesQueryParticipantTest.java 2012-01-09 18:08:56 UTC (rev 37727)
@@ -23,6 +23,8 @@
matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "numberGuess"));
matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "numberGuess"));
+ matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "numberGuess"));
+ matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "numberGuess"));
QueryParticipantTestUtils.testSearchParticipant(project,
"src/org/jboss/seam/example/numberguess/NumberGuess.java",
@@ -37,6 +39,7 @@
ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "remainingGuesses"));
+ matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "remainingGuesses"));
QueryParticipantTestUtils.testSearchParticipant(project,
"src/org/jboss/seam/example/numberguess/NumberGuess.java",
@@ -51,6 +54,7 @@
ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "possibilities"));
+ matches.add(new MatchStructure("/numberguess/web/giveup.jspx", "possibilities"));
QueryParticipantTestUtils.testSearchParticipant(project,
"src/org/jboss/seam/example/numberguess/NumberGuess.java",
12 years, 11 months
JBoss Tools SVN: r37726 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-09 11:52:10 -0500 (Mon, 09 Jan 2012)
New Revision: 37726
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java
Log:
[JBIDE-10479] added javadoc
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java 2012-01-09 16:50:46 UTC (rev 37725)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java 2012-01-09 16:52:10 UTC (rev 37726)
@@ -89,7 +89,7 @@
File tmpFolder = FileUtils.getRandomTmpFolder();
File repositoryFile = cloneRepository(getApplication(), getRemoteName(), tmpFolder, monitor);
IProject project = getProject(getProjectName());
- copyOpenshiftConfiguration(repositoryFile, project, monitor);
+ copyOpenshiftConfigurations(repositoryFile, project, monitor);
FileUtil.safeDelete(tmpFolder);
shareProject(project, monitor);
@@ -120,7 +120,7 @@
* the monitor to report progress to
* @throws IOException
*/
- private void copyOpenshiftConfiguration(final File sourceFolder, IProject project, IProgressMonitor monitor)
+ private void copyOpenshiftConfigurations(final File sourceFolder, IProject project, IProgressMonitor monitor)
throws IOException {
Assert.isLegal(project != null);
File projectFolder = project.getLocation().toFile();
12 years, 11 months
JBoss Tools SVN: r37725 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-01-09 11:50:46 -0500 (Mon, 09 Jan 2012)
New Revision: 37725
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java
Log:
[JBIDE-10479] added javadoc
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java 2012-01-09 16:07:16 UTC (rev 37724)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/appimport/AddToExistingProjectOperation.java 2012-01-09 16:50:46 UTC (rev 37725)
@@ -103,7 +103,14 @@
/**
* Copies the openshift configuration from the given source folder to the
- * given project.
+ * given project. Copies
+ * <ul>
+ * <li>.git</li>
+ * <li>.openshift</li>
+ * <li>deployments</li>
+ * <li>pom.xml</li>
+ * </ul>
+ * to the project in the workspace
*
* @param sourceFolder
* the source to copy the openshift config from
12 years, 11 months
JBoss Tools SVN: r37724 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-01-09 11:07:16 -0500 (Mon, 09 Jan 2012)
New Revision: 37724
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
Log:
Added features as dependencies. Narrowd the scope of performed tests to Java core portlets.
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml 2012-01-09 16:06:16 UTC (rev 37723)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/pom.xml 2012-01-09 16:07:16 UTC (rev 37724)
@@ -9,7 +9,7 @@
</parent>
<groupId>org.jboss.tools.portlet.tests</groupId>
<artifactId>org.jboss.tools.portlet.ui.bot.test</artifactId>
-
+
<packaging>eclipse-test-plugin</packaging>
<properties>
@@ -26,11 +26,32 @@
<configuration>
<useUIThread>false</useUIThread>
<testSuite>org.jboss.tools.portlet.ui.bot.test</testSuite>
- <testClass>org.jboss.tools.portlet.ui.bot.test.AllTestsSuite</testClass>
+ <testClass>org.jboss.tools.portlet.ui.bot.test.core.JavaPortletTestSuite</testClass>
<skip>${swtbot.test.skip}</skip>
+ <dependencies combine.children="append">
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.jst.server_ui.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.jboss.tools.portlet.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.jst.enterprise_ui.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ <dependency>
+ <type>p2-installable-unit</type>
+ <artifactId>org.eclipse.jst.web_core.feature.feature.group</artifactId>
+ <version>0.0.0</version>
+ </dependency>
+ </dependencies>
</configuration>
</plugin>
</plugins>
</build>
-
</project>
12 years, 11 months
JBoss Tools SVN: r37723 - trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF.
by jbosstools-commits@lists.jboss.org
Author: ljelinko
Date: 2012-01-09 11:06:16 -0500 (Mon, 09 Jan 2012)
New Revision: 37723
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
Log:
Cleanup of tenst dependencies
Modified: trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2012-01-09 15:49:20 UTC (rev 37722)
+++ trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/META-INF/MANIFEST.MF 2012-01-09 16:06:16 UTC (rev 37723)
@@ -19,15 +19,4 @@
org.eclipse.ui.forms;bundle-version="3.5.0",
org.eclipse.wst.jsdt.web.core;bundle-version="1.0.401",
org.eclipse.wst.jsdt.web.support.jsp;bundle-version="1.0.400",
- org.eclipse.wst.jsdt.web.ui;bundle-version="1.0.401",
- org.eclipse.jst.ejb.doc.user;bundle-version="1.1.301",
- org.eclipse.jst.ejb.ui;bundle-version="1.1.600",
- org.eclipse.jst.ejb.ui.infopop;bundle-version="1.0.300",
- org.eclipse.jst.j2ee.doc.user;bundle-version="1.1.400",
- org.eclipse.jst.j2ee.ejb.annotations.emitter;bundle-version="1.1.200",
- org.eclipse.jst.j2ee.ejb.annotations.ui;bundle-version="1.1.200",
- org.eclipse.jst.j2ee.ejb.annotations.xdoclet;bundle-version="1.2.200",
- org.eclipse.jst.j2ee.infopop;bundle-version="1.0.300",
- org.eclipse.jst.j2ee.xdoclet.runtime;bundle-version="1.1.300",
- org.eclipse.jst.jee.ejb;bundle-version="1.0.301",
- org.eclipse.jst.jee.web;bundle-version="1.0.301"
+ org.eclipse.wst.jsdt.web.ui;bundle-version="1.0.401"
12 years, 11 months