| java.lang.Object org.mockejb.MockContainer
MockContainer | public class MockContainer (Code) | | Provides methods to "deploy" EJBs. Most deploy
methods simply create Home proxy and bind it to the JNDI.
Since MockEjb is not a container in a true sense, the purpose of this class
is to provide an abstraction that emulates EJB deployment.
author: Alexander Ananiev |
Constructor Summary | |
public | MockContainer(Context context) Creates a new instance of the MockContainer for
the given context, deletes all aspects from the AspectSystem and adds the system interceptors, such as
ExceptionHandler.
Clears the EntityDatabase as well.
Creates a default (anonymous) user which is used for all EJB operations unless "login"
is called explicitly. |
Method Summary | |
public MessageListener | createMessageBean(MockEjbObject ejbObject) Creates message-driven bean. | public void | deploy(SessionBeanDescriptor descriptor) Deploys session bean specified by the given descriptor.
MockContainer creates the proxy implementing
session bean home interface and binds it to the JNDI context
using rebind() method. | public void | deploy(EntityBeanDescriptor descriptor) Deploys entity bean specified by the given descriptor. | public void | deploy(MDBDescriptor descriptor) If "isAlreadyBound" is "false" in deployment descriptor,
creates mock connection factory and destination and bind them to JNDI.
Otherwise, assumes that the connection factory and destination were created
previously and available from JNDI. | public EntityDatabase | getEntityDatabase() Returns an instance of the EntityDatabase that will be used by the
system interceptors (Finder Handlers) used by this instance of the container. | public static MockUser | getUser() Returns the user that was passed to the
MockContainer.login method. | public static boolean | isSystemException(Throwable throwable) Tests if the given throwable is the system exception in terms of the container. | protected void | loadEntityDatabase() | public void | login(MockUser user) Simulates the login operation of the container. | protected void | setupDefaultInterceptors() Add the interceptors that should always be present to
the AspectSystem. |
MockContainer | public MockContainer(Context context)(Code) | | Creates a new instance of the MockContainer for
the given context, deletes all aspects from the AspectSystem and adds the system interceptors, such as
ExceptionHandler.
Clears the EntityDatabase as well.
Creates a default (anonymous) user which is used for all EJB operations unless "login"
is called explicitly.
Parameters: context - JNDI context to use for all "bind" operations |
createMessageBean | public MessageListener createMessageBean(MockEjbObject ejbObject)(Code) | | Creates message-driven bean. This method emulates create()
method of the Session bean home interface.
Since MDBs don't have home interface, MockContainer provides this
service for MDB clients.
Parameters: ejbObject - MockEjbObject of the message bean created by deployMessageBean() implementation of the MessageListener interface. The interface is implemented by a proxy provided by MockEjbObject. |
deploy | public void deploy(SessionBeanDescriptor descriptor) throws NamingException(Code) | | Deploys session bean specified by the given descriptor.
MockContainer creates the proxy implementing
session bean home interface and binds it to the JNDI context
using rebind() method.
Clients can subsequently lookup the home and invoke create() .
Parameters: descriptor - descriptor of the session bean to deploy As of MockEJB 0.6, this method does not return MockEjbObject since the direct use of MockEjbObject is deprecated. AspectSystem should be used instead. |
deploy | public void deploy(MDBDescriptor descriptor) throws NamingException, JMSException(Code) | | If "isAlreadyBound" is "false" in deployment descriptor,
creates mock connection factory and destination and bind them to JNDI.
Otherwise, assumes that the connection factory and destination were created
previously and available from JNDI. The default is "false".
Creates MDB and sets it to listen on the destination.
Handles both queues and topics, depending on "isTopic" setting of the
deployment descriptor.
Note that mock JMS implementation is synchronous, in other words the message sent
to the destination is delivered to MDB right away.
Parameters: descriptor - deployment descriptor of the MDB specifying JNDI names ofconnection factory and destinations as well as the bean implementation object. throws: NamingException - in case of problems binding to JNDI or retrieving objects from JNDI throws: JMSException - in case of problems with mock connection factory or destination. |
getEntityDatabase | public EntityDatabase getEntityDatabase()(Code) | | Returns an instance of the EntityDatabase that will be used by the
system interceptors (Finder Handlers) used by this instance of the container.
an instance of the entity database |
getUser | public static MockUser getUser()(Code) | | Returns the user that was passed to the
MockContainer.login method. Note that the user
is stored as a ThreadLocal variable, so it is available to all classes.
Returns the anonymous user if
login was not called.
the current user of the MockContainer |
isSystemException | public static boolean isSystemException(Throwable throwable)(Code) | | Tests if the given throwable is the system exception in terms of the container.
Currently we consider all runtime exceptions and transaction-related exceptions
system exceptions.
Note that the spec is vague on
what is system and non-system exception, so this method might change in the future.
Parameters: throwable - exception in question true if the given throwable is "system" exception |
loadEntityDatabase | protected void loadEntityDatabase()(Code) | | |
login | public void login(MockUser user)(Code) | | Simulates the login operation of the container. This method does
not perform any security checks.
It simply stores the given MockUser object for further use by EJBContext's security-related methods.
Parameters: user - user of the MockContainer |
setupDefaultInterceptors | protected void setupDefaultInterceptors()(Code) | | Add the interceptors that should always be present to
the AspectSystem.
|
|
|