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 */
017package org.apache.commons.vfs2.provider;
018
019import org.apache.commons.logging.Log;
020import org.apache.commons.vfs2.FileSystemException;
021
022/**
023 * A partial {@link VfsComponent} implementation.
024 */
025public abstract class AbstractVfsComponent
026    implements VfsComponent
027{
028    private VfsComponentContext context;
029    private Log log;
030
031    /**
032     * Sets the Logger to use for the component.
033     * @param log The Log to use.
034     */
035    @Override
036    public final void setLogger(final Log log)
037    {
038        this.log = log;
039    }
040
041    /**
042     * Sets the context for this file system provider.
043     * @param context The VfsComponentContext.
044     */
045    @Override
046    public final void setContext(final VfsComponentContext context)
047    {
048        this.context = context;
049    }
050
051    /**
052     * Initializes the component.  This implementation does nothing.
053     * @throws FileSystemException if an error occurs.
054     */
055    @Override
056    public void init() throws FileSystemException
057    {
058    }
059
060    /**
061     * Closes the provider.  This implementation does nothing.
062     */
063    @Override
064    public void close()
065    {
066    }
067
068    /**
069     * Returns the logger for this file system to use.
070     */
071    protected final Log getLogger()
072    {
073        return log;
074    }
075
076    /**
077     * Returns the context for this provider.
078     */
079    protected final VfsComponentContext getContext()
080    {
081        return context;
082    }
083}