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