Method from org.apache.geronimo.jetty6.cluster.wadi.builder.WADIJettyClusteringBuilder Detail: |
protected void addAbstractNameQueries(Set<AbstractNameQuery> patterns,
GerPatternType[] patternTypes) {
for (GerPatternType patternType : patternTypes) {
AbstractNameQuery query = ENCConfigBuilder.buildAbstractNameQuery(patternType, null, null, null);
patterns.add(query);
}
}
|
protected AbstractName addPreHandlerFactory(DeploymentContext moduleContext,
GBeanData webModuleData,
AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
"WADIClusteredPreHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
GBeanData beanData = new GBeanData(name, WADIClusteredPreHandlerFactory.class);
beanData.setReferencePattern(WADIClusteredPreHandlerFactory.GBEAN_REF_WADI_SESSION_MANAGER, sessionManagerName);
webModuleData.setReferencePattern(JettyWebAppContext.GBEAN_REF_PRE_HANDLER_FACTORY, name);
moduleContext.addGBean(beanData);
return name;
}
|
protected AbstractName addSessionHandlerFactory(DeploymentContext moduleContext,
GBeanData webModuleData,
AbstractName sessionManagerName) throws GBeanAlreadyExistsException {
AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
"ClusteredSessionHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
GBeanData beanData = new GBeanData(name, ClusteredSessionHandlerFactory.class);
beanData.setReferencePattern(ClusteredSessionHandlerFactory.GBEAN_REF_SESSION_MANAGER, sessionManagerName);
webModuleData.setReferencePattern(JettyWebAppContext.GBEAN_REF_SESSION_HANDLER_FACTORY, name);
moduleContext.addGBean(beanData);
return name;
}
|
protected AbstractName addSessionManager(GerClusteringWadiType clustering,
GBeanData webModuleData,
DeploymentContext moduleContext) throws GBeanAlreadyExistsException {
AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(),
"WADISessionManager", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
GBeanData beanData = new GBeanData(name, BasicWADISessionManager.class);
setConfigInfo(clustering, webModuleData, beanData);
setCluster(clustering, beanData);
setBackingStrategyFactory(clustering, beanData);
moduleContext.addGBean(beanData);
return name;
}
|
public void build(XmlObject container,
DeploymentContext applicationContext,
DeploymentContext moduleContext) throws DeploymentException {
GerClusteringWadiType clusteringWadiType = getWadiClusterConfig(container);
if (clusteringWadiType != null) {
GBeanData webModuleData = extractWebModule(moduleContext);
try {
AbstractName sessionManagerName = addSessionManager(clusteringWadiType, webModuleData, moduleContext);
addSessionHandlerFactory(moduleContext, webModuleData, sessionManagerName);
addPreHandlerFactory(moduleContext, webModuleData, sessionManagerName);
} catch (GBeanAlreadyExistsException e) {
throw new DeploymentException("Duplicate GBean", e);
}
}
}
|
public void buildEnvironment(XmlObject container,
Environment environment) throws DeploymentException {
if (getWadiClusterConfig(container) != null) {
EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
}
}
|
protected AbstractNameQuery createJettyWebAppContextNameQuery(DeploymentContext moduleContext) {
String name = moduleContext.getModuleName().getNameProperty(Jsr77Naming.J2EE_NAME);
return new AbstractNameQuery(null,
Collections.singletonMap(Jsr77Naming.J2EE_NAME, name),
Collections.singleton(JettyWebAppContext.class.getName()));
}
|
protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException {
AbstractNameQuery webModuleQuery = createJettyWebAppContextNameQuery(moduleContext);
Configuration configuration = moduleContext.getConfiguration();
try {
return configuration.findGBeanData(webModuleQuery);
} catch (GBeanNotFoundException e) {
throw new DeploymentException("Could not locate web module gbean in web app configuration", e);
}
}
|
public QName getBaseQName() {
return BASE_CLUSTERING_QNAME;
}
|
protected int getNumberOfPartitions(GerClusteringWadiType clustering) {
if (clustering.isSetNumPartitions()) {
return clustering.getNumPartitions().intValue();
}
return defaultNumPartitions;
}
|
public QNameSet getPlanQNameSet() {
return CLUSTERING_WADI_QNAME_SET;
}
|
protected Integer getSessionTimeout(GBeanData webModuleData) throws AssertionError {
Integer sessionTimeout = (Integer) webModuleData.getAttribute(JettyWebAppContext.GBEAN_ATTR_SESSION_TIMEOUT);
if (null == sessionTimeout) {
throw new AssertionError();
}
return sessionTimeout;
}
|
public QNameSet getSpecQNameSet() {
return QNameSet.EMPTY;
}
|
protected int getSweepInterval(GerClusteringWadiType clustering) {
if (clustering.isSetSweepInterval()) {
return clustering.getSweepInterval().intValue();
}
return defaultSweepInterval;
}
|
protected GerClusteringWadiType 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 (GerClusteringWadiType) items[0].copy().changeType(GerClusteringWadiType.type);
}
return null;
}
|
protected boolean isDeltaReplication(GerClusteringWadiType clustering) {
if (clustering.isSetDeltaReplication()) {
return clustering.getDeltaReplication();
}
return false;
}
|
protected boolean isDisableReplication(GerClusteringWadiType clustering) {
if (clustering.isSetDisableReplication()) {
return clustering.getDisableReplication();
}
return false;
}
|
protected void setBackingStrategyFactory(GerClusteringWadiType clustering,
GBeanData beanData) {
Set< AbstractNameQuery > patterns = new HashSet< AbstractNameQuery >();
if (clustering.isSetBackingStrategyFactory()) {
addAbstractNameQueries(patterns, clustering.getBackingStrategyFactory().getPatternArray());
} else {
patterns.add(defaultBackingStrategyFactoryName);
}
beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_BACKING_STRATEGY_FACTORY, patterns);
}
|
protected void setCluster(GerClusteringWadiType clustering,
GBeanData beanData) {
Set< AbstractNameQuery > patterns = new HashSet< AbstractNameQuery >();
if (clustering.isSetCluster()) {
addAbstractNameQueries(patterns, clustering.getCluster().getPatternArray());
} else {
patterns.add(defaultClusterName);
}
beanData.setReferencePatterns(BasicWADISessionManager.GBEAN_REF_CLUSTER, patterns);
}
|
protected void setConfigInfo(GerClusteringWadiType clustering,
GBeanData webModuleData,
GBeanData beanData) {
int sweepInterval = getSweepInterval(clustering);
int numPartitions = getNumberOfPartitions(clustering);
Integer sessionTimeout = getSessionTimeout(webModuleData);
boolean disableReplication = isDisableReplication(clustering);
boolean deltaReplication = isDeltaReplication(clustering);
String contextPath = (String) webModuleData.getAttribute("contextPath");
URI serviceSpaceName;
try {
serviceSpaceName = new URI(contextPath);
} catch (URISyntaxException e) {
throw (AssertionError) new AssertionError("contextPath [" + contextPath + "] cannot be parsed as an URI.").initCause(e);
}
WADISessionManagerConfigInfo configInfo = new WADISessionManagerConfigInfo(serviceSpaceName,
sweepInterval,
numPartitions,
sessionTimeout,
disableReplication,
deltaReplication);
beanData.setAttribute(BasicWADISessionManager.GBEAN_ATTR_WADI_CONFIG_INFO, configInfo);
}
|