KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > framework > interfaces > ClusteringTargetsRepository


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ha.framework.interfaces;
23
24 import java.util.Hashtable JavaDoc;
25 import java.util.List JavaDoc;
26
27 /**
28  * JVM singleton that associates a list of targets (+ other info)
29  * contained in a FamilyClusterInfo to a proxy family. For example
30  * All remote proxies for a given EJB in a given cluster are part of the
31  * same proxy family. Note that home and remote for a same EJB form *2*
32  * proxy families.
33  *
34  * @see org.jboss.ha.framework.interfaces.FamilyClusterInfo
35  * @see org.jboss.ha.framework.interfaces.FamilyClusterInfoImpl
36  *
37  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>.
38  * @version $Revision: 56227 $
39  *
40  * <p><b>Revisions:</b>
41  *
42  * <p><b>2002/08/23, Sacha Labourey:</b>
43  * <ul>
44  * <li> First implementation </li>
45  * </ul>
46  */

47
48 public class ClusteringTargetsRepository
49 {
50    // Constants -----------------------------------------------------
51

52    // Attributes ----------------------------------------------------
53

54    protected static Hashtable JavaDoc families = new Hashtable JavaDoc ();
55    
56    // Static --------------------------------------------------------
57

58    public synchronized static FamilyClusterInfo initTarget (String JavaDoc familyName, List JavaDoc targets)
59    {
60       return initTarget (familyName, targets, 0L);
61    }
62    
63    public synchronized static FamilyClusterInfo initTarget (String JavaDoc familyName, List JavaDoc targets, long viewId)
64    {
65       // this method must be somehow synchronized to avoid multiple FamilyClusterInfoImpl
66
// for the same familyName in multi-threaded app accessing the same bean
67
//
68
FamilyClusterInfoImpl family = (FamilyClusterInfoImpl)families.get (familyName);
69       if (family == null)
70       {
71          family = new FamilyClusterInfoImpl (familyName, targets, viewId);
72          families.put (familyName, family);
73       }
74       else
75       {
76          // no need to initialize: it is already done: we keep the same object
77
//
78
family.updateClusterInfo (targets, viewId); // should not happen: possible if redeploy after undeploy fails
79
}
80          
81       return family;
82          
83    }
84    
85    public static FamilyClusterInfo getFamilyClusterInfo (String JavaDoc familyName)
86    {
87       return (FamilyClusterInfo)families.get (familyName);
88    }
89    
90    // Constructors --------------------------------------------------
91

92    private ClusteringTargetsRepository () {}
93    
94    // Public --------------------------------------------------------
95

96    // Z implementation ----------------------------------------------
97

98    // Y overrides ---------------------------------------------------
99

100    // Package protected ---------------------------------------------
101

102    // Protected -----------------------------------------------------
103

104    // Private -------------------------------------------------------
105

106    // Inner classes -------------------------------------------------
107

108 }
109
Popular Tags