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     * Signifies that there were unsatified conditions during a start or stop operation.  The service is left in the
024     * STARTING state or STOPPING state.
025     *
026     * @author Dain Sundstrom
027     * @version $Id$
028     * @since 2.0
029     */
030    public class UnsatisfiedConditionsException extends Exception {
031        private final ServiceName serviceName;
032        private final Set unsatisfiedConditions;
033    
034        /**
035         * Creates an UnsatisfiedConditionsException for the specified service and unsatisfied conditions.
036         *
037         * @param message information about the unsatisfied conditions
038         * @param serviceName the name of the service that has unsatisfied conditions
039         * @param unsatisfiedConditions the unsatisfied conditions
040         */
041        public UnsatisfiedConditionsException(String message, ServiceName serviceName, Set unsatisfiedConditions) {
042            super(message + ": serviceName=" + serviceName + ": unsatisfiedConditions=" + unsatisfiedConditions);
043            if (serviceName == null) throw new NullPointerException("serviceName is null");
044            if (unsatisfiedConditions == null) throw new NullPointerException("unsatisfiedConditions is null");
045            this.serviceName = serviceName;
046            this.unsatisfiedConditions = Collections.unmodifiableSet(unsatisfiedConditions);
047        }
048    
049        /**
050         * Gets the name of the service that has unsatisfied conditions.
051         *
052         * @return the service name
053         */
054        public ServiceName getServiceName() {
055            return serviceName;
056        }
057    
058        /**
059         * Gets the conditions that were unsatified when the exception was thrown.
060         *
061         * @return the unsatified conditions that were ignored
062         */
063        public Set getUnsatisfiedConditions() {
064            return unsatisfiedConditions;
065        }
066    }