I have a Rest service using Resteasy (running on top of Appengine), with the following psuedo code:
@Path("/service")
public class MyService {
@GET
@Path("/start")
public Response startService() {
// Need to read properties file here.
// like: servletContext.getResourceAsStream("/WEB-INF/config.properties")
}
}
However its obvious that the servlet context cannot be accessed here.
And code like:
InputStream inputStream = this.getClass().getClassLoader()
.getResourceAsStream("/WEB-INF/config.properties");
Can't be executed within the Appengine environment.
EDIT:
I have tried doing it with Spring like:
appContext.xml
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="/WEB-INF/auth.properties"/>
</bean>
Then, put this on the actual class fields:
@Path("/service")
public MyService{
@Autowired
@Value("${myservice.userid}")
private String username;
@Autowired
@Value("${myservice.passwd}")
private String password;
// Code omitted
}
However, part of the code of the MyService
complains because the username
and password
was not "injected", I mean its empty although its on the auth.properties
file