KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > server > httpd > HttpEjbServer


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

17 package org.openejb.server.httpd;
18
19 import org.openejb.server.ServerService;
20 import org.openejb.server.ServiceException;
21 import org.openejb.server.ejbd.EjbServer;
22
23 import java.util.Properties JavaDoc;
24 import java.net.Socket JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.InputStream JavaDoc;
27 import java.io.OutputStream JavaDoc;
28
29 /**
30  * @version $Revision$ $Date$
31  */

32 public class HttpEjbServer implements ServerService {
33
34     private HttpServer httpServer;
35     private String JavaDoc name;
36
37     public void init(Properties JavaDoc props) throws Exception JavaDoc {
38         name = props.getProperty("name");
39         EjbServer ejbServer = new EjbServer();
40         ServerServiceAdapter adapter = new ServerServiceAdapter(ejbServer);
41         httpServer = new HttpServer(adapter);
42         httpServer.init(props);
43         ejbServer.init(props);
44     }
45
46
47     public void service(Socket JavaDoc socket) throws ServiceException, IOException JavaDoc {
48         httpServer.service(socket);
49     }
50
51     public void service(InputStream JavaDoc in, OutputStream JavaDoc out) throws ServiceException, IOException JavaDoc {
52         httpServer.service(in, out);
53     }
54
55     public void start() throws ServiceException {
56         httpServer.start();
57     }
58
59     public void stop() throws ServiceException {
60         httpServer.stop();
61     }
62
63     public String JavaDoc getName() {
64         return name;
65     }
66
67     public int getPort() {
68         return httpServer.getPort();
69     }
70
71     public String JavaDoc getIP() {
72         return httpServer.getIP();
73     }
74 }
75
Popular Tags