EjbConnection

public class EjbConnection

An EjbConnection represents a connection to the initial context by which the specified EJBHome can be looked up. The URL connection string for an EJBConnection should comply the following format: PROVIDER_URL@INITIAL_CONTEXT_FACTORY {@SECURITY_PROTOCOL}

Author:Hugo Y. K. Lam

Constructors

EjbConnection

public EjbConnection(String url, String username, String password)

Creates a new instance of EjbConnection.

Methods

close

public synchronized void close()

Closes this connection and releases any resources associated.

Throws:
  • EjbConnectionException – if errors occurred during closing the connection or, the connection has not yet been connected or has been closed already.

connect

public synchronized void connect()

Connects to the destination URL using the username and password stored in this connection.

Throws:

connect

public synchronized void connect(String username, String password)

Connects to the destination URL using the specified username and password.

Parameters:
  • username – the username used to connect. null if authentication is not required.
  • password – the password used to connect. null if authentication is not required.
Throws:
  • EjbConnectionException – if errors occurred during the establishment of connection or, the connection has been connected or closed already.

finalize

protected void finalize()

Closes this connection in finalization.

See also: java.lang.Object.finalize()

getUrl

public String getUrl()

Gets the URL of this connection.

Returns:the URL of this connection.

getUsername

public String getUsername()

Gets the username used for this connection.

Returns:the username used in this connection.

lookupHome

public Object lookupHome(String jndiName, Class narrowTo)

Retrieves the EJBHome by looking it up using the specified JNDI name. The EJBHome will be narrowed to the specified class if it is a remote interface.

Parameters:
  • jndiName – the JNDI name for the EJBHome to be looked up.
  • narrowTo – the class to which the EJBHome should be narrowed.
Throws:
Returns:

the EJBHome bound to the specified JNDI name.

toString

public String toString()

Returns a string representation of this object, which is the URL.

See also: java.lang.Object.toString()