Lecture 5 Flashcards

1
Q

What are components of business layer?

A

EJBs, Entities and Ordinary JavaBeans.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Enterprise Java Beans?

A

Components, Written in Java, run on server, provide services to clients (software that calls them), managed by EJB container. Must be deployed on server before used. Provide business logic. Confirm to Oracles EJB spec. My used for presentation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why use EJBs?

A

Separation of concerns, code maintainability, but they also provide networking, security, persistence based on JPA, transactions, session management, multithreading. No need for programmer to implement these himself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Other benefits of EJBs?

A

Relieve other components from implementing business logic, portable and vendor independent, can be run on different host or JVM than client (unlike ordinary Java Object), more flexible, not restricted to http or stream I/O

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When do you need a business tier?

A

If app must deal with large group of clients, needs security management, transaction management, messaging between components, or runs distributed on multiple servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Deployed EJBs run on the JavaEE server under management of EJB container (itself a part of the JavaEE server). When is extra functionality provided by container?

A

At runtime, not via linking packages as with normal Java classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Note: outside container EJBs are just POJOs… Why does this mean?

A

They can be used and tested just like normal Java objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Name three types of EJBs:

A

Session beans(stateless and stateful, and singleton), message-driven beans, entity beans (instead use JPA entities).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a session bean?

A

A server side component that interacts with a client (another component which calls beans methods), clients can be local or remote. Multiple instances created for each client. Short lived, removed when server or client ends. Does not store data in database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The clients of session Beans are thin clients. Explain…

A

They only do presentation tasks, all business logic in the EJB, and all transactions security is provided by EJB container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain Ststeless session beans…

A

Simplest kind of session beans, execute a request, don’t save any data beyond one call of a method, used for temporary piers of business logic needed by specific client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Typical use of Stateless:

A

Client just needs info without any further interaction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Stateful session beans, explain…

A

Each stateful interacts with one client, maintains a client specific state over an entire session, ie a shopping cart, annotated with @Stateful.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How stateful and Stateless are deployed…

A

When EJBs are deployed the EJB container creates a number of instances (EJB pool), a client obtained an instance from pool, if the ran is stateful it’s state is maintained over multiple EJB method calls, if Stateless no state is maintained and the server may even use a different instance from pool next time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Three things needed to program a bean:

A

A Java class which contains bean functionality, a business interface which defines those bean methods accessible to client, and annotation of the class an interface to tell server they should become EJBs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A client can only access an EJB via a business interface. Usin interfaces EJBs are encapsulated. Client only needs to know interface. What are two types of interfaces?

A

Remote (@Remote): EJB can run on a JVM different to clients. Local (@Local) EJB must run on clients JVM.

17
Q

What are typical clients of EJBs?

A

Ordinary Java applications, servlets or JSPs, other EJBs, a web service.

18
Q

JBDI?

A

Java Naming and Directory Interface. Outdated way of a Java class declaring an instance variable of EJB interface. Avoid. Use annotations instead @EJB

19
Q

@EJB uses dependency injection. Explain…

A

The container provides client with a reference to EJB, when client calls injected EJB method, the sever calls corresponding method of EJB instance on server.

20
Q

Business tier (also called EJB tier) uses EJBs and JPA and deals with business logic (or Domain Logic). What’s the purpose of business logic?

A

Modeling the domain/business ie customer management, logistics etc, modeling the interaction, policies and workflow.

21
Q

What does CDI stand for?

A

Contexts and Dependency Injection.