Skip to content

Commit

Permalink
Stopped using local servletContext
Browse files Browse the repository at this point in the history
  • Loading branch information
afeinberg committed Jul 14, 2010
1 parent 51b7dc2 commit 47a497b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ tomcat.manager.password=tomcat
tomcat.context=/voldemort

## Release
curr.release=0.81.1.li4
curr.release=0.81.1.li5
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -74,21 +75,23 @@ public ReadOnlyStoreManagementServlet(VoldemortServer server, VelocityEngine eng
}

@Override
public void init() throws ServletException {
super.init();
VoldemortServer server = (VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY);
public void init(ServletConfig config) throws ServletException {
super.init(config);
VoldemortServer server = (VoldemortServer) config.getServletContext()
.getAttribute(VoldemortServletContextListener.SERVER_KEY);

initStores(server);
initVelocity();
initVelocity(config);
setFetcherClass(server);
}

public void initStores(VoldemortServer server) {
this.stores = getReadOnlyStores(server);
}

public void initVelocity() {
this.velocityEngine = (VelocityEngine) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
public void initVelocity(ServletConfig config) {
this.velocityEngine = (VelocityEngine) Utils.notNull(config.getServletContext()
.getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
}

private void setFetcherClass(VoldemortServer server) {
Expand Down Expand Up @@ -125,7 +128,6 @@ private List<ReadOnlyStorageEngine> getReadOnlyStores(VoldemortServer server) {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
initStores((VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
Map<String, Object> params = Maps.newHashMap();
params.put("stores", stores);
velocityEngine.render("read-only-mgmt.vm", params, resp.getOutputStream());
Expand Down Expand Up @@ -209,7 +211,6 @@ private String getRequired(HttpServletRequest req, String name) throws ServletEx
}

private ReadOnlyStorageEngine getStore(String storeName) throws ServletException {
initStores((VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
for(ReadOnlyStorageEngine store: this.stores)
if(store.getName().equals(storeName))
return store;
Expand Down

0 comments on commit 47a497b

Please sign in to comment.