You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2006/03/08 22:50:43 UTC
svn commit: r384338 - in /cocoon/trunk/cocoon-blocks-fw:
cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/
cocoon-blocks-fw-osgi-impl/META-INF/
cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/
Author: danielf
Date: Wed Mar 8 13:50:40 2006
New Revision: 384338
URL: http://svn.apache.org/viewcvs?rev=384338&view=rev
Log:
OSGi based blocks.
- Two blocks are defined in components.xml the second one uses the first.
- Block properties goes to servlet init-params and other blocks are called through getNamedDispatcher
- The o.a.c.core.osgi.BlockContext should have extended o.a.c.core.BlockContext but it didn't work in a way that I failed to debug. I copied most of it instead. Will try to get the inheritance to work some other time.
Added:
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java (with props)
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java (with props)
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java (with props)
Modified:
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java?rev=384338&r1=384337&r2=384338&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java (original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java Wed Mar 8 13:50:40 2006
@@ -315,13 +315,13 @@
this.properties = properties;
}
- private class NamedDispatcher implements RequestDispatcher {
+ protected class NamedDispatcher implements RequestDispatcher {
private String blockName;
private boolean superCall = false;
private ServletContext context;
- private NamedDispatcher(String blockName) {
+ public NamedDispatcher(String blockName) {
this.blockName = blockName;
this.superCall = Block.SUPER.equals(this.blockName);
@@ -339,7 +339,7 @@
}
}
- private boolean exists() {
+ protected boolean exists() {
return this.context != null;
}
Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml?rev=384338&r1=384337&r2=384338&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml (original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/META-INF/components.xml Wed Mar 8 13:50:40 2006
@@ -23,13 +23,25 @@
</scr:service>
<scr:property name="path" value="/test1"/>
<scr:property name="attr" value="foo"/>
- <scr:reference name="Servlet"
+ <scr:reference name="blockServlet"
interface="javax.servlet.Servlet"
- target="(component.name=cocoon.servlet1)"
- bind="setServlet"/>
+ target="(component.name=cocoon.servlet1)"/>
</scr:component>
-
+ <scr:component name="cocoon.blockServlet2">
+ <scr:implementation class="org.apache.cocoon.blocks.osgi.BlockServlet"/>
+ <scr:service>
+ <scr:provide interface="javax.servlet.Servlet"/>
+ </scr:service>
+ <scr:property name="path" value="/test2"/>
+ <scr:property name="attr" value="bar"/>
+ <scr:reference name="blockServlet"
+ interface="javax.servlet.Servlet"
+ target="(component.name=cocoon.servlet2)"/>
+ <scr:reference name="block1"
+ interface="javax.servlet.Servlet"
+ target="(component.name=cocoon.blockServlet1)"/>
+ </scr:component>
<scr:component name="cocoon.servlet1">
<scr:implementation class="org.apache.cocoon.blocks.osgi.TestServlet"/>
@@ -39,10 +51,17 @@
</scr:component>
<scr:component name="cocoon.servlet2">
+ <scr:implementation class="org.apache.cocoon.blocks.osgi.TestServlet2"/>
+ <scr:service>
+ <scr:provide interface="javax.servlet.Servlet"/>
+ </scr:service>
+ </scr:component>
+
+ <scr:component name="cocoon.servlet3">
<scr:implementation class="org.apache.cocoon.blocks.osgi.TestServlet"/>
<scr:service>
<scr:provide interface="javax.servlet.Servlet"/>
</scr:service>
- <scr:property name="path" value="/test2"/>
+ <scr:property name="path" value="/test3"/>
</scr:component>
</components>
Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java?rev=384338&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java Wed Mar 8 13:50:40 2006
@@ -0,0 +1,414 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blocks.osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cocoon.blocks.Block;
+import org.apache.cocoon.blocks.BlockCallStack;
+import org.apache.cocoon.blocks.util.ServletContextWrapper;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * @version $Id$
+ */
+public class BlockContext extends ServletContextWrapper {
+
+ private Hashtable attributes;
+ private Servlet servlet;
+ private String mountPath;
+ private Dictionary properties;
+ protected ComponentContext componentContext;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
+ */
+ public Object getAttribute(String name) {
+ return this.attributes.get(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#setAttribute(java.lang.String,
+ * java.lang.Object)
+ */
+ public void setAttribute(String name, Object value) {
+ this.attributes.put(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
+ */
+ public void removeAttribute(String name) {
+ this.attributes.remove(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getAttributeNames()
+ */
+ public Enumeration getAttributeNames() {
+ return this.attributes.keys();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getResource(java.lang.String)
+ */
+ public URL getResource(String path) throws MalformedURLException {
+ if (path.length() == 0 || path.charAt(0) != '/')
+ throw new MalformedURLException("The path must start with '/' " + path);
+ return this.componentContext.getBundleContext().getBundle().getResource(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
+ */
+ public String getRealPath(String path) {
+ // We better don't assume that blocks are unpacked
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
+ */
+ // FIXME, this should be defined in the config instead
+ public String getInitParameter(String name) {
+ String value = (String) this.properties.get(name);
+ // Ask the super block for the property
+ if (value == null) {
+ ServletContext superContext = this.getNamedContext(Block.SUPER);
+ if (superContext != null)
+ value = superContext.getInitParameter(name);
+ }
+ // Ask the parent context
+ if (value == null) {
+ super.getInitParameter(name);
+ }
+ return value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getInitParameterNames()
+ */
+ public Enumeration getInitParameterNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
+ */
+ public InputStream getResourceAsStream(String path) {
+ try {
+ return this.getResource(path).openStream();
+ } catch (IOException e) {
+ // FIXME Error handling
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getContext(java.lang.String)
+ */
+ public ServletContext getContext(String uripath) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getMajorVersion()
+ */
+ public int getMajorVersion() {
+ return 2;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getMinorVersion()
+ */
+ public int getMinorVersion() {
+ return 3;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
+ */
+ public Set getResourcePaths(String arg0) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
+ */
+ public RequestDispatcher getRequestDispatcher(String path) {
+ PathDispatcher dispatcher = new PathDispatcher(path);
+ return dispatcher.exists() ? dispatcher : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
+ */
+ public RequestDispatcher getNamedDispatcher(String name) {
+ NamedDispatcher dispatcher = new NamedDispatcher(name);
+ return dispatcher.exists() ? dispatcher : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getServerInfo()
+ */
+ public String getServerInfo() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.ServletContext#getServletContextName()
+ */
+ public String getServletContextName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ // Block specific methods
+
+ /**
+ * Set the servlet of the block
+ * @param servlet
+ */
+ public void setServlet(Servlet servlet) {
+ this.servlet = servlet;
+ }
+
+ /**
+ * Takes the scheme specific part of a block URI (the scheme is the
+ * responsibilty of the BlockSource) and resolve it with respect to the
+ * blocks mount point.
+ */
+ public URI absolutizeURI(URI uri) throws URISyntaxException {
+ String blockName = uri.getScheme();
+ BlockContext blockContext;
+ if (blockName == null) {
+ // this block
+ blockContext = this;
+ } else {
+ // another block
+ blockContext = (BlockContext) this.getNamedContext(blockName);
+ if (blockContext == null)
+ throw new URISyntaxException(uri.toString(), "Unknown block name");
+ }
+
+ String mountPath = blockContext.getMountPath();
+ if (mountPath == null)
+ throw new URISyntaxException(uri.toString(),
+ "No mount point for this URI");
+ if (mountPath.endsWith("/"))
+ mountPath = mountPath.substring(0, mountPath.length() - 1);
+ String absoluteURI = mountPath + uri.getSchemeSpecificPart();
+ log("Resolving " + uri.toString() + " to " + absoluteURI);
+ return new URI(absoluteURI);
+ }
+
+ /**
+ * Get the context of a block with a given name.
+ */
+ public ServletContext getNamedContext(String name) {
+ BlockServlet blockServlet =
+ (BlockServlet) this.componentContext.locateService(name);
+ System.out.println("OSGIBlockContext: " + name + "=" + blockServlet);
+ return blockServlet.getBlockContext();
+ }
+
+ /**
+ * @param mountPath The mountPath to set.
+ */
+ public void setMountPath(String mountPath) {
+ this.mountPath = mountPath;
+ }
+
+ /**
+ * Get the mount path of the block context
+ */
+ public String getMountPath() {
+ return this.mountPath;
+ }
+
+ /**
+ * @param properties The properties to set.
+ */
+ public void setProperties(Dictionary properties) {
+ this.properties = properties;
+ }
+
+ protected void activate(ComponentContext componentContext) {
+ this.componentContext = componentContext;
+ }
+
+ protected class NamedDispatcher implements RequestDispatcher {
+
+ private String blockName;
+ private boolean superCall = false;
+ private ServletContext context;
+
+ public NamedDispatcher(String blockName) {
+ this.blockName = blockName;
+ this.superCall = Block.SUPER.equals(this.blockName);
+
+ // Call to a named block that exists in the current context
+ this.context = BlockContext.this.getNamedContext(this.blockName);
+ if (this.context == null) {
+ // If there is a super block, the connection might
+ // be defined there instead.
+ BlockContext superContext =
+ (BlockContext) BlockContext.this.getNamedContext(Block.SUPER);
+ if (superContext != null) {
+ this.context = superContext.getNamedContext(this.blockName);
+ this.superCall = true;
+ }
+ }
+ }
+
+ protected boolean exists() {
+ return this.context != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.RequestDispatcher#forward(javax.servlet.ServletRequest,
+ * javax.servlet.ServletResponse)
+ */
+ public void forward(ServletRequest request, ServletResponse response)
+ throws ServletException, IOException {
+ // Call to named block
+
+ BlockContext.this.log("Enter processing in block " + this.blockName);
+ RequestDispatcher dispatcher =
+ this.context.getRequestDispatcher(((HttpServletRequest)request).getPathInfo());
+ if (dispatcher != null) {
+ if (!this.superCall) {
+ try {
+ // It is important to set the current block each time
+ // a new block is entered, this is used for the block
+ // protocol
+ BlockCallStack.enterBlock(this.context);
+ dispatcher.forward(request, response);
+ } finally {
+ BlockCallStack.leaveBlock();
+ }
+ } else {
+ // A super block should be called in the context of
+ // the called block to get polymorphic calls resolved
+ // in the right way. Therefore no new current block is
+ // set.
+ dispatcher.forward(request, response);
+ }
+ } else {
+ // Cannot happen
+ throw new IllegalStateException();
+ }
+ BlockContext.this.log("Leaving processing in block " + this.blockName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest,
+ * javax.servlet.ServletResponse)
+ */
+ public void include(ServletRequest request, ServletResponse response)
+ throws ServletException, IOException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ * Limited functionality, assumes that there is at most one servlet in the block
+ */
+ private class PathDispatcher implements RequestDispatcher {
+
+ // Ignores path, as the assumed only servlet within the block is
+ // implicitly mounted on '/*'
+ private PathDispatcher(String path) {
+ }
+
+ private boolean exists() {
+ return BlockContext.this.servlet != null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.RequestDispatcher#forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
+ */
+ public void forward(ServletRequest request, ServletResponse response)
+ throws ServletException, IOException {
+ BlockContext.this.servlet.service(request, response);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
+ */
+ public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockContext.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java?rev=384338&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java Wed Mar 8 13:50:40 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blocks.osgi;
+
+import java.io.IOException;
+import java.util.Enumeration;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cocoon.blocks.util.ServletConfigurationWrapper;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * @version $Id$
+ */
+public class BlockServlet extends HttpServlet {
+ private ComponentContext componentContext;
+ private BlockContext blockContext;
+ private Servlet blockServlet;
+
+ /* (non-Javadoc)
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ this.blockContext.setServletContext(servletConfig.getServletContext());
+ ServletConfig blockServletConfig =
+ new ServletConfigurationWrapper(servletConfig, this.blockContext) {
+
+ // FIXME: The context should get the init parameters from the
+ // config rather than the oposite way around.
+ public String getInitParameter(String name) {
+ return super.getServletContext().getInitParameter(name);
+ }
+
+ public Enumeration getInitParameterNames() {
+ return super.getServletContext().getInitParameterNames();
+ }
+
+ };
+ this.blockServlet.init(blockServletConfig);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.GenericServlet#destroy()
+ */
+ public void destroy() {
+ this.blockServlet.destroy();
+ super.destroy();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ protected void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ RequestDispatcher dispatcher =
+ this.blockContext.getRequestDispatcher(request.getPathInfo());
+ dispatcher.forward(request, response);
+ }
+
+ /**
+ * @return the blockContext
+ */
+ public BlockContext getBlockContext() {
+ return this.blockContext;
+ }
+
+ protected void activate(ComponentContext componentContext) {
+ this.componentContext = componentContext;
+ this.blockContext = new BlockContext();
+
+ this.blockContext.setProperties(this.componentContext.getProperties());
+ this.blockContext.setMountPath((String) this.componentContext.getProperties().get("path"));
+ this.blockServlet =
+ (Servlet) this.componentContext.locateService("blockServlet");
+ this.blockContext.setServlet(this.blockServlet);
+ this.blockContext.activate(this.componentContext);
+ }
+}
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/BlockServlet.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java?rev=384338&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java (added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java Wed Mar 8 13:50:40 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blocks.osgi;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @version $Id$
+ */
+public class TestServlet2 extends HttpServlet {
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ System.out.println("TestServlet2: context=" + this.getServletContext());
+ RequestDispatcher block1 = this.getServletContext().getNamedDispatcher("block1");
+ System.out.println("TestServlet2: dispatcher=" + block1);
+ block1.forward(request, response);
+ }
+
+}
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-osgi-impl/src/main/java/org/apache/cocoon/blocks/osgi/TestServlet2.java
------------------------------------------------------------------------------
svn:keywords = Id