## org.apache.ivy.core
Class IvyContext

    java.lang.Object
      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()`
`IvyContext(IvyContext ctx)`

Method Summary
`void` `checkInterrupted()`
`java.lang.Object` `get(java.lang.String key)`
`CircularDependencyStrategy` `getCircularDependencyStrategy()`
`static IvyContext` `getContext()`
`DependencyDescriptor` `getDependencyDescriptor()`
`EventManager` `getEventManager()`
`Ivy` `getIvy()` Returns the current ivy instance.
`MessageLogger` `getMessageLogger()`
`java.lang.Thread` `getOperatingThread()`
`ResolveData` `getResolveData()`
`IvySettings` `getSettings()`
`java.lang.Object` `peek(java.lang.String key)` Reads the first object from the list saved under given key in the context.
`static java.lang.Object` `peekInContextStack(java.lang.String key)` Reads the first object from the list saved under given key in the first context from the context stack in which this key is defined.
`Ivy` `peekIvy()` Returns the Ivy instance associated with this context, or `null` if no such instance is currently associated with this 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.
`static IvyContext` `popContext()` Pops one context used with this thread.
`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.
`static IvyContext` `pushContext(IvyContext context)` Changes the context associated with this thread.
`static IvyContext` `pushNewContext()` Creates a new IvyContext and pushes it as the current context in the current thread.
`static IvyContext` `pushNewCopyContext()` Creates a new IvyContext as a copy of the current one and pushes it as the current context in the current thread.
`void` `set(java.lang.String key, java.lang.Object value)`
`void` `setDependencyDescriptor(DependencyDescriptor dd)`
`void` `setIvy(Ivy ivy)`
`void` `setResolveData(ResolveData data)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IvyContext

    public IvyContext()

### IvyContext

    public IvyContext(IvyContext ctx)

Method Detail

### getContext

    public static IvyContext getContext()

### pushNewContext

    public static IvyContext pushNewContext()

  Creates a new IvyContext and pushes it as the current context in the current thread.

  `popContext()` should usually be called when the job for which this context has been pushed is finished.

  Returns:
    the newly pushed context

### pushNewCopyContext

    public static IvyContext pushNewCopyContext()

  Creates a new IvyContext as a copy of the current one and pushes it as the current context in the current thread.

  `popContext()` should usually be called when the job for which this context has been pushed is finished.

  Returns:
    the newly pushed context

### pushContext

    public static IvyContext pushContext(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. Do not forget to call `popContext()` when done.

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

### popContext

    public static IvyContext popContext()

  Pops one context used with this thread. This is usually called after having finished a task for which a call to `pushNewContext()` or `pushContext(IvyContext)` was done prior to beginning the task.

  Returns:
    the popped context

### peekInContextStack

    public static java.lang.Object peekInContextStack(java.lang.String key)

  Reads the first object from the list saved under given key in the first context from the context stack in which this key is defined. If value under key in any of the contexts form the stack represents non List object then a RuntimeException is thrown.

  This methods does a similar job to `peek(String)`, except that it considers the whole context stack and not only one instance.

  Parameters:
    `key` - context key for the string
  Returns:
    top object from the list (index 0) of the first context in the stack containing this key or null if no key or list empty in all contexts from the context stack
  See Also:
    `peek(String)`

### 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

### peekIvy

    public Ivy peekIvy()

  Returns the Ivy instance associated with this context, or `null` if no such instance is currently associated with this context.

  If you want get a default Ivy instance in case no instance if currently associated, use `getIvy()`.

  Returns:
    the current ivy instance, or `null` if there is no current ivy instance.

### setIvy

    public void setIvy(Ivy ivy)

### 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()

### getMessageLogger

    public MessageLogger getMessageLogger()

### getEventManager

    public EventManager getEventManager()

### checkInterrupted

    public void checkInterrupted()

### setResolveData

    public void setResolveData(ResolveData data)

### getResolveData

    public ResolveData getResolveData()

### setDependencyDescriptor

    public void setDependencyDescriptor(DependencyDescriptor dd)

### getDependencyDescriptor

    public DependencyDescriptor getDependencyDescriptor()