org.maemo.mica.common.core.sdk
Class SDKManager

java.lang.Object
  extended by org.maemo.mica.common.core.sdk.SDKManager
All Implemented Interfaces:
ISDKManager

public class SDKManager
extends java.lang.Object
implements ISDKManager

The SDK manager manages the SDKs and targets known to Mica through the org.maemo.mica.common.core.sdk_provider extension point.

The providers are queried lazily when the first client asks for ISDK or ISDKTarget instances through this manager. The first access to the manager will yield empty content and spawn a refreshing job. Usually, ISDK and ISDKTarget instances based on BaseSDK and BaseSDKTarget will use caching so that the initial refreshing job in a new Eclipse instance will be fast.

Clients using this interface should use waitForRefreshComplete(IProgressMonitor) if they want to ensure that a successive call to fetch SDKs or targets will be up-to-date.

See Also:
ISDKProvider

Field Summary
static java.lang.String SDK_CLASS
           
 
Constructor Summary
SDKManager()
           
 
Method Summary
 void addListener(ISDKFactoryListener listener)
          Add a listener to respond to changes to the SDKs
 void cancelRefresh()
          Cancel any ongoing refresh job.
 ISDKTarget findSDKTarget(java.lang.String sdkName, java.lang.String sdkTargetName, java.lang.String sdkDisplayName)
          Find the ISDKTarget with the given SDK name, display name, and target name.
 void fireListeners()
          Force listeners to be fired.
 ISDK[] getAllSDKs()
          Get an array of all the SDKs known to the IDE
 ISDKTarget[] getAllSDKTargets()
          Get an array of all the SDK targets known to the IDE
static ISDKManager getInstance()
          Get the singleton instance of the SDKFactory.
 java.util.List<ISDKProvider> getSDKProviders()
          Get access to the SDK provider list.
 java.util.List<ISDK> getSDKs()
           
<T extends ISDK>
java.util.List<T>
getSDKsOfType(java.lang.Class<T> klass)
          Get a list of the currently available SDKs which implement or extend the given class.
<T extends ISDKTarget>
java.util.List<T>
getSDKTargetsOfType(java.lang.Class<T> klass)
          Get a list of the currently available SDK targets which implement or extend the given class.
 boolean hasScannedYet()
          Tell if the factory has scanned any of its SDKs yet (until then, any polling of SDKs/targets will fail).
 boolean isRefreshing()
          Tell if the SDK factory is refreshing.
 void lock()
          Lock the factory so it will not refresh in the meantime.
 void refresh(boolean force)
          Refresh the SDKs by re-querying all the SDK providers.
 void refresh(IProgressMonitor monitor)
          Refresh the SDKs by re-querying all the SDK providers, reading from cache if possible.
 void refreshFull(IProgressMonitor monitor)
          Refresh the SDKs by re-querying all the SDK providers, not using a cache.
 void removeListener(ISDKFactoryListener listener)
          Remove a listener to respond to changes to the SDKs
 void setSDKs(java.util.List<ISDK> sdks)
          Set the array of SDKs
protected  org.maemo.mica.internal.api.common.core.sdk.RefreshSDKManagerJob spawnRefreshJob(boolean force)
          Create and schedule a refreshing job.
 void unlock()
          Unlock a previous lock() call.
 void waitForRefreshComplete(IProgressMonitor monitor)
          Wait for the SDK factory to be initialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SDK_CLASS

public static java.lang.String SDK_CLASS
Constructor Detail

SDKManager

public SDKManager()
Method Detail

getInstance

public static ISDKManager getInstance()
Get the singleton instance of the SDKFactory. This will trigger the initial SDK scanning if it has not happened yet.


getSDKProviders

public java.util.List<ISDKProvider> getSDKProviders()
Get access to the SDK provider list. Clients should invoke #refresh() if they modify the list.

Returns:
modifiable list

getSDKs

public java.util.List<ISDK> getSDKs()

isRefreshing

public boolean isRefreshing()
Tell if the SDK factory is refreshing.


waitForRefreshComplete

public void waitForRefreshComplete(IProgressMonitor monitor)
Description copied from interface: ISDKManager
Wait for the SDK factory to be initialized. The initial task of gathering SDKs and targets occurs in the background, with calls to #getSDKs(), #getAllSDKTargets(), etc. receiving empty or outdated lists in the meantime. If you are prepared to wait, issue this call first.

Specified by:
waitForRefreshComplete in interface ISDKManager
Parameters:
monitor - optional progress monitor

refresh

public void refresh(boolean force)
Refresh the SDKs by re-querying all the SDK providers. This is a long-running task which happens asynchronously. Attach a listener to detect changes.

Parameters:
force - true throw away any cached state

refreshFull

public void refreshFull(IProgressMonitor monitor)
Refresh the SDKs by re-querying all the SDK providers, not using a cache. This is a long-running task which blocks until the refresh is complete.

Parameters:
monitor - unused!

refresh

public void refresh(IProgressMonitor monitor)
Refresh the SDKs by re-querying all the SDK providers, reading from cache if possible. This is a long-running task which blocks until the refresh is complete.

Parameters:
monitor - unused!

spawnRefreshJob

protected org.maemo.mica.internal.api.common.core.sdk.RefreshSDKManagerJob spawnRefreshJob(boolean force)
Create and schedule a refreshing job.

Returns:
the new job

fireListeners

public void fireListeners()
Description copied from interface: ISDKManager
Force listeners to be fired. Do this if, for example, you know that the list of targets or number of SDKs for your provider has changed.

Specified by:
fireListeners in interface ISDKManager

getAllSDKs

public ISDK[] getAllSDKs()
Description copied from interface: ISDKManager
Get an array of all the SDKs known to the IDE

Specified by:
getAllSDKs in interface ISDKManager
Returns:
list of SDKs, never null

getAllSDKTargets

public ISDKTarget[] getAllSDKTargets()
Description copied from interface: ISDKManager
Get an array of all the SDK targets known to the IDE

Specified by:
getAllSDKTargets in interface ISDKManager
Returns:
array of ISDKTarget, never null

addListener

public void addListener(ISDKFactoryListener listener)
Description copied from interface: ISDKManager
Add a listener to respond to changes to the SDKs

Specified by:
addListener in interface ISDKManager

removeListener

public void removeListener(ISDKFactoryListener listener)
Description copied from interface: ISDKManager
Remove a listener to respond to changes to the SDKs

Specified by:
removeListener in interface ISDKManager

setSDKs

public void setSDKs(java.util.List<ISDK> sdks)
Set the array of SDKs


getSDKsOfType

public <T extends ISDK> java.util.List<T> getSDKsOfType(java.lang.Class<T> klass)
Description copied from interface: ISDKManager
Get a list of the currently available SDKs which implement or extend the given class.

Specified by:
getSDKsOfType in interface ISDKManager
Parameters:
klass - a class each SDK must implement or extend
Returns:
list of matching SDKs, never null

getSDKTargetsOfType

public <T extends ISDKTarget> java.util.List<T> getSDKTargetsOfType(java.lang.Class<T> klass)
Description copied from interface: ISDKManager
Get a list of the currently available SDK targets which implement or extend the given class.

Specified by:
getSDKTargetsOfType in interface ISDKManager
Parameters:
klass - a class each SDK target implement or extend
Returns:
list of matching SDK targets, never null

cancelRefresh

public void cancelRefresh()
Cancel any ongoing refresh job.


lock

public void lock()
Lock the factory so it will not refresh in the meantime. Any current refresh will complete first.

Any refreshes (automatically or manually triggered) will be queued.

This must be unlock()ed once for each lock().


unlock

public void unlock()
Unlock a previous lock() call. Once the matching number of unlocks have been executed, the factory will refresh if there were any refresh requests in the meantime.


findSDKTarget

public ISDKTarget findSDKTarget(java.lang.String sdkName,
                                java.lang.String sdkTargetName,
                                java.lang.String sdkDisplayName)
Description copied from interface: ISDKManager
Find the ISDKTarget with the given SDK name, display name, and target name.

Specified by:
findSDKTarget in interface ISDKManager
sdkDisplayName - name, or null if unknown
Returns:
ISDKTarget or null

hasScannedYet

public boolean hasScannedYet()
Tell if the factory has scanned any of its SDKs yet (until then, any polling of SDKs/targets will fail).

Returns:
false: not scanned, so all lookups will fail; true: one scan has finished, data is likely valid


Copyright © 2007-2009 INdT, 2007-2009 Nokia. All Rights Reserved.