apiType) throws NoSuchCapabilityException {
+ String fullName = RuntimeCapability.buildDynamicCapabilityName(capabilityBaseName, dynamicPart);
+ return getCapabilityRuntimeAPI(fullName, apiType);
+ }
+
+ @Override
+ public ServiceName getCapabilityServiceName(String capabilityName) {
+ return ServiceName.parse(capabilityName);
+ }
+
+ @Override
+ public ServiceName getCapabilityServiceName(String capabilityBaseName, String dynamicPart) {
+ return getCapabilityServiceName(capabilityBaseName).append(dynamicPart);
+ }
+ }
+
}
diff --git a/controller/src/main/java/org/jboss/as/controller/ParallelBootOperationContext.java b/controller/src/main/java/org/jboss/as/controller/ParallelBootOperationContext.java
index fc7853dbe75..f393ca3107a 100644
--- a/controller/src/main/java/org/jboss/as/controller/ParallelBootOperationContext.java
+++ b/controller/src/main/java/org/jboss/as/controller/ParallelBootOperationContext.java
@@ -30,6 +30,7 @@
import org.jboss.as.controller.access.AuthorizationResult;
import org.jboss.as.controller.access.ResourceAuthorization;
import org.jboss.as.controller.audit.AuditLogger;
+import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.MessageSeverity;
import org.jboss.as.controller.logging.ControllerLogger;
@@ -399,6 +400,11 @@ public ServiceName getCapabilityServiceName(String capabilityBaseName, String dy
serviceType, activeStep);
}
+ @Override
+ public CapabilityServiceSupport getCapabilityServiceSupport() {
+ return primaryContext.getCapabilityServiceSupport();
+ }
+
@Override
void releaseStepLocks(Step step) {
if(lockStep == step) {
diff --git a/controller/src/main/java/org/jboss/as/controller/ReadOnlyContext.java b/controller/src/main/java/org/jboss/as/controller/ReadOnlyContext.java
index c1cdc66f3aa..ae5d8448d4e 100644
--- a/controller/src/main/java/org/jboss/as/controller/ReadOnlyContext.java
+++ b/controller/src/main/java/org/jboss/as/controller/ReadOnlyContext.java
@@ -30,6 +30,7 @@
import org.jboss.as.controller.access.Action;
import org.jboss.as.controller.access.AuthorizationResult;
import org.jboss.as.controller.access.ResourceAuthorization;
+import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.MessageSeverity;
import org.jboss.as.controller.logging.ControllerLogger;
@@ -422,4 +423,9 @@ public ServiceName getCapabilityServiceName(String capabilityName, Class> type
public ServiceName getCapabilityServiceName(String capabilityBaseName, String dynamicPart, Class> serviceType) {
throw readOnlyContext();
}
+
+ @Override
+ public CapabilityServiceSupport getCapabilityServiceSupport() {
+ throw readOnlyContext();
+ }
}
diff --git a/controller/src/main/java/org/jboss/as/controller/capability/CapabilityServiceSupport.java b/controller/src/main/java/org/jboss/as/controller/capability/CapabilityServiceSupport.java
new file mode 100644
index 00000000000..465edd1a7ba
--- /dev/null
+++ b/controller/src/main/java/org/jboss/as/controller/capability/CapabilityServiceSupport.java
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2015, 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.
+ */
+
+package org.jboss.as.controller.capability;
+
+import org.jboss.msc.service.ServiceName;
+
+/**
+ * Provides support for capability integration outside the management layer,
+ * in service implementations.
+ *
+ * Note that use of this interface in no way creates a requirement on the
+ * referenced capability by the caller.
+ *
+ * @author Brian Stansberry
+ */
+public interface CapabilityServiceSupport {
+
+ /**
+ * Exception thrown when support for an unregistered capability is requested. This is a checked
+ * exception because {@code CapabilityServiceSupport} is used outside the management layer and
+ * the requirements for capability availability available in {@link org.jboss.as.controller.OperationContext}
+ * are not possible. So callers need to be aware of and handle non-existent capabilities.
+ */
+ class NoSuchCapabilityException extends Exception {
+
+ static final long serialVersionUID = 1L;
+
+ public NoSuchCapabilityException(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Gets the runtime API associated with a given capability, if there is one.
+ * @param capabilityName the name of the capability. Cannot be {@code null}
+ * @param apiType class of the java type that exposes the API. Cannot be {@code null}
+ * @param the java type that exposes the API
+ * @return the runtime API. Will not return {@code null}
+ *
+ * @throws NoSuchCapabilityException if no matching capability is registered
+ * @throws java.lang.IllegalArgumentException if the capability does not provide a runtime API
+ * @throws java.lang.ClassCastException if the runtime API exposed by the capability cannot be cast to type {code T}
+ */
+ T getCapabilityRuntimeAPI(String capabilityName, Class apiType) throws NoSuchCapabilityException;
+
+ /**
+ * Gets the runtime API associated with a given {@link RuntimeCapability#isDynamicallyNamed() dynamically named}
+ * capability, if there is one.
+ *
+ * @param capabilityBaseName the base name of the capability. Cannot be {@code null}
+ * @param dynamicPart the dynamic part of the capability name. Cannot be {@code null}
+ * @param apiType class of the java type that exposes the API. Cannot be {@code null}
+ * @param the java type that exposes the API
+ * @return the runtime API. Will not return {@code null}
+ *
+ * @throws NoSuchCapabilityException if no matching capability is registered
+ * @throws java.lang.IllegalArgumentException if the capability does not provide a runtime API
+ * @throws java.lang.ClassCastException if the runtime API exposed by the capability cannot be cast to type {code T}
+ */
+ T getCapabilityRuntimeAPI(String capabilityBaseName, String dynamicPart, Class apiType) throws NoSuchCapabilityException;
+
+ /**
+ * Gets the name of a service associated with a given capability. This method does not confirm that the
+ * capability is currently registered.
+ *
+ * @param capabilityName the name of the capability. Cannot be {@code null}
+ * @return the name of the service. Will not return {@code null}
+ */
+ ServiceName getCapabilityServiceName(String capabilityName);
+
+ /**
+ * Gets the name of a service associated with a given {@link RuntimeCapability#isDynamicallyNamed() dynamically named}
+ * capability. This method does not confirm that the capability is currently registered.
+ *
+ * @param capabilityBaseName the base name of the capability. Cannot be {@code null}
+ * @param dynamicPart the dynamic part of the capability name. Cannot be {@code null}
+ * @return the name of the service. Will not return {@code null}
+ */
+ ServiceName getCapabilityServiceName(String capabilityBaseName, String dynamicPart);
+}
diff --git a/controller/src/test/java/org/jboss/as/controller/access/management/AuthorizedAddressTest.java b/controller/src/test/java/org/jboss/as/controller/access/management/AuthorizedAddressTest.java
index 4f12af9d6b2..8a5b0dff854 100644
--- a/controller/src/test/java/org/jboss/as/controller/access/management/AuthorizedAddressTest.java
+++ b/controller/src/test/java/org/jboss/as/controller/access/management/AuthorizedAddressTest.java
@@ -43,6 +43,7 @@
import org.jboss.as.controller.access.Caller;
import org.jboss.as.controller.access.Environment;
import org.jboss.as.controller.access.ResourceAuthorization;
+import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.MessageSeverity;
import org.jboss.as.controller.notification.Notification;
@@ -550,6 +551,11 @@ public ServiceName getCapabilityServiceName(String capabilityBaseName, String dy
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
+ @Override
+ public CapabilityServiceSupport getCapabilityServiceSupport() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
@Override
public void emit(Notification notification) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
diff --git a/host-controller/src/test/java/org/jboss/as/domain/controller/operations/AbstractOperationTestCase.java b/host-controller/src/test/java/org/jboss/as/domain/controller/operations/AbstractOperationTestCase.java
index 07b0de8529e..a05ee3d8f3d 100644
--- a/host-controller/src/test/java/org/jboss/as/domain/controller/operations/AbstractOperationTestCase.java
+++ b/host-controller/src/test/java/org/jboss/as/domain/controller/operations/AbstractOperationTestCase.java
@@ -76,6 +76,7 @@
import org.jboss.as.controller.access.Environment;
import org.jboss.as.controller.access.ResourceAuthorization;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
+import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.client.MessageSeverity;
import org.jboss.as.controller.client.OperationAttachments;
@@ -684,6 +685,11 @@ public ServiceName getCapabilityServiceName(String capabilitBaseyName, String dy
return null;
}
+ @Override
+ public CapabilityServiceSupport getCapabilityServiceSupport() {
+ return null;
+ }
+
@Override
public void emit(Notification notification) {
// no-op
diff --git a/server/src/main/java/org/jboss/as/server/deployment/Attachments.java b/server/src/main/java/org/jboss/as/server/deployment/Attachments.java
index 5fe3e7e86fa..e5c5c461ab4 100644
--- a/server/src/main/java/org/jboss/as/server/deployment/Attachments.java
+++ b/server/src/main/java/org/jboss/as/server/deployment/Attachments.java
@@ -29,6 +29,7 @@
import java.util.jar.Manifest;
import org.jboss.as.controller.ServiceVerificationHandler;
+import org.jboss.as.controller.capability.CapabilityServiceSupport;
import org.jboss.as.controller.services.path.PathManager;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.as.server.deployment.module.AdditionalModuleSpecification;
@@ -204,11 +205,14 @@ public final class Attachments {
public static final AttachmentKey