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/04/07 18:59:28 UTC
cvs commit: avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/WEB-INF web.log web.xml
mcconnell 2003/04/07 09:59:28
Added: merlin/merlin-smp/src/examples/afs/simple-servlet .cvsignore
maven.xml project.xml
merlin/merlin-smp/src/examples/afs/simple-servlet/src/etc
LICENSE.txt project.mf stylesheet.css
merlin/merlin-smp/src/examples/afs/simple-servlet/src/java/org/apache/bank
SimpleServlet.java
merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/BLOCK-INF
block.xml
merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/WEB-INF
web.log web.xml
Log:
Initial commit of a servlet containing an embedded Merlin Kernel that establishes a container holding a component that establishes a Bank instance.
Revision Changes Path
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/.cvsignore
Index: .cvsignore
===================================================================
build
logs
tutorial.jar
working
target
maven.log
bank.jar
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/maven.xml
Index: maven.xml
===================================================================
<project default="java:jar" xmlns:maven="jelly:maven" xmlns:j="jelly:core" xmlns:util="jelly:util">
<!--
<preGoal name="war:war">
<mkDir dir="${basedir}/target/classes/WEB-INF/lib"/>
<j:forEach var="dependency" items="${pom.dependencies}">
<copy
todir="${basedir}/target/classes/WEB-INF/lib"
file="${maven.repo.local}/${dependency.artifactDirectory}/jars/${dependency.artifact}"/>
</j:forEach>
</preGoal>
-->
</project>
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<extend>${basedir}/../project.xml</extend>
<groupId>merlin</groupId>
<id>merlin-example-simple-bank-servlet</id>
<name>Simple Bank Servlet</name>
<package>org.apache.bank</package>
<inceptionYear>2003</inceptionYear>
<shortDescription>Apache Financial Service - Simple Bank</shortDescription>
<description>
A demonstration of a very simple component based implementation of a bank within a servlet.
</description>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet</connection>
<url>http://cvs.apache.org/viewcvs/avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet</url>
</repository>
<dependencies>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-example-simple-bank</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-servlet</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-framework</artifactId>
<version>4.1.4</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>servletapi</groupId>
<artifactId>servletapi</artifactId>
<version>2.3</version>
</dependency>
<!-- pre JDK 1.4 dependencies -->
<dependency>
<id>xml-apis</id>
<version>1.0.b2</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
<dependency>
<id>xerces</id>
<version>2.2.1</version>
<url>http://xml.apache.org/xerces2-j/</url>
</dependency>
<!-- unit test -->
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-logkit</artifactId>
<version>1.2</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-lifecycle</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-meta</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-meta-spi</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-assembly-spi</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>avalon</groupId>
<artifactId>avalon-assembly</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-i18n</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-event</artifactId>
<version>2.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-util-concurrent</artifactId>
<version>1.3.1</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-configuration</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>excalibur</groupId>
<artifactId>excalibur-extension</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-spi</artifactId>
<version>1.0</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<groupId>merlin</groupId>
<artifactId>merlin-core</artifactId>
<version>2.1</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
<dependency>
<id>commons-collections</id>
<version>2.1</version>
<properties>
<war.bundle.jar>true</war.bundle.jar>
</properties>
</dependency>
</dependencies>
</project>
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/etc/LICENSE.txt
Index: LICENSE.txt
===================================================================
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/etc/project.mf
Index: project.mf
===================================================================
Manifest-Version: 1.0
Created-By: Apache Avalon
Extension-Name: apache-bank
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: ASF
Implementation-Version: 1.0
Extension-List: merlin
merlin-Extension-Name: avalon-merlin
merlin-Specification-Version: 2.0
merlin-Implementation-Version: 2.1
merlin-Implementation-Vendor-Id: ASF
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/etc/stylesheet.css
Index: stylesheet.css
===================================================================
/* Javadoc style sheet */
/* Define colors, fonts and other style attributes here to override the defaults */
/* Page background color */
body { background-color: #FFFFFF }
/* Table colors */
.TableHeadingColor { background: #CCCCFF } /* Dark mauve */
.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */
.TableRowColor { background: #FFFFFF } /* White */
/* Font used in left-hand frame lists */
.FrameTitleFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
.FrameHeadingFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
.FrameItemFont { font-size: 10pts; font-family: Helvetica, Arial, san-serif }
/* Example of smaller, sans-serif font in frames */
/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
/* Navigation bar fonts and colors */
.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */
.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */
.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/java/org/apache/bank/SimpleServlet.java
Index: SimpleServlet.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.bank;
import java.io.File;
import java.net.URL;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.avalon.assembly.appliance.Appliance;
import org.apache.avalon.merlin.block.Block;
import org.apache.avalon.merlin.servlet.MerlinServlet;
import org.apache.bank.Bank;
/**
* Servlet example containing an embedded Merlin Kernel.
*
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
*/
public class SimpleServlet extends MerlinServlet
{
private Bank m_bank;
public void init()
throws ServletException
{
super.init();
try
{
//
// get the bank
//
Block block = super.getRootBlock();
URL banking = block.getURL();
URL url = new URL( banking, banking.getPath() + "bank" );
Appliance manager = (Appliance) url.getContent();
m_bank = (Bank) manager.resolve( this );
log( "Bank established: " + m_bank );
//
// ok - we have bank so we can now create and destroy
// accounts - need to think about the best way to move on
// from here
//
}
catch( Exception e )
{
throw new ServletException( "Bank initialization error.", e );
}
}
/**
* Printout some information about the bank.
*
* @param request The servlet request we are processing
* @param response The servlet response we are producing
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html>");
writer.println("<head>");
writer.println("<title>");
writer.println( m_bank.getName() );
writer.println("</title>");
writer.println("</head>");
writer.println("<body bgcolor=white>");
writer.println("<table border=\"0\">");
writer.println("<tr><td><h1>");
writer.println( m_bank.getName() );
writer.println( "</h1>" );
writer.println("<p>This servlet extends the abstract MerlinServet (which establishes a Merlin Kernel) and extracts from the kernel a reference to the Bank appliance. The implementation instantiates a bank instance and that's about it for now.</p>");
writer.println("</td></tr></table>");
writer.println("<hr/>");
writer.println("<table border=\"0\">");
writer.println("<tr><td>Name:</td><td>");
writer.println( m_bank.getName() );
writer.println("</td></tr>");
writer.println("<tr><td>No. accounts:</td><td>");
writer.println( m_bank.accounts() );
writer.println("</td></tr>");
writer.println("</table>");
writer.println("</body>");
writer.println("</html>");
}
public void destroy()
{
m_bank = null;
super.destroy();
}
}
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/BLOCK-INF/block.xml
Index: block.xml
===================================================================
<block name="banking">
<container>
<component name="bank" class="org.apache.bank.impl.BankProvider" activation="startup">
<configuration>
<name>Apache Financial Services</name>
</configuration>
</component>
</container>
</block>
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/WEB-INF/web.log
Index: web.log
===================================================================
User requested job termination...
%%[ Warning: Job cancelled. No PDF file produced. ] %%
1.1 avalon-sandbox/merlin/merlin-smp/src/examples/afs/simple-servlet/src/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Simple Bank</display-name>
<description>
Demonstration of an embedded application within a servlet.
</description>
<servlet>
<servlet-name>simple</servlet-name>
<servlet-class>org.apache.bank.SimpleServlet</servlet-class>
<init-param>
<param-name>block</param-name>
<param-value>/BLOCK-INF/block.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>simple</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org