gnu.CORBA

Class OrbFunctional

Known Direct Subclasses:
ORB_1_4

public class OrbFunctional
extends OrbRestricted

The ORB implementation, capable to handle remote invocations on the registered object. This class implements all features, required till the jdk 1.3 inclusive, but does not support the POA that appears since 1.4. The POA is supported by ORB_1_4.

Nested Class Summary

protected class
OrbFunctional.portServer
A server, responsible for listening on requests on some local port.
protected class
OrbFunctional.sharedPortServer
A server, responsible for listening on requests on some local port and serving multiple requests (probably to the different objects) on the same thread.

Field Summary

static String
AFTER_RECEIVING
If the message body is received, the time out changes to the specifice value.
static int
DEFAULT_INITIAL_PORT
The default value where the first instance of this ORB will start looking for a free port.
static String
LISTEN_ON
The property of port, on that this ORB is listening for requests from clients.
String
LOCAL_HOST
The address of the local host.
static String
NAME_SERVICE
The string, defining the naming service initial reference.
static String
NS_HOST
The property, defining the host on that the default name service is running.
static String
NS_PORT
The property, defining the port on that the default name service is running.
static String
ORB_ID
Defines the ORB ID that is accessible by IOR interceptors.
static int
RANDOM_PORT_ATTEMPTS
The number of attempts to try when opening random port.
static int
RANDOM_PORT_FROM
When trying to open the socket on a random port, start of the interval to try.
static int
RANDOM_PORT_TO
When trying to open the socket on a random port, end of the interval to try.
static String
REFERENCE
The property, defining the IOR of the intial reference to resolve.
static String
SERVER_ERROR_PAUSE
The server waits for this duration after the potentially transient error during its servicing cycle.
static String
SERVER_ID
Defines the SERVER ID that is accessible by IOR interceptors.
static String
START_READING_MESSAGE
The if the client has once opened a socket, it should start sending the message header in a given time.
static int
TANDEM_REQUESTS
Some clients tend to submit multiple requests over the same socket.
int
TOUT_AFTER_RECEIVING
If the message body is received, the time out changes to the specifice value.
int
TOUT_START_READING_MESSAGE
The if the client has once opened a socket, it should start sending the message header in a given time.
int
TOUT_WHILE_READING
If the client has started to send the request message, the socket time out changes to the specified value.
int
TWAIT_SERVER_ERROR_PAUSE
The server waits for this duration after the potentially transient error during its servicing cycle.
static String
WHILE_READING
If the client has started to send the request message, the socket time out changes to the specified value.
protected Asynchron
asynchron
The instance, stored in this field, handles the asynchronous dynamic invocations.
protected Connected_objects
connected_objects
The map of the already conncted objects.
protected LinkedList<T>
freed_ports
The list of the freed ports.
protected Hashtable<K,V>
identities
Maps a single-threaded POAs to they sharedPortServants.
protected Map<K,V>
initial_references
The map of the initial references.
protected Version
max_version
The maximal CORBA version, supported by this ORB.
String
orb_id
The Id of this ORB.
protected ArrayList<E>
portServers
The currently active portServers.
protected boolean
running
Setting this value to false causes the ORB to shutdown after the latest serving operation is complete.
static String
server_id
The Id of this Server.
SocketFactory
socketFactory
The producer of the client and server sockets for this ORB.

Fields inherited from class gnu.CORBA.OrbRestricted

Singleton, factories, iClient, iIor, iServer, icSlotSize, policyFactories

Constructor Summary

OrbFunctional()
Create the instance of the Functional ORB.

Method Summary

void
connect(Object object)
Connect the given CORBA object to this ORB.
void
connect(Object object, byte[] key)
Connect the given CORBA object to this ORB, explicitly specifying the object key.
void
connect_1_thread(Object object, byte[] key, Object identity)
Connect the given CORBA object to this ORB, explicitly specifying the object key and the identity of the thread (and port), where the object must be served.
int
countConnectedObjects()
Get the number of objects that are connected to this ORB.
protected IOR
createIOR(Connected_objects.cObject ref)
Create IOR for the given object references.
void
destroy()
Destroy this server, releasing the occupied resources.
void
disconnect(Object object)
Disconnect the given CORBA object from this ORB.
void
ensureRunning()
Start the server in a new thread, if not already running.
protected void
finalize()
Set the flag, forcing all server threads to terminate.
protected Object
find_connected_object(byte[] key, int port)
Find and return the object, that must be previously connected to this ORB.
Object
find_local_object(IOR ior)
Find the local object, connected to this ORB.
protected Object
getDefaultNameService()
Get the default naming service for the case when there no NameService entries.
int
getFreePort()
Get the currently free port, starting from the initially set port and going up max 20 steps, then trying to bind into any free address.
IOR
getLocalIor(Object forObject)
Get the local IOR for the given object, null if the object is not local.
Version
getMaxVersion()
Get the maximal supported GIOP version or null if the version is not checked.
Request
get_next_response()
Get the next instance with a response being received.
void
identityDestroyed(Object identity)
Notifies ORB that the shared service indentity (usually POA) is destroyed.
Object
ior_to_object(IOR ior)
Convert ior reference to CORBA object.
String[]
list_initial_services()
List the initially available CORBA objects (services).
String
object_to_string(Object forObject)
Get the IOR reference string for the given object.
boolean
poll_next_response()
Find if any of the requests that have been previously sent with send_multiple_requests_deferred(Request[]), have a response yet.
protected void
prepareObject(Object object, IOR ior)
Prepare object for connecting it to this ORB.
Object
resolve_initial_references(String name)
Find and return the easily accessible CORBA object, addressed by name.
void
run()
Start the ORBs main working cycle (receive invocation - invoke on the local object - send response - wait for another invocation).
void
send_multiple_requests_deferred(Request[] requests)
Send multiple prepared requests expecting to get a reply.
void
send_multiple_requests_oneway(Request[] requests)
Send multiple prepared requests one way, do not caring about the answer.
void
setMaxVersion(Version max_supported)
If the max version is assigned, the orb replies with the error message if the request version is above the supported 1.2 version.
static void
setPort(int a_Port)
Set the port, on that the server is listening for the client requests.
protected void
set_parameters(Applet app, Properties props)
Set the ORB parameters.
protected void
set_parameters(String[] para, Properties props)
Set the ORB parameters.
void
shutdown(boolean wait_for_completion)
Shutdown the ORB server.
void
startService(IOR ior)
Start the service on the given port of this IOR.
Object
string_to_object(String an_ior)
Find and return the CORBA object, addressed by the given IOR string representation.
protected void
useProperties(Properties props)
Set the ORB parameters from the properties that were accumulated from several locations.

Methods inherited from class gnu.CORBA.OrbRestricted

create_alias_tc, create_any, create_array_tc, create_context_list, create_enum_tc, create_environment, create_exception_list, create_exception_tc, create_interface_tc, create_list, create_named_value, create_output_stream, create_recursive_sequence_tc, create_sequence_tc, create_string_tc, create_struct_tc, create_union_tc, create_wstring_tc, destroy, get_default_context, get_next_response, get_primitive_tc, list_initial_services, lookup_value_factory, object_to_string, poll_next_response, register_value_factory, resolve_initial_references, run, send_multiple_requests_deferred, send_multiple_requests_oneway, set_parameters, set_parameters, shutdown, string_to_object, unregister_value_factory

Methods inherited from class org.omg.CORBA_2_3.ORB

get_value_def, lookup_value_factory, register_value_factory, set_delegate, unregister_value_factory

Methods inherited from class org.omg.CORBA.ORB

connect, create_abstract_interface_tc, create_alias_tc, create_any, create_array_tc, create_basic_dyn_any, create_context_list, create_dyn_any, create_dyn_array, create_dyn_enum, create_dyn_sequence, create_dyn_struct, create_dyn_union, create_enum_tc, create_environment, create_exception_list, create_exception_tc, create_fixed_tc, create_interface_tc, create_list, create_named_value, create_native_tc, create_operation_list, create_output_stream, create_policy, create_recursive_sequence_tc, create_recursive_tc, create_sequence_tc, create_string_tc, create_struct_tc, create_union_tc, create_value_box_tc, create_value_tc, create_wstring_tc, destroy, disconnect, get_current, get_default_context, get_next_response, get_primitive_tc, get_service_information, init, init, init, list_initial_services, object_to_string, perform_work, poll_next_response, resolve_initial_references, run, send_multiple_requests_deferred, send_multiple_requests_oneway, set_parameters, set_parameters, shutdown, string_to_object, work_pending

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

AFTER_RECEIVING

public static String AFTER_RECEIVING
If the message body is received, the time out changes to the specifice value. This must be longer, as includes time, required to process the received task. We make it 40 minutes.

DEFAULT_INITIAL_PORT

public static int DEFAULT_INITIAL_PORT
The default value where the first instance of this ORB will start looking for a free port.

LISTEN_ON

public static final String LISTEN_ON
The property of port, on that this ORB is listening for requests from clients. This class supports one port per ORB only.
Field Value:
"gnu.classpath.CORBA.ListenOn"

LOCAL_HOST

public final String LOCAL_HOST
The address of the local host.

NAME_SERVICE

public static final String NAME_SERVICE
The string, defining the naming service initial reference.
Field Value:
"NameService"

NS_HOST

public static final String NS_HOST
The property, defining the host on that the default name service is running.
Field Value:
"org.omg.CORBA.ORBInitialHost"

NS_PORT

public static final String NS_PORT
The property, defining the port on that the default name service is running.
Field Value:
"org.omg.CORBA.ORBInitialPort"

ORB_ID

public static final String ORB_ID
Defines the ORB ID that is accessible by IOR interceptors.
Field Value:
"org.omg.CORBA.ORBid"

RANDOM_PORT_ATTEMPTS

public static int RANDOM_PORT_ATTEMPTS
The number of attempts to try when opening random port.

RANDOM_PORT_FROM

public static int RANDOM_PORT_FROM
When trying to open the socket on a random port, start of the interval to try.

RANDOM_PORT_TO

public static int RANDOM_PORT_TO
When trying to open the socket on a random port, end of the interval to try.

REFERENCE

public static final String REFERENCE
The property, defining the IOR of the intial reference to resolve.
Field Value:
"org.omg.CORBA.ORBInitRef"

SERVER_ERROR_PAUSE

public static String SERVER_ERROR_PAUSE
The server waits for this duration after the potentially transient error during its servicing cycle.

SERVER_ID

public static final String SERVER_ID
Defines the SERVER ID that is accessible by IOR interceptors.
Field Value:
"org.omg.CORBA.ServerId"

START_READING_MESSAGE

public static String START_READING_MESSAGE
The if the client has once opened a socket, it should start sending the message header in a given time. Otherwise the server will close the socket. This prevents server hang when the client opens the socket, but does not send any message, usually due crash on the client side.

TANDEM_REQUESTS

public static int TANDEM_REQUESTS
Some clients tend to submit multiple requests over the same socket. The server waits for the next request on the same socket for the duration, specified below. In additions, the request of this implementation also waits for the same duration before closing the socket. The default time is seven seconds.

TOUT_AFTER_RECEIVING

public int TOUT_AFTER_RECEIVING
If the message body is received, the time out changes to the specifice value. This must be longer, as includes time, required to process the received task. We make it 40 minutes.

TOUT_START_READING_MESSAGE

public int TOUT_START_READING_MESSAGE
The if the client has once opened a socket, it should start sending the message header in a given time. Otherwise the server will close the socket. This prevents server hang when the client opens the socket, but does not send any message, usually due crash on the client side.

TOUT_WHILE_READING

public int TOUT_WHILE_READING
If the client has started to send the request message, the socket time out changes to the specified value.

TWAIT_SERVER_ERROR_PAUSE

public int TWAIT_SERVER_ERROR_PAUSE
The server waits for this duration after the potentially transient error during its servicing cycle.

WHILE_READING

public static String WHILE_READING
If the client has started to send the request message, the socket time out changes to the specified value.

asynchron

protected Asynchron asynchron
The instance, stored in this field, handles the asynchronous dynamic invocations.

connected_objects

protected final Connected_objects connected_objects
The map of the already conncted objects.

freed_ports

protected LinkedList<T> freed_ports
The list of the freed ports. The ORB reuses ports, when possible.

identities

protected Hashtable<K,V> identities
Maps a single-threaded POAs to they sharedPortServants.

initial_references

protected Map<K,V> initial_references
The map of the initial references.

max_version

protected Version max_version
The maximal CORBA version, supported by this ORB. The default value 0 means that the ORB will not check the request version while trying to respond.

orb_id

public String orb_id
The Id of this ORB.

portServers

protected ArrayList<E> portServers
The currently active portServers.

running

protected boolean running
Setting this value to false causes the ORB to shutdown after the latest serving operation is complete.

server_id

public static String server_id
The Id of this Server. This field is defined static to ensure it has the same value over all ORB's in this machine.

socketFactory

public SocketFactory socketFactory
The producer of the client and server sockets for this ORB.

Constructor Details

OrbFunctional

public OrbFunctional()
Create the instance of the Functional ORB.

Method Details

connect

public void connect(Object object)
Connect the given CORBA object to this ORB. After the object is connected, it starts receiving remote invocations via this ORB. The ORB tries to connect the object to the port, that has been previously set by setPort(int). On failure, it tries 20 subsequent larger values and then calls the parameterless server socked constructor to get any free local port. If this fails, the NO_RESOURCES is thrown.
Overrides:
connect in interface ORB
Parameters:
object - the object, must implement the InvokeHandler) interface.
Throws:
BAD_PARAM - if the object does not implement the InvokeHandler).

connect

public void connect(Object object,
                    byte[] key)
Connect the given CORBA object to this ORB, explicitly specifying the object key. The ORB tries to connect the object to the port, that has been previously set by setPort(int). On failure, it tries 20 subsequent larger values and then calls the parameterless server socked constructor to get any free local port. If this fails, the NO_RESOURCES is thrown.
Parameters:
object - the object, must implement the InvokeHandler) interface.
key - the object key, usually used to identify the object from remote side.
Throws:
BAD_PARAM - if the object does not implement the InvokeHandler).

connect_1_thread

public void connect_1_thread(Object object,
                             byte[] key,
                             Object identity)
Connect the given CORBA object to this ORB, explicitly specifying the object key and the identity of the thread (and port), where the object must be served. The identity is normally the POA. The new port server will be started only if there is no one already running for the same identity. Otherwise, the task of the existing port server will be widened, including duty to serve the given object. All objects, connected to a single identity by this method, will process they requests subsequently in the same thread. The method is used when the expected number of the objects is too large to have a single port and thread per object. This method is used by POAs, having a single thread policy.
Parameters:
object - the object, must implement the InvokeHandler) interface.
key - the object key, usually used to identify the object from remote side.
Throws:
BAD_PARAM - if the object does not implement the InvokeHandler).

countConnectedObjects

public int countConnectedObjects()
Get the number of objects that are connected to this ORB.
Returns:
the number of objects, connected to this ORB.

createIOR

protected IOR createIOR(Connected_objects.cObject ref)
            throws BAD_OPERATION
Create IOR for the given object references.

destroy

public void destroy()
Destroy this server, releasing the occupied resources.
Overrides:
destroy in interface OrbRestricted

disconnect

public void disconnect(Object object)
Disconnect the given CORBA object from this ORB. The object will be no longer receiving the remote invocations. In response to the remote invocation on this object, the ORB will send the exception OBJECT_NOT_EXIST. The object, however, is not destroyed and can receive the local invocations.
Overrides:
disconnect in interface ORB
Parameters:
object - the object to disconnect.

ensureRunning

public void ensureRunning()
Start the server in a new thread, if not already running. This method is used to ensure that the objects being transfered will be served from the remote side, if required. If the ORB is started using this method, it starts as a daemon thread.

finalize

protected void finalize()
            throws Throwable
Set the flag, forcing all server threads to terminate.
Overrides:
finalize in interface Object

find_connected_object

protected Object find_connected_object(byte[] key,
                                       int port)
Find and return the object, that must be previously connected to this ORB. Return null if no such object is available.
Parameters:
key - the object key.
port - the port where the object is connected.
Returns:
the connected object, null if none.

find_local_object

public Object find_local_object(IOR ior)
Find the local object, connected to this ORB.
Parameters:
ior - the ior of the potentially local object.
Returns:
the local object, represented by the given IOR, or null if this is not a local connected object.

getDefaultNameService

protected Object getDefaultNameService()
Get the default naming service for the case when there no NameService entries.

getFreePort

public int getFreePort()
            throws BAD_OPERATION
Get the currently free port, starting from the initially set port and going up max 20 steps, then trying to bind into any free address.
Returns:
the currently available free port.
Throws:
NO_RESOURCES - if the server socked cannot be opened on the local host.

getLocalIor

public IOR getLocalIor(Object forObject)
Get the local IOR for the given object, null if the object is not local.

getMaxVersion

public Version getMaxVersion()
Get the maximal supported GIOP version or null if the version is not checked.

get_next_response

public Request get_next_response()
            throws WrongTransaction
Get the next instance with a response being received. If all currently sent responses not yet processed, this method pauses till at least one of them is complete. If there are no requests currently sent, the method pauses till some request is submitted and the response is received. This strategy is identical to the one accepted by Suns 1.4 ORB implementation. The returned response is removed from the list of the currently submitted responses and is never returned again.
Overrides:
get_next_response in interface OrbRestricted
Returns:
the previously sent request that now contains the received response.
Throws:
WrongTransaction - If the method was called from the transaction scope different than the one, used to send the request. The exception can be raised only if the request is implicitly associated with some particular transaction.

identityDestroyed

public void identityDestroyed(Object identity)
Notifies ORB that the shared service indentity (usually POA) is destroyed. The matching shared port server is terminated and the identity table entry is deleted. If this identity is not known for this ORB, the method returns without action.
Parameters:
identity - the identity that has been destroyed.

ior_to_object

public Object ior_to_object(IOR ior)
Convert ior reference to CORBA object.

list_initial_services

public String[] list_initial_services()
List the initially available CORBA objects (services).
Overrides:
list_initial_services in interface OrbRestricted
Returns:
a list of services.
See Also:
resolve_initial_references(String)

object_to_string

public String object_to_string(Object forObject)
Get the IOR reference string for the given object. The string embeds information about the object repository Id, its access key and the server internet address and port. With this information, the object can be found by another ORB, possibly located on remote computer.
Overrides:
object_to_string in interface OrbRestricted
Parameters:
forObject - CORBA object
Returns:
the object IOR representation.
Throws:
BAD_PARAM - if the object has not been previously connected to this ORB.
BAD_OPERATION - in the unlikely case if the local host address cannot be resolved.
See Also:
string_to_object(String)

poll_next_response

public boolean poll_next_response()
Find if any of the requests that have been previously sent with send_multiple_requests_deferred(Request[]), have a response yet.
Overrides:
poll_next_response in interface OrbRestricted
Returns:
true if there is at least one response to the previously sent request, false otherwise.

prepareObject

protected void prepareObject(Object object,
                             IOR ior)
            throws BAD_PARAM
Prepare object for connecting it to this ORB.
Parameters:
object - the object being connected.
Throws:
BAD_PARAM - if the object does not implement the InvokeHandler).

resolve_initial_references

public Object resolve_initial_references(String name)
            throws InvalidName
Find and return the easily accessible CORBA object, addressed by name.
Overrides:
resolve_initial_references in interface OrbRestricted
Parameters:
name - the object name.
Returns:
the object
Throws:
InvalidName - if the given name is not associated with the known object.

run

public void run()
Start the ORBs main working cycle (receive invocation - invoke on the local object - send response - wait for another invocation). The method only returns after calling shutdown(boolean).
Overrides:
run in interface OrbRestricted

send_multiple_requests_deferred

public void send_multiple_requests_deferred(Request[] requests)
Send multiple prepared requests expecting to get a reply. All requests are send in parallel, each in its own separate thread. When the reply arrives, it is stored in the agreed fields of the corresponing request data structure. If this method is called repeatedly, the new requests are added to the set of the currently sent requests, but the old set is not discarded.
Overrides:
send_multiple_requests_deferred in interface OrbRestricted
Parameters:
requests - the prepared array of requests.

send_multiple_requests_oneway

public void send_multiple_requests_oneway(Request[] requests)
Send multiple prepared requests one way, do not caring about the answer. The messages, containing requests, will be marked, indicating that the sender is not expecting to get a reply.
Overrides:
send_multiple_requests_oneway in interface OrbRestricted
Parameters:
requests - the prepared array of requests.

setMaxVersion

public void setMaxVersion(Version max_supported)
If the max version is assigned, the orb replies with the error message if the request version is above the supported 1.2 version. This behavior is recommended by OMG, but not all implementations respond that error message by re-sending the request, encoded in the older version.

setPort

public static void setPort(int a_Port)
Set the port, on that the server is listening for the client requests. If only one object is connected to the orb, the server will be try listening on this port first. It the port is busy, or if more objects are connected, the subsequent object will receive a larger port values, skipping unavailable ports, if required. The change applies globally.
Parameters:
a_Port - a port, on that the server is listening for requests.

set_parameters

protected void set_parameters(Applet app,
                              Properties props)
Set the ORB parameters. This method is normally called from init(Applet,Properties).
Overrides:
set_parameters in interface OrbRestricted
Parameters:
app - the current applet.
props - application specific properties, passed as the second parameter in init(Applet,Properties). Can be null.

set_parameters

protected void set_parameters(String[] para,
                              Properties props)
Set the ORB parameters. This method is normally called from init(String[],Properties).
Overrides:
set_parameters in interface OrbRestricted
Parameters:
para - the parameters, that were passed as the parameters to the main(String[] args) method of the current standalone application.
props - application specific properties that were passed as a second parameter in init(String[], Properties)). Can be null.

shutdown

public void shutdown(boolean wait_for_completion)
Shutdown the ORB server.
Overrides:
shutdown in interface OrbRestricted
Parameters:
wait_for_completion - if true, the current thread is suspended until the shutdown process is complete.

startService

public void startService(IOR ior)
Start the service on the given port of this IOR.
Parameters:
ior - the ior (only Internet.port is used).

string_to_object

public Object string_to_object(String an_ior)
Find and return the CORBA object, addressed by the given IOR string representation. The object can (an usually is) located on a remote computer, possibly running a different (not necessary java) CORBA implementation.
Overrides:
string_to_object in interface OrbRestricted
Parameters:
an_ior - the object IOR representation string.
Returns:
the found CORBA object.
See Also:
object_to_string(org.omg.CORBA.Object)

useProperties

protected void useProperties(Properties props)
Set the ORB parameters from the properties that were accumulated from several locations.

OrbFunctional.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.