KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > remotemanager > RemoteManagerTestConfiguration


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

19
20
21
22 package org.apache.james.remotemanager;
23
24 import org.apache.avalon.framework.configuration.DefaultConfiguration;
25 import org.apache.james.test.util.Util;
26
27 public class RemoteManagerTestConfiguration extends DefaultConfiguration {
28
29     private int m_remoteManagerListenerPort;
30     private Integer JavaDoc m_connectionLimit = null;
31     private String JavaDoc m_loginName = "testLogin";
32     private String JavaDoc m_loginPassword = "testPassword";
33     private String JavaDoc commandClassName = "org.apache.james.remotemanager.EchoCommand";
34     
35     public RemoteManagerTestConfiguration(int smtpListenerPort) {
36         super("smptserver");
37
38         m_remoteManagerListenerPort = smtpListenerPort;
39     }
40
41     
42     
43     public String JavaDoc getCommandClassName() {
44         return commandClassName;
45     }
46
47
48
49     public void setCommandClassName(String JavaDoc commandClassName) {
50         this.commandClassName = commandClassName;
51     }
52
53
54
55     public void setConnectionLimit(int iConnectionLimit) {
56         m_connectionLimit = new Integer JavaDoc(iConnectionLimit);
57     }
58
59     public String JavaDoc getLoginName() {
60         return m_loginName;
61     }
62
63     public void setLoginName(String JavaDoc loginName) {
64         m_loginName = loginName;
65     }
66
67     public String JavaDoc getLoginPassword() {
68         return m_loginPassword;
69     }
70
71     public void setLoginPassword(String JavaDoc loginPassword) {
72         m_loginPassword = loginPassword;
73     }
74
75     public void init() {
76
77         setAttribute("enabled", true);
78
79         addChild(Util.getValuedConfiguration("port", "" + m_remoteManagerListenerPort));
80         if (m_connectionLimit != null) addChild(Util.getValuedConfiguration("connectionLimit", "" + m_connectionLimit.intValue()));
81
82         DefaultConfiguration handlerConfig = new DefaultConfiguration("handler");
83         handlerConfig.addChild(Util.getValuedConfiguration("helloName", "myMailServer"));
84         handlerConfig.addChild(Util.getValuedConfiguration("connectiontimeout", "360000"));
85         
86         DefaultConfiguration adminAccounts = new DefaultConfiguration("administrator_accounts");
87         
88         DefaultConfiguration account = new DefaultConfiguration("account");
89         
90         account.setAttribute("login", m_loginName);
91         account.setAttribute("password", m_loginPassword);
92
93         adminAccounts.addChild(account);
94         handlerConfig.addChild(adminAccounts);
95         
96         // handlerConfig.addChild(Util.getValuedConfiguration("prompt", ">"));
97

98         handlerConfig.addChild(Util.createRemoteManagerHandlerChainConfiguration());
99         addChild(handlerConfig);
100         
101         DefaultConfiguration commandConfiguration = new DefaultConfiguration("command");
102         commandConfiguration.addChild(Util.getValuedConfiguration("class-name", commandClassName));
103         
104         addChild(commandConfiguration);
105     }
106
107 }
108
Popular Tags