Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBMETA-351 Missing parser support for replication-config and passivation-config #30

Merged
merged 1 commit into from Jan 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -194,6 +194,15 @@ public static JBossWebMetaData parse(XMLStreamReader reader) throws XMLStreamExc
}
servlets.add(JBossServletMetaDataParser.parse(reader));
break;
case MAX_ACTIVE_SESSIONS:
wmd.setMaxActiveSessions(Integer.valueOf(getElementText(reader)));
break;
case REPLICATION_CONFIG:
wmd.setReplicationConfig(ReplicationConfigParser.parse(reader));
break;
case PASSIVATION_CONFIG:
wmd.setPassivationConfig(PassivationConfigParser.parse(reader));
break;
default: throw unexpectedElement(reader);
}
}
Expand Down
@@ -0,0 +1,61 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 (at your option) any later version.
*
* This software 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 software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.metadata.parser.jbossweb;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.metadata.parser.util.MetaDataElementParser;
import org.jboss.metadata.web.jboss.PassivationConfig;

/**
* @author paul
*
*/
public class PassivationConfigParser extends MetaDataElementParser {
public static PassivationConfig parse(XMLStreamReader reader) throws XMLStreamException {
PassivationConfig config = new PassivationConfig();
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case USE_SESSION_PASSIVATION: {
config.setUseSessionPassivation(Boolean.valueOf(getElementText(reader)));
break;
}
case PASSIVATION_MIN_IDLE_TIME: {
config.setPassivationMinIdleTime(Integer.valueOf(getElementText(reader)));
break;
}
case PASSIVATION_MAX_IDLE_TIME: {
config.setPassivationMaxIdleTime(Integer.valueOf(getElementText(reader)));
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
return config;
}
}
@@ -0,0 +1,92 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This 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 (at your option) any later version.
*
* This software 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 software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.metadata.parser.jbossweb;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.jboss.metadata.parser.util.MetaDataElementParser;
import org.jboss.metadata.web.jboss.ReplicationConfig;
import org.jboss.metadata.web.jboss.ReplicationGranularity;
import org.jboss.metadata.web.jboss.ReplicationMode;
import org.jboss.metadata.web.jboss.ReplicationTrigger;
import org.jboss.metadata.web.jboss.SnapshotMode;

/**
* @author Paul Ferraro
*/
public class ReplicationConfigParser extends MetaDataElementParser {
public static ReplicationConfig parse(XMLStreamReader reader) throws XMLStreamException {
ReplicationConfig config = new ReplicationConfig();
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case CACHE_NAME: {
config.setCacheName(getElementText(reader));
break;
}
case REPLICATION_TRIGGER: {
config.setReplicationTrigger(ReplicationTrigger.valueOf(getElementText(reader)));
break;
}
case REPLICATION_GRANULARITY: {
config.setReplicationGranularity(ReplicationGranularity.valueOf(getElementText(reader)));
break;
}
case REPLICATION_MODE: {
config.setReplicationMode(ReplicationMode.valueOf(getElementText(reader)));
break;
}
case BACKUPS: {
config.setBackups(Integer.valueOf(getElementText(reader)));
break;
}
case USE_JK: {
config.setUseJK(Boolean.valueOf(getElementText(reader)));
break;
}
case MAX_UNREPLICATED_INTERVAL: {
config.setMaxUnreplicatedInterval(Integer.valueOf(getElementText(reader)));
break;
}
case SNAPSHOT_MODE: {
config.setSnapshotMode(SnapshotMode.valueOf(getElementText(reader)));
break;
}
case SNAPSHOT_INTERVAL: {
config.setSnapshotInterval(Integer.valueOf(getElementText(reader)));
break;
}
case SESSION_NOTIFICATION_POLICY: {
config.setSessionNotificationPolicy(getElementText(reader));
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
return config;
}
}
Expand Up @@ -38,9 +38,7 @@ public class JBossWeb60UnitTestCase extends AbstractJavaEEEverythingTest
{
public void testClustering() throws Exception
{
System.out.println("JBossWeb60UnitTestCase.java skipped");
}
/*
// System.out.println("JBossWeb60UnitTestCase.java skipped");
JBossWebMetaData jbossWeb = JBossWebMetaDataParser.parse(getReader());
ReplicationConfig replConfig = jbossWeb.getReplicationConfig();
assertNotNull(replConfig);
Expand Down Expand Up @@ -73,5 +71,4 @@ public void testClustering() throws Exception
assertNotNull(passConfig.getPassivationMaxIdleTime());
assertEquals(5, passConfig.getPassivationMaxIdleTime().intValue());
}
*/
}