250+ TOP MCQs on Building a Service and Business Process with Spring and Answers

Basic Java Spring questions and answers on “Building a Service and Business Process with Spring”.

1. jBPM will expose beans using the:-
a) jBPM expression language
b) jBoss
c) Spring expression language
d) None of the mentioned
Answer: a
Clarification: jBPM will expose beans using the jBPM expression language, and you can then just reference them by name.

2. jBPM, and indeed most workflow engines, passivate state for you, allowing a process to wait on external events :-
a) True
b) False
Answer: a
Clarification: Indeed, because you’ve decomposed your process into a series of isolated steps, each of which contributes to the larger goal while remaining independently useful, you get the best of both worlds:
stateful processes and stateless scalability.

3. We override the List bean (with id annotatedHibernateClasses) that we created for the last recipe (jbpm4 context.xml) to provide the session factory with a collection of annotated entities which is here as:-

xml version="1.0" encoding="UTF-8"?>
	<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:util="http://www.springframework.org/schema/util" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-3.0.xsd
	http://www.springframework.org/schema/util
	http://www.springframework.org/schema/util/spring-util-3.0.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	">
	<import resource="jbpm4-context.xml"/>
	<context:annotation-config/>
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
	<tx:attributes>
	<tx:method propagation="REQUIRED" name="*"/>
	tx:attributes>
	tx:advice>
	<aop:config>
	<aop:advisor advice-ref="txAdvice" pointcut="execution(* 
	com.apress.springrecipes..jbpm4.*.*(..))"/>
	aop:config>
	<util:list id="annotatedHibernateClasses">
	<value>com.apress.springrecipes.jbpm.jbpm4.customers.Customervalue>
	util:list>
	<bean id="customerService" class="com.apress.springrecipes.jbpm.jbpm4.customers.
	CustomerServiceImpl">
	<property name="processDefinitions">
	<list>
	<value>/process-definitions/RegisterCustomer.jpdl.xmlvalue>
	list>
	property>
        bean>
beans>

a) HibernateCustom
b) Customer
c) All of the mentioned
d) None of the mentioned

Answer: b
Clarification: This bean leverages Hibernate (through the HibernateTemplate instance) to handle persistence, and it leverages jBPM (through the SpringConfiguration instance) to handle BPM.

4. The method annotated with @PostConstruct will be run after the bean’s been configured to let the user inject custom initialization logic.
a) True
b) False
Answer: a
Clarification: The bean handles as part of its duties in its post-initialization phase.

5. The business process file’s name needs to end in :-
a) jpdl
b) xml
c) jpdl.xml
d) none of the mentioned
Answer: c
Clarification: The business process file’s name needs to end in jpdl.xml; otherwise, jBPM won’t deploy it.

6. At the top, we’ve injected some dependencies:
a) springConfiguration
b) repositoryService
c) executionService
d) all of the mentioned
Answer: d
Clarification: At the top, we’ve injected three dependencies:
springConfiguration (which doesn’t get used, though its configuration is worth noting because you may use it to access other services), repositoryService, and executionService.

7. The class(CustomerServiceImpl) provides a few salient methods:-

package com.apress.springrecipes.jbpm.jbpm4.customers;
public interface CustomerService {
void sendWelcomeEmail(Long customerId);
void deauthorizeCustomer(Long customerId);
void authorizeCustomer(Long customerId);
Customer getCustomerById(Long customerId);
Customer createCustomer(String email, String password, String firstName, 
String lastName);
void sendCustomerVerificationEmail(Long customerId);
}

a) void setupProcessDefinitions()
b) Customer createCustomer(String email, String passphrase, String firstName, String lastName)
c) void sendCustomerVerificationEmail(Long customerId)
d) all of the mentioned
Answer: d
Clarification: The class provides a few
salient methods (some of which are required by its interface, CustomerService):
• void setupProcessDefinitions()
• Customer createCustomer(String email, String passphrase, String firstName,
String lastName)
• void sendCustomerVerificationEmail(Long customerId)
• void authorizeCustomer(Long customerId)

  250+ TOP MCQs on EJB 3.0 with Spring and Answers

8. In the bean, setupProcessDefinitions is run when the bean is created.
a) True
b) False
Answer: a
Clarification: It iterates through the processDefinitions collection and deploys the resource whose path it is given.

9. Process definition will reference Spring beans using the JBoss expression language.
a) True
b) False
Answer: a
Clarification: We’ll walk through how the business process uses our customerService bean and how the customerService bean uses the business process to handle the customer’s sign-up.

10. In jBPM, a business process is built using jPDL.
a) True
b) False
Answer: a
Clarification: You can use the Eclipse plug-in to model jBPM processes, but the jPDL schema is so simple that you don’t really need it.

11.In the customerService bean, a client will use createCustomer to create a customer record.

xml version="1.0" encoding="UTF-8"?>
<process name="RegisterCustomer" xmlns="http://jbpm.org/4.0/jpdl">
          <start>
          <transition to="send-verification-email" />
          start>
          <java name="send-verification-email" expr="#{customerService}"
          method="sendCustomerVerificationEmail">
          <arg> <object expr="#{customerId}" /> arg>
          <transition to="confirm-receipt-of-verification-email" />
          java>
          <state name="confirm-receipt-of-verification-email">
          <transition to="send-welcome-email" />
          state>
          <java name="send-welcome-email"
          expr="#{customerService}" method="sendWelcomeEmail">
          <arg> <object expr="#{customerId}" /> arg>
          java>
process>

a) True
b) False
Answer: a
Clarification: In a real-world example, you might imagine exposing these services as a SOAP endpoint to be consumed by various clients, such as a web application or other business applications.

12.Inside the createCustomer method, we use jBPM to start the business process to track the Customer. This is done with the :-

xml version="1.0" encoding="UTF-8"?>
<process name="RegisterCustomer" xmlns="http://jbpm.org/4.0/jpdl">
          <start>
          <transition to="send-verification-email" />
          start>
          <java name="send-verification-email" expr="#{customerService}"
          method="sendCustomerVerificationEmail">
          <arg> <object expr="#{customerId}" /> arg>
          <transition to="confirm-receipt-of-verification-email" />
          java>
          <state name="confirm-receipt-of-verification-email">
          <transition to="send-welcome-email" />
          state>
          <java name="send-welcome-email"
          expr="#{customerService}" method="sendWelcomeEmail">
          <arg> <object expr="#{customerId}" /> arg>
          java>
process>

a) startProcessInstanceByKey
b) startProcessInstance
c) all of the mentioned
d) none of the mentioned

Answer: a
Clarification: In the invocation, we give jBPM variables through a Map instance (acting as something of a context for the process variables).

13. Once in the java element named send-verification-email, jBPM will invoke the method:-
a) sendCustomerVerificationEmail
b) sendCustomerVerification
c) veifyCustomerVerificationEmail
d) all of the mentioned
Answer: a
Clarification: Once in the java element named send-verification-email, jBPM will invoke the method sendCustomerVerificationEmail on the customerService bean in Spring.

14. Inside authorizeCustomer, the service queries the server for the any processes waiting at the:-
a) confirm-receipt-of-verification
b) confirm-receipt
c) confirm-receipt-of-verification-email
d) none of the mentioned
Answer: c
Clarification: Inside authorizeCustomer, the service queries the server for the any processes waiting at the confirm-receipt-of-verification-email state and having this customer’s ID.

15. The authorizeCustomer method also updates the Customer entity, marking it as authorized. From there, execution proceeds to the send-welcome-email java element.
a) True
b) False
Answer: a
Clarification: As before, the java element will be used to invoke a method on the customerService bean. This time, it will invoke sendWelcomeEmail to send the newly registered Customer a welcome email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top