01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1999-2004 Gerald Brose
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library 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: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: *
20: */
21: package org.jacorb.orb.policies;
22:
23: import org.omg.CORBA.*;
24: import org.omg.Messaging.*;
25:
26: /**
27: * Specifies a relative timeout for a CORBA roundtrip. It is an upper bound
28: * for the time it may take for a request to reach the server, be processed,
29: * and the reply delivered back to the client.
30: *
31: * @author Andre Spiegel spiegel@gnu.org
32: * @version $Id: RelativeRoundtripTimeoutPolicy.java,v 1.7 2007/02/14 09:49:53 andre.spiegel Exp $
33: */
34: public class RelativeRoundtripTimeoutPolicy extends
35: _RelativeRoundtripTimeoutPolicyLocalBase {
36: /**
37: * The length of this timeout, in CORBA time units
38: * (100 nanosecond resolution).
39: */
40: private final long relative_expiry;
41:
42: /**
43: * Constructs a new RelativeRoundtripTimeoutPolicy object from
44: * an Any value. This is the official CORBA way of constructing
45: * this policy (via orb.create_policy()), but JacORB also has a
46: * convenience constructor that directly takes the timeout value
47: * as a parameter.
48: *
49: * @param value an Any that contains the timeout as a CORBA
50: * "unsigned long long" value (use Any.insert_ulonglong()).
51: * The timeout is specified in CORBA time units (100 nanosecond resolution).
52: * If you have a value in milliseconds, multiply that by 10,000.
53: */
54: public RelativeRoundtripTimeoutPolicy(org.omg.CORBA.Any value) {
55: super ();
56: this .relative_expiry = value.extract_ulonglong();
57: }
58:
59: /**
60: * Convenience constructor for RelativeRoundtripTimeoutPolicy. This
61: * constructor is JacORB-specific, non-portable, but it allows you to
62: * create a policy object in a single line of code, rather than going
63: * via the ORB and stuffing the timeout value into an Any.
64: * @param relative_expiry the duration of this timeout, in CORBA
65: * time units (100 nanosecond resolution). If you have a value in
66: * milliseconds, multiply that by 10,000.
67: */
68: public RelativeRoundtripTimeoutPolicy(long relative_expiry) {
69: super ();
70: this .relative_expiry = relative_expiry;
71: }
72:
73: /**
74: * Returns the duration of this timeout, in CORBA time units (100 nanosecond
75: * resolution). To convert it to milliseconds, divide by 10,000.
76: */
77: public long relative_expiry() {
78: return relative_expiry;
79: }
80:
81: public int policy_type() {
82: return RELATIVE_RT_TIMEOUT_POLICY_TYPE.value;
83: }
84:
85: public Policy copy() {
86: return this ;
87: }
88:
89: public void destroy() {
90: }
91: }
|