KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > SimpleConnectionHandlerFactory


1 /*
2  * Copyright 2004 Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package tutorial;
19
20 import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
21 import org.apache.avalon.cornerstone.services.connection.
22
    ConnectionHandlerFactory;
23 import org.apache.avalon.framework.logger.Logger;
24 import org.apache.avalon.framework.logger.LogEnabled;
25
26 /**
27  * A simple factory for creating instances of <code>SimpleConnectionHandler</code>.
28  * We're not doing anything fancy (or safe) here like pooling connections or queuing
29  * if we are busy.
30  *
31  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
32  * @avalon.component version="1.0" name="connection-handler-factory" lifestyle="singleton"
33  * @avalon.service type="org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory"
34  */

35 public class SimpleConnectionHandlerFactory
36     implements ConnectionHandlerFactory, LogEnabled {
37   /**
38    * Internal reference to the logging channel supplied by the container.
39    */

40   private Logger m_logger;
41
42   /**
43    * Constructs an instance of a <code>SimpleConnectionHandler</code> that will
44    * handle an incoming web request.
45    *
46    * @see org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory#createConnectionHandler()
47    */

48   public ConnectionHandler createConnectionHandler() throws Exception JavaDoc {
49     SimpleConnectionHandler handler = new SimpleConnectionHandler();
50     handler.setLogger(m_logger);
51     return handler;
52   }
53
54   /**
55    * Does nothing since we aren't doing anything fancy here...
56    *
57    * @see org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory#releaseConnectionHandler(org.apache.avalon.cornerstone.services.connection.ConnectionHandler)
58    */

59   public void releaseConnectionHandler(ConnectionHandler handler) {
60   }
61
62   /**
63    * Sets the container-supplied logger.
64    */

65   public void enableLogging(Logger logger) {
66     m_logger = logger;
67   }
68 }
69
Popular Tags