org.apache.ivy.core
Class IvyContext

java.lang.Object
  extended by org.apache.ivy.core.IvyContext

public class IvyContext
extends java.lang.Object

This class represents an execution context of an Ivy action. It contains several getters to retrieve information, like the used Ivy instance, the cache location...

See Also:
IvyThread

Constructor Summary
IvyContext()
           
 
Method Summary
 void checkInterrupted()
           
 java.lang.Object get(java.lang.String key)
           
 java.io.File getCache()
           
 CacheManager getCacheManager()
           
 CircularDependencyStrategy getCircularDependencyStrategy()
           
static IvyContext getContext()
           
 EventManager getEventManager()
           
 Ivy getIvy()
          Returns the current ivy instance.
 MessageImpl getMessageImpl()
           
 java.lang.Thread getOperatingThread()
           
 DependencyResolver getResolver()
           
 IvySettings getSettings()
           
 java.lang.Object peek(java.lang.String key)
          Reads the first object from the list saved under given key in the context.
 java.lang.Object pop(java.lang.String key)
          Removes and returns first object from the list saved under given key in the context.
 boolean pop(java.lang.String key, java.lang.Object expectedValue)
          Removes and returns first object from the list saved under given key in the context but only if it equals the given expectedValue - if not a false value is returned.
 void popResolver()
           
 void push(java.lang.String key, java.lang.Object value)
          Puts a new object at the start of the list saved under given key in the context.
 void pushResolver(DependencyResolver resolver)
           
 void set(java.lang.String key, java.lang.Object value)
           
 void setCache(java.io.File cache)
           
static void setContext(IvyContext context)
          Changes the context associated with this thread.
 void setIvy(Ivy ivy)
           
 void setMessageImpl(MessageImpl impl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IvyContext

public IvyContext()
Method Detail

getContext

public static IvyContext getContext()

setContext

public static void setContext(IvyContext context)
Changes the context associated with this thread. This is especially useful when launching a new thread, to associate it with the same context as the initial one.

Parameters:
context - the new context to use in this thread.

getIvy

public Ivy getIvy()
Returns the current ivy instance. When calling any public ivy method on an ivy instance, a reference to this instance is put in this context, and thus accessible using this method, until no code reference this instance and the garbage collector collects it. Then, or if no ivy method has been called, a default ivy instance is returned by this method, so that it never returns null.

Returns:
the current ivy instance

setIvy

public void setIvy(Ivy ivy)

getCache

public java.io.File getCache()

setCache

public void setCache(java.io.File cache)

getSettings

public IvySettings getSettings()

getCircularDependencyStrategy

public CircularDependencyStrategy getCircularDependencyStrategy()

get

public java.lang.Object get(java.lang.String key)

set

public void set(java.lang.String key,
                java.lang.Object value)

peek

public java.lang.Object peek(java.lang.String key)
Reads the first object from the list saved under given key in the context. If value under key represents non List object then a RuntimeException is thrown.

Parameters:
key - context key for the string
Returns:
top object from the list (index 0) or null if no key or list empty

pop

public java.lang.Object pop(java.lang.String key)
Removes and returns first object from the list saved under given key in the context. If value under key represents non List object then a RuntimeException is thrown.

Parameters:
key - context key for the string
Returns:
top object from the list (index 0) or null if no key or list empty

pop

public boolean pop(java.lang.String key,
                   java.lang.Object expectedValue)
Removes and returns first object from the list saved under given key in the context but only if it equals the given expectedValue - if not a false value is returned. If value under key represents non List object then a RuntimeException is thrown.

Parameters:
key - context key for the string
Returns:
true if the r

push

public void push(java.lang.String key,
                 java.lang.Object value)
Puts a new object at the start of the list saved under given key in the context. If value under key represents non List object then a RuntimeException is thrown. If no list exists under given key a new LinkedList is created. This is kept without WeakReference in opposite to the put() results.

Parameters:
key - key context key for the string
value - value to be saved under the key

getOperatingThread

public java.lang.Thread getOperatingThread()

getMessageImpl

public MessageImpl getMessageImpl()

setMessageImpl

public void setMessageImpl(MessageImpl impl)

getEventManager

public EventManager getEventManager()

getCacheManager

public CacheManager getCacheManager()

checkInterrupted

public void checkInterrupted()

getResolver

public DependencyResolver getResolver()

pushResolver

public void pushResolver(DependencyResolver resolver)

popResolver

public void popResolver()