KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > common > datagram > DatagramFactoryHolder


1 package com.ubermq.jms.common.datagram;
2
3 import com.ubermq.kernel.IDatagramFactory;
4
5 /**
6  * Holds all the datagram factories necessary for normal
7  * operation, as a convenience, and to grow to support new
8  * additions.
9  */

10 public final class DatagramFactoryHolder
11     implements java.io.Serializable JavaDoc
12 {
13     private final IDatagramFactory f;
14     private final IAckDatagramFactory adf;
15     private final IControlDatagramFactory cdf;
16     private final IMessageDatagramFactory mdf;
17
18     public static final long serialVersionUID = 1l;
19
20     /**
21      * Constructs a factory holder with the given
22      * implementations.
23      *
24      * @param f an implementation of IDatagramFactory
25      * @param adf an IAckDatagramFactory
26      * @param cdf an IControlDatagramFactory
27      * @param mdf an IMessageDatagramFactory
28      */

29     public DatagramFactoryHolder(IDatagramFactory f,
30                                  IAckDatagramFactory adf,
31                                  IControlDatagramFactory cdf,
32                                  IMessageDatagramFactory mdf)
33     {
34         this.f = f;
35         this.adf = adf;
36         this.cdf = cdf;
37         this.mdf = mdf;
38     }
39
40     /**
41      * Constructs a factory holder with a datagram factory
42      * and an object that implements the other three
43      * datagram factories.
44      *
45      * @param f an implementation of IDatagramFactory
46      * @param o an object implementing IAckDatagramFactory,
47      * IControlDatagramFactory and IMessageDatagramFactory
48      */

49     public DatagramFactoryHolder(IDatagramFactory f,
50                                  Object JavaDoc o)
51     {
52         this.f = f;
53         this.adf = (IAckDatagramFactory)o;
54         this.cdf = (IControlDatagramFactory)o;
55         this.mdf = (IMessageDatagramFactory)o;
56     }
57
58     /**
59      * Constructs a factory holder with an object that
60      * implements all of the datagram factory interfaces.
61      *
62      * @param o an object implementing IDatagramFactory,
63      * IAckDatagramFactory, IControlDatagramFactory and
64      * IMessageDatagramFactory
65      */

66     public DatagramFactoryHolder(Object JavaDoc o)
67     {
68         this.f = (IDatagramFactory)o;
69         this.adf = (IAckDatagramFactory)o;
70         this.cdf = (IControlDatagramFactory)o;
71         this.mdf = (IMessageDatagramFactory)o;
72     }
73
74     public IDatagramFactory datagramFactory() {return f;}
75     public IAckDatagramFactory ackFactory() {return adf;}
76     public IControlDatagramFactory controlFactory() {return cdf;}
77     public IMessageDatagramFactory messageFactory() {return mdf;}
78 }
79
Popular Tags