KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > phoenix > components > embeddor > SingleAppEmbeddor


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.phoenix.components.embeddor;
9
10 import java.io.File JavaDoc;
11 import org.apache.avalon.framework.component.Component;
12 import org.apache.avalon.framework.component.ComponentException;
13 import org.apache.avalon.framework.component.ComponentManager;
14 import org.apache.avalon.phoenix.interfaces.Application;
15
16 /**
17  * WARNING: DO NOT USE THIS SERVLET FOR PRODUCTION SERVICE. THIS IS EXPERIMENTAL.
18  * Embeddor to host only a single application.
19  * It is required that the user set parameter
20  * <ul>
21  * <li>application-location = location of application directory or file
22  * </ul>
23  * Other parameters are inherited from PhoenixEmbeddor.
24  *
25  * @author <a HREF="colus@isoft.co.kr">Eung-ju Park</a>
26  * @author <a HREF="peter at apache.org">Peter Donald</a>
27  * @deprecated
28  */

29 public class SingleAppEmbeddor
30     extends DefaultEmbeddor
31     implements ComponentManager
32 {
33     ///Sole application hosted in kernel
34
private Application m_application;
35
36     /**
37      * Deploy a single application.
38      *
39      * @throws Exception if an error occurs
40      */

41     protected void deployDefaultApplications()
42         throws Exception JavaDoc
43     {
44         final String JavaDoc applicationName =
45             getParameters().getParameter( "application-name", "default" );
46         final String JavaDoc applicationLocation = getParameters().getParameter( "application-location" );
47         final File JavaDoc directory = new File JavaDoc( applicationLocation );
48         deployFile( applicationName, directory );
49         m_application = getKernel().getApplication( applicationName );
50     }
51
52     /**
53      * List all block names in application.
54      *
55      * @return the list of all block names
56      */

57     public String JavaDoc[] list()
58     {
59         return m_application.getBlockNames();
60     }
61
62     /**
63      * Get a Block by name.
64      *
65      * @return the block in application
66      */

67     public Component lookup( final String JavaDoc role )
68         throws ComponentException
69     {
70         final Object JavaDoc component = m_application.getBlock( role );
71         if( null == component )
72         {
73             throw new ComponentException( role, "Could not find component" );
74         }
75         return (Component)component;
76     }
77
78     public boolean hasComponent( final String JavaDoc role )
79     {
80         return (null != m_application.getBlock( role ));
81     }
82
83     /**
84      * Release block back to application.
85      *
86      * @param component the block
87      */

88     public void release( final Component component )
89     {
90     }
91 }
92
Popular Tags