diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-27 06:27:51 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-27 06:27:51 +0000 |
commit | 006f0478cd30171b39d4d29bd7d8ddad824d3157 (patch) | |
tree | 1936bfc3b1b7928b9dcff266335c79eec64e6ecf /java/sca | |
parent | c8a471118f4ee5d081c140976f65720f32938959 (diff) |
Add some comments, support for sca-contribution.xml, and use the new tuscany annotations processor
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@779023 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r-- | java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java index 8d3e48ae2c..53932c8d7c 100644 --- a/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java +++ b/java/sca/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java @@ -30,18 +30,33 @@ import org.apache.catalina.Loader; import org.apache.catalina.core.StandardContext;
import org.apache.catalina.deploy.FilterDef;
+/**
+ * A Tuscany StandardContext to initilize SCA applications.
+ * There is a StandardContext instance for each webapp and its
+ * called to handle all start/stop/etc requests. This intercepts
+ * the start and inserts any required Tuscany configuration.
+ */
public class TuscanyStandardContext extends StandardContext {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(TuscanyStandardContext.class.getName());
+ // TODO: this gives an instance per connector, work out how to have only one per server
private ClassLoader tuscanyClassLoader;
+ /**
+ * Overrides the getLoader method in the Tomcat StandardContext as its a convenient
+ * point to insert the Tuscany initilization. This gets called the first time during
+ * StandardContext.start after the webapp resources have been created so this can
+ * use getResources() to look for the SCA web.composite or sca-contribution.xml files,
+ * but its still early enough in start to insert the required Tuscany config.
+ */
+ @Override
public Loader getLoader() {
if (loader != null) {
return loader;
}
- if (isSCAAlication()) {
+ if (isSCAApplication()) {
initTuscany();
}
@@ -49,21 +64,37 @@ public class TuscanyStandardContext extends StandardContext { }
private void initTuscany() {
+
setParentClassLoader(getTuscanyClassloader());
+
addApplicationListener("org.apache.tuscany.sca.host.webapp.TuscanyContextListener");
+
FilterDef filterDef = new FilterDef();
filterDef.setFilterName("TuscanyFilter");
filterDef.setFilterClass("org.apache.tuscany.sca.host.webapp.TuscanyServletFilter");
addFilterDef(filterDef);
+
+ if (isUseNaming() && getNamingContextListener() != null) {
+ setAnnotationProcessor(new TuscanyAnnotationsProcessor(this, getNamingContextListener().getEnvContext()));
+ } else {
+ setAnnotationProcessor(new TuscanyAnnotationsProcessor(this, null));
+ }
+
log.info("Tuscany enabled for: " + this.getName());
}
- private boolean isSCAAlication() {
+ private boolean isSCAApplication() {
Object o = null;
try {
o = getResources().lookup("WEB-INF/web.composite");
} catch (NamingException e) {
}
+ if (o == null) {
+ try {
+ o = getResources().lookup("META-INF/sca-contribution.xml");
+ } catch (NamingException e) {
+ }
+ }
return o != null;
}
|