KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > cmdui > CommandInterface


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

16 package org.jmanage.cmdui;
17
18 import org.jmanage.core.services.ServiceFactory;
19 import org.jmanage.core.services.ConfigurationService;
20 import org.jmanage.core.services.ServiceContext;
21 import org.jmanage.core.services.ServiceContextImpl;
22 import org.jmanage.core.auth.User;
23 import org.jmanage.core.data.ApplicationConfigData;
24
25 /**
26  *
27  * date: Jan 19, 2005
28  * @author Rakesh Kalra
29  */

30 public class CommandInterface {
31
32     static{
33         /* initialize ServiceFactory */
34         ServiceFactory.init(ServiceFactory.MODE_REMOTE);
35     }
36
37     public static void main(String JavaDoc[] args){
38         ConfigurationService configService =
39                 ServiceFactory.getConfigurationService();
40
41         ApplicationConfigData configData = new ApplicationConfigData();
42         configData.setHost("localhost");
43         configData.setPort(new Integer JavaDoc(7001));
44         configData.setName("testApp");
45         configData.setType("weblogic");
46         configData.setUsername("system");
47         configData.setPassword("12345678");
48
49         configData = configService.addApplication(getServiceContext(),
50                 configData);
51         System.out.println("ApplicationId:" + configData.getApplicationId());
52         System.out.println("Host:" + configData.getHost());
53         System.out.println("Port:" + configData.getPort());
54         System.out.println("Name:" + configData.getName());
55         System.out.println("Type:" + configData.getType());
56         System.out.println("Username:" + configData.getUsername());
57         System.out.println("Password:" + configData.getPassword());
58     }
59
60     private static ServiceContext getServiceContext(){
61         ServiceContextImpl context = new ServiceContextImpl();
62         User user = new User("admin", null, null, null, 0);
63         context.setUser(user);
64         return context;
65     }
66 }
67
Popular Tags