org.apgrid.grpc.ng
Class NgGrpcClient

java.lang.Object
  extended byorg.apgrid.grpc.ng.NgGrpcClient
All Implemented Interfaces:
GrpcClient

public class NgGrpcClient
extends java.lang.Object
implements GrpcClient

Ninf-G implementation of GrpcClient interface.
Provides functions defined in standard interfaces and also provides Ninf-G special functions.


Constructor Summary
NgGrpcClient()
          Creates NgGrpcClient object.
 
Method Summary
 void activate(java.util.Properties prop)
          Initialize with Properties object which contains information for server.
If "user.configFile" SystemProperty was set, use it as configuration file.
If it's not set, then use Properties as information of the server.
 void activate(java.lang.String configFilename)
          Initialize with a name of configuration file.
If configFilename was null, "user.configFile" SystemProperty is used as configuration file.
 void deactivate()
          Finalize GrpcClient.
 GrpcFunctionHandle getFunctionHandle(int executableID)
          Gets GrpcFunctionHandle object which associated by executableID.
 GrpcFunctionHandle getFunctionHandle(java.lang.String functionName)
          Creates GrpcFunctionHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.
 GrpcFunctionHandle getFunctionHandle(java.lang.String functionName, java.util.Properties prop)
          Creates GrpcFunctionHandle for the specified function on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.
 GrpcFunctionHandle[] getFunctionHandles(java.lang.String functionName, int nHandles)
          Create specified number of GrpcFunctionHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.
 GrpcFunctionHandle[] getFunctionHandles(java.lang.String functionName, java.util.Properties prop, int nHandles)
          Creates specified number of GrpcFunctionHandle for the specified function on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.
 java.lang.Object getHandle(int executableID)
          Gets GrpcFunctionHandle or GrpcObjectHandle object which associated with executableID.
 int getID()
          Gets ID of this NgGrpcClient.
 GrpcObjectHandle getObjectHandle(int executableID)
          Gets GrpcObjectHandle object which associated by executableID.
 GrpcObjectHandle getObjectHandle(java.lang.String objectName)
          Creates GrpcObjectHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.
 GrpcObjectHandle getObjectHandle(java.lang.String objectName, java.util.Properties prop)
          Creates GrpcObjectHandle for the specified object on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.
 GrpcObjectHandle[] getObjectHandles(java.lang.String objectName, int nHandles)
          Creates specified number of GrpcObjectHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.
 GrpcObjectHandle[] getObjectHandles(java.lang.String objectName, java.util.Properties prop, int nHandles)
          Creates specified number of GrpcObjectHandle for the specified function on the server.
 void readConfig(java.lang.String configFile)
          read specified configfile.
 java.lang.String toString(int indent)
          Put information about this instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NgGrpcClient

public NgGrpcClient()
Creates NgGrpcClient object.

Method Detail

activate

public void activate(java.lang.String configFilename)
              throws GrpcException
Initialize with a name of configuration file.
If configFilename was null, "user.configFile" SystemProperty is used as configuration file.

Specified by:
activate in interface GrpcClient
Parameters:
configFilename - a name of configuration file.
Throws:
GrpcException - it it failed to initialize.

activate

public void activate(java.util.Properties prop)
              throws GrpcException
Initialize with Properties object which contains information for server.
If "user.configFile" SystemProperty was set, use it as configuration file.
If it's not set, then use Properties as information of the server.

Specified by:
activate in interface GrpcClient
Parameters:
prop - information of server.
Throws:
GrpcException - if it failed to initialize.

getFunctionHandle

public GrpcFunctionHandle getFunctionHandle(java.lang.String functionName,
                                            java.util.Properties prop)
                                     throws GrpcException
Creates GrpcFunctionHandle for the specified function on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.

Specified by:
getFunctionHandle in interface GrpcClient
Parameters:
functionName - a name of function.
prop - information of server.
Returns:
GrpcFunctionHandle.
Throws:
GrpcException - if it failed to create FunctionHandle.
See Also:
NgGrpcHandleAttr

getFunctionHandle

public GrpcFunctionHandle getFunctionHandle(java.lang.String functionName)
                                     throws GrpcException
Creates GrpcFunctionHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.

Specified by:
getFunctionHandle in interface GrpcClient
Parameters:
functionName - a name of function.
Returns:
GrpcFunctionHandle.
Throws:
GrpcException - if it failed to create FunctionHandle.

getFunctionHandles

public GrpcFunctionHandle[] getFunctionHandles(java.lang.String functionName,
                                               java.util.Properties prop,
                                               int nHandles)
                                        throws GrpcException
Creates specified number of GrpcFunctionHandle for the specified function on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.

Specified by:
getFunctionHandles in interface GrpcClient
Parameters:
functionName - a name of function.
prop - information of server.
nHandles - a number of FunctionHandle.
Returns:
a list of GrpcFunctionHandle.
Throws:
GrpcException - if it failed to create FunctionHandle.
See Also:
NgGrpcHandleAttr

getFunctionHandles

public GrpcFunctionHandle[] getFunctionHandles(java.lang.String functionName,
                                               int nHandles)
                                        throws GrpcException
Create specified number of GrpcFunctionHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.

Specified by:
getFunctionHandles in interface GrpcClient
Parameters:
functionName - a name of function.
nHandles - a number of FunctionHandle.
Returns:
a list of GrpcFunctionHandle.
Throws:
GrpcException - if it failed to create FunctionHandle.

getObjectHandle

public GrpcObjectHandle getObjectHandle(java.lang.String objectName,
                                        java.util.Properties prop)
                                 throws GrpcException
Creates GrpcObjectHandle for the specified object on the server.
Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.

Specified by:
getObjectHandle in interface GrpcClient
Parameters:
objectName - a name of object.
prop - information of server.
Returns:
GrpcObjectHandle.
Throws:
GrpcException - if it failed to create ObjectHandle.
See Also:
NgGrpcHandleAttr

getObjectHandle

public GrpcObjectHandle getObjectHandle(java.lang.String objectName)
                                 throws GrpcException
Creates GrpcObjectHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.

Specified by:
getObjectHandle in interface GrpcClient
Parameters:
objectName - a name of object.
Returns:
GrpcObjectHandle.
Throws:
GrpcException - if it failed to create ObjectHandle.

getObjectHandles

public GrpcObjectHandle[] getObjectHandles(java.lang.String objectName,
                                           java.util.Properties prop,
                                           int nHandles)
                                    throws GrpcException
Creates specified number of GrpcObjectHandle for the specified function on the server. Use prop argument to set attribute variables of the server.
Use strings defined in NgGrpcHandleAttr as key strings.

Specified by:
getObjectHandles in interface GrpcClient
Parameters:
objectName - a name of object.
prop - information of server.
nHandles - a number of ObjectHandle.
Returns:
a list of GrpcObjectHandle.
Throws:
GrpcException - if it failed to create ObjectHandle.
See Also:
NgGrpcHandleAttr

getObjectHandles

public GrpcObjectHandle[] getObjectHandles(java.lang.String objectName,
                                           int nHandles)
                                    throws GrpcException
Creates specified number of GrpcObjectHandle without server information.
The server which described at the 1st < SERVER > section in a configuration file will be used.

Specified by:
getObjectHandles in interface GrpcClient
Parameters:
objectName - a name of object.
nHandles - a number of ObjectHandle.
Returns:
a list of GrpcObjectHandle.
Throws:
GrpcException - if it failed to create ObjectHandle.

deactivate

public void deactivate()
                throws GrpcException
Description copied from interface: GrpcClient
Finalize GrpcClient.

Specified by:
deactivate in interface GrpcClient
Throws:
GrpcException - if it failed to finalize.

getID

public int getID()
Gets ID of this NgGrpcClient.

Returns:
ID number of this.

getHandle

public java.lang.Object getHandle(int executableID)
Gets GrpcFunctionHandle or GrpcObjectHandle object which associated with executableID.

Parameters:
executableID - ID of Grpc*Handle.
Returns:
Grpc*Handle if there is a object associated with executableID in this object. If there isn't the object, this returns null.

getFunctionHandle

public GrpcFunctionHandle getFunctionHandle(int executableID)
Gets GrpcFunctionHandle object which associated by executableID.

Parameters:
executableID - ID of GrpcFunctionHandle.
Returns:
GrpcFunctionHandle if there is a object associated with executableID in this object. If there isn't the object, this returns null.

getObjectHandle

public GrpcObjectHandle getObjectHandle(int executableID)
Gets GrpcObjectHandle object which associated by executableID.

Parameters:
executableID - ID of GrpcObjectHandle.
Returns:
GrpcObjectHandle if there is a object associated with executableID in this object. If there isn't the object, this returns null.

readConfig

public void readConfig(java.lang.String configFile)
                throws GrpcException
read specified configfile.

Parameters:
configFile -
Throws:
GrpcException

toString

public java.lang.String toString(int indent)
Put information about this instance.

Parameters:
indent - a number of white spaces before information.
Returns:
String which indicates this NgGrpcClient.