Author: asoldano
Date: 2014-01-28 14:58:30 -0500 (Tue, 28 Jan 2014)
New Revision: 18284
Added:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/JandexAnnotationsInfo.java
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/AbstractDeploymentModelBuilder.java
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/injection/WSHandlerChainAnnotationProcessor.java
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java
Log:
[JBWS-3737] Add an instance of AnnotationsInfo into deployment
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/AbstractDeploymentModelBuilder.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/AbstractDeploymentModelBuilder.java 2014-01-28
19:57:42 UTC (rev 18283)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/AbstractDeploymentModelBuilder.java 2014-01-28
19:58:30 UTC (rev 18284)
@@ -46,6 +46,7 @@
import org.jboss.ws.common.ResourceLoaderAdapter;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.AnnotationsInfo;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentModelFactory;
@@ -214,6 +215,8 @@
}
dep.setRuntimeClassLoader(classLoader);
dep.setType(deploymentType);
+ //add an AnnotationInfo attachment that uses composite jandex index
+ dep.addAttachment(AnnotationsInfo.class, new JandexAnnotationsInfo(unit));
return dep;
}
Added:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/JandexAnnotationsInfo.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/JandexAnnotationsInfo.java
(rev 0)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/JandexAnnotationsInfo.java 2014-01-28
19:58:30 UTC (rev 18284)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.webservices.deployers.deployment;
+
+import static org.jboss.as.server.deployment.Attachments.ANNOTATION_INDEX;
+
+import java.util.List;
+
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.module.ResourceRoot;
+import org.jboss.as.webservices.util.ASHelper;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.Index;
+import org.jboss.wsf.spi.deployment.AnnotationsInfo;
+
+/**
+ * A Jandex based implementation of org.jboss.wsf.spi.deployment.AnnotationsInfo
+ *
+ * @author <a href="mailto:alessio.soldano@jboss.com">Alessio
Soldano</a>
+ */
+public final class JandexAnnotationsInfo implements AnnotationsInfo {
+
+ private final List<ResourceRoot> resourceRoots;
+
+ public JandexAnnotationsInfo(DeploymentUnit unit) {
+ resourceRoots = ASHelper.getResourceRoots(unit);
+ }
+
+ @Override
+ public boolean hasAnnotatedClasses(String... annotation) {
+ if (annotation == null) {
+ throw new IllegalArgumentException();
+ }
+ if (resourceRoots != null) {
+ Index index = null;
+ for (ResourceRoot resourceRoot : resourceRoots) {
+ index = resourceRoot.getAttachment(ANNOTATION_INDEX);
+ if (index != null) {
+ for (String ann : annotation) {
+ List<AnnotationInstance> list =
index.getAnnotations(DotName.createSimple(ann));
+ if (list != null && !list.isEmpty()) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+}
Property changes on:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/deployers/deployment/JandexAnnotationsInfo.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/injection/WSHandlerChainAnnotationProcessor.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/injection/WSHandlerChainAnnotationProcessor.java 2014-01-28
19:57:42 UTC (rev 18283)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/injection/WSHandlerChainAnnotationProcessor.java 2014-01-28
19:58:30 UTC (rev 18284)
@@ -23,8 +23,6 @@
package org.jboss.as.webservices.injection;
import static org.jboss.as.server.deployment.Attachments.ANNOTATION_INDEX;
-import static org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT;
-import static org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS;
import static org.jboss.as.webservices.WSMessages.MESSAGES;
import static org.jboss.as.webservices.util.ASHelper.isJaxwsService;
import static org.jboss.as.webservices.util.DotNames.HANDLER_CHAIN_ANNOTATION;
@@ -44,13 +42,12 @@
import org.jboss.as.ee.structure.DeploymentType;
import org.jboss.as.ee.structure.DeploymentTypeMarker;
-import org.jboss.as.server.deployment.AttachmentList;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
-import org.jboss.as.server.deployment.EjbDeploymentMarker;
import org.jboss.as.server.deployment.module.ResourceRoot;
+import org.jboss.as.webservices.util.ASHelper;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
@@ -72,14 +69,7 @@
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
- // 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);
- }
+ List<ResourceRoot> resourceRoots = ASHelper.getResourceRoots(unit);
if (resourceRoots == null) {
return;
}
Modified:
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java
===================================================================
---
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java 2014-01-28
19:57:42 UTC (rev 18283)
+++
container/jboss72/branches/jbossws-jboss720/server-integration/src/main/java/org/jboss/as/webservices/util/ASHelper.java 2014-01-28
19:58:30 UTC (rev 18284)
@@ -21,6 +21,8 @@
*/
package org.jboss.as.webservices.util;
+import static org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT;
+import static org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS;
import static org.jboss.as.webservices.util.DotNames.JAXWS_SERVICE_CLASS;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JAXRPC_ENDPOINTS_KEY;
import static org.jboss.as.webservices.util.WSAttachmentKeys.JAXWS_ENDPOINTS_KEY;
@@ -30,9 +32,12 @@
import org.jboss.as.controller.OperationContext;
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.as.web.deployment.WarMetaData;
import org.jboss.as.webservices.metadata.model.EJBEndpoint;
import org.jboss.as.webservices.metadata.model.JAXRPCDeployment;
@@ -299,4 +304,15 @@
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;
+ }
}