RmiWrapper.java

biz/hammurapi/config/RmiWrapper.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 089 Undocumented method 2 45:9
Java Inspector 089 Undocumented method 2 49:9
Java Inspector 089 Undocumented method 2 64:9
Java Inspector 089 Undocumented method 2 68:9
Java Inspector 089 Undocumented method 2 73:9
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 56:58
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 56:83
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 58:58
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 58:83
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 60:58
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 60:81
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 75:37
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 77:37
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 79:72
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 81:66
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 81:112

Source code

1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.config;
24
25import java.net.MalformedURLException;
26import java.rmi.Naming;
27import java.rmi.NotBoundException;
28import java.rmi.RemoteException;
29
30import javax.rmi.PortableRemoteObject;
31
32import org.w3c.dom.Element;
33import org.w3c.dom.Node;
34
35/**
36 * Binds remote object to name tree.
37 * @author Pavel Vlasov
38 * @revision $Revision$
39 */
40public class RmiWrapper implements Wrapper, Component, DomConfigurable {
41 private Object master;
42 private Class narrowTo;
43 private String url;
44
45 public Object getMaster() {
46 return master;
47 }
48
49 public void start() throws ConfigurationException {
50 try {
51 master=Naming.lookup(url);
52 if (narrowTo!=null) {
53 master=PortableRemoteObject.narrow(master, narrowTo);
54 }
55 } catch (MalformedURLException e) {
56 throw new ConfigurationException("Could not lookup '"+url+"' - "+e, e);
57 } catch (RemoteException e) {
58 throw new ConfigurationException("Could not lookup '"+url+"' - "+e, e);
59 } catch (NotBoundException e) {
60 throw new ConfigurationException("Could not bind '"+url+"' - "+e, e);
61 }
62 }
63
64 public void stop() {
65 // Nothing
66 }
67
68 public void setOwner(Object owner) {
69 // nothing
70
71 }
72
73 public void configure(Node configNode, Context context, ClassLoader classLoader) throws ConfigurationException {
74 Element ce = (Element) configNode;
75 url=ce.getAttribute("url");
76
77 if (ce.hasAttribute("narrow-to")) {
78 try {
79 narrowTo=Class.forName(ce.getAttribute("narrow-to"));
80 } catch (ClassNotFoundException e) {
81 throw new ConfigurationException("Narrow-to class not found: "+ce.getAttribute("narrow-to"), e);
82 }
83 }
84 }
85
86}
87