nl.toolforge.karma.core.boot
Class WorkingContext

java.lang.Object
  extended bynl.toolforge.karma.core.boot.WorkingContext

public final class WorkingContext
extends java.lang.Object

A WorkingContext is used by Karma to determine the environment in which the user wants to use Karma. A working context is represented on your local harddisk by a directory in which a developers' project work will be stored. The WorkingContext class is the bridge from Karma domain objects (Manifest and Module to name the most important ones) to a developer's harddisk.

A WorkingContext should be configured before it can be constructed. The configure(WorkingContextConfiguration)-method should be called to configure a WorkingContext.

Version:
$Id: WorkingContext.java,v 1.24 2004/11/16 22:18:28 hippe Exp $
Author:
D.A. Smedes

Field Summary
static ErrorCode CANNOT_REMOVE_ACTIVE_WORKING_CONTEXT
           
static java.lang.String CONFIGURATION_BASE_DIRECTORY
           
static java.lang.String DEFAULT
          The default working context.
static java.lang.String LOCATION_STORE_MODULE
           
static java.lang.String MANIFEST_STORE_MODULE
           
static java.lang.String PROJECT_BASE_DIRECTORY_PROPERTY
          Property indicating the base directory for development projects.
static java.lang.String PROJECT_LOCAL_REPOSITORY_PROPERTY
          Property indicating the root of a repository directory `Maven style`.
static java.lang.String WORKING_CONTEXT_PREFERENCE
           
 
Constructor Summary
WorkingContext(java.lang.String workingContext)
          Constructs a WorkingContext in the default configuration base directory.
WorkingContext(java.lang.String workingContext, java.io.File configBaseDir)
          Constructs a WorkingContext with configBaseDir as the configuration base directory.
 
Method Summary
 void configure(WorkingContextConfiguration configuration)
           
 java.io.File getAdminDir()
          Returns a File reference to the administration directory for the working context.
 WorkingContextConfiguration getConfiguration()
          Get the configuration for this working context or null it this working context had not been configured.
static java.io.File getConfigurationBaseDir()
          Returns a File reference to the default base directory for Karma configuration files.
 java.lang.String getContextManifestPreference()
          Determines the last used manifest for this working context.
static java.io.File getKarmaHome()
           
static java.io.File getLocalRepository()
          See PROJECT_LOCAL_REPOSITORY_PROPERTY.
 LocationLoader getLocationLoader()
          Returns a reference to the LocationLoader for the working context.
 java.io.File getLocationStoreBasedir()
          Returns a File reference to the location store directory for the working context.
 ManifestCollector getManifestCollector()
          Returns a reference to the ManifestCollector for the working context.
 ManifestLoader getManifestLoader()
          Returns a reference to the ManifestLoader for the working context.
 java.io.File getManifestStoreBasedir()
          Returns a File reference to the manifest store directory for the working context.
 java.lang.String getName()
          Returns the name of this working context.
 java.io.File getProjectBaseDirectory()
          Returns a File reference to the project base directory, which can be configured by the projects.basedir property in the working-context.xml file.
 java.util.Properties getProperties()
          Get the properties of this working context.
 java.io.File getWorkingContextConfigurationBaseDir()
          Returns a File reference to the configuration directory for the current working context.
 void remove()
          Removes a working contexts' configuration directory.
 java.lang.String toString()
          Returns the working contexts' name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CANNOT_REMOVE_ACTIVE_WORKING_CONTEXT

public static final ErrorCode CANNOT_REMOVE_ACTIVE_WORKING_CONTEXT

WORKING_CONTEXT_PREFERENCE

public static final java.lang.String WORKING_CONTEXT_PREFERENCE
See Also:
Constant Field Values

CONFIGURATION_BASE_DIRECTORY

public static final java.lang.String CONFIGURATION_BASE_DIRECTORY

PROJECT_BASE_DIRECTORY_PROPERTY

public static final java.lang.String PROJECT_BASE_DIRECTORY_PROPERTY
Property indicating the base directory for development projects. All manifests will be checked out under this directory, and the manifest store and location store are checked out at this location as well.

See Also:
Constant Field Values

PROJECT_LOCAL_REPOSITORY_PROPERTY

public static final java.lang.String PROJECT_LOCAL_REPOSITORY_PROPERTY
Property indicating the root of a repository directory `Maven style`. For those who don't know Maven, check out the Maven website. This directory does not have to be the default Maven repository directory. It can be any directory on a users' harddisk, as long as binary dependencies can be resolved `Maven style`, because that is what Karma does as well.

See Also:
Constant Field Values

MANIFEST_STORE_MODULE

public static final java.lang.String MANIFEST_STORE_MODULE
See Also:
Constant Field Values

LOCATION_STORE_MODULE

public static final java.lang.String LOCATION_STORE_MODULE
See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
The default working context.

See Also:
Constant Field Values
Constructor Detail

WorkingContext

public WorkingContext(java.lang.String workingContext)
Constructs a WorkingContext in the default configuration base directory. The configure(WorkingContextConfiguration)-method should be called to configure this working context.

Parameters:
workingContext - A working context name. If workingContext doesn't match the \w+ pattern, DEFAULT is assumed.

WorkingContext

public WorkingContext(java.lang.String workingContext,
                      java.io.File configBaseDir)
Constructs a WorkingContext with configBaseDir as the configuration base directory. When configBaseDir does not exist, it will be created. The configure(WorkingContextConfiguration)- method should be called to configure this working context.

Parameters:
workingContext - A working context name. If workingContext doesn't match the \w+ pattern, DEFAULT is assumed.
configBaseDir - The configuration base directory. If the directory does not exist, it will be created.
Method Detail

getConfigurationBaseDir

public static java.io.File getConfigurationBaseDir()
Returns a File reference to the default base directory for Karma configuration files. When the directory does not exist, it is created.

Returns:
A File reference to the default base directory for Karma configuration files.

configure

public void configure(WorkingContextConfiguration configuration)

getName

public java.lang.String getName()
Returns the name of this working context.

Returns:
The name of this working context.

getConfiguration

public WorkingContextConfiguration getConfiguration()
Get the configuration for this working context or null it this working context had not been configured.

Returns:
The configuration for this working context.

getProperties

public java.util.Properties getProperties()
Get the properties of this working context. The properties are stored in the karma.properties, which are located in the project base dir.

Returns:
A Properties object containing the properties of this working context or an empty Properties object when something went wrong.

remove

public void remove()
            throws java.io.IOException
Removes a working contexts' configuration directory.

Throws:
java.io.IOException

getWorkingContextConfigurationBaseDir

public java.io.File getWorkingContextConfigurationBaseDir()
Returns a File reference to the configuration directory for the current working context. When the directory does not exist, it is created. This method will return the directory File reference to $HOME/.karma/working-contexts/<working-context-name>.

Returns:
a File reference to the configuration directory for the current working context.

getProjectBaseDirectory

public java.io.File getProjectBaseDirectory()
Returns a File reference to the project base directory, which can be configured by the projects.basedir property in the working-context.xml file.

Returns:
a File reference to the project base directory.

getAdminDir

public java.io.File getAdminDir()
Returns a File reference to the administration directory for the working context. In the administration directory, the manifest store and the location store are located for the current working context.

Returns:
A reference to the administration directory for the current working context.

getManifestStoreBasedir

public java.io.File getManifestStoreBasedir()
Returns a File reference to the manifest store directory for the working context. When the directory does not exist, it will be created. In this directory, the manifest store will be checked out.

Returns:
A reference to the manifest store directory.

getLocationStoreBasedir

public java.io.File getLocationStoreBasedir()
Returns a File reference to the location store directory for the working context. When the directory does not exist, it will be created. In this directory, the location store will be checked out.

Returns:
A reference to the location store directory.

getLocalRepository

public static java.io.File getLocalRepository()
See PROJECT_LOCAL_REPOSITORY_PROPERTY. When the property is not set, the default repository is assumed to be in getConfigurationBaseDir()/.repository.

Returns:
See method description.
See Also:
PROJECT_LOCAL_REPOSITORY_PROPERTY

getKarmaHome

public static java.io.File getKarmaHome()

getContextManifestPreference

public java.lang.String getContextManifestPreference()

Determines the last used manifest for this working context. This fact is maintained in the .java file on a users' harddisk, as per the specification for java.template.prefs, included in the JDK since 1.4.

A String made up of the working context name and karma.manifest.last.


getLocationLoader

public LocationLoader getLocationLoader()
                                 throws LocationException
Returns a reference to the LocationLoader for the working context.

Returns:
A location loader.
Throws:
LocationException

getManifestCollector

public ManifestCollector getManifestCollector()
Returns a reference to the ManifestCollector for the working context.

Returns:
A manifest loader.

getManifestLoader

public ManifestLoader getManifestLoader()
Returns a reference to the ManifestLoader for the working context.

Returns:
A manifest loader.

toString

public java.lang.String toString()
Returns the working contexts' name.

Returns:
The working contexts' name.


Copyright © 2002-2004 Toolforge. All Rights Reserved.