src/org/sonews/storage/StorageManager.java
changeset 37 74139325d305
parent 35 ed84c8bdd87b
child 42 7f84f4de2893
     1.1 --- a/src/org/sonews/storage/StorageManager.java	Sun Aug 29 17:43:58 2010 +0200
     1.2 +++ b/src/org/sonews/storage/StorageManager.java	Sun Aug 29 18:17:37 2010 +0200
     1.3 @@ -26,64 +26,53 @@
     1.4  public final class StorageManager
     1.5  {
     1.6  
     1.7 -  private static StorageProvider provider;
     1.8 +	private static StorageProvider provider;
     1.9  
    1.10 -  public static Storage current()
    1.11 -    throws StorageBackendException
    1.12 -  {
    1.13 -    synchronized(StorageManager.class)
    1.14 -    {
    1.15 -      if(provider == null)
    1.16 -      {
    1.17 -        return null;
    1.18 -      }
    1.19 -      else
    1.20 -      {
    1.21 -        return provider.storage(Thread.currentThread());
    1.22 -      }
    1.23 -    }
    1.24 -  }
    1.25 +	public static Storage current()
    1.26 +		throws StorageBackendException
    1.27 +	{
    1.28 +		synchronized (StorageManager.class) {
    1.29 +			if (provider == null) {
    1.30 +				return null;
    1.31 +			} else {
    1.32 +				return provider.storage(Thread.currentThread());
    1.33 +			}
    1.34 +		}
    1.35 +	}
    1.36  
    1.37 -  public static StorageProvider loadProvider(String pluginClassName)
    1.38 -  {
    1.39 -    try
    1.40 -    {
    1.41 -      Class<?> clazz = Class.forName(pluginClassName);
    1.42 -      Object   inst  = clazz.newInstance();
    1.43 -      return (StorageProvider)inst;
    1.44 -    }
    1.45 -    catch(Exception ex)
    1.46 -    {
    1.47 -      System.err.println(ex);
    1.48 -      return null;
    1.49 -    }
    1.50 -  }
    1.51 +	public static StorageProvider loadProvider(String pluginClassName)
    1.52 +	{
    1.53 +		try {
    1.54 +			Class<?> clazz = Class.forName(pluginClassName);
    1.55 +			Object inst = clazz.newInstance();
    1.56 +			return (StorageProvider) inst;
    1.57 +		} catch (Exception ex) {
    1.58 +			System.err.println(ex);
    1.59 +			return null;
    1.60 +		}
    1.61 +	}
    1.62  
    1.63 -  /**
    1.64 -   * Sets the current storage provider.
    1.65 -   * @param provider
    1.66 -   */
    1.67 -  public static void enableProvider(StorageProvider provider)
    1.68 -  {
    1.69 -    synchronized(StorageManager.class)
    1.70 -    {
    1.71 -      if(StorageManager.provider != null)
    1.72 -      {
    1.73 -        disableProvider();
    1.74 -      }
    1.75 -      StorageManager.provider = provider;
    1.76 -    }
    1.77 -  }
    1.78 +	/**
    1.79 +	 * Sets the current storage provider.
    1.80 +	 * @param provider
    1.81 +	 */
    1.82 +	public static void enableProvider(StorageProvider provider)
    1.83 +	{
    1.84 +		synchronized (StorageManager.class) {
    1.85 +			if (StorageManager.provider != null) {
    1.86 +				disableProvider();
    1.87 +			}
    1.88 +			StorageManager.provider = provider;
    1.89 +		}
    1.90 +	}
    1.91  
    1.92 -  /**
    1.93 -   * Disables the current provider.
    1.94 -   */
    1.95 -  public static void disableProvider()
    1.96 -  {
    1.97 -    synchronized(StorageManager.class)
    1.98 -    {
    1.99 -      provider = null;
   1.100 -    }
   1.101 -  }
   1.102 -
   1.103 +	/**
   1.104 +	 * Disables the current provider.
   1.105 +	 */
   1.106 +	public static void disableProvider()
   1.107 +	{
   1.108 +		synchronized (StorageManager.class) {
   1.109 +			provider = null;
   1.110 +		}
   1.111 +	}
   1.112  }