use of org.jboss.as.controller.descriptions.OverrideDescriptionProvider in project wildfly by wildfly.
the class ParsedRaDeploymentProcessor method deploy.
/**
* Process a deployment for a Connector. Will install a {@Code
* JBossService} for this ResourceAdapter.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ConnectorXmlDescriptor connectorXmlDescriptor = deploymentUnit.getAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY);
final ManagementResourceRegistration registration;
final ManagementResourceRegistration baseRegistration = deploymentUnit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
final Resource deploymentResource = deploymentUnit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (connectorXmlDescriptor == null) {
return;
}
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
if (deploymentUnit.getParent() != null) {
registration = baseRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement("subdeployment")));
} else {
registration = baseRegistration;
}
final IronJacamarXmlDescriptor ironJacamarXmlDescriptor = deploymentUnit.getAttachment(IronJacamarXmlDescriptor.ATTACHMENT_KEY);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
DEPLOYMENT_CONNECTOR_LOGGER.debugf("ParsedRaDeploymentProcessor: Processing=%s", deploymentUnit);
final ClassLoader classLoader = module.getClassLoader();
Map<ResourceRoot, Index> annotationIndexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);
ServiceBuilder builder = process(connectorXmlDescriptor, ironJacamarXmlDescriptor, classLoader, serviceTarget, annotationIndexes, deploymentUnit.getServiceName(), registration, deploymentResource, support);
if (builder != null) {
String bootstrapCtx = null;
if (ironJacamarXmlDescriptor != null && ironJacamarXmlDescriptor.getIronJacamar() != null && ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext() != null)
bootstrapCtx = ironJacamarXmlDescriptor.getIronJacamar().getBootstrapContext();
if (bootstrapCtx == null)
bootstrapCtx = "default";
builder.requires(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootstrapCtx));
// Register an empty override model regardless of we're enabled or not - the statistics listener will add the relevant childresources
if (registration.isAllowsOverride() && registration.getOverrideModel(deploymentUnit.getName()) == null) {
registration.registerOverrideModel(deploymentUnit.getName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
}
builder.setInitialMode(Mode.ACTIVE).install();
}
}
use of org.jboss.as.controller.descriptions.OverrideDescriptionProvider in project wildfly by wildfly.
the class ForkProtocolResourceRegistrationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
String protocolName = context.getCurrentAddressValue();
String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, operation).asString();
Class<? extends Protocol> protocolClass = ProtocolResourceRegistrationHandler.findProtocolClass(context, protocolName, moduleName);
final Map<String, Attribute> attributes = ProtocolMetricsHandler.findProtocolAttributes(protocolClass);
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
Map<String, ModelNode> result = new HashMap<>();
for (Attribute attribute : attributes.values()) {
ModelNode value = new ModelNode();
value.get(ModelDescriptionConstants.DESCRIPTION).set(attribute.getDescription());
result.put(attribute.getName(), value);
}
return result;
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
};
ManagementResourceRegistration protocolRegistration = registration.registerOverrideModel(protocolName, provider);
ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this);
for (Attribute attribute : attributes.values()) {
String name = attribute.getName();
FieldType type = FieldType.valueOf(attribute.getType());
protocolRegistration.registerMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType()).setStorageRuntime().build(), handler);
}
}
use of org.jboss.as.controller.descriptions.OverrideDescriptionProvider in project wildfly by wildfly.
the class ForkProtocolRuntimeResourceRegistration method register.
@Override
public void register(OperationContext context) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
String protocolName = context.getCurrentAddressValue();
String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, resource.getModel()).asString();
Class<? extends Protocol> protocolClass = ChannelRuntimeResourceRegistration.findProtocolClass(context, protocolName, moduleName);
Map<String, Attribute> attributes = ProtocolMetricsHandler.findProtocolAttributes(protocolClass);
// If this is a wildcard registration, create an override model registration with which to register protocol-specific metrics
if (registration.getPathAddress().getLastElement().isWildcard()) {
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
Map<String, ModelNode> result = new HashMap<>();
for (Attribute attribute : attributes.values()) {
ModelNode value = new ModelNode();
value.get(ModelDescriptionConstants.DESCRIPTION).set(attribute.getDescription());
result.put(attribute.getName(), value);
}
return result;
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
};
registration = registration.registerOverrideModel(protocolName, provider);
}
ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this.executors);
for (Attribute attribute : attributes.values()) {
String name = attribute.getName();
FieldType type = FieldType.valueOf(attribute.getType());
registration.registerMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType()).setStorageRuntime().build(), handler);
}
}
Aggregations