KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > server > ProtocolFactory


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb.server;
18
19 import org.alfresco.filesys.smb.Dialect;
20
21 /**
22  * SMB Protocol Factory Class.
23  * <p>
24  * The protocol factory class generates protocol handlers for SMB dialects.
25  */

26 class ProtocolFactory
27 {
28
29     /**
30      * ProtocolFactory constructor comment.
31      */

32     public ProtocolFactory()
33     {
34         super();
35     }
36
37     /**
38      * Return a protocol handler for the specified SMB dialect type, or null if there is no
39      * appropriate protocol handler.
40      *
41      * @param dialect int
42      * @return ProtocolHandler
43      */

44     protected static ProtocolHandler getHandler(int dialect)
45     {
46
47         // Determine the SMB dialect type
48

49         ProtocolHandler handler = null;
50
51         switch (dialect)
52         {
53
54         // Core dialect
55

56         case Dialect.Core:
57         case Dialect.CorePlus:
58             handler = new CoreProtocolHandler();
59             break;
60
61         // LanMan dialect
62

63         case Dialect.DOSLanMan1:
64         case Dialect.DOSLanMan2:
65         case Dialect.LanMan1:
66         case Dialect.LanMan2:
67         case Dialect.LanMan2_1:
68             handler = new LanManProtocolHandler();
69             break;
70
71         // NT dialect
72

73         case Dialect.NT:
74             handler = new NTProtocolHandler();
75             break;
76         }
77
78         // Return the protocol handler
79

80         return handler;
81     }
82 }
Popular Tags