SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol
Class AccountManagerImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.AccountManagerImpl
All Implemented Interfaces:
AccountManager

public class AccountManagerImpl
extends Object
implements AccountManager

Represents an implementation of AccountManager which loads the accounts in a separate thread.

Author:
Lubomir Marinov, Yana Stamcheva

Constructor Summary
AccountManagerImpl(org.osgi.framework.BundleContext bundleContext)
          Initializes a new AccountManagerImpl instance loaded in a specific BundleContext (in which the caller will usually later register it).
 
Method Summary
 void addListener(AccountManagerListener listener)
          Implements AccountManager#addListener(AccountManagerListener).
 Collection<AccountID> getStoredAccounts()
          Returns an Iterator over a list of all stored AccountIDs.
 boolean hasStoredAccounts(String protocolName, boolean includeHidden)
          Determines whether the account store represented by this manager contains stored accounts.
 boolean isAccountLoaded(AccountID accountID)
          Checks if the account corresponding to the given accountID is loaded.
 void loadAccount(AccountID accountID)
          Loads the account corresponding to the given AccountID.
 void removeListener(AccountManagerListener listener)
          Implements AccountManager#removeListener(AccountManagerListener).
 boolean removeStoredAccount(ProtocolProviderFactory factory, AccountID accountID)
          Removes the account with accountID from the set of accounts that are persistently stored inside the configuration service.
 void storeAccount(ProtocolProviderFactory factory, AccountID accountID)
          Stores an account represented in the form of an AccountID created by a specific ProtocolProviderFactory.
 void unloadAccount(AccountID accountID)
          Unloads the account corresponding to the given AccountID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountManagerImpl

public AccountManagerImpl(org.osgi.framework.BundleContext bundleContext)
Initializes a new AccountManagerImpl instance loaded in a specific BundleContext (in which the caller will usually later register it).

Parameters:
bundleContext - the BundleContext in which the new instance is loaded (and in which the caller will usually later register it as a service)
Method Detail

addListener

public void addListener(AccountManagerListener listener)
Implements AccountManager#addListener(AccountManagerListener).

Specified by:
addListener in interface AccountManager
Parameters:
listener - the AccountManagerListener to add

hasStoredAccounts

public boolean hasStoredAccounts(String protocolName,
                                 boolean includeHidden)
Description copied from interface: AccountManager
Determines whether the account store represented by this manager contains stored accounts.

Specified by:
hasStoredAccounts in interface AccountManager
Parameters:
protocolName - the name of the protocol for which the stored accounts are to be checked or null for all protocols
includeHidden - true to take into account both non-hidden and hidden stored accounts; false for non-hidden only
Returns:
true if the account store represented by this manager contains stored accounts; false, otherwise

removeListener

public void removeListener(AccountManagerListener listener)
Implements AccountManager#removeListener(AccountManagerListener).

Specified by:
removeListener in interface AccountManager
Parameters:
listener - the AccountManagerListener to remove

storeAccount

public void storeAccount(ProtocolProviderFactory factory,
                         AccountID accountID)
                  throws OperationFailedException
Stores an account represented in the form of an AccountID created by a specific ProtocolProviderFactory.

Specified by:
storeAccount in interface AccountManager
Parameters:
factory - the ProtocolProviderFactory which created the account to be stored
accountID - the account in the form of AccountID to be stored
Throws:
OperationFailedException - if anything goes wrong while storing the account

removeStoredAccount

public boolean removeStoredAccount(ProtocolProviderFactory factory,
                                   AccountID accountID)
Removes the account with accountID from the set of accounts that are persistently stored inside the configuration service.

Specified by:
removeStoredAccount in interface AccountManager
Parameters:
factory - the ProtocolProviderFactory which created the account to be stored
accountID - the AccountID of the account to remove.
Returns:
true if an account has been removed and false otherwise.

getStoredAccounts

public Collection<AccountID> getStoredAccounts()
Returns an Iterator over a list of all stored AccountIDs. The list of stored accounts include all registered accounts and all disabled accounts. In other words in this list we could find accounts that aren't loaded.

In order to check if an account is already loaded please use the #isAccountLoaded(AccountID accountID) method. To load an account use the #loadAccount(AccountID accountID) method.

Specified by:
getStoredAccounts in interface AccountManager
Returns:
an Iterator over a list of all stored AccountIDs

loadAccount

public void loadAccount(AccountID accountID)
                 throws OperationFailedException
Loads the account corresponding to the given AccountID. An account is loaded when its ProtocolProviderService is registered in the bundle context. This method is meant to load the account through the corresponding ProtocolProviderFactory.

Specified by:
loadAccount in interface AccountManager
Parameters:
accountID - the identifier of the account to load
Throws:
OperationFailedException - if anything goes wrong while loading the account corresponding to the specified accountID

unloadAccount

public void unloadAccount(AccountID accountID)
                   throws OperationFailedException
Unloads the account corresponding to the given AccountID. An account is unloaded when its ProtocolProviderService is unregistered in the bundle context. This method is meant to unload the account through the corresponding ProtocolProviderFactory.

Specified by:
unloadAccount in interface AccountManager
Parameters:
accountID - the identifier of the account to load
Throws:
OperationFailedException - if anything goes wrong while unloading the account corresponding to the specified accountID

isAccountLoaded

public boolean isAccountLoaded(AccountID accountID)
Checks if the account corresponding to the given accountID is loaded. An account is loaded if its ProtocolProviderService is registered in the bundle context. By default all accounts are loaded. However the user could manually unload an account, which would be unregistered from the bundle context, but would remain in the configuration file.

Specified by:
isAccountLoaded in interface AccountManager
Parameters:
accountID - the identifier of the account to load
Returns:
true to indicate that the account with the given accountID is loaded, false - otherwise

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.