/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2017, 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.clustering.controller;

import java.util.function.Function;

import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.ModelVersionRange;
import org.jboss.as.controller.ResourceDefinition;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.persistence.SubsystemMarshallingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.transform.CombinedTransformer;
import org.jboss.as.controller.transform.OperationTransformer;
import org.jboss.as.controller.transform.ResourceTransformer;
import org.jboss.as.controller.transform.TransformersSubRegistration;
import org.jboss.staxmapper.XMLElementWriter;

/**
 * Generic {@link SubsystemRegistration} decorator.
 * @author Paul Ferraro
 */
public class DecoratingSubsystemRegistration<R extends ManagementResourceRegistration> implements SubsystemRegistration {

    private final SubsystemRegistration registration;
    private final Function<ManagementResourceRegistration, R> decorator;

    public DecoratingSubsystemRegistration(SubsystemRegistration registration, Function<ManagementResourceRegistration, R> decorator) {
        this.registration = registration;
        this.decorator = decorator;
    }

    @Override
    public void setHostCapable() {
        this.registration.setHostCapable();
    }

    @Deprecated
    @Override
    public void registerXMLElementWriter(XMLElementWriter<SubsystemMarshallingContext> writer) {
        this.registration.registerXMLElementWriter(writer);
    }

    @Deprecated
    @Override
    public TransformersSubRegistration registerModelTransformers(ModelVersionRange version, ResourceTransformer resourceTransformer) {
        return this.registration.registerModelTransformers(version, resourceTransformer);
    }

    @Deprecated
    @Override
    public TransformersSubRegistration registerModelTransformers(ModelVersionRange version, ResourceTransformer resourceTransformer, OperationTransformer operationTransformer) {
        return this.registration.registerModelTransformers(version, resourceTransformer, operationTransformer);
    }

    @Deprecated
    @Override
    public TransformersSubRegistration registerModelTransformers(ModelVersionRange version, ResourceTransformer resourceTransformer, OperationTransformer operationTransformer, boolean placeholder) {
        return this.registration.registerModelTransformers(version, resourceTransformer, operationTransformer, placeholder);
    }

    @Deprecated
    @Override
    public TransformersSubRegistration registerModelTransformers(ModelVersionRange version, CombinedTransformer combinedTransformer) {
        return this.registration.registerModelTransformers(version, combinedTransformer);
    }

    @Override
    public ModelVersion getSubsystemVersion() {
        return this.registration.getSubsystemVersion();
    }

    @Override
    public R registerSubsystemModel(ResourceDefinition definition) {
        return this.decorator.apply(this.registration.registerSubsystemModel(definition));
    }

    @Override
    public R registerDeploymentModel(ResourceDefinition definition) {
        return this.decorator.apply(this.registration.registerDeploymentModel(definition));
    }
}

@@ -2410,32 +2410,149 @@
 %0A    @Deprecated
+ // note that since https://issues.redhat.com/browse/WFCORE-3441 this method is no longer deprecated in the interface
 %0A    @Override%0A 
@@ -2706,32 +2706,168 @@
 writer);%0A    %7D%0A%0A
+    /**%0A     * Do not use. Always throws %7B@code UnsupportedOperationException%7D. See https://issues.redhat.com/browse/WFLY-17319%0A     */%0A
     @Deprecated%0A
@@ -2862,38 +2862,24 @@
 @Deprecated%0A
-    @Override%0A
     public T
@@ -3013,96 +3013,205 @@
     
-return this.registration.registerModelTransformers(version, resourceTransformer);
+throw new UnsupportedOperationException(%22WFLY-17319%22);%0A    %7D%0A%0A    /**%0A     * Do not use. Always throws %7B@code UnsupportedOperationException%7D. See https://issues.redhat.com/browse/WFLY-17319
 %0A    
-%7D%0A
+ */
 %0A   
@@ -3219,38 +3219,24 @@
 @Deprecated%0A
-    @Override%0A
     public T
@@ -3413,118 +3413,205 @@
     
-return this.registration.registerModelTransformers(version, resourceTransformer, operationTransformer);
+throw new UnsupportedOperationException(%22WFLY-17319%22);%0A    %7D%0A%0A    /**%0A     * Do not use. Always throws %7B@code UnsupportedOperationException%7D. See https://issues.redhat.com/browse/WFLY-17319
 %0A    
-%7D%0A
+ */
 %0A   
@@ -3619,38 +3619,24 @@
 @Deprecated%0A
-    @Override%0A
     public T
@@ -3834,131 +3834,205 @@
     
-return this.registration.registerModelTransformers(version, resourceTransformer, operationTransformer, placeholder);
+throw new UnsupportedOperationException(%22WFLY-17319%22);%0A    %7D%0A%0A    /**%0A     * Do not use. Always throws %7B@code UnsupportedOperationException%7D. See https://issues.redhat.com/browse/WFLY-17319
 %0A    
-%7D%0A
+ */
 %0A   
@@ -4044,30 +4044,16 @@
 recated%0A
-    @Override%0A
     publ
@@ -4191,87 +4191,60 @@
     
-return this.registration.registerModelTransformers(version, combinedTransformer
+throw new UnsupportedOperationException(%22WFLY-17319%22
 );%0A 

Remove uses of deprecated SubsystemRegistration methods -- step 1