KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > resin > SrunPort


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.server.resin;
30
31 import com.caucho.config.ConfigException;
32 import com.caucho.server.port.Port;
33 import com.caucho.server.port.ProtocolConfig;
34 import com.caucho.util.L10N;
35
36 /**
37  * Represents a protocol connection.
38  */

39 public class SrunPort extends Port {
40   private static L10N L = new L10N(SrunPort.class);
41
42   private int _index = -1;
43   private String JavaDoc _group = "";
44   private boolean _isBackup;
45   private String JavaDoc _protocolName = "hmux";
46
47   /**
48    * Sets the srun protocol (srun or hmux)
49    */

50   public void setProtocol(ProtocolConfig protocol)
51     throws ConfigException
52   {
53     if (protocol.getId().equals("srun"))
54       _protocolName = "srun";
55     else if (protocol.getId().equals("hmux"))
56       _protocolName = "hmux";
57     else
58       throw new ConfigException(L.l("`{0}' is an unknown srun protocol. The protocol must be:\n hmux - new Resin P2P srun protocol\n srun - old Resin protocol",
59                                     protocol));
60   }
61
62   /**
63    * Returns the protocol class.
64    */

65   public String JavaDoc getSrunProtocol()
66   {
67     return _protocolName;
68   }
69
70   /**
71    * Sets the session index for the srun.
72    */

73   public void setIndex(int index)
74   {
75     _index = index - 1;
76   }
77
78   /**
79    * Returns the session index for the srun.
80    */

81   public int getIndex()
82   {
83     return _index;
84   }
85
86   /**
87    * Set true for a backup.
88    */

89   public void setBackup(boolean isBackup)
90   {
91     _isBackup = isBackup;
92   }
93
94   /**
95    * Return true for a backup.
96    */

97   public boolean isBackup()
98   {
99     return _isBackup;
100   }
101
102   // backwards compat
103
public void setSrunIndex(int index)
104   {
105     setIndex(index);
106   }
107
108   public int getSrunIndex()
109   {
110     return getIndex();
111   }
112
113   public void setSrunGroup(String JavaDoc group)
114   {
115     setGroup(group);
116   }
117
118   public String JavaDoc getSrunGroup()
119   {
120     return getGroup();
121   }
122
123   /**
124    * Sets the session group for the srun.
125    */

126   public void setGroup(String JavaDoc group)
127   {
128     _group = group;
129   }
130
131   /**
132    * Gets the session group for the srun.
133    */

134   public String JavaDoc getGroup()
135   {
136     return _group;
137   }
138 }
139
Popular Tags