protected KeycloakSubsystemDefinition() { super(KeycloakExtension.PATH_SUBSYSTEM, KeycloakExtension.getResourceDescriptionResolver("subsystem"), KeycloakSubsystemAdd.INSTANCE, KeycloakSubsystemRemoveHandler.INSTANCE ); }
ServerUtil(ModelNode operation) { this.deploymentName = getDeploymentName(operation); this.subsysModule = findSubsysModule(); this.serverWar = findServerWarUri(); }
static void addStepToRedeployServerWar(OperationContext context, String deploymentName) { addDeploymentAction(context, REDEPLOY, deploymentName); }
@Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String deploymentName = ServerUtil.getDeploymentName(operation); KeycloakAdapterConfigService.INSTANCE.setWebContext(null); if (requiresRuntime(context)) { // don't do this on a domain controller addStepToRemoveServerWar(context, deploymentName); } super.performRemove(context, operation, model); }
@Override protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { if (!context.isNormalServer() || attribNotChanging(attributeName, newValue, oldValue)) { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); return; } String deploymentName = ServerUtil.getDeploymentName(operation); if (attributeName.equals(KeycloakSubsystemDefinition.WEB_CONTEXT.getName())) { KeycloakAdapterConfigService.INSTANCE.setWebContext(newValue.asString()); ServerUtil.addStepToRedeployServerWar(context, deploymentName); } super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); }
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); // set attribute values from parsed model for (AttributeDefinition attrDef : KeycloakSubsystemDefinition.ALL_ATTRIBUTES) { attrDef.validateAndSet(operation, model); } // returns early if on domain controller if (!requiresRuntime(context)) { return; } // don't want to try to start server on host controller if (!context.isNormalServer()) { return; } ModelNode webContextNode = resource.getModel().get(KeycloakSubsystemDefinition.WEB_CONTEXT.getName()); if (!webContextNode.isDefined()) { webContextNode = KeycloakSubsystemDefinition.WEB_CONTEXT.getDefaultValue(); } String webContext = webContextNode.asString(); ServerUtil serverUtil = new ServerUtil(operation); serverUtil.addStepToUploadServerWar(context); KeycloakAdapterConfigService.INSTANCE.setWebContext(webContext); } }
private static void addDeploymentAction(OperationContext context, String operation, String deploymentName) { if (!context.isNormalServer()) { return; } PathAddress deploymentAddress = deploymentAddress(deploymentName); ModelNode op = Util.createOperation(operation, deploymentAddress); op.get(RUNTIME_NAME).set(deploymentName); context.addStep(op, getHandler(context, deploymentAddress, operation), OperationContext.Stage.MODEL); }
@Override protected void execute(DeploymentProcessorTarget processorTarget) { processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, Phase.POST_MODULE, // PHASE Phase.POST_MODULE_VALIDATOR_FACTORY - 1, // PRIORITY new KeycloakServerDeploymentProcessor()); } }, OperationContext.Stage.RUNTIME);
/** * {@inheritDoc} */ @Override public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { context.startSubsystemElement(KeycloakExtension.NAMESPACE, false); writeWebContext(writer, context); writer.writeEndElement(); }
private boolean attribNotChanging(String attributeName, ModelNode newValue, ModelNode oldValue) { SimpleAttributeDefinition attribDef = KeycloakSubsystemDefinition.lookup(attributeName); if (!oldValue.isDefined()) { oldValue = attribDef.getDefaultValue(); } if (!newValue.isDefined()) { newValue = attribDef.getDefaultValue(); } return newValue.equals(oldValue); } }
private void addStepToRemoveServerWar(OperationContext context, String deploymentName) { PathAddress deploymentAddress = PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT, deploymentName)); ModelNode op = Util.createOperation(REMOVE, deploymentAddress); context.addStep(op, getRemoveHandler(context, deploymentAddress), OperationContext.Stage.MODEL); }
@Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String deploymentName = ServerUtil.getDeploymentName(operation); KeycloakAdapterConfigService.INSTANCE.setWebContext(null); if (requiresRuntime(context)) { // don't do this on a domain controller addStepToRemoveServerWar(context, deploymentName); } super.performRemove(context, operation, model); }
@Override protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { if (!context.isNormalServer() || attribNotChanging(attributeName, newValue, oldValue)) { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); return; } String deploymentName = ServerUtil.getDeploymentName(operation); if (attributeName.equals(KeycloakSubsystemDefinition.WEB_CONTEXT.getName())) { KeycloakAdapterConfigService.INSTANCE.setWebContext(newValue.asString()); ServerUtil.addStepToRedeployServerWar(context, deploymentName); } super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); }
ServerUtil(ModelNode operation) { this.deploymentName = getDeploymentName(operation); this.subsysModule = findSubsysModule(); this.serverWar = findServerWarUri(); }
private static void addDeploymentAction(OperationContext context, String operation, String deploymentName) { if (!context.isNormalServer()) { return; } PathAddress deploymentAddress = deploymentAddress(deploymentName); ModelNode op = Util.createOperation(operation, deploymentAddress); op.get(RUNTIME_NAME).set(deploymentName); context.addStep(op, getHandler(context, deploymentAddress, operation), OperationContext.Stage.MODEL); }
protected KeycloakSubsystemDefinition() { super(KeycloakExtension.PATH_SUBSYSTEM, KeycloakExtension.getResourceDescriptionResolver("subsystem"), KeycloakSubsystemAdd.INSTANCE, KeycloakSubsystemRemoveHandler.INSTANCE ); }
static void addStepToRedeployServerWar(OperationContext context, String deploymentName) { addDeploymentAction(context, REDEPLOY, deploymentName); }
@Override protected void execute(DeploymentProcessorTarget processorTarget) { processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, Phase.POST_MODULE, // PHASE Phase.POST_MODULE_VALIDATOR_FACTORY - 1, // PRIORITY new KeycloakServerDeploymentProcessor()); } }, OperationContext.Stage.RUNTIME);
/** * {@inheritDoc} */ @Override public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { context.startSubsystemElement(KeycloakExtension.NAMESPACE, false); writeWebContext(writer, context); writer.writeEndElement(); }
private boolean attribNotChanging(String attributeName, ModelNode newValue, ModelNode oldValue) { SimpleAttributeDefinition attribDef = KeycloakSubsystemDefinition.lookup(attributeName); if (!oldValue.isDefined()) { oldValue = attribDef.getDefaultValue(); } if (!newValue.isDefined()) { newValue = attribDef.getDefaultValue(); } return newValue.equals(oldValue); } }