001    /*
002     * Copyright (c) 2005 Stephen J. McConnell
003     *
004     * Licensed  under the  Apache License,  Version 2.0  (the "License");
005     * you may not use  this file  except in  compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *   http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed  under the  License is distributed on an "AS IS" BASIS,
012     * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
013     * implied.
014     *
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package net.dpml.metro.runtime;
020    
021    import java.net.URI;
022    
023    import net.dpml.component.ControlException;
024    
025    /**
026     * Exception thrown when an attempt is made to reference an unknown 
027     * or unresolvable controller.
028     *
029     * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
030     * @version 1.0.4
031     */
032    public class ControllerNotFoundException extends ControlException 
033    {
034       /**
035        * Serial version identifier.
036        */
037        static final long serialVersionUID = 1L;
038        
039        private final URI m_target;
040    
041       /**
042        * Creation of a new <tt>ControllerNotFoundException</tt>.
043        * @param uri the uri of the controller raising the exception
044        * @param target the uri of the target controller
045        */
046        public ControllerNotFoundException( URI uri, URI target )
047        {
048            this( uri, target, null );
049        }
050    
051       /**
052        * Creation of a new <tt>ControllerNotFoundException</tt>.
053        * @param uri the uri of the controller raising the exception
054        * @param target the uri of the target controller
055        * @param cause the causal exception
056        */
057        public ControllerNotFoundException( URI uri, URI target, Throwable cause )
058        {
059            super( uri, createMessage( uri ), cause );
060            m_target = target;
061        }
062    
063       /**
064        * Return the uri of the target controller.
065        * @return the target controller uri
066        */
067        public URI getTargetURI()
068        {
069            return m_target;
070        }
071    
072        private static String createMessage( URI target )
073        {
074            return "Unable to locate the target controller [" + target + "].";
075        }
076    }
077