View Javadoc

1   /*
2   Copyright (C) 2000 - 2007 Grid Systems, S.A.
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License, version 2, as
6   published by the Free Software Foundation.
7   
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17  package com.gridsystems.innergrid.kernel.client;
18  
19  import java.net.URL;
20  
21  import javax.xml.namespace.QName;
22  
23  import com.gridsystems.innergrid.api.ClientApiFactory;
24  
25  /**
26   * API Client Bindings factory for the Management STS Plugin.
27   *
28   * @author Rodrigo Ruiz
29   */
30  public final class KernelApiFactory extends ClientApiFactory {
31  
32    /**
33     * API interfaces.
34     */
35    @SuppressWarnings("unchecked")
36    private static final Class[] IFACES = {
37      com.gridsystems.innergrid.kernel.services.ApiKernelManager.class,
38      com.gridsystems.innergrid.kernel.services.ApiTomcatManager.class,
39    };
40  
41    /**
42     * API service local names.
43     */
44    private static final String[] LOCAL_NAMES = {
45      "ApiKernelManager",
46      "ApiTomcatManager",
47    };
48  
49    /**
50     * API service namespaces.
51     */
52    private static final String[] NS = {
53      "http://services.kernel.innergrid.gridsystems.com",
54      "http://services.kernel.innergrid.gridsystems.com",
55    };
56  
57    /**
58     * API WSDL resource locations.
59     */
60    private static final String[] WSDL = {
61      "/com/gridsystems/innergrid/kernel/services/ApiKernelManager.wsdl",
62      "/com/gridsystems/innergrid/kernel/services/ApiTomcatManager.wsdl",
63    };
64  
65    /**
66     * {@inheritDoc}
67     */
68    @Override protected void registerApis() {
69      assert IFACES.length == LOCAL_NAMES.length;
70      assert IFACES.length == NS.length;
71      assert IFACES.length == WSDL.length;
72  
73      // All services share the same descriptor
74      URL wsdd = this.getClass().getResource("client-config.wsdd");
75  
76      for (int i = 0; i < LOCAL_NAMES.length; i++) {
77        ClientApiFactory.ApiEntry entry = new ClientApiFactory.ApiEntry();
78        entry.factory = this;
79        entry.iface = IFACES[i];
80        entry.portName = new QName(NS[i], LOCAL_NAMES[i]);
81        entry.serviceName = new QName(NS[i], LOCAL_NAMES[i] + "Service");
82        entry.wsdd = (i == 0) ? wsdd : null;
83        entry.wsdl = this.getClass().getResource(WSDL[i]);
84        register(entry);
85      }
86    }
87  }