This repository has been archived by the owner on Oct 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding jaxrs-server-integration maven module
- Loading branch information
Showing
26 changed files
with
2,729 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ JBoss, Home of Professional Open Source. | ||
~ Copyright 2010, Red Hat, Inc., and individual contributors | ||
~ as indicated by the @author tags. See the copyright.txt file in the | ||
~ distribution for a full listing of individual contributors. | ||
~ | ||
~ This is free software; you can redistribute it and/or modify it | ||
~ under the terms of the GNU Lesser General Public License as | ||
~ published by the Free Software Foundation; either version 2.1 of | ||
~ the License, or (at your option) any later version. | ||
~ | ||
~ This software is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
~ Lesser General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU Lesser General Public | ||
~ License along with this software; if not, write to the Free | ||
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.jboss.ws</groupId> | ||
<artifactId>jbossws-wildfly901-parent</artifactId> | ||
<version>5.1.4.rest-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<name>JBossWS JBoss WildFly 9.0.1.Final JAXRS Server Side Integration</name> | ||
<description>JBossWS WildFly 9.0.1.Final JAXRS Server Side Integration</description> | ||
<groupId>org.jboss.ws</groupId> | ||
<artifactId>jbossws-wildfly901-jaxrs-server-integration</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-ee</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-security-manager</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly.core</groupId> | ||
<artifactId>wildfly-server</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-web-common</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly</groupId> | ||
<artifactId>wildfly-undertow</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-annotations</artifactId> | ||
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other | ||
projects that depend on this project.--> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-processor</artifactId> | ||
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other | ||
projects that depend on this project.--> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.msc</groupId> | ||
<artifactId>jboss-msc</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.spec.javax.ws.rs</groupId> | ||
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.spec.javax.annotation</groupId> | ||
<artifactId>jboss-annotations-api_1.2_spec</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.ws</groupId> | ||
<artifactId>jbossws-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.ws</groupId> | ||
<artifactId>jbossws-common</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.ws</groupId> | ||
<artifactId>jbossws-spi</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.wildfly.core</groupId> | ||
<artifactId>wildfly-subsystem-test</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
165 changes: 165 additions & 0 deletions
165
jaxrs-server-integration/src/main/java/org/jboss/as/jaxrs/ASHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.jaxrs; | ||
|
||
import static org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT; | ||
import static org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.server.CurrentServiceContainer; | ||
import org.jboss.as.server.deployment.AttachmentKey; | ||
import org.jboss.as.server.deployment.AttachmentList; | ||
import org.jboss.as.server.deployment.Attachments; | ||
import org.jboss.as.server.deployment.DeploymentUnit; | ||
import org.jboss.as.server.deployment.EjbDeploymentMarker; | ||
import org.jboss.as.server.deployment.annotation.CompositeIndex; | ||
import org.jboss.as.server.deployment.module.ResourceRoot; | ||
import org.jboss.jandex.AnnotationInstance; | ||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
import org.jboss.jandex.Index; | ||
import org.jboss.metadata.web.jboss.JBossServletMetaData; | ||
import org.jboss.metadata.web.jboss.JBossWebMetaData; | ||
import org.jboss.metadata.web.spec.ServletMetaData; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.msc.service.ServiceName; | ||
|
||
/** | ||
* JBoss AS integration helper class. | ||
* | ||
* @author <a href="ropalka@redhat.com">Richard Opalka</a> | ||
* @author <a href="alessio.soldano@jboss.com">Alessio Soldano</a> | ||
*/ | ||
public final class ASHelper { | ||
|
||
private ASHelper() { | ||
} | ||
|
||
/** | ||
* Returns endpoint name. | ||
* | ||
* @param servletMD servlet meta data | ||
* @return endpoint name | ||
*/ | ||
public static String getEndpointName(final ServletMetaData servletMD) { | ||
final String endpointName = servletMD.getName(); | ||
return endpointName != null ? endpointName.trim() : null; | ||
} | ||
|
||
/** | ||
* Returns endpoint class name. | ||
* | ||
* @param servletMD servlet meta data | ||
* @return endpoint class name | ||
*/ | ||
public static String getEndpointClassName(final ServletMetaData servletMD) { | ||
final String endpointClass = servletMD.getServletClass(); | ||
return endpointClass != null ? endpointClass.trim() : null; | ||
} | ||
|
||
/** | ||
* Returns servlet meta data for requested servlet name. | ||
* | ||
* @param jbossWebMD jboss web meta data | ||
* @param servletName servlet name | ||
* @return servlet meta data | ||
*/ | ||
public static ServletMetaData getServletForName(final JBossWebMetaData jbossWebMD, final String servletName) { | ||
for (JBossServletMetaData servlet : jbossWebMD.getServlets()) { | ||
if (servlet.getName().equals(servletName)) { | ||
return servlet; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Returns required attachment value from deployment unit. | ||
* | ||
* @param <A> expected value | ||
* @param unit deployment unit | ||
* @param key attachment key | ||
* @return required attachment | ||
* @throws IllegalStateException if attachment value is null | ||
*/ | ||
public static <A> A getRequiredAttachment(final DeploymentUnit unit, final AttachmentKey<A> key) { | ||
final A value = unit.getAttachment(key); | ||
if (value == null) { | ||
throw new IllegalStateException(); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
/** | ||
* Returns optional attachment value from deployment unit or null if not bound. | ||
* | ||
* @param <A> expected value | ||
* @param unit deployment unit | ||
* @param key attachment key | ||
* @return optional attachment value or null | ||
*/ | ||
public static <A> A getOptionalAttachment(final DeploymentUnit unit, final AttachmentKey<A> key) { | ||
return unit.getAttachment(key); | ||
} | ||
|
||
public static boolean hasClassesFromPackage(final Index index, final String pck) { | ||
for (ClassInfo ci : index.getKnownClasses()) { | ||
if (ci.name().toString().startsWith(pck)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static List<AnnotationInstance> getAnnotations(final DeploymentUnit unit, final DotName annotation) { | ||
final CompositeIndex compositeIndex = getRequiredAttachment(unit, Attachments.COMPOSITE_ANNOTATION_INDEX); | ||
return compositeIndex.getAnnotations(annotation); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> T getMSCService(final ServiceName serviceName, final Class<T> clazz) { | ||
ServiceController<T> service = (ServiceController<T>) CurrentServiceContainer.getServiceContainer().getService(serviceName); | ||
return service != null ? service.getValue() : null; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static <T> T getMSCService(final ServiceName serviceName, final Class<T> clazz, final OperationContext context) { | ||
ServiceController<T> service = (ServiceController<T>)context.getServiceRegistry(false).getService(serviceName); | ||
return service != null ? service.getValue() : null; | ||
} | ||
|
||
public static List<ResourceRoot> getResourceRoots(DeploymentUnit unit) { | ||
// wars define resource roots | ||
AttachmentList<ResourceRoot> resourceRoots = unit.getAttachment(RESOURCE_ROOTS); | ||
if (!unit.getName().endsWith(".war") && EjbDeploymentMarker.isEjbDeployment(unit)) { | ||
// ejb archives don't define resource roots, using root resource | ||
resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class); | ||
final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT); | ||
resourceRoots.add(root); | ||
} | ||
return resourceRoots; | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
jaxrs-server-integration/src/main/java/org/jboss/as/jaxrs/JaxrsAnnotations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat Inc., and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.jaxrs; | ||
|
||
import org.jboss.jandex.DotName; | ||
|
||
/** | ||
* Class that stores the {@link DotName}s of Jax-RS annotations | ||
* | ||
* @author Stuart Douglas | ||
* | ||
*/ | ||
public enum JaxrsAnnotations { | ||
|
||
CONSUMES("Consumes"), | ||
COOKIE_PARAM("CookieParam"), | ||
DEFAULT_VALUE("DefaultValue"), | ||
DELETE("DELETE"), | ||
ENCODED("Encoded"), | ||
FORM_PARAM("FormParam"), | ||
GET("GET"), | ||
HEAD("HEAD"), | ||
HEADER_PARAM("HeaderParam"), | ||
HTTP_METHOD("HttpMethod"), | ||
MATRIX_PARAM("MatrixParam"), | ||
PATH("Path"), | ||
PATH_PARAM("PathParam"), | ||
POST("POST"), | ||
PRODUCES("Produces"), | ||
PUT("PUT"), | ||
QUERY_PARAM("QueryParam"), | ||
CONTEXT(Constants.JAVAX_WS_CORE,"Context"), | ||
PROVIDER(Constants.JAVAX_WS_EXT,"Provider"), | ||
APPLICATION_PATH("ApplicationPath"); | ||
|
||
private final String simpleName; | ||
private final DotName dotName; | ||
|
||
private JaxrsAnnotations(String simpleName) { | ||
this.simpleName = simpleName; | ||
this.dotName = DotName.createComponentized(Constants.JAVAX_WS_RS, simpleName); | ||
} | ||
private JaxrsAnnotations(DotName prefix,String simpleName) { | ||
this.simpleName = simpleName; | ||
this.dotName = DotName.createComponentized(prefix, simpleName); | ||
} | ||
// this can't go on the enum itself | ||
private static class Constants { | ||
public static final DotName JAVAX = DotName.createComponentized(null, "javax"); | ||
public static final DotName JAVAX_WS = DotName.createComponentized(JAVAX, "ws"); | ||
public static final DotName JAVAX_WS_RS = DotName.createComponentized(JAVAX_WS, "rs"); | ||
public static final DotName JAVAX_WS_CORE = DotName.createComponentized(JAVAX_WS_RS, "core"); | ||
public static final DotName JAVAX_WS_EXT = DotName.createComponentized(JAVAX_WS_RS, "ext"); | ||
} | ||
|
||
public DotName getDotName() { | ||
return dotName; | ||
} | ||
|
||
public String getSimpleName() { | ||
return simpleName; | ||
} | ||
|
||
} |
Oops, something went wrong.