01: /*
02: * $Id: UnsupportedProtocolException.java,v 1.20 2007/03/16 09:54:59 agoubard Exp $
03: *
04: * Copyright 2003-2007 Orange Nederland Breedband B.V.
05: * See the COPYRIGHT file for redistribution and use restrictions.
06: */
07: package org.xins.common.service;
08:
09: import org.xins.common.MandatoryArgumentChecker;
10:
11: /**
12: * Exception that indicates that protocol specified in a
13: * <code>TargetDescriptor</code> is not supported by a service caller.
14: *
15: * @version $Revision: 1.20 $ $Date: 2007/03/16 09:54:59 $
16: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
17: *
18: * @since XINS 1.1.0
19: *
20: * @see TargetDescriptor
21: * @see ServiceCaller
22: */
23: public final class UnsupportedProtocolException extends
24: RuntimeException {
25:
26: /**
27: * Serial version UID. Used for serialization. The assigned value is for
28: * compatibility with XINS 1.2.5.
29: */
30: private static final long serialVersionUID = 2847976540646154938L;
31:
32: /**
33: * The target descriptor that has an unsupported protocol. Cannot be
34: * <code>null</code>.
35: */
36: private final TargetDescriptor _target;
37:
38: /**
39: * Constructs a new <code>UnsupportedProtocolException</code> for the
40: * specified target descriptor.
41: *
42: * @param target
43: * the {@link TargetDescriptor} that has an unsupported protocol, cannot
44: * be <code>null</code>.
45: *
46: * @throws IllegalArgumentException
47: * if <code>target == null</code>.
48: */
49: public UnsupportedProtocolException(TargetDescriptor target)
50: throws IllegalArgumentException {
51:
52: super (createMessage(target));
53:
54: // Store
55: _target = target;
56: }
57:
58: /**
59: * Creates the message for the constructor to pass up to the
60: * superconstructor.
61: *
62: * @param target
63: * the {@link TargetDescriptor} that has an unsupported protocol, cannot
64: * be <code>null</code>.
65: *
66: * @return
67: * the created message, never <code>null</code>.
68: *
69: * @throws IllegalArgumentException
70: * if <code>target == null</code>.
71: */
72: private static String createMessage(TargetDescriptor target)
73: throws IllegalArgumentException {
74:
75: // Check preconditions
76: MandatoryArgumentChecker.check("target", target);
77:
78: return "Unsupported protocol \"" + target.getProtocol() + "\".";
79: }
80:
81: /**
82: * Returns the target descriptor that has an unsupported protocol.
83: *
84: * @return
85: * the {@link TargetDescriptor}, never <code>null</code>.
86: */
87: public TargetDescriptor getTargetDescriptor() {
88: return _target;
89: }
90: }
|