01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Victor A. Martynov
21: * @version $Revision: 1.1.2.4 $
22: */package org.apache.harmony.rmi.activation;
23:
24: import java.lang.reflect.Constructor;
25:
26: import java.security.AccessController;
27: import java.security.PrivilegedExceptionAction;
28:
29: import org.apache.harmony.rmi.common.RMILog;
30: import org.apache.harmony.rmi.internal.nls.Messages;
31:
32: /**
33: * Factory class to create RmidMonitors.
34: *
35: * @author Victor A. Martynov
36: * @version $Revision: 1.1.2.4 $
37: */
38: class RmidMonitorFactory {
39:
40: /**
41: * Standard logger for RMI Activation.
42: *
43: * @see org.apache.harmony.rmi.common.RMILog#getActivationLog()
44: */
45: private static RMILog rLog = RMILog.getActivationLog();
46:
47: /**
48: * Factory method intended to obtain RmidMonitor implementation.
49: *
50: * @param className
51: * Fully qualified class name of the monitor.
52: *
53: * @return instance of the monitor class, <code>null</code> - if class
54: * was not found.
55: * @see Rmid
56: * @see org.apache.harmony.rmi.common.RMIProperties#ACTIVATION_MONITOR_CLASS_NAME_PROP
57: * @see org.apache.harmony.rmi.common.RMIConstants#DEFAULT_ACTIVATION_MONITOR_CLASS_NAME
58: * @see org.apache.harmony.rmi.activation.RmidMonitorAdapter
59: */
60: static RmidMonitor getRmidMonitor(String className) {
61:
62: try {
63: final Class cl = Class.forName(className);
64: // rmi.log.36=RMID Monitor class = {0}
65: rLog.log(Rmid.commonDebugLevel, Messages.getString(
66: "rmi.log.36", cl)); //$NON-NLS-1$
67:
68: return (RmidMonitor) AccessController
69: .doPrivileged(new PrivilegedExceptionAction() {
70:
71: public Object run() throws Exception {
72: Constructor constructor = cl
73: .getConstructor(new Class[0]);
74:
75: return constructor
76: .newInstance(new Object[0]);
77: }
78: });
79: } catch (Exception e) {
80: return null;
81: }
82: }
83: }
|