Remote System Explorer DataStore
Release 3.3

org.eclipse.dstore.core.miners
Class Miner

java.lang.Object
  extended by java.lang.Thread
      extended by org.eclipse.dstore.core.server.SecuredThread
          extended by org.eclipse.dstore.core.model.Handler
              extended by org.eclipse.dstore.core.miners.Miner
All Implemented Interfaces:
Runnable, ISchemaExtender

public abstract class Miner
extends Handler
implements ISchemaExtender

Miner is the abstract base class of all DataStore extensions). The DataStore framework knows how to load and route commands to miners because it interfaces miners through the restricted set of interfaces declared here. To add a new miner, developers must extend this class and implement the abstract methods declared here. This class and its subclasses are not intended to be instantiated by clients. The dstore server infrastructure will take care of loading the Miner.


Field Summary
protected  List _commandQueue
           
protected  ArrayList _dependencies
           
 DataElement _minerData
           
 DataElement _minerElement
           
 DataElement _minerTransient
           
protected  String _name
           
protected  ResourceBundle _resourceBundle
           
protected  String _value
           
 
Fields inherited from class org.eclipse.dstore.core.model.Handler
_keepRunning, _waitIncrement
 
Fields inherited from class org.eclipse.dstore.core.server.SecuredThread
_dataStore
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected Miner()
          Creates a new Miner
 
Method Summary
protected  DataElement command(DataElement command)
          Issues a specified command on this miner from the DataStore framework.
 DataElement createAbstractCommandDescriptor(DataElement descriptor, String name, String value)
          Creates an abstract command descriptor.
 DataElement createAbstractObjectDescriptor(DataElement descriptor, String name)
          Creates an abstract object descriptor.
 DataElement createAbstractObjectDescriptor(DataElement descriptor, String name, String source)
          Creates an abstract object descriptor.
 DataElement createAbstractRelationship(DataElement from, DataElement to)
          Creates an abstract relationship between two descriptors.
 DataElement createCommandDescriptor(DataElement descriptor, String name, String value)
          Creates a command descriptor.
 DataElement createCommandDescriptor(DataElement descriptor, String name, String value, boolean visible)
          Creates a command descriptor.
 DataElement createObjectDescriptor(DataElement descriptor, String name)
          Creates a object descriptor.
 DataElement createObjectDescriptor(DataElement descriptor, String name, String source)
          Creates a object descriptor.
 DataElement createReference(DataElement from, DataElement to)
          Creates a contents relationship between any two elements.
 DataElement createRelationDescriptor(DataElement descriptor, String name)
          Creates a new type of relationship descriptor.
 void finish()
          Shuts down the miner and cleans up it's meta-information.
 DataElement getCommandArgument(DataElement command, int arg)
          Returns the argument of a command specified at a given index.
 String getCommandName(DataElement command)
          Returns the name of a command.
 DataElement getCommandStatus(DataElement command)
          Returns the status of a command.
protected  ArrayList getDependencies()
           
 IExternalLoader getExternalLoader()
          Implement this to returns the external class loader for this extender implementation.
 DataElement getMinerData()
          Returns the element that contains this miners meta-information.
 ArrayList getMinerDependencies()
          Returns the qualified names of all miners that this miner depends on.
 DataElement getMinerElement()
          Returns the element that represents this miner.
 String getMinerName()
          Returns the qualified name of this miner
 DataElement getMinerTransient()
          Returns the transient object container for this element.
 int getNumberOfCommandArguments(DataElement command)
          Returns the number of arguments for this command.
 ResourceBundle getResourceBundle()
          Interface to retrieve an NL enabled resource bundle.
 DataElement getSchemaRoot()
          Returns the descriptor root for the DataStore schema
 String getValue()
          Returns the name of this miner
abstract  String getVersion()
          Returns the version of this miner The expected format for this is ".
 void handle()
          Implemented to provide the periodic activity to be done in a handler.
abstract  DataElement handleCommand(DataElement theCommand)
          Handle commands that are routed to this miner.
 void initMiner(DataElement status)
           
 boolean isConnected()
          Indicates whether the miner has been connected to the DataStore yet.
 boolean isInitialized()
          Indicates whether the miner has been initialized yet
protected  void load()
          Default method that gets called on a Miner when it is loaded.
protected  void load(DataElement status)
          Default method that gets called on a Miner when it is loaded.
 void makeTransient(DataElement objectDescriptor)
          Identifies a give object descriptor type to be transient in this miner.
 void requestCommand(DataElement command)
           
 void setDataStore(DataStore dataStore)
          Sets the DataStore and performs some fundamental initialization for this miner.
 void setExternalLoader(IExternalLoader loader)
           
protected  void updateMinerInfo()
          This gets called after a miner is initialized.
 void waitForInput()
          Causes the current thread to wait until this class request has been fulfilled.
 
Methods inherited from class org.eclipse.dstore.core.model.Handler
getWaitTime, isFinished, notifyInput, run, setWaitTime
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.dstore.core.model.ISchemaExtender
extendSchema
 

Field Detail

_minerElement

public DataElement _minerElement

_minerData

public DataElement _minerData

_minerTransient

public DataElement _minerTransient

_name

protected String _name

_value

protected String _value

_dependencies

protected ArrayList _dependencies

_commandQueue

protected List _commandQueue

_resourceBundle

protected ResourceBundle _resourceBundle
Constructor Detail

Miner

protected Miner()
Creates a new Miner

Method Detail

getMinerDependencies

public final ArrayList getMinerDependencies()
Returns the qualified names of all miners that this miner depends on. A miner depends on another miner if it's schema extends or uses another's schema. By default it returns an empty list.

Returns:
a list of miner dependencies, each represented as a qualified name

getDependencies

protected ArrayList getDependencies()

isInitialized

public final boolean isInitialized()
Indicates whether the miner has been initialized yet

Returns:
whether the miner has been initialized

isConnected

public final boolean isConnected()
Indicates whether the miner has been connected to the DataStore yet.

Returns:
whether the miner has been connected to the DataStore

finish

public void finish()
Shuts down the miner and cleans up it's meta-information. Override this function to do your own cleanup.

Subclasses may override this method but must call super.finish() at the end of their overriding method.

Overrides:
finish in class Handler

getResourceBundle

public ResourceBundle getResourceBundle()
Interface to retrieve an NL enabled resource bundle. Override this function to get access to a real resource bundle.


load

protected void load()
Default method that gets called on a Miner when it is loaded. Override this function to perform some initialization at miner loading time.


load

protected void load(DataElement status)
Default method that gets called on a Miner when it is loaded. Override this function to perform some initialization at miner loading time. If loading the miner can result in some failure, set that status to incomplete

Parameters:
status - the status of the initialize miner command

updateMinerInfo

protected void updateMinerInfo()
This gets called after a miner is initialized. If you need to update element information at that time, override this method.


getMinerName

public final String getMinerName()
Returns the qualified name of this miner

Returns:
the qualified name of this miner

getValue

public final String getValue()
Returns the name of this miner

Returns:
the name of this miner

handle

public final void handle()
Description copied from class: Handler
Implemented to provide the periodic activity to be done in a handler. This method is called between wait intervals by the handler thread.

Specified by:
handle in class Handler

requestCommand

public final void requestCommand(DataElement command)

initMiner

public final void initMiner(DataElement status)

command

protected final DataElement command(DataElement command)
Issues a specified command on this miner from the DataStore framework. The base class handles "C_INIT_MINERS" but other commands are delegated to the concrete miner implementations through handleCommand()

Parameters:
command - the command that has been sent to this miner
Returns:
the status of the command

setDataStore

public final void setDataStore(DataStore dataStore)
Sets the DataStore and performs some fundamental initialization for this miner. The framework calls this method on a miner before any commands are issued. The extendSchema() is called on the miner.

Overrides:
setDataStore in class Handler
Parameters:
dataStore - the DataStore that owns this miner

createAbstractCommandDescriptor

public final DataElement createAbstractCommandDescriptor(DataElement descriptor,
                                                         String name,
                                                         String value)
Creates an abstract command descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the command
value - the identifier for this command
Returns:
the new command descriptor

createCommandDescriptor

public final DataElement createCommandDescriptor(DataElement descriptor,
                                                 String name,
                                                 String value)
Creates a command descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the command
value - the identifier for this command
Returns:
the new command descriptor

createCommandDescriptor

public final DataElement createCommandDescriptor(DataElement descriptor,
                                                 String name,
                                                 String value,
                                                 boolean visible)
Creates a command descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the command
value - the identifier for this command
visible - an indication whether this command descriptor should be visible to an end-user
Returns:
the new command descriptor

createAbstractObjectDescriptor

public final DataElement createAbstractObjectDescriptor(DataElement descriptor,
                                                        String name)
Creates an abstract object descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the object type
Returns:
the new object descriptor

createAbstractObjectDescriptor

public final DataElement createAbstractObjectDescriptor(DataElement descriptor,
                                                        String name,
                                                        String source)
Creates an abstract object descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the object type
source - the plugin location of the miner that owns this object type
Returns:
the new object descriptor

createObjectDescriptor

public final DataElement createObjectDescriptor(DataElement descriptor,
                                                String name)
Creates a object descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the object type
Returns:
the new object descriptor

createObjectDescriptor

public final DataElement createObjectDescriptor(DataElement descriptor,
                                                String name,
                                                String source)
Creates a object descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the object type
source - the plugin location of the miner that owns this object type
Returns:
the new object descriptor

createRelationDescriptor

public final DataElement createRelationDescriptor(DataElement descriptor,
                                                  String name)
Creates a new type of relationship descriptor. This is a helper method that miner may call when it creates or updates the schema for it's tool domain

Parameters:
descriptor - the parent descriptor for the new descriptor
name - the name of the relationship type
Returns:
the new relationship descriptor

createAbstractRelationship

public final DataElement createAbstractRelationship(DataElement from,
                                                    DataElement to)
Creates an abstract relationship between two descriptors. An abstract relationship between two descriptors indicates that the first descriptor abstracts the second, while the second inherits the properties of the first. This is a helper method that miner may call when it creates or updates the schema for it's tool domain.

Parameters:
from - the abstacting descriptor
to - the descriptor that is abstracted
Returns:
the new relationship descriptor

createReference

public final DataElement createReference(DataElement from,
                                         DataElement to)
Creates a contents relationship between any two elements.

Parameters:
from - the containing element
to - the element that is contained
Returns:
the new relationship

getMinerElement

public final DataElement getMinerElement()
Returns the element that represents this miner.

Returns:
the miner element

getMinerData

public final DataElement getMinerData()
Returns the element that contains this miners meta-information.

Returns:
the miner data element

getMinerTransient

public final DataElement getMinerTransient()
Returns the transient object container for this element.

Returns:
the transient element

makeTransient

public final void makeTransient(DataElement objectDescriptor)
Identifies a give object descriptor type to be transient in this miner.

Parameters:
objectDescriptor - the object descriptor type that is transient

getCommandName

public final String getCommandName(DataElement command)
Returns the name of a command. This is a helper method to be used inside handleCommand().

Parameters:
command - a tree of elements representing a command
Returns:
the name of the command

getCommandStatus

public final DataElement getCommandStatus(DataElement command)
Returns the status of a command. This is a helper method to be used inside handleCommand().

Parameters:
command - a tree of elements representing a command
Returns:
the status element for the command

getNumberOfCommandArguments

public final int getNumberOfCommandArguments(DataElement command)
Returns the number of arguments for this command. This is a helper method to be used inside handleCommand().

Parameters:
command - a tree of elements representing a command
Returns:
the number of arguments for this command

getCommandArgument

public final DataElement getCommandArgument(DataElement command,
                                            int arg)
Returns the argument of a command specified at a given index. This is a helper method to be used inside handleCommand().

Parameters:
command - a tree of elements representing a command
arg - the index into the commands children
Returns:
the argument of the command

getSchemaRoot

public final DataElement getSchemaRoot()
Returns the descriptor root for the DataStore schema

Returns:
the descriptor root

setExternalLoader

public void setExternalLoader(IExternalLoader loader)

getExternalLoader

public IExternalLoader getExternalLoader()
Description copied from interface: ISchemaExtender
Implement this to returns the external class loader for this extender implementation. In order for a tool extension to be loaded by the DataStore, it's class loader needs to be supplied.

Specified by:
getExternalLoader in interface ISchemaExtender
Returns:
the external loader

waitForInput

public void waitForInput()
Description copied from class: Handler
Causes the current thread to wait until this class request has been fulfilled.

Overrides:
waitForInput in class Handler

handleCommand

public abstract DataElement handleCommand(DataElement theCommand)
                                   throws Exception
Handle commands that are routed to this miner. This interface must be implemented by each miner in order to perform tool actions driven from user interface interaction.

Parameters:
theCommand - an instance of a command containing a tree of arguments
Throws:
Exception

getVersion

public abstract String getVersion()
Returns the version of this miner The expected format for this is ".."


Remote System Explorer DataStore
Release 3.3

Copyright (c) IBM Corporation and others 2000, 2011. All Rights Reserved.