org.ow2.carol.cmi.info.ClusteredObjectInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cmi-api Show documentation
Show all versions of cmi-api Show documentation
API used/provided by CMI.
/**
* CMI : Cluster Method Invocation
* Copyright (C) 2007,2008 Bull S.A.S.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* --------------------------------------------------------------------------
* $Id:ClusteredBeanInfo.java 914 2007-05-25 16:48:16Z loris $
* --------------------------------------------------------------------------
*/
package org.ow2.carol.cmi.info;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.ejb.EJBObject;
import org.ow2.carol.cmi.lb.policy.ILBPolicy;
import org.ow2.carol.cmi.lb.strategy.ILBStrategy;
import net.jcip.annotations.NotThreadSafe;
/**
* Contain informations on a clustered object.
* @author The new CMI team
* @see ClusteredObject
* @see CMIInfoExtractor
*/
@NotThreadSafe
public final class ClusteredObjectInfo {
/**
* Name of the interface that the object implements.
* With ejb2 this is the home interface.
*/
private final Class> itfName;
/**
* Name of the business interface.
* Only for ejb2 support.
*/
private final Class extends EJBObject> businessName;
/**
* Name of the cluster where is deployed this object.
*/
private final String clusterName;
/**
* Type of LB policy to use to access at this object.
*/
@SuppressWarnings("unchecked")
private final Class extends ILBPolicy> policyType;
/**
* Type of LB strategy to use to access at this object.
* Can be null if no strategy is used.
*/
@SuppressWarnings("unchecked")
private final Class extends ILBStrategy> strategyType;
/**
* Minimal size for the pool of CMIReferenceable.
*/
private final int minPoolSize;
/**
* Maximal size for the pool of CMIReferenceable.
*/
private final int maxPoolSize;
/**
* Properties of the policy.
* Values are casted.
* Null if the policy doesn't support properties.
*/
private final Map properties;
/**
* True if this object has a state.
*/
private final boolean stateful;
/**
* True if the state of this object is replicated for high-availability.
*/
private final boolean replicated;
/**
* Classnames of the application exceptions.
*/
private final Set applicationExceptionNames;
/**
* Constructs informations for a clustered object with the default strategy for the given LB policy.
* @param itfName a name of interface that the object implements
* @param businessName the name of the business interface (only for ejb2)
* @param clusterName a name of cluster
* @param minPoolSize a minimal size for the pool of CMIReferenceable
* @param maxPoolSize a maximal size for the pool of CMIReferenceable
* @param policyType a type of policy for load-balancing
* @param strategyType a type of strategy for load-balancing
* @param properties properties of the policy
* @param stateful true if this object has a state
* @param replicated true if the state of this object is replicated for high-availability
* @param applicationExceptionNames classnames of the application exceptions
*/
@SuppressWarnings("unchecked")
public ClusteredObjectInfo(
final Class> itfName, final Class extends EJBObject> businessName,
final String clusterName, final int minPoolSize, final int maxPoolSize,
final Class extends ILBPolicy> policyType,
final Class extends ILBStrategy> strategyType,
final Map properties,
final boolean stateful,
final boolean replicated,
final Set applicationExceptionNames) {
this.itfName = itfName;
this.businessName = businessName;
this.clusterName = clusterName;
this.policyType = policyType;
this.strategyType = strategyType;
this.minPoolSize = minPoolSize;
this.maxPoolSize = maxPoolSize;
this.properties = properties;
this.stateful = stateful;
this.replicated = replicated;
if(applicationExceptionNames == null) {
this.applicationExceptionNames = new HashSet();
} else {
this.applicationExceptionNames = new HashSet(applicationExceptionNames);
}
}
/**
* @return a name of the cluster where is deployed this object
*/
public String getClusterName() {
return clusterName;
}
/**
* @return Name of the interface that the object implements.
*/
public Class> getItfClass() {
return itfName;
}
/**
* @return the lbPolicyType
*/
@SuppressWarnings("unchecked")
public Class extends ILBPolicy> getPolicyType() {
return policyType;
}
/**
* @return the lbStrategyType
*/
@SuppressWarnings("unchecked")
public Class extends ILBStrategy> getStrategyType() {
return strategyType;
}
/**
* @return the businessName
*/
public Class extends EJBObject> getBusinessClass() {
return businessName;
}
/**
* @return the lbProperties
*/
public Map getProperties() {
return properties;
}
/**
* @return the maximal size for the pool of CMIReferenceable
*/
public int getMaxPoolSize() {
return maxPoolSize;
}
/**
* @return the minimal size for the pool of CMIReferenceable
*/
public int getMinPoolSize() {
return minPoolSize;
}
/**
* Return true if this object has a state
*/
public boolean hasState() {
return stateful;
}
/**
* @return true if the state of this object is replicated for high-availability
*/
public boolean isReplicated() {
return replicated;
}
/**
* @return classnames of the application exceptions
*/
public Set getApplicationExceptionNames() {
return applicationExceptionNames;
}
@Override
public String toString() {
return "ClusteredObject[itfName:" + itfName
+ ",buisnessName:" + businessName
+ ",clusterName:" + clusterName
+ ",isStateful:" + stateful
+ ",policyType:" + policyType
+ ",strategyType:" + strategyType
+ ",properties:" + properties
+ ",hasState:" + stateful
+ ",replicated:" + replicated
+ "]";
}
}