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
Expand Up @@ -33,4 +33,4 @@ tomcat.manager.password=tomcat
tomcat.context=/voldemort tomcat.context=/voldemort


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


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


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


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


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


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


private void setFetcherClass(VoldemortServer server) { private void setFetcherClass(VoldemortServer server) {
Expand Down Expand Up @@ -125,7 +128,6 @@ private List<ReadOnlyStorageEngine> getReadOnlyStores(VoldemortServer server) {
@Override @Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException { IOException {
initStores((VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
Map<String, Object> params = Maps.newHashMap(); Map<String, Object> params = Maps.newHashMap();
params.put("stores", stores); params.put("stores", stores);
velocityEngine.render("read-only-mgmt.vm", params, resp.getOutputStream()); 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 { private ReadOnlyStorageEngine getStore(String storeName) throws ServletException {
initStores((VoldemortServer) getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
for(ReadOnlyStorageEngine store: this.stores) for(ReadOnlyStorageEngine store: this.stores)
if(store.getName().equals(storeName)) if(store.getName().equals(storeName))
return store; return store;
Expand Down

0 comments on commit 47a497b

Please sign in to comment.