1 /* |
|
2 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 // RMI Activation Functional Test |
|
25 |
|
26 import java.rmi.*; |
|
27 import java.rmi.activation.*; |
|
28 import java.rmi.server.*; |
|
29 import java.util.*; |
|
30 |
|
31 // NotActivatableServerImpl |
|
32 |
|
33 public class NotActivatableServerImpl |
|
34 extends UnicastRemoteObject |
|
35 implements NotActivatableInterface { |
|
36 |
|
37 private static final String PROG_NAME = "NotActivatableServerImpl"; |
|
38 private static final String SERVER_OBJECT = "NotActivatableServer"; |
|
39 private static final String CLASS_NAME = "activation.NotActivatableServerImpl"; |
|
40 |
|
41 private static final String POLICY_FILE = "policy_file"; |
|
42 |
|
43 private static final String USER_DIR = |
|
44 System.getProperty("user.dir").replace('\\', '/'); |
|
45 |
|
46 private static final String CODE_LOCATION = "file:"+USER_DIR+"/"; |
|
47 |
|
48 private static final MarshalledObject DATA = null; |
|
49 private static ActivationDesc ACTIVATION_DESC = null; |
|
50 |
|
51 public NotActivatableServerImpl() throws RemoteException {} |
|
52 |
|
53 public void ping() throws RemoteException {} |
|
54 |
|
55 public void exit() throws RemoteException { |
|
56 System.exit(0); |
|
57 } |
|
58 |
|
59 private static void setup() { |
|
60 |
|
61 try { |
|
62 |
|
63 NotActivatableInterface rsi; // Remote server interface |
|
64 |
|
65 System.setSecurityManager(new RMISecurityManager()); |
|
66 |
|
67 rsi = (NotActivatableInterface)Activatable.register(ACTIVATION_DESC); |
|
68 System.out.println("Got stub for "+SERVER_OBJECT+" implementation"); |
|
69 |
|
70 Naming.rebind(SERVER_OBJECT, rsi); |
|
71 System.out.println("Exported "+SERVER_OBJECT+" implementation"); |
|
72 |
|
73 } catch (Exception e) { |
|
74 System.err.println("Exception: " + e); |
|
75 e.printStackTrace(); |
|
76 } |
|
77 } |
|
78 |
|
79 public static void main(String[] args) { |
|
80 |
|
81 try { |
|
82 Properties props = new Properties(); |
|
83 props.setProperty("java.security.policy", POLICY_FILE); |
|
84 |
|
85 ActivationGroupDesc agd = new ActivationGroupDesc(props, null); |
|
86 |
|
87 ActivationGroupID agid = ActivationGroup.getSystem().registerGroup(agd); |
|
88 |
|
89 ACTIVATION_DESC = new ActivationDesc(agid, |
|
90 CLASS_NAME, CODE_LOCATION, DATA, false); |
|
91 } |
|
92 catch (Exception e) { |
|
93 System.err.println("Exception: " + e); |
|
94 e.printStackTrace(); |
|
95 } |
|
96 |
|
97 setup(); |
|
98 } |
|
99 } |
|