final void removePathEntry(final String pathName, boolean check) throws OperationFailedException{ synchronized (pathEntries) { PathEntry pathEntry = pathEntries.get(pathName); if (pathEntry.isReadOnly()) { throw MESSAGES.pathEntryIsReadOnly(pathName); } Set<String> dependents = dependenctRelativePaths.get(pathName); if (check && dependents != null) { throw MESSAGES.cannotRemovePathWithDependencies(pathName, dependents); } pathEntries.remove(pathName); triggerCallbacksForEvent(pathEntry, Event.REMOVED); if (pathEntry.getRelativeTo() != null) { dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); if (dependents != null) { dependents.remove(pathEntry.getName()); if (dependents.size() == 0) { dependenctRelativePaths.remove(pathEntry.getRelativeTo()); } } } } }
final void removePathEntry(final String pathName, boolean check) throws OperationFailedException{ synchronized (pathEntries) { PathEntry pathEntry = pathEntries.get(pathName); if (pathEntry.isReadOnly()) { throw MESSAGES.pathEntryIsReadOnly(pathName); } Set<String> dependents = dependenctRelativePaths.get(pathName); if (check && dependents != null) { throw MESSAGES.cannotRemovePathWithDependencies(pathName, dependents); } pathEntries.remove(pathName); triggerCallbacksForEvent(pathEntry, Event.REMOVED); if (pathEntry.getRelativeTo() != null) { dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); if (dependents != null) { dependents.remove(pathEntry.getName()); if (dependents.size() == 0) { dependenctRelativePaths.remove(pathEntry.getRelativeTo()); } } } } }
if (pathEntry.getRelativeTo() != null) { dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); if (dependents != null) { dependents.remove(pathEntry.getName()); if (dependents.size() == 0) { dependenctRelativePaths.remove(pathEntry.getRelativeTo());
if (pathEntry.getRelativeTo() != null) { dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); if (dependents != null) { dependents.remove(pathEntry.getName()); if (dependents.size() == 0) { dependenctRelativePaths.remove(pathEntry.getRelativeTo());
final void changeRelativePath(String pathName, String relativePath, boolean check) throws OperationFailedException { PathEntry pathEntry = findPathEntry(pathName); synchronized (pathEntries) { if (pathEntry.getRelativeTo() != null) { Set<String> dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); dependents.remove(pathEntry.getName()); } if (check && relativePath != null && pathEntries.get(relativePath) == null) { throw MESSAGES.pathEntryNotFound(pathName); } pathEntry.setRelativeTo(relativePath); pathEntry.setPathResolver(relativePath == null ? absoluteResolver : relativeResolver); addDependent(pathEntry.getName(), pathEntry.getRelativeTo()); } triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
final void changeRelativePath(String pathName, String relativePath, boolean check) throws OperationFailedException { PathEntry pathEntry = findPathEntry(pathName); synchronized (pathEntries) { if (pathEntry.getRelativeTo() != null) { Set<String> dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); dependents.remove(pathEntry.getName()); } if (check && relativePath != null && pathEntries.get(relativePath) == null) { throw MESSAGES.pathEntryNotFound(pathName); } pathEntry.setRelativeTo(relativePath); pathEntry.setPathResolver(relativePath == null ? absoluteResolver : relativeResolver); addDependent(pathEntry.getName(), pathEntry.getRelativeTo()); } triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
/** * Updates the {@link PathEntry#getRelativeTo() relative to} value for an entry and sends an * {@link org.jboss.as.controller.services.path.PathManager.Event#UPDATED} * notification to any registered * {@linkplain org.jboss.as.controller.services.path.PathManager.Callback#pathEvent(Event, PathEntry) callbacks}. * @param pathName the logical name of the path within the model. Cannot be {@code null} * @param relativePath the new name of the path this path is relative to. If {@code null} this is an absolute path * @param check {@code true} if a check for the existence of an entry for the new {@code relativePath} value * should be performed * @throws OperationFailedException if {@code check} is {@code true} and no path exists whose name matches {@code relativePath} */ final void changeRelativePath(String pathName, String relativePath, boolean check) throws OperationFailedException { PathEntry pathEntry = findPathEntry(pathName); synchronized (pathEntries) { if (check && relativePath != null && pathEntries.get(relativePath) == null) { // TODO per method signature and usage in PathWriteAttributeHandler this should throw OFE. // But leave it for now as a better way to deal with this is to have capabilities for paths // and use capability resolution to detect invalid references throw ControllerLogger.ROOT_LOGGER.pathEntryNotFound(pathName); } if (pathEntry.getRelativeTo() != null) { Set<String> dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); dependents.remove(pathEntry.getName()); } pathEntry.setRelativeTo(relativePath); pathEntry.setPathResolver(relativePath == null ? absoluteResolver : relativeResolver); addDependent(pathEntry.getName(), pathEntry.getRelativeTo()); } triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
/** * Updates the {@link PathEntry#getRelativeTo() relative to} value for an entry and sends an * {@link org.jboss.as.controller.services.path.PathManager.Event#UPDATED} * notification to any registered * {@linkplain org.jboss.as.controller.services.path.PathManager.Callback#pathEvent(Event, PathEntry) callbacks}. * @param pathName the logical name of the path within the model. Cannot be {@code null} * @param relativePath the new name of the path this path is relative to. If {@code null} this is an absolute path * @param check {@code true} if a check for the existence of an entry for the new {@code relativePath} value * should be performed * @throws OperationFailedException if {@code check} is {@code true} and no path exists whose name matches {@code relativePath} */ final void changeRelativePath(String pathName, String relativePath, boolean check) throws OperationFailedException { PathEntry pathEntry = findPathEntry(pathName); synchronized (pathEntries) { if (check && relativePath != null && pathEntries.get(relativePath) == null) { // TODO per method signature and usage in PathWriteAttributeHandler this should throw OFE. // But leave it for now as a better way to deal with this is to have capabilities for paths // and use capability resolution to detect invalid references throw ControllerLogger.ROOT_LOGGER.pathEntryNotFound(pathName); } if (pathEntry.getRelativeTo() != null) { Set<String> dependents = dependenctRelativePaths.get(pathEntry.getRelativeTo()); dependents.remove(pathEntry.getName()); } pathEntry.setRelativeTo(relativePath); pathEntry.setPathResolver(relativePath == null ? absoluteResolver : relativeResolver); addDependent(pathEntry.getName(), pathEntry.getRelativeTo()); } triggerCallbacksForEvent(pathEntry, Event.UPDATED); }
final void changePathServices(final OperationContext operationContext, String pathName, String path, ServiceVerificationHandler verificationHandler) { PathEntry pathEntry = findPathEntry(pathName); removePathService(operationContext, pathName); if (pathEntry.getRelativeTo() == null) { addAbsolutePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, verificationHandler); } else { addRelativePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, false, pathEntry.getRelativeTo(), verificationHandler); } }
final void changePathServices(final OperationContext operationContext, String pathName, String path) { PathEntry pathEntry = findPathEntry(pathName); removePathService(operationContext, pathName); if (pathEntry.getRelativeTo() == null) { addAbsolutePathService(operationContext.getServiceTarget(), pathEntry.getName(), path); } else { addRelativePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, false, pathEntry.getRelativeTo()); } }
final void changePathServices(final OperationContext operationContext, String pathName, String path) { PathEntry pathEntry = findPathEntry(pathName); removePathService(operationContext, pathName); if (pathEntry.getRelativeTo() == null) { addAbsolutePathService(operationContext.getServiceTarget(), pathEntry.getName(), path); } else { addRelativePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, false, pathEntry.getRelativeTo()); } }
final void changePathServices(final OperationContext operationContext, String pathName, String path, ServiceVerificationHandler verificationHandler) { PathEntry pathEntry = findPathEntry(pathName); removePathService(operationContext, pathName); if (pathEntry.getRelativeTo() == null) { addAbsolutePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, verificationHandler); } else { addRelativePathService(operationContext.getServiceTarget(), pathEntry.getName(), path, false, pathEntry.getRelativeTo(), verificationHandler); } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, PathUpdate handback) throws OperationFailedException { final String pathName = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue(); final PathEntry backup = handback.backup; final PathEventContextImpl pathEventContext = handback.context; if (pathEventContext.isInstallServices()) { if (attributeName.equals(PATH)) { pathManager.changePath(pathName, backup.getPath()); pathManager.changePathServices(context, pathName, valueToRestore.asString(), null); } else if (attributeName.equals(RELATIVE_TO)) { try { pathManager.changeRelativePath(pathName, backup.getRelativeTo(), false); } catch (OperationFailedException e) { //Should not happen since false passed in for the 'check' parameter throw new RuntimeException(e); } pathManager.changeRelativePathServices(context, pathName, valueToRestore.isDefined() ? valueToRestore.asString() : null, null); } } else { pathEventContext.revert(); } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, PathUpdate handback) throws OperationFailedException { final String pathName = context.getCurrentAddressValue(); final PathEntry backup = handback.backup; final PathEventContextImpl pathEventContext = handback.context; if (pathEventContext.isInstallServices()) { if (attributeName.equals(PATH)) { pathManager.changePath(pathName, backup.getPath()); pathManager.changePathServices(context, pathName, valueToRestore.asString()); } else if (attributeName.equals(RELATIVE_TO)) { try { pathManager.changeRelativePath(pathName, backup.getRelativeTo(), false); } catch (OperationFailedException e) { //Should not happen since false passed in for the 'check' parameter throw new RuntimeException(e); } pathManager.changeRelativePathServices(context, pathName, valueToRestore.isDefined() ? valueToRestore.asString() : null); } } else { pathEventContext.revert(); } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, PathUpdate handback) throws OperationFailedException { final String pathName = context.getCurrentAddressValue(); final PathEntry backup = handback.backup; final PathEventContextImpl pathEventContext = handback.context; if (pathEventContext.isInstallServices()) { if (attributeName.equals(PATH)) { pathManager.changePath(pathName, backup.getPath()); pathManager.changePathServices(context, pathName, valueToRestore.asString()); } else if (attributeName.equals(RELATIVE_TO)) { try { pathManager.changeRelativePath(pathName, backup.getRelativeTo(), false); } catch (OperationFailedException e) { //Should not happen since false passed in for the 'check' parameter throw new RuntimeException(e); } pathManager.changeRelativePathServices(context, pathName, valueToRestore.isDefined() ? valueToRestore.asString() : null); } } else { pathEventContext.revert(); } }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, PathUpdate handback) throws OperationFailedException { final String pathName = PathAddress.pathAddress(operation.get(OP_ADDR)).getLastElement().getValue(); final PathEntry backup = handback.backup; final PathEventContextImpl pathEventContext = handback.context; if (pathEventContext.isInstallServices()) { if (attributeName.equals(PATH)) { pathManager.changePath(pathName, backup.getPath()); pathManager.changePathServices(context, pathName, valueToRestore.asString(), null); } else if (attributeName.equals(RELATIVE_TO)) { try { pathManager.changeRelativePath(pathName, backup.getRelativeTo(), false); } catch (OperationFailedException e) { //Should not happen since false passed in for the 'check' parameter throw new RuntimeException(e); } pathManager.changeRelativePathServices(context, pathName, valueToRestore.isDefined() ? valueToRestore.asString() : null, null); } } else { pathEventContext.revert(); } }