Method from org.apache.geronimo.openejb.deployment.cluster.WADIOpenEJBClusteringBuilder Detail: |
protected void addAbstractNameQueries(Set<AbstractNameQuery> patterns,
GerPatternType patternType) {
AbstractNameQuery query = ENCConfigBuilder.buildAbstractNameQuery(patternType, null, null, null);
patterns.add(query);
}
|
protected void addGBean(DeploymentContext moduleContext,
GBeanData beanData) throws DeploymentException {
try {
moduleContext.addGBean(beanData);
} catch (GBeanAlreadyExistsException e) {
throw new DeploymentException(e);
}
}
|
public void addGBeans(EARContext earContext,
Module module,
ClassLoader cl,
Collection repository) throws DeploymentException {
EjbModule ejbModule = (EjbModule) module;
OpenejbGeronimoEjbJarType geronimoEjbJarType = ejbModule.getVendorDD();
GerOpenejbClusteringWadiType clusteringWadiType = getWadiClusterConfig(geronimoEjbJarType);
if (clusteringWadiType != null) {
AbstractName sessionManagerName = addSessionManager(clusteringWadiType, ejbModule, earContext);
addNetworkConnectorMonitor(earContext, sessionManagerName);
EjbJar ejbJar = ejbModule.getEjbJar();
for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
switch (sessionBean.getSessionType()) {
case STATEFUL:
replaceByClusteredDeploymentGBean(earContext,
ejbModule,
sessionManagerName,
enterpriseBean);
}
}
}
}
}
|
protected void addNetworkConnectorMonitor(DeploymentContext moduleContext,
AbstractName sessionManagerName) throws DeploymentException {
AbstractName name = newGBeanName(moduleContext, "NetworkConnectorMonitor");
GBeanData networkConnectorMonitor = new GBeanData(name, NetworkConnectorMonitor.GBEAN_INFO);
networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_NETWORK_CONNECTORS,
defaultNetworkConnectorName);
networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_EJB_DEP_ID_ACCESSOR,
new AbstractNameQuery(ClusteredStatefulDeployment.class.getName()));
networkConnectorMonitor.setReferencePattern(NetworkConnectorMonitor.GBEAN_REF_WADI_SESSION_MANAGER,
sessionManagerName);
addGBean(moduleContext, networkConnectorMonitor);
}
|
protected AbstractName addSessionManager(GerOpenejbClusteringWadiType clustering,
EjbModule ejbModule,
DeploymentContext moduleContext) throws DeploymentException {
AbstractName name = newGBeanName(moduleContext, "WADISessionManager");
GBeanData beanData = new GBeanData(name, BasicWADISessionManager.class);
setConfigInfo(clustering, ejbModule, beanData);
setCluster(clustering, beanData);
setBackingStrategyFactory(clustering, beanData);
setClusteredServiceHolders(moduleContext, beanData);
addGBean(moduleContext, beanData);
return name;
}
|
public void createModule(Module module,
Object plan,
JarFile moduleFile,
String targetPath,
URL specDDUrl,
Environment environment,
Object moduleContextInfo,
AbstractName earName,
Naming naming,
ModuleIDBuilder idBuilder) throws DeploymentException {
EjbModule ejbModule = (EjbModule) module;
GeronimoEjbJarType tmpGeronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getEjbModule().getAltDDs().get("geronimo-openejb.xml");
OpenejbGeronimoEjbJarType geronimoEjbJarType = XmlUtil.convertToXmlbeans(tmpGeronimoEjbJarType);
GerOpenejbClusteringWadiType clusteringWadiType = getWadiClusterConfig(geronimoEjbJarType);
if (null == clusteringWadiType) {
return;
}
EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
ejbModule.getPreAutoConfigDeployer().add(new MapSFSBToContainerIDDeployer(defaultClusteredStatefulContainerId));
}
|
public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
|
protected int getNumberOfPartitions(GerOpenejbClusteringWadiType clustering) {
if (clustering.isSetNumPartitions()) {
return clustering.getNumPartitions().intValue();
}
return defaultNumPartitions;
}
|
protected Integer getSessionTimeout() throws AssertionError {
return defaultSessionTimeout;
}
|
protected int getSweepInterval(GerOpenejbClusteringWadiType clustering) {
if (clustering.isSetSweepInterval()) {
return clustering.getSweepInterval().intValue();
}
return defaultSweepInterval;
}
|
protected GerOpenejbClusteringWadiType getWadiClusterConfig(XmlObject container) throws DeploymentException {
XmlObject[] items = container.selectChildren(CLUSTERING_WADI_QNAME_SET);
if (items.length > 1) {
throw new DeploymentException("Unexpected count of clustering elements in geronimo plan " + items.length
+ " qnameset: " + CLUSTERING_WADI_QNAME_SET);
}
if (items.length == 1) {
return (GerOpenejbClusteringWadiType) items[0].copy().changeType(GerOpenejbClusteringWadiType.type);
}
return null;
}
|
public void initContext(EARContext earContext,
Module module,
ClassLoader cl) throws DeploymentException {
}
|
public void installModule(JarFile earFile,
EARContext earContext,
Module module,
Collection configurationStores,
ConfigurationStore targetConfigurationStore,
Collection repository) throws DeploymentException {
}
|
protected boolean isDeltaReplication(GerOpenejbClusteringWadiType clustering) {
if (clustering.isSetDeltaReplication()) {
return clustering.getDeltaReplication();
}
return false;
}
|
protected boolean isDisableReplication(GerOpenejbClusteringWadiType clustering) {
if (clustering.isSetDisableReplication()) {
return clustering.getDisableReplication();
}
return false;
}
|
protected AbstractName newGBeanName(DeploymentContext moduleContext,
String name) {
return moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
name,
GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
}
|
protected void replaceByClusteredDeploymentGBean(EARContext earContext,
EjbModule ejbModule,
AbstractName sessionManagerName,
EnterpriseBean enterpriseBean) throws DeploymentException {
AbstractName name = beanNameBuilder.createEjbName(earContext, ejbModule, enterpriseBean);
GBeanData beanInstance;
try {
beanInstance = earContext.getGBeanInstance(name);
earContext.removeGBean(name);
} catch (GBeanNotFoundException e) {
throw new DeploymentException("No GBean [" + name + "]", e);
}
GBeanData clusteredDeploymentGBean = new GBeanData(beanInstance);
clusteredDeploymentGBean.setGBeanInfo(ClusteredStatefulDeployment.GBEAN_INFO);
clusteredDeploymentGBean.setReferencePattern(ClusteredStatefulDeployment.GBEAN_REF_SESSION_MANAGER, sessionManagerName);
try {
earContext.addGBean(clusteredDeploymentGBean);
} catch (GBeanAlreadyExistsException e) {
throw new DeploymentException("See nested", e);
}
}
|
protected void setBackingStrategyFactory(GerOpenejbClusteringWadiType clustering,
GBeanData beanData) {
Set< AbstractNameQuery > patterns = new HashSet< AbstractNameQuery >();
if (clustering.isSetBackingStrategyFactory()) {
addAbstractNameQueries(patterns, clustering.getBackingStrategyFactory());
} else {
patterns.add(defaultBackingStrategyFactoryName);
}
beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY, patterns);
}
|
protected void setCluster(GerOpenejbClusteringWadiType clustering,
GBeanData beanData) {
Set< AbstractNameQuery > patterns = new HashSet< AbstractNameQuery >();
if (clustering.isSetCluster()) {
addAbstractNameQueries(patterns, clustering.getCluster());
} else {
patterns.add(defaultClusterName);
}
beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_CLUSTER, patterns);
}
|
protected void setClusteredServiceHolders(DeploymentContext moduleContext,
GBeanData beanData) throws DeploymentException {
AbstractName name = newGBeanName(moduleContext, "NetworkConnectorTrackerHolder");
GBeanData serviceHolder = new GBeanData(name, BasicNetworkConnectorTrackerServiceHolder.GBEAN_INFO);
addGBean(moduleContext, serviceHolder);
beanData.setReferencePattern(BasicWADISessionManager.GBEAN_REF_SERVICE_HOLDERS, name);
}
|
protected void setConfigInfo(GerOpenejbClusteringWadiType clustering,
EjbModule ejbModule,
GBeanData beanData) {
int sweepInterval = getSweepInterval(clustering);
int numPartitions = getNumberOfPartitions(clustering);
Integer sessionTimeout = getSessionTimeout();
boolean disableReplication = isDisableReplication(clustering);
boolean deltaReplication = isDeltaReplication(clustering);
String ejbModuleName = ejbModule.getName();
URI serviceSpaceName;
try {
serviceSpaceName = new URI(ejbModuleName);
} catch (URISyntaxException e) {
AssertionError error = new AssertionError("contextPath [" + ejbModuleName + "] cannot be parsed as an URI.");
throw (AssertionError) error.initCause(e);
}
WADISessionManagerConfigInfo configInfo = new WADISessionManagerConfigInfo(serviceSpaceName,
sweepInterval,
numPartitions,
sessionTimeout,
disableReplication,
deltaReplication);
beanData.setAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO, configInfo);
}
|