001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.xbean.kernel;
018    
019    import java.util.Collections;
020    import java.util.Set;
021    
022    /**
023     * Signafies that a StopStrategies would like the kernel to ignore any unsatified stop conditions and continue to
024     * destroy the service.
025     *
026     * @author Dain Sundstrom
027     * @version $Id$
028     * @since 2.0
029     */
030    public class ForcedStopException extends Exception {
031        private final ServiceName serviceName;
032        private final Set unsatisfiedConditions;
033    
034        /**
035         * Creates a ForcedStopException for the specified service name.
036         *
037         * @param serviceName the name of the service that is to be forceably stopped
038         * @param unsatisfiedConditions the unsatisfied conditions that will be ignored
039         */
040        public ForcedStopException(ServiceName serviceName, Set unsatisfiedConditions) {
041            super("Forced stop and ignored unsatisfied conditons:" +
042                    " serviceName=" + serviceName +
043                    ", unsatisfiedConditions=" + unsatisfiedConditions);
044            if (serviceName == null) throw new NullPointerException("serviceName is null");
045            if (unsatisfiedConditions == null) throw new NullPointerException("unsatisfiedConditions is null");
046            this.serviceName = serviceName;
047            this.unsatisfiedConditions = Collections.unmodifiableSet(unsatisfiedConditions);
048        }
049    
050        /**
051         * Gets the name of the service that is to be forceably stopped.
052         *
053         * @return the service name
054         */
055        public ServiceName getServiceName() {
056            return serviceName;
057        }
058    
059        /**
060         * Gets the conditions that were unsatified when the exception was thrown.
061         *
062         * @return the unsatified conditions that were ignored
063         */
064        public Set getUnsatisfiedConditions() {
065            return unsatisfiedConditions;
066        }
067    }