Given an ApplicationContext containing multiple bean definitions of a Java type "Foo", which of the following @Autowired scenarios will cause the ApplicationContext to FAIL to initialize? Assume that the ApplicationContext is configured to process the @Autowired annotations. (Select one)
A. @Autowired public void setFoo(Foo aFoo) {}
B. @Autowired private Foo foo;
C. Both a and b
D. Neither a or b
public class AppConfig {
public ClientService clientService() {
return new ClientServiceImpl();
}
}
The Spring Java configuration above is NOT correct. Why? (select one)
A. The class should be annotated with @Configuration
B. The method should be annotated with @Bean
C. Both (a) and (b)
D. Neither (a) or (b)
@Configuration
public class AppConfig {
@Bean
public ClientService clientService() {
ClientServiceImpl clientService = new ClientServiceImpl();
clientService.addClientDao(new ClientDao());
return clientService;
}
In the example above, which statement is NOT true with regards to Spring Java configuration? (select one)
A. The declared bean is a singleton by default
B. This bean might be wrapped by a proxy
C. This bean cannot use a method starting with "add" to inject a dependency
D. The bean is of type ClientService
To register for a bean destruction callback, one can (Select one)
A. Decorate the destroy method with @PreDestroy
B. Decorate the destroy method with @PreDestroy and add a
C. Set the bean instance in a "prototype" scope
D. Set the lazy-init attribute within the
Which of the following statements is NOT a characteristic of Spring Transaction Management? (Select one)
A. It abstracts the differences between local and JTA transactions
B. It simplifies migration to distributed transactions
C. The use of JTA transactions is a requirement
D. Both declarative and programmatic transaction management is supported
If the propagation behavior is Propagation.REQUIRES_NEW, choose the statement which describes the propagation behavior (select one)
A. Runs in a nested transaction if an active transaction exists. If an active transaction does not exist, the transaction behaves as if Propagation.REQUIRED is set
B. Supports a transaction if one already exists. Throws an exception if an active transaction does not exist.
C. Always starts a new transaction. If an active transaction already exists, it is suspended
D. Always executes without a transaction even if an active transaction exists. Throws an exeception if an active transaction exists.
public class ClientServiceImpl implements ClientService {
@Transactional(propagation=Propagation.REQUIRED)
public void update1() {
update2();
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void update2() { // ... }
}
You are using transactions with Spring AOP. What is happening when the update1 method is called?
(Select one)
A. There is only one transaction because the call to update2() is internal (it does not go through the proxy)
B. There is only one transaction because REQUIRES_NEW runs into the active transaction if one already exists
C. There are 2 transactions because REQUIRES_NEW always runs in a new transaction
@Transactional(timeout=60)
public class ClientServiceImpl implements ClientService {
@Transactional(timeout=30)
public void update1() {}
}
What timeout setting is applied to the timeout inside the update1 method? (Select one)
A. 60
B. 30
C. This will not compile. Attributes such as timeout, propagation and isolation cannot be declared at the class level
D. This will not compile. Attributes such as timeout, propagation and isolation cannot be declared at the method level
Method level security can be configured using which of the following mechanisms? (select one)
A. Using the @Secured annotation on methods to be secured
B. Using the @RolesAllowed annotation on methods to be secured
C. Configuring using a pointcut expression in Spring XML configuration file
D. All of the above
Which of the following statement is true concerning Spring's JmsTemplate (select one)
A. The JmsTemplate manages resources transparently (e.g. Connections, default Queue...)
B. The JmsTemplate converts checked JMSExceptions to runtime equivalents
C. The JmsTemplate provides convenience methods and callbacks
D. All of the above