You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/05/09 07:41:27 UTC
cvs commit: avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF merlin.tld web.xml
mcconnell 2003/05/08 22:41:27
Modified: merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/jsp/tag
TargetTag.java
merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/servlet
MerlinServlet.java TestServlet.java
merlin/merlin-extensions/merlin-servlet/src/webapp
header.jsp index.jsp
merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF
merlin.tld web.xml
Log:
Updated to use Kernel.getURL()
Revision Changes Path
1.5 +27 -32 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/jsp/tag/TargetTag.java
Index: TargetTag.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/jsp/tag/TargetTag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TargetTag.java 16 Apr 2003 14:56:19 -0000 1.4
+++ TargetTag.java 9 May 2003 05:41:27 -0000 1.5
@@ -15,7 +15,7 @@
import javax.servlet.jsp.tagext.IterationTag;
import javax.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.avalon.merlin.block.Block;
+import org.apache.avalon.merlin.kernel.Kernel;
public class TargetTag extends BodyTagSupport
{
@@ -232,7 +232,6 @@
//
m_adapter = invoke( m_adapter, m_keyword );
-System.out.println("## DELAGATING: " + m_keyword + ", " + m_adapter );
if( m_adapter != null )
{
return BodyTag.EVAL_BODY_BUFFERED;
@@ -414,42 +413,38 @@
}
else
{
- return pageContext.findAttribute( Block.BLOCK_KEY );
+ m_source = "";
}
}
- else
- {
- Block block = (Block) pageContext.getServletContext().getAttribute( Block.BLOCK_KEY );
- if( block == null )
- {
- final String error =
- "Servlet context attribute " + Block.BLOCK_KEY + " is null.";
- throw new JspException( error );
- }
-
- Object object = null;
- try
- {
- URL base = block.getURL();
- URL ref = new URL( base, m_source );
- object = ref.getContent();
- }
- catch( Throwable e )
- {
- final String error =
- "Cannot resolve target url " + m_source;
- throw new JspException( error, e );
- }
- if( object == null )
- {
- final String error = "Null object reference returned for the path: " + m_source;
- throw new JspException( error );
- }
+ URL root = (URL) pageContext.getServletContext().getAttribute( Kernel.BASE_URL_KEY );
+ if( root == null )
+ {
+ final String error =
+ "Servlet context attribute '" + Kernel.BASE_URL_KEY + "' is null.";
+ throw new JspException( error );
+ }
- return object;
+ Object object = null;
+ try
+ {
+ URL ref = new URL( root, m_source );
+ object = ref.getContent();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Cannot resolve target url " + m_source;
+ throw new JspException( error, e );
+ }
+ if( object == null )
+ {
+ final String error = "Null object reference returned for the path: " + m_source;
+ throw new JspException( error );
}
+
+ return object;
}
/**
1.5 +7 -36 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/servlet/MerlinServlet.java
Index: MerlinServlet.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/servlet/MerlinServlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MerlinServlet.java 26 Apr 2003 12:37:49 -0000 1.4
+++ MerlinServlet.java 9 May 2003 05:41:27 -0000 1.5
@@ -61,11 +61,14 @@
import org.apache.avalon.merlin.kernel.impl.DefaultKernel;
/**
- * Servlet implementing the Merlin Kernel interface.
- *
+ * Servlet that handles the establishment of a Merlin Kernel
+ * and registration of the kernel base URL under the servlet
+ * context using the key {@link Kernel.BASE_URL_KEY}.
+ *
+ *
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
*/
-public class MerlinServlet extends HttpServlet implements Kernel
+public class MerlinServlet extends HttpServlet
{
private DefaultKernel m_kernel;
@@ -108,7 +111,7 @@
m_kernel.contextualize( context );
m_kernel.initialize();
- getServletContext().setAttribute( Block.BLOCK_KEY, getRootBlock() );
+ getServletContext().setAttribute( Kernel.BASE_URL_KEY, m_kernel.getURL() );
log( "kernel established" );
}
@@ -118,37 +121,6 @@
}
}
-
-
- /**
- * Return the root block.
- * @return the root block
- */
- public Block getRootBlock()
- {
- if( m_kernel == null )
- {
- final String message =
- "Kernel has not been initialized.";
- throw new IllegalStateException( message );
- }
- return m_kernel.getRootBlock();
- }
-
- /**
- * Initiate an orderly shutdown of the kernel.
- */
- public void shutdown()
- {
- if( m_kernel == null )
- {
- final String message =
- "Kernel has not been initialized.";
- throw new IllegalStateException( message );
- }
- m_kernel.shutdown();
- }
-
/**
* Disposes of container manager and container instance.
*/
@@ -173,5 +145,4 @@
return value;
}
}
-
}
1.4 +21 -3 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/servlet/TestServlet.java
Index: TestServlet.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/java/org/apache/avalon/merlin/servlet/TestServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestServlet.java 16 Apr 2003 14:56:19 -0000 1.3
+++ TestServlet.java 9 May 2003 05:41:27 -0000 1.4
@@ -52,11 +52,14 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
+import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.avalon.merlin.kernel.Kernel;
+
/**
* Servlet implementing the Merlin Kernel interface.
*
@@ -65,6 +68,21 @@
public class TestServlet extends MerlinServlet
{
+ URL m_root;
+
+ public void init()
+ throws ServletException
+ {
+ super.init();
+ m_root = (URL) getServletContext().getAttribute( Kernel.BASE_URL_KEY );
+ if( m_root == null )
+ {
+ final String error =
+ "Unable to locate the Merlin Kernel base URL for the supplied context.";
+ throw new ServletException( error );
+ }
+ }
+
/**
* Respond to a GET request for the content produced by
* this servlet. This method should be overidden in a
@@ -92,7 +110,7 @@
writer.println("<tr>");
writer.println("<td>");
writer.println("<h1>Merlin Test Servlet Page</h1>");
- writer.println("<p>This servlet extends the MerlinServlet and presents information about the root block.</p>");
+ writer.println("<p>This servlet extends the MerlinServlet.</p>");
writer.println("</td>");
writer.println("</tr>");
writer.println("</table>");
@@ -102,10 +120,10 @@
writer.println("<table border=\"0\">");
writer.println("<tr>");
writer.println("<td>");
- writer.println( "Block:" );
+ writer.println( "URL:" );
writer.println("</td>");
writer.println("<td>");
- writer.println( getRootBlock().toString() );
+ writer.println( m_root.toString() );
writer.println("</td>");
writer.println("</tr>");
writer.println("</table>");
1.3 +2 -2 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/header.jsp
Index: header.jsp
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/header.jsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- header.jsp 15 Apr 2003 14:33:42 -0000 1.2
+++ header.jsp 9 May 2003 05:41:27 -0000 1.3
@@ -52,7 +52,7 @@
</tr>
<tr>
<td>
- <p class="caption">
+ <p class="caption">
<%
for( int i=0; i<m_options.length; i++ )
{
@@ -82,7 +82,7 @@
</tr>
<tr>
<td align="left">
- <p class="caption">
+ <p class="caption">
<%
for( int i=0; i<m_actions.length; i++ )
{
1.4 +6 -14 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/index.jsp
Index: index.jsp
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/index.jsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- index.jsp 15 Apr 2003 14:33:42 -0000 1.3
+++ index.jsp 9 May 2003 05:41:27 -0000 1.4
@@ -6,11 +6,11 @@
<%! String m_info; %>
<%
request.setAttribute("urn:merlin:page.title", "Merlin Index" );
- pageContext.include("header.jsp");
+ pageContext.include("/header.jsp");
m_base = request.getContextPath();
if( request.getPathInfo() == null )
{
- m_info = "/";
+ m_info = "";
}
else
{
@@ -20,20 +20,12 @@
<m:target url="<%=m_info%>">
<p>INFO: <%=m_info%></p>
- <p>BLOCK: <m:target feature="this"/></p>
- <p>Activation: <m:target feature="activationPolicy"/></p>
- <p>Name: <m:target feature="name"/></p>
- <p>Partition: <m:target feature="partitionName"/></p>
- <p>Path: <m:target feature="path"/></p>
- <m:target resolve="contextProvider">
- <p>Name: <m:target feature="name"/></p>
- <p>Context Provider: <a href="<%=m_base%>/navigator/<m:target feature="path"/>"><m:target feature="name"/></a></p>
- </m:target>
- <p>Base: <%=m_base%></p>
- <p>URL: <a href="<%=m_base%>/navigator/<m:target feature="path"/>"><m:target feature="URL"/></a></p>
+ <p>TARGET: <m:target feature="this"/></p>
+ <p>CLASS: <m:target feature="class"/></p>
+ <p>URL: <a href="<%=m_base%>/<%=m_info%>"><%=m_base%>/<%=m_info%></a></p>
</m:target>
<%
- pageContext.include("footer.jsp");
+ pageContext.include("/footer.jsp");
%>
1.2 +1 -1 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF/merlin.tld
Index: merlin.tld
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF/merlin.tld,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- merlin.tld 13 Apr 2003 05:43:05 -0000 1.1
+++ merlin.tld 9 May 2003 05:41:27 -0000 1.2
@@ -16,7 +16,7 @@
<tag>
<name>target</name>
- <tag-class>org.apache.avalon.merlin.jsp.TargetTag</tag-class>
+ <tag-class>org.apache.avalon.merlin.jsp.tag.TargetTag</tag-class>
<body-content>JSP</body-content>
<description>
Tag representing a target object that represents business
1.4 +1 -1 avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-extensions/merlin-servlet/src/webapp/WEB-INF/web.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- web.xml 15 Apr 2003 14:33:42 -0000 1.3
+++ web.xml 9 May 2003 05:41:27 -0000 1.4
@@ -29,7 +29,7 @@
<servlet-mapping>
<servlet-name>navigator</servlet-name>
- <url-pattern>/navigator/*</url-pattern>
+ <url-pattern>/merlin/*</url-pattern>
</servlet-mapping>
<taglib>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org