Package org.baeldung.service

Source Code of org.baeldung.service.FooService

package org.baeldung.service;

import org.baeldung.web.dto.Foo;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class FooService implements IFooService, InitializingBean {

    @Value("${foo1}")
    private String foo1;

    @Autowired
    private Environment env;

    public FooService() {
        super();
    }

    // API

    @Override
    public Foo findOne(final Long id) {
        return new Foo();
    }

    @Override
    public final void afterPropertiesSet() {
        System.out.println("In Parent Context, property via @Value = " + foo1);
        System.out.println("In Parent Context, property via env = " + env.getProperty("foo2"));
    }

}
TOP

Related Classes of org.baeldung.service.FooService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.