improve ScmWebPlugin api

This commit is contained in:
Sebastian Sdorra
2010-09-26 16:16:38 +02:00
parent 16052aeb4b
commit 2d666f5b14
3 changed files with 45 additions and 11 deletions

View File

@@ -7,14 +7,6 @@
package sonia.scm.web; package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Module;
//~--- JDK imports ------------------------------------------------------------
import java.io.InputStream;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
@@ -22,7 +14,19 @@ import java.io.InputStream;
public interface ScmWebPlugin public interface ScmWebPlugin
{ {
public void contextInitialized( ScmWebPluginContext context ); /**
* Method description
*
*
* @param context
*/
public void contextDestroyed(ScmWebPluginContext context);
public void contextDestroyed( ScmWebPluginContext context ); /**
* Method description
*
*
* @param context
*/
public void contextInitialized(ScmWebPluginContext context);
} }

View File

@@ -17,6 +17,8 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.servlet.ServletContext;
/** /**
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra
@@ -24,6 +26,19 @@ import java.util.Set;
public class ScmWebPluginContext public class ScmWebPluginContext
{ {
/**
* Constructs ...
*
*
* @param servletContext
*/
public ScmWebPluginContext(ServletContext servletContext)
{
this.servletContext = servletContext;
}
//~--- methods --------------------------------------------------------------
/** /**
* Method description * Method description
* *
@@ -92,6 +107,17 @@ public class ScmWebPluginContext
return scriptResources; return scriptResources;
} }
/**
* Method description
*
*
* @return
*/
public ServletContext getServletContext()
{
return servletContext;
}
//~--- fields --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------
/** Field description */ /** Field description */
@@ -99,4 +125,7 @@ public class ScmWebPluginContext
/** Field description */ /** Field description */
private Set<Module> injectModules = new HashSet<Module>(); private Set<Module> injectModules = new HashSet<Module>();
/** Field description */
private ServletContext servletContext;
} }

View File

@@ -62,7 +62,8 @@ public class ContextListener extends GuiceServletContextListener
@Override @Override
public void contextInitialized(ServletContextEvent servletContextEvent) public void contextInitialized(ServletContextEvent servletContextEvent)
{ {
webPluginContext = new ScmWebPluginContext(); webPluginContext =
new ScmWebPluginContext(servletContextEvent.getServletContext());
List<ScmWebPlugin> plugins = ServiceUtil.getServices(ScmWebPlugin.class); List<ScmWebPlugin> plugins = ServiceUtil.getServices(ScmWebPlugin.class);