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