Fork me on GitHub

Résultats CPD

Le document suivant contient les résultats de l'inspection CPD CPD 5.1.2.

Duplicatas

Fichier Ligne
eu/sydisnet/blog/samples/deltaspike/cdi12/boundary/DependentHelloService.java 22
eu/sydisnet/blog/samples/deltaspike/cdi12/boundary/SingletonHelloService.java 22
eu/sydisnet/blog/samples/deltaspike/cdi12/boundary/SingletonHelloServiceV2.java 20
public class DependentHelloService {

    /**
     * Static Logger.
     */
    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

    /**
     * Constant used by the service when userName is not defined by the client.
     */
    private static final String UNKNOWN_USERNAME = "M. John Doe";

    /**
     * The default message template assigned when the bean is loaded.
     */
    private String defaultMessage;

    /**
     * Delegate service.
     */
    @Inject
    private MessageFormatter messageFormatter;

    /**
     * Method called by the CDI container when the bean is retrieved from
     * {@link javax.enterprise.inject.spi.BeanManager}. See the JSR 250 Callback {@link javax.annotation.PostConstruct}
     * annotation.
     */
    @PostConstruct
    void initBean() {
        defaultMessage = "Welcome %s !";

        LOG.info(String.format("##### %s stopped !", MethodHandles.lookup().lookupClass().getSimpleName()));
    }

    /**
     * Method called by the CDI container before the destruction of the bean from the
     * {@link javax.enterprise.inject.spi.BeanManager}. See the JSR 250 Callback {@link javax.annotation.PreDestroy}
     * annotation.
     *
     * This method will be never called since the bean has the scope {@link javax.enterprise.context.Dependent}.
     */
    @PreDestroy
    void tearDown() {
        LOG.info(String.format("##### %s stopped !", MethodHandles.lookup().lookupClass().getSimpleName()));
    }

    /**
     * Service called by <strong>client-tier</strong> in order to send a welcome message.
     *
     * @param userName the name of the user
     * @return the welcome message
     */
    public String sayHello(final String userName) {
        if (userName == null || userName.isEmpty()) {
            return messageFormatter.format(defaultMessage, UNKNOWN_USERNAME);
        }

        return messageFormatter.format(defaultMessage, userName);
    }
}