001    /*
002     * Copyright 2005 Stephen McConnell
003     * Licensed  under the  Apache License,  Version 2.0  (the "License");
004     * you may not use  this file  except in  compliance with the License.
005     * You may obtain a copy of the License at
006     *
007     *   http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software
010     * distributed  under the  License is distributed on an "AS IS" BASIS,
011     * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
012     * implied.
013     *
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package net.dpml.transit.local;
019    
020    import java.io.IOException;
021    
022    import java.net.URL;
023    import java.net.URLConnection;
024    import java.net.URLStreamHandler;
025    
026    /** 
027     * The <code>local</code> protocol references a local resource 
028     * under ${dpml.prefs}. Local resources are located using the artifact 
029     * protocol uri structure with a direct mapping to ${dpml.prefs}/[group]/[type]s/[name].[type].
030     * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
031     * @version 1.1.0
032     */
033    public class Handler extends URLStreamHandler
034    {
035       /**
036        * Creation of a new local protocol handler.
037        */
038        public Handler()
039        {
040        }
041    
042        // ------------------------------------------------------------------------
043        // implementation
044        // ------------------------------------------------------------------------
045    
046        /**
047         * Opens a connection to the specified URL.
048         *
049         * @param url A URL to open a connection to.
050         * @return The established connection.
051         * @throws IOException If a connection failure occurs.
052         */
053        protected URLConnection openConnection( final URL url )
054            throws IOException
055        {
056            return new LocalURLConnection( url );
057        }
058    }