Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MODE-1859 - Fixed the removal of ModeShape services when a repository…

… is removed. Refactored the general remove & recover operations, as they are very similar.
  • Loading branch information...
commit 88809fab2d4626e6b74c4fabce8ced29edb9fa9e 1 parent aee0a09
@hchiorean hchiorean authored
View
92 ...ystem/src/main/java/org/modeshape/jboss/subsystem/AbstractModeShapeRemoveStepHandler.java
@@ -0,0 +1,92 @@
+/*
+ * ModeShape (http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you 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.
+ *
+ * ModeShape 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.modeshape.jboss.subsystem;
+
+import java.util.List;
+import org.jboss.as.controller.AbstractRemoveStepHandler;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.dmr.ModelNode;
+import org.jboss.logging.Logger;
+import org.jboss.msc.service.ServiceName;
+import org.jboss.msc.service.ServiceRegistry;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+
+/**
+ * Base {@link AbstractRemoveStepHandler} which should be extended by all ModeShape subsystem services, as removal & recovery
+ * is similar for all.
+ *
+ * @author Horia Chiorean (hchiorea@redhat.com)
+ */
+abstract class AbstractModeShapeRemoveStepHandler extends AbstractRemoveStepHandler {
+
+ protected final Logger log = Logger.getLogger(getClass().getName());
+
+ @Override
+ protected void performRuntime( OperationContext context,
+ ModelNode operation,
+ ModelNode model ) throws OperationFailedException {
+ String repositoryName = null;
+
+ for (ServiceName serviceName : servicesToRemove(operation, model)) {
+ context.removeService(serviceName);
+ if (log.isDebugEnabled()) {
+ if (repositoryName == null) {
+ repositoryName = repositoryName(operation);
+ }
+ log.debugf("service '%s' removed for repository '%s'", serviceName, repositoryName);
+ }
+ }
+ }
+
+ @Override
+ protected void recoverServices( OperationContext context,
+ ModelNode operation,
+ ModelNode model ) throws OperationFailedException {
+ String repositoryName = null;
+
+ ServiceRegistry serviceRegistry = context.getServiceRegistry(false);
+ for (ServiceName serviceName : servicesToRemove(operation, model)) {
+ context.getServiceTarget().addService(serviceName, serviceRegistry.getService(serviceName).getService());
+ if (log.isDebugEnabled()) {
+ if (repositoryName == null) {
+ repositoryName = repositoryName(operation);
+ }
+ log.debugf("service '%s' recovered for repository '%s'", serviceName, repositoryName);
+ }
+ }
+ }
+
+ abstract List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model );
+
+ String repositoryName(ModelNode operation) {
+ // Get the service addresses ...
+ final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
+ // Get the repository name ...
+ return serviceAddress.getLastElement().getValue();
+ }
+}
View
10 ...odeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/AddRepository.java
@@ -65,11 +65,10 @@
public class AddRepository extends AbstractAddStepHandler {
- private static final org.jboss.logging.Logger LOG = org.jboss.logging.Logger.getLogger(AddRepository.class.getPackage()
- .getName());
-
public static final AddRepository INSTANCE = new AddRepository();
+ private static final org.jboss.logging.Logger LOG = org.jboss.logging.Logger.getLogger(AddRepository.class.getPackage()
+ .getName());
private AddRepository() {
}
@@ -223,8 +222,9 @@ protected void performRuntime( final OperationContext context,
// Set up the JNDI binder service ...
final ReferenceFactoryService<JcrRepository> referenceFactoryService = new ReferenceFactoryService<JcrRepository>();
- final ServiceName referenceFactoryServiceName = repositoryServiceName.append("reference-factory");
- final ServiceBuilder<?> referenceBuilder = target.addService(referenceFactoryServiceName, referenceFactoryService);
+ ServiceName referenceFactoryServiceName = ModeShapeServiceNames.referenceFactoryServiceName(repositoryName);
+ final ServiceBuilder<?> referenceBuilder = target.addService(referenceFactoryServiceName,
+ referenceFactoryService);
referenceBuilder.addDependency(repositoryServiceName, JcrRepository.class, referenceFactoryService.getInjector());
referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
View
25 ...-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/ModeShapeServiceNames.java
@@ -60,27 +60,30 @@ public static ServiceName dataDirectoryServiceName( String name ) {
/**
* Obtain the name of the service for the {@link IndexStorage} for the given repository name
*
- * @param name the repository name
+ * @param repositoryName the repository name
* @return the service name
*/
- public static ServiceName indexStorageServiceName( String name ) {
- return ServiceName.of(ServiceName.JBOSS, "modeshape", name, "indexes");
+ public static ServiceName indexStorageServiceName( String repositoryName ) {
+ return ServiceName.of(ServiceName.JBOSS, "modeshape", repositoryName, "indexes");
}
- public static ServiceName indexStorageDirectoryServiceName( String name ) {
- return ServiceName.of(ServiceName.JBOSS, "modeshape", name, "indexes.dir");
+ public static ServiceName indexStorageDirectoryServiceName( String repositoryName ) {
+ return ServiceName.of(ServiceName.JBOSS, "modeshape", repositoryName, "indexes.dir");
}
- public static ServiceName indexSourceStorageDirectoryServiceName( String name ) {
- return ServiceName.of(ServiceName.JBOSS, "modeshape", name, "indexes.source-dir");
+ public static ServiceName indexSourceStorageDirectoryServiceName( String repositoryName ) {
+ return ServiceName.of(ServiceName.JBOSS, "modeshape", repositoryName, "indexes.source-dir");
}
- public static ServiceName binaryStorageServiceName( String name ) {
- return ServiceName.of(ServiceName.JBOSS, "modeshape", name, "binaries");
+ public static ServiceName binaryStorageServiceName( String repositoryName ) {
+ return ServiceName.of(ServiceName.JBOSS, "modeshape", repositoryName, "binaries");
}
- public static ServiceName binaryStorageDirectoryServiceName( String name ) {
- return ServiceName.of(ServiceName.JBOSS, "modeshape", name, "binaries.dir");
+ public static ServiceName binaryStorageDirectoryServiceName( String repositoryName ) {
+ return ServiceName.of(ServiceName.JBOSS, "modeshape", repositoryName, "binaries.dir");
}
+ public static ServiceName referenceFactoryServiceName( String repositoryName ) {
+ return repositoryServiceName(repositoryName).append("reference-factory");
+ }
}
View
30 ...pe-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveAuthenticator.java
@@ -23,43 +23,29 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
+import java.util.Arrays;
+import java.util.List;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-class RemoveAuthenticator extends AbstractRemoveStepHandler {
-
- private static final Logger log = Logger.getLogger(RemoveAuthenticator.class.getPackage().getName());
+class RemoveAuthenticator extends AbstractModeShapeRemoveStepHandler {
- public static final RemoveAuthenticator INSTANCE = new RemoveAuthenticator();
+ static final RemoveAuthenticator INSTANCE = new RemoveAuthenticator();
private RemoveAuthenticator() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
// Get the service addresses ...
final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
// Get the repository name ...
final String authenticatorName = serviceAddress.getLastElement().getValue();
final String repositoryName = serviceAddress.getElement(1).getValue();
- // Remove the service ...
- final ServiceName serviceName = ModeShapeServiceNames.authenticatorServiceName(repositoryName, authenticatorName);
- context.removeService(serviceName);
- log.debugf("authenticator '%s' removed for repository '%s'", authenticatorName, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ return Arrays.asList(ModeShapeServiceNames.authenticatorServiceName(repositoryName, authenticatorName));
}
}
View
45 ...pe-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveBinaryStorage.java
@@ -23,52 +23,33 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.PathAddress;
+import java.util.ArrayList;
+import java.util.List;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
-class RemoveBinaryStorage extends AbstractRemoveStepHandler {
+class RemoveBinaryStorage extends AbstractModeShapeRemoveStepHandler {
- protected static final Logger log = Logger.getLogger(RemoveBinaryStorage.class.getPackage().getName());
-
- public static final RemoveBinaryStorage INSTANCE = new RemoveBinaryStorage();
+ static final RemoveBinaryStorage INSTANCE = new RemoveBinaryStorage();
private RemoveBinaryStorage() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // Get the service addresses ...
- final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
- // Get the repository name ...
- final String repositoryName = serviceAddress.getElement(1).getValue();
- final ServiceName serviceName = ModeShapeServiceNames.binaryStorageServiceName(repositoryName);
-
- // Simply remove all services started by any/all of the Add*BinaryStorage operations ...
- context.removeService(serviceName);
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
+ String repositoryName = repositoryName(operation);
+ List<ServiceName> servicesToRemove = new ArrayList<ServiceName>();
+ servicesToRemove.add(ModeShapeServiceNames.binaryStorageServiceName(repositoryName));
- // Now see if we need to remove the path service ...
+ //see if we need to remove the path service ...
if (model.has(ModelKeys.RELATIVE_TO)
- && model.get(ModelKeys.RELATIVE_TO).asString().contains(AddFileBinaryStorage.DATA_DIR_VARIABLE)) {
+ && model.get(ModelKeys.RELATIVE_TO).asString().contains(AddFileBinaryStorage.DATA_DIR_VARIABLE)) {
// The binaries were stored in the data directory, so we need to remove the path service ...
ServiceName dirServiceName = ModeShapeServiceNames.binaryStorageDirectoryServiceName(repositoryName);
- context.removeService(dirServiceName);
+ servicesToRemove.add(dirServiceName);
}
- String service = serviceAddress.getLastElement().getValue();
- log.debugf("binary storage '%s' removed for repository '%s'", service, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ return servicesToRemove;
}
}
View
51 ...ape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveIndexStorage.java
@@ -23,58 +23,35 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.PathAddress;
+import java.util.ArrayList;
+import java.util.List;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
-class RemoveIndexStorage extends AbstractRemoveStepHandler {
+class RemoveIndexStorage extends AbstractModeShapeRemoveStepHandler {
- protected static final Logger log = Logger.getLogger(RemoveIndexStorage.class.getPackage().getName());
-
- public static final RemoveIndexStorage INSTANCE = new RemoveIndexStorage();
+ static final RemoveIndexStorage INSTANCE = new RemoveIndexStorage();
private RemoveIndexStorage() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // Get the service addresses ...
- final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
- // Get the repository name ...
- final String repositoryName = serviceAddress.getElement(1).getValue();
- final ServiceName serviceName = ModeShapeServiceNames.indexStorageServiceName(repositoryName);
-
- // Simply remove all services started by any/all of the Add*IndexStorage operations ...
- context.removeService(serviceName);
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
+ String repositoryName = repositoryName(operation);
+ List<ServiceName> servicesToRemove = new ArrayList<ServiceName>();
+ servicesToRemove.add(ModeShapeServiceNames.indexStorageServiceName(repositoryName));
// Now see if we need to remove the path service ...
if (model.has(ModelKeys.RELATIVE_TO)
- && model.get(ModelKeys.RELATIVE_TO).asString().contains(AddLocalFileSystemIndexStorage.DATA_DIR_VARIABLE)) {
- // The binaries were stored in the data directory, so we need to remove the path service ...
- ServiceName dirServiceName = ModeShapeServiceNames.indexStorageDirectoryServiceName(repositoryName);
- context.removeService(dirServiceName);
+ && model.get(ModelKeys.RELATIVE_TO).asString().contains(AddLocalFileSystemIndexStorage.DATA_DIR_VARIABLE)) {
+ servicesToRemove.add(ModeShapeServiceNames.indexStorageDirectoryServiceName(repositoryName));
}
if (model.has(ModelKeys.SOURCE_RELATIVE_TO)
- && model.get(ModelKeys.SOURCE_RELATIVE_TO).asString().contains(AddLocalFileSystemIndexStorage.DATA_DIR_VARIABLE)) {
- // The binaries were stored in the data directory, so we need to remove the path service ...
- ServiceName dirServiceName = ModeShapeServiceNames.indexStorageDirectoryServiceName(repositoryName);
- context.removeService(dirServiceName);
+ && model.get(ModelKeys.SOURCE_RELATIVE_TO).asString().contains(AddLocalFileSystemIndexStorage.DATA_DIR_VARIABLE)) {
+ servicesToRemove.add(ModeShapeServiceNames.indexSourceStorageDirectoryServiceName(repositoryName));
}
- String service = serviceAddress.getLastElement().getValue();
- log.debugf("index storage '%s' removed for repository '%s'", service, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ return servicesToRemove;
}
}
View
48 ...shape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveRepository.java
@@ -23,53 +23,33 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
-import org.jboss.as.controller.PathAddress;
+import java.util.Arrays;
+import java.util.List;
import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
-class RemoveRepository extends AbstractRemoveStepHandler {
+class RemoveRepository extends AbstractModeShapeRemoveStepHandler {
- private static final Logger log = Logger.getLogger(RemoveRepository.class.getPackage().getName());
-
- public static final RemoveRepository INSTANCE = new RemoveRepository();
+ static final RemoveRepository INSTANCE = new RemoveRepository();
private RemoveRepository() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // Get the service addresses ...
- final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
- // Get the repository name ...
- final String repositoryName = serviceAddress.getLastElement().getValue();
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
+ String repositoryName = repositoryName(operation);
- // Remove the JNDI binder service
final String jndiName = ModeShapeJndiNames.jndiNameFrom(model, repositoryName);
ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
- context.removeService(bindInfo.getBinderServiceName());
-
- // Remove the repository service ...
- final ServiceName serviceName = ModeShapeServiceNames.repositoryServiceName(repositoryName);
- context.removeService(serviceName);
-
- // Remove the data path service added by the AddRepository ...
- final ServiceName dataDirServiceName = ModeShapeServiceNames.dataDirectoryServiceName(repositoryName);
- context.removeService(dataDirServiceName);
- log.debugf("repository '%s' removed", repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ return Arrays.asList(ModeShapeServiceNames.referenceFactoryServiceName(repositoryName),
+ bindInfo.getBinderServiceName(),
+ ModeShapeServiceNames.referenceFactoryServiceName(repositoryName),
+ ModeShapeServiceNames.indexStorageServiceName(repositoryName),
+ ModeShapeServiceNames.binaryStorageServiceName(repositoryName),
+ ModeShapeServiceNames.repositoryServiceName(repositoryName),
+ ModeShapeServiceNames.dataDirectoryServiceName(repositoryName));
}
}
View
32 ...eshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveSequencer.java
@@ -23,43 +23,27 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
+import java.util.Arrays;
+import java.util.List;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-class RemoveSequencer extends AbstractRemoveStepHandler {
-
- private static final Logger log = Logger.getLogger(RemoveSequencer.class.getPackage().getName());
+class RemoveSequencer extends AbstractModeShapeRemoveStepHandler {
- public static final RemoveSequencer INSTANCE = new RemoveSequencer();
+ static final RemoveSequencer INSTANCE = new RemoveSequencer();
private RemoveSequencer() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
// Get the service addresses ...
final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
- // Get the repository name ...
final String sequencerName = serviceAddress.getLastElement().getValue();
- final String repositoryName = serviceAddress.getElement(1).getValue();
- // Remove the service ...
- final ServiceName serviceName = ModeShapeServiceNames.sequencerServiceName(repositoryName, sequencerName);
- context.removeService(serviceName);
- log.debugf("sequencer '%s' removed for repository '%s'", sequencerName, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ return Arrays.asList(ModeShapeServiceNames.sequencerServiceName(repositoryName(operation), sequencerName));
}
}
View
29 ...modeshape-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveSource.java
@@ -23,11 +23,11 @@
*/
package org.modeshape.jboss.subsystem;
+import java.util.Arrays;
+import java.util.List;
import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
@@ -36,35 +36,18 @@
*
* @author Horia Chiorean
*/
-public class RemoveSource extends AbstractRemoveStepHandler {
+class RemoveSource extends AbstractModeShapeRemoveStepHandler {
static final RemoveSource INSTANCE = new RemoveSource();
- private static final Logger LOGGER = Logger.getLogger(RemoveSource.class.getPackage().getName());
-
private RemoveSource() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // Get the service addresses ...
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
- // Get the repository name ...
final String sourceName = serviceAddress.getLastElement().getValue();
- final String repositoryName = serviceAddress.getElement(1).getValue();
- // Remove the service ...
- final ServiceName serviceName = ModeShapeServiceNames.sourceServiceName(repositoryName, sourceName);
- context.removeService(serviceName);
-
- LOGGER.debugf("sequencer '%s' removed for repository '%s'", sourceName, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- //TODO author=Horia Chiorean date=12/27/12 description=Re-add service
+ return Arrays.asList(ModeShapeServiceNames.sourceServiceName(repositoryName(operation), sourceName));
}
}
View
34 ...pe-jbossas-subsystem/src/main/java/org/modeshape/jboss/subsystem/RemoveTextExtractor.java
@@ -23,43 +23,27 @@
*/
package org.modeshape.jboss.subsystem;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-import org.jboss.as.controller.AbstractRemoveStepHandler;
-import org.jboss.as.controller.OperationContext;
+import java.util.Arrays;
+import java.util.List;
import org.jboss.as.controller.PathAddress;
import org.jboss.dmr.ModelNode;
-import org.jboss.logging.Logger;
import org.jboss.msc.service.ServiceName;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
-class RemoveTextExtractor extends AbstractRemoveStepHandler {
-
- private static final Logger log = Logger.getLogger(RemoveTextExtractor.class.getPackage().getName());
+class RemoveTextExtractor extends AbstractModeShapeRemoveStepHandler {
- public static final RemoveTextExtractor INSTANCE = new RemoveTextExtractor();
+ static final RemoveTextExtractor INSTANCE = new RemoveTextExtractor();
private RemoveTextExtractor() {
}
@Override
- protected void performRuntime( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
+ List<ServiceName> servicesToRemove( ModelNode operation,
+ ModelNode model ) {
// Get the service addresses ...
final PathAddress serviceAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
// Get the repository name ...
- final String sequencerName = serviceAddress.getLastElement().getValue();
- final String repositoryName = serviceAddress.getElement(1).getValue();
- // Remove the service ...
- final ServiceName serviceName = ModeShapeServiceNames.textExtractorServiceName(repositoryName, sequencerName);
- context.removeService(serviceName);
-
- log.debugf("extractor '%s' removed for repository '%s'", sequencerName, repositoryName);
- }
-
- @Override
- protected void recoverServices( OperationContext context,
- ModelNode operation,
- ModelNode model ) {
- // TODO: RE-ADD SERVICES
+ final String textExtractorName = serviceAddress.getLastElement().getValue();
+ return Arrays.asList(ModeShapeServiceNames.textExtractorServiceName(repositoryName(operation), textExtractorName));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.