# weblogic.jws.control
EJBControl Interface

public interface EJBControl
extends `Control`

Enterprise Java Bean Control base interface

All Superinterfaces
  `Control`, `Control`, `Serializable`

All Known Subinterfaces
  `EntityEJBControl`, `EntityEJBControl`, `SessionEJBControl`, `SessionEJBControl`

## Method Summary

`public `Object`` | `getEJBBeanInstance`() Returns the current target instance of the EJB business interface used for business interface method invocations.
`public `Throwable`` | `getEJBException`() Returns the last EJB exception serviced by this control on the developer's behalf.
`public `Object`` | `getEJBHomeInstance`() Returns an instance of the home interface associated with the target EJB.
`public `String`` | `getJNDIName`() Returns the JNDI name associated with the EJB which this control represents.
`public boolean` | `hasEJBBeanInstance`() Returns `true` if this control currently has a target bean instance upon which bean business interface methods may be invoked.
`public void` | `setJNDIName`(`String` jndiName) Sets the JNDI name associated with this control; in other words, this method effectively sets which EJB is associated with the control.

## Method Detail

### getEJBBeanInstance() Method

    public Object getEJBBeanInstance()

Returns the current target instance of the EJB business interface used for business interface method invocations. This API is provided for advanced use cases were direct access to the local/ remote interfaces outside of the control is required. It will return `null` if no target instance is currently selected.

#### Returns

The business interface instance for the EJB that this control represents; `null` if no target instance is currently selected.

### getEJBException() Method

    public Throwable getEJBException()

Returns the last EJB exception serviced by this control on the developer's behalf. This can be used to discover or log additional information, such as when a create or find method is unable to locate a target bean instance.

#### Returns

The last EJB exception serviced by this control.

### getEJBHomeInstance() Method

    public Object getEJBHomeInstance()

Returns an instance of the home interface associated with the target EJB.

#### Returns

The home interface instance for the EJB with which this control is associated.

### getJNDIName() Method

    public String getJNDIName()

Returns the JNDI name associated with the EJB which this control represents. If the control was defined using the jndi-home-name attribute, the returned value will start with "jndi:" and will start with "java:comp/env" if the control was defined using an ejb-link attribute.

#### Returns

The JNDI name for the EJB represented by this control.

### hasEJBBeanInstance() Method

    public boolean hasEJBBeanInstance()

Returns `true` if this control currently has a target bean instance upon which bean business interface methods may be invoked. This will be true after successful execution of a create or single select find method, or in cases where implicit creation or find has occurred by the control on the control user's behalf. You can use this method as a simple way to procedurally check the status of explicit or implicit bean instance creation or find operations.

#### Returns

`true` if this control is associated with a target bean instance; otherwise, `false`.

### setJNDIName(String) Method

    public void setJNDIName(String jndiName)

Sets the JNDI name associated with this control; in other words, this method effectively sets which EJB is associated with the control. This method validates that jndiName is a valid JNDI name. The method then drops the EJB instance that was associated with the previous JNDI name and loads the EJB associated with the new JNDI name.

You can use this method to associate this control with an EJB that has the same interface as the previous EJB, but a different JNDI name.

#### Parameters

jndiName
  The JNDI name of the EJB which with this control should be associated.