Question: I am not that experienced with python, but do some python coding for small jobs. Currently I have a job that opens a log file and pulls any records that are considered errors. This list of errors is then added as part of an email notification. What I would like to do is either include the list or a notification that the list was empty. I have been able to do this in the console, but don't know how to get this added as a parameter in the email.

```
if errorlist:
    print "\n".join(errorlist)
else:
    print "No Errors Found"

# Send Email 
SMTP_SERVER = {SMTP SERVER}
SMTP_PORT = {SMTP PORT}

sender = {Sender}
password = {Password}
recipient = {Recipient}
subject = "This is the subject line"
errorlist = "<br>" "\n".join(errorlist)

body = "" + errorlist + ""

headers = ["From: " + sender,
       "Subject: " + subject,
       "To: " + ", " .join(recipient),
       "MIME-Version: 1.0",
       "Content-Type: text/html"]
headers = "\r\n".join(headers)

session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)

session.ehlo()
session.starttls()
session.ehlo
session.login(sender, password)

session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()

```

Answer: 
You can configure the same beans using JavaConfig as follows:

```
@Component
@Configuration
public class AppConfig
{
    @Value("${accessTokenEndpointUrl}") String accessTokenUri;
    @Value("${clientId}") String clientId;
    @Value("${clientSecret}") String clientSecret;
    @Value("${policyAdminUserName}") String username;
    @Value("${policyAdminUserPassword}") String password;

    @Bean
    public OAuth2RestTemplate myPolicyAdmin(ResourceOwnerPasswordResourceDetails details)
    {
        return new OAuth2RestTemplate(details);
    }

    @Bean
    public ResourceOwnerPasswordResourceDetails resourceOwnerPasswordResourceDetails()
    {
         ResourceOwnerPasswordResourceDetails bean = new ResourceOwnerPasswordResourceDetails();
         bean.setAccessTokenUri(accessTokenUri);
         bean.setClientId(clientId);
         bean.setClientSecret(clientSecret);
         bean.setUsername(username);
         bean.setPassword(password);         
         return bean;
    }
}

```
To set the props of a bean you can either use [@Value](http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Value.html) during construction:

[How to inject a value to bean constructor using annotations](https://stackoverflow.com/questions/4203302/how-to-inject-a-value-to-bean-constructor-using-annotations)

and this one:

[Spring: constructor injection of primitive values (properties) with annotation based configuration](https://stackoverflow.com/questions/2306078/spring-constructor-injection-of-primitive-values-properties-with-annotation-b)

Or @Value in the variables. You could also actually use @Resource, but I wouldn't recommend it.

In your case, the constructor for the 
 org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails

Would be kinda like

```
@Autowired
public ResourceOwnerPasswordResourceDetails(
    @Value("${accessTokenEndpointUrl}") String accessTokenUri,
    @Value("${clientId}") String clientId,
    @Value("${clientSecret}") String clientSecret,
    @Value("${policyAdminUserName}") String username,
    @Value("${policyAdminUserPassword}") String password
)

```