42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
A cleanly coded web application will have a clear separation of concerns, with business logic in the ``++@Service++`` layer, and communication with other systems in the data access layer.
|
|
|
|
|
|
To help enforce such a separation of concerns, this rule raises an issue when a ``++@Service++`` class has ``++RestTemplate++``, ``++JmsTemplate++``, ``++WebServiceTemplate++``, ``++JdbcTemplate++``, or ``++DataSource++`` member.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,java]
|
|
----
|
|
@Service ("greetingmanager")
|
|
public class GreetingManagerImpl implements GreetingManager
|
|
{
|
|
@Autowired
|
|
DataSource ds; // Noncompliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,java]
|
|
----
|
|
@Service ("greetingmanager")
|
|
public class GreetingManagerImpl implements GreetingManager
|
|
{
|
|
@Autowired
|
|
GreetingDao gdao; // DataSource and its use have been moved here
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|