KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > ss > ASSocketServiceConfig


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.server.ss;
24
25 import java.net.SocketAddress JavaDoc;
26 import java.net.InetSocketAddress JavaDoc;
27 import com.sun.enterprise.config.ConfigBean;
28 import com.sun.enterprise.config.ConfigContext;
29 import com.sun.enterprise.config.serverbeans.Config;
30 import com.sun.enterprise.config.serverbeans.ServerBeansFactory;
31 import com.sun.enterprise.server.ServerContext;
32
33 /**
34  * Helper class representing configuration
35  * of one Socket Service.
36  *
37  * @see ASSocketService
38  */

39 class ASSocketServiceConfig {
40
41     private ConfigBean config = null;
42     private String JavaDoc addressTag = null;
43     private String JavaDoc portTag = null;
44     private int port ;
45     private String JavaDoc address = null;
46     private SocketAddress JavaDoc sAddress = null;
47
48     ASSocketServiceConfig(ConfigBean config) {
49         this.config = config;
50     }
51
52     void setAddressTag(String JavaDoc addressTag) {
53         this.addressTag = addressTag;
54     }
55
56     String JavaDoc getAddressTag() {
57         return this.addressTag;
58     }
59
60     void setPortTag(String JavaDoc portTag) {
61         this.portTag = portTag;
62     }
63
64     String JavaDoc getPortTag() {
65         return this.portTag;
66     }
67
68     int getPort() {
69         return this.port;
70     }
71
72     String JavaDoc getAddress() {
73         return this.address;
74     }
75
76     SocketAddress JavaDoc getSocketAddress() {
77         return this.sAddress;
78     }
79
80     void init() {
81         this.port = Integer.parseInt(config.getAttributeValue(getPortTag()));
82
83         if (getAddressTag() != null) {
84             this.address = config.getAttributeValue(getAddressTag());
85         }
86
87         String JavaDoc address = getAddress();
88         if (address != null) {
89             this.sAddress = new InetSocketAddress JavaDoc(address, getPort());
90         } else {
91             this.sAddress = new InetSocketAddress JavaDoc(getPort());
92         }
93     }
94
95     public String JavaDoc toString() {
96         return getAddress() + ":" + getPort();
97     }
98 }
99
Popular Tags