You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kalumet-commits@incubator.apache.org by jb...@apache.org on 2011/10/22 13:10:04 UTC
svn commit: r1187711 [2/5] - in /incubator/kalumet/trunk: ./ common/
common/src/ common/src/main/ common/src/main/java/
common/src/main/java/org/ common/src/main/java/org/apache/
common/src/main/java/org/apache/kalumet/ common/src/main/java/org/apache/...
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Application.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Application.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Application.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Application.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,372 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>application</code> tag in the Kalumet DOM.
+ */
+public class Application implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -1198170476993837094L;
+
+ private String name;
+ private String uri;
+ private boolean active;
+ private boolean blocker;
+ private String agent;
+ private LinkedList archives;
+ private LinkedList contentManagers;
+ private LinkedList configurationFiles;
+ private LinkedList databases;
+
+ /**
+ * Default constructor to create a <code>Application</code>
+ */
+ public Application() {
+ this.archives = new LinkedList();
+ this.contentManagers = new LinkedList();
+ this.configurationFiles = new LinkedList();
+ this.databases = new LinkedList();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ /**
+ * Add a new <code>Archive</code> in the <code>Application</code> archives container.
+ *
+ * @param archive the <code>Archive</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the archive name already exists in the application.
+ */
+ public void addArchive(Archive archive) throws ModelObjectAlreadyExistsException {
+ if (this.getArchive(archive.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Archive name already exists in the JZEE application.");
+ }
+ this.archives.add(archive);
+ }
+
+ /**
+ * Get the <code>Archive</code> list in the <code>Application</code> archives container.
+ *
+ * @return the <code>Archive</code> list
+ */
+ public List getArchives() {
+ return this.archives;
+ }
+
+ /**
+ * Overwrite the <code>Archive</code> list in the <code>Application</code> archives container.
+ *
+ * @param archives the new <code>Archive</code> list.
+ */
+ public void setArchives(LinkedList archives) {
+ this.archives = archives;
+ }
+
+ /**
+ * Get the <code>Archive</code> identified by a given name in the <code>Application</code> archives container.
+ *
+ * @param name the <code>Archive</code> name.
+ * @return the <code>Archive</code> found or null if not found.
+ */
+ public Archive getArchive(String name) {
+ for (Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext();) {
+ Archive archive = (Archive) archiveIterator.next();
+ if (archive.getName().equals(name)) {
+ return archive;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>ContentManager</code> in the <code>Application</code> content managers container.
+ *
+ * @param contentManager the <code>ContentManager</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>ContentManager</code> already exists in the application.
+ */
+ public void addContentManager(ContentManager contentManager) throws ModelObjectAlreadyExistsException {
+ if (this.getContentManager(contentManager.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Content manager name already exists in the JZEE application.");
+ }
+ this.contentManagers.add(contentManager);
+ }
+
+ /**
+ * Get the <code>ContentManager</code> list in the <code>Application</code> content managers container.
+ *
+ * @return the <code>ContentManager</code> list.
+ */
+ public List getContentManagers() {
+ return this.contentManagers;
+ }
+
+ /**
+ * Overwrite the <code>ContentManager</code> list in the <code>Application</code> content managers container.
+ *
+ * @param contentManagers the new <code>ContentManagers</code> list.
+ */
+ public void setContentManagers(LinkedList contentManagers) {
+ this.contentManagers = contentManagers;
+ }
+
+ /**
+ * Return the <code>ContentManager</code> identified by a given name in the <code>Application</code> content managers container.
+ *
+ * @return the <code>ContentManager</code> found or null if not found.
+ */
+ public ContentManager getContentManager(String name) {
+ for (Iterator contentManagerIterator = this.getContentManagers().iterator(); contentManagerIterator.hasNext();) {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ if (contentManager.getName().equals(name)) {
+ return contentManager;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>ConfigurationFile</code> in the <code>Application</code>
+ * configuration files container.
+ *
+ * @param configurationFile the <code>ConfigurationFile</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>ConfigurationFile</code> name already exists in the application.
+ */
+ public void addConfigurationFile(ConfigurationFile configurationFile) throws ModelObjectAlreadyExistsException {
+ if (this.getConfigurationFile(configurationFile.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Configuration file name already exists in the JZEE application.");
+ }
+ this.configurationFiles.add(configurationFile);
+ }
+
+ /**
+ * Get the <code>ConfigurationFile</code> list in the
+ * <code>Application</code> configuration files container.
+ *
+ * @return the <code>ConfigurationFile</code> list.
+ */
+ public List getConfigurationFiles() {
+ return this.configurationFiles;
+ }
+
+ /**
+ * Overwrite the <code>ConfigurationFile</code> list in the
+ * <code>Application</code> configuration files container.
+ *
+ * @param configurationFiles the new <code>ConfigurationFile</code> list.
+ */
+ public void setConfigurationFiles(LinkedList configurationFiles) {
+ this.configurationFiles = configurationFiles;
+ }
+
+ /**
+ * Get the <code>ConfigurationFile</code> identified by a given name in the
+ * <code>Application</code> configuration files container.
+ *
+ * @param name the <code>ConfigurationFile</code> name.
+ * @return the <code>ConfigurationFile</code> found or null if not found.
+ */
+ public ConfigurationFile getConfigurationFile(String name) {
+ for (Iterator configurationFileIterator = this.getConfigurationFiles().iterator(); configurationFileIterator.hasNext();) {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ if (configurationFile.getName().equals(name)) {
+ return configurationFile;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>Database</code> in the <code>Application</code>
+ * databases container.
+ *
+ * @param database the <code>Database</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>Database</code> name already exists in the application.
+ */
+ public void addDatabase(Database database) throws ModelObjectAlreadyExistsException {
+ if (this.getDatabase(database.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Database name already exists in the J2EE application.");
+ }
+ this.databases.add(database);
+ }
+
+ /**
+ * Get the <code>Database</code> list in the <code>Application</code>
+ * databases container.
+ *
+ * @return the <code>Database</code> list.
+ */
+ public List getDatabases() {
+ return this.databases;
+ }
+
+ /**
+ * Overwrite the <code>Database</code> list in the <code>Application</code>
+ * databases container.
+ *
+ * @param databases the new <code>Database</code> list.
+ */
+ public void setDatabases(LinkedList databases) {
+ this.databases = databases;
+ }
+
+ /**
+ * Get the <code>Database</code> identified by a given name in the
+ * <code>Application</code> databases container.
+ *
+ * @param name the <code>Database</code> name.
+ * @return the <code>Database</code> found or null if not found.
+ */
+ public Database getDatabase(String name) {
+ for (Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext();) {
+ Database database = (Database) databaseIterator.next();
+ if (database.getName().equals(name)) {
+ return database;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Application clone = new Application();
+ clone.setName(this.getName());
+ clone.setUri(this.getUri());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setAgent(this.getAgent());
+ for (Iterator archiveIterator = this.archives.iterator(); archiveIterator.hasNext(); ) {
+ Archive archive = (Archive)archiveIterator.next();
+ clone.archives.add((Archive)archive.clone());
+ }
+ for (Iterator contentManagerIterator = this.contentManagers.iterator(); contentManagerIterator.hasNext(); ) {
+ ContentManager contentManager = (ContentManager)contentManagerIterator.next();
+ clone.contentManagers.add((ContentManager)contentManager.clone());
+ }
+ for (Iterator configurationFileIterator = this.configurationFiles.iterator(); configurationFileIterator.hasNext(); ) {
+ ConfigurationFile configurationFile = (ConfigurationFile)configurationFileIterator.next();
+ clone.configurationFiles.add((ConfigurationFile)configurationFile.clone());
+ }
+ for (Iterator databaseIterator = this.databases.iterator(); databaseIterator.hasNext(); ) {
+ Database database = (Database)databaseIterator.next();
+ clone.databases.add((Database)database.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Application</code> POJO to a DOM element.
+ *
+ * @param document the core DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "application");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("uri", this.getUri());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("agent", this.getAgent());
+ // archives
+ ElementImpl archives = new ElementImpl(document, "archives");
+ for (Iterator archiveIterator = this.getArchives().iterator(); archiveIterator.hasNext();) {
+ Archive archive = (Archive) archiveIterator.next();
+ archives.appendChild(archive.toDOMElement(document));
+ }
+ element.appendChild(archives);
+ // contentmanagers
+ ElementImpl contentmanagers = new ElementImpl(document, "contentmanagers");
+ for (Iterator contentManagerIterator = this.getContentManagers().iterator(); contentManagerIterator.hasNext();) {
+ ContentManager contentManager = (ContentManager) contentManagerIterator.next();
+ contentmanagers.appendChild(contentManager.toDOMElement(document));
+ }
+ element.appendChild(contentmanagers);
+ // configurationfiles
+ ElementImpl configurationfiles = new ElementImpl(document, "configurationfiles");
+ for (Iterator configurationFileIterator = this.getConfigurationFiles().iterator(); configurationFileIterator.hasNext();) {
+ ConfigurationFile configurationFile = (ConfigurationFile) configurationFileIterator.next();
+ configurationfiles.appendChild(configurationFile.toDOMElement(document));
+ }
+ element.appendChild(configurationfiles);
+ // databases
+ ElementImpl databases = new ElementImpl(document, "databases");
+ for (Iterator databaseIterator = this.getDatabases().iterator(); databaseIterator.hasNext();) {
+ Database database = (Database) databaseIterator.next();
+ databases.appendChild(database.toDOMElement(document));
+ }
+ element.appendChild(databases);
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherApplication) {
+ return this.getName().compareTo(((Application)anotherApplication).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServer.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServer.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServer.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServer.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,750 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CDATASectionImpl;
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>applicationserver</code> tag in the Kalumet DOM.
+ */
+public class ApplicationServer implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = 2272703476099937797L;
+
+ private String name;
+ private boolean active;
+ private boolean blocker;
+ private String classname;
+ private String jmxurl;
+ private String adminuser;
+ private String adminpassword;
+ private boolean updateRequireRestart;
+ private boolean updateRequireCacheCleaning;
+ private boolean usejmxstop;
+ private boolean deletecomponents;
+ private String startupcommand;
+ private String shutdowncommand;
+ private String agent;
+ private LinkedList connectionPools;
+ private LinkedList dataSources;
+ private LinkedList jmsConnectionFactories;
+ private LinkedList jmsServers;
+ private LinkedList nameSpaceBindings;
+ private LinkedList sharedLibraries;
+ private LinkedList applications;
+ private LinkedList caches;
+ private LinkedList logAccesses;
+
+ /**
+ * Default constructor to create a new <code>ApplicationServer</code>.
+ */
+ public ApplicationServer() {
+ this.connectionPools = new LinkedList();
+ this.dataSources = new LinkedList();
+ this.jmsConnectionFactories = new LinkedList();
+ this.jmsServers = new LinkedList();
+ this.nameSpaceBindings = new LinkedList();
+ this.sharedLibraries = new LinkedList();
+ this.applications = new LinkedList();
+ this.caches = new LinkedList();
+ this.logAccesses = new LinkedList();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public String getClassname() {
+ return this.classname;
+ }
+
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
+
+ public String getJmxurl() {
+ return this.jmxurl;
+ }
+
+ public void setJmxurl(String jmxurl) {
+ this.jmxurl = jmxurl;
+ }
+
+ public String getAdminuser() {
+ return this.adminuser;
+ }
+
+ public void setAdminuser(String adminuser) {
+ this.adminuser = adminuser;
+ }
+
+ public String getAdminpassword() {
+ return this.adminpassword;
+ }
+
+ public void setAdminpassword(String adminpassword) {
+ this.adminpassword = adminpassword;
+ }
+
+ public boolean getUpdateRequireRestart() {
+ return this.updateRequireRestart;
+ }
+
+ public void setUpdateRequireRestart(boolean updateRequireRestart) {
+ this.updateRequireRestart = updateRequireRestart;
+ }
+
+ public boolean isUpdateRequireCacheCleaning() {
+ return this.updateRequireCacheCleaning;
+ }
+
+ public void setUpdateRequireCacheCleaning(boolean updateRequireCacheCleaning) {
+ this.updateRequireCacheCleaning = updateRequireCacheCleaning;
+ }
+
+ public boolean isUsejmxstop() {
+ return this.usejmxstop;
+ }
+
+ public void setUsejmxstop(boolean usejmxstop) {
+ this.usejmxstop = usejmxstop;
+ }
+
+ public boolean isDeletecomponents() {
+ return this.deletecomponents;
+ }
+
+ public void setDeletecomponents(boolean deletecomponents) {
+ this.deletecomponents = deletecomponents;
+ }
+
+ public String getStartupcommand() {
+ return this.startupcommand;
+ }
+
+ public void setStartupcommand(String startupcommand) {
+ this.startupcommand = startupcommand;
+ }
+
+ public String getShutdowncommand() {
+ return this.shutdowncommand;
+ }
+
+ public void setShutdowncommand(String shutdowncommand) {
+ this.shutdowncommand = shutdowncommand;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ /**
+ * Add a new <code>ConnectionPool</code> in the
+ * <code>ApplicationServer</code> connection pools container.
+ *
+ * @param connectionPool the <code>ConnectionPool</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>ConnectionPool</code> name already exists in the application server.
+ */
+ public void addConnectionPool(ConnectionPool connectionPool) throws ModelObjectAlreadyExistsException {
+ if (this.getConnectionPool(connectionPool.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Connection pool name already exists in the JZEE server.");
+ }
+ this.connectionPools.add(connectionPool);
+ }
+
+ /**
+ * Get the <code>ConnectionPool</code> list in the
+ * <code>ApplicationServer</code> connection pools container.
+ *
+ * @return the <code>ConnectionPool</code> list.
+ */
+ public List getConnectionPools() {
+ return this.connectionPools;
+ }
+
+ /**
+ * Overwrite the <code>ConnectionPool</code> list in the
+ * <code>ApplicationServer</code> connection pools container.
+ *
+ * @param connectionPools the new <code>ConnectionPool</code> list.
+ */
+ public void setConnectionPools(LinkedList connectionPools) {
+ this.connectionPools = connectionPools;
+ }
+
+ /**
+ * Get the <code>ConnectionPool</code> identified by a given name in the
+ * <code>ApplicationServer</code> connection pools container.
+ *
+ * @param name the <code>ConnectionPool</code> name.
+ * @return the <code>ConnectionPool</code> found or null if not found.
+ */
+ public ConnectionPool getConnectionPool(String name) {
+ for (Iterator connectionPoolIterator = this.getConnectionPools().iterator(); connectionPoolIterator.hasNext();) {
+ ConnectionPool connectionPool = (ConnectionPool) connectionPoolIterator.next();
+ if (connectionPool.getName().equals(name)) {
+ return connectionPool;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>DataSource</code> in the <code>ApplicationServer</code>
+ * data sources container.
+ *
+ * @param dataSource the <code>DataSource</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>DataSource</code> name already exists in the application server.
+ */
+ public void addDataSource(DataSource dataSource) throws ModelObjectAlreadyExistsException {
+ if (this.getDataSource(dataSource.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Datasource name already exists in the JZEE server.");
+ }
+ this.dataSources.add(dataSource);
+ }
+
+ /**
+ * Get the <code>DataSource</code> list in the
+ * <code>ApplicationServer</code> data sources container.
+ *
+ * @return the <code>DataSource</code> list.
+ */
+ public List getDataSources() {
+ return this.dataSources;
+ }
+
+ /**
+ * Overwrite the <code>DataSource</code> list in the
+ * <code>ApplicationServer</code> data sources container.
+ *
+ * @param dataSources the new <code>DataSource</code> list.
+ */
+ public void setDataSources(LinkedList dataSources) {
+ this.dataSources = dataSources;
+ }
+
+ /**
+ * Get the <code>DataSource</code> identified by a given name in the
+ * <code>ApplicationServer</code> data sources container.
+ *
+ * @param name the <code>DataSource</code> name.
+ * @return the <code>DataSource</code> found or null if not found.
+ */
+ public DataSource getDataSource(String name) {
+ for (Iterator dataSourceIterator = this.getDataSources().iterator(); dataSourceIterator.hasNext();) {
+ DataSource dataSource = (DataSource) dataSourceIterator.next();
+ if (dataSource.getName().equals(name)) {
+ return dataSource;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Add a new <code>JMSConnectionFactory</code> in the
+ * <code>ApplicationServer</code> JMS connection factories container.
+ *
+ * @param jmsConnectionFactory the <code>JMSConnectionFactory</code> to add.
+ * @throws ModelObjectAlreadyExistsException
+ */
+ public void addJMSConnectionFactory(JMSConnectionFactory jmsConnectionFactory) throws ModelObjectAlreadyExistsException {
+ if (this.getJMSConnectionFactory(jmsConnectionFactory.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("JMS connection factory name already exists in the JZEE server.");
+ }
+ this.jmsConnectionFactories.add(jmsConnectionFactory);
+ }
+
+ /**
+ * Get the <code>JMSConnectionFactory</code> list in the
+ * <code>ApplicationServer</code> JMS connection factories container.
+ *
+ * @return the <code>JMSConnectionFactory</code> list.
+ */
+ public List getJMSConnectionFactories() {
+ return this.jmsConnectionFactories;
+ }
+
+ /**
+ * Overwrites the <code>JMSConnectionFactory</code> list in the
+ * <code>ApplicationServer</code> JMS connection factories container.
+ *
+ * @param jmsConnectionFactories the new <code>JMSConnectionFactory</code> list.
+ */
+ public void setJMSConnectionFactories(LinkedList jmsConnectionFactories) {
+ this.jmsConnectionFactories = jmsConnectionFactories;
+ }
+
+ /**
+ * Gets the <code>JMSConnectionFactory</code> identified by a given name in
+ * the <code>ApplicationServer</code> JMS connection factories container.
+ *
+ * @param name the <code>JMSConnectionFactory</code> name.
+ * @return the <code>JMSConnectionFactory</code> found or null if not found.
+ */
+ public JMSConnectionFactory getJMSConnectionFactory(String name) {
+ for (Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator(); jmsConnectionFactoryIterator.hasNext();) {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ if (jmsConnectionFactory.getName().equals(name)) {
+ return jmsConnectionFactory;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>JMSServer</code> in the <code>ApplicationServer</code>
+ * JMS servers container.
+ *
+ * @param jmsServer the <code>JMSServer</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>JMSServer</code> name already exists in the application server.
+ */
+ public void addJMSServer(JMSServer jmsServer) throws ModelObjectAlreadyExistsException {
+ if (this.getJMSServer(jmsServer.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("JMS server name already exists in the JZEE server.");
+ }
+ this.jmsServers.add(jmsServer);
+ }
+
+ /**
+ * Gets the <code>JMSServer</code> list in the <code>ApplicationServer</code>
+ * JMS servers container.
+ *
+ * @return the <code>JMSServer</code> list.
+ */
+ public List getJMSServers() {
+ return this.jmsServers;
+ }
+
+ /**
+ * Overwrites the <code>JMSServer</code> list in the
+ * <code>ApplicationServer</code> JMS servers container.
+ *
+ * @param jmsServers the new <code>JMSServer</code> list.
+ */
+ public void setJMSServers(LinkedList jmsServers) {
+ this.jmsServers = jmsServers;
+ }
+
+ /**
+ * Gets the <code>JMSServer</code> identified by a given name in the
+ * <code>ApplicationServer</code> JMS servers container.
+ *
+ * @param name the <code>JMSServer</code> name.
+ * @return the <code>JMSServer</code> found or null if not found.
+ */
+ public JMSServer getJMSServer(String name) {
+ for (Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext();) {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ if (jmsServer.getName().equals(name)) {
+ return jmsServer;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>NameSpaceBinding</code> in the
+ * <code>ApplicationServer</code> name space bindings container.
+ *
+ * @param nameSpaceBinding the <code>NameSpaceBinding</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>NameSpaceBinding</code> name already exists in the application server.
+ */
+ public void addNameSpaceBinding(NameSpaceBinding nameSpaceBinding) throws ModelObjectAlreadyExistsException {
+ if (this.getNameSpaceBinding(nameSpaceBinding.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Name space binding name already exists in the JZEE server.");
+ }
+ this.nameSpaceBindings.add(nameSpaceBinding);
+ }
+
+ /**
+ * Gets the <code>NameSpaceBinding</code> list in the
+ * <code>ApplicationServer</code> name space bindings container.
+ *
+ * @return the <code>NameSpaceBinding</code> list.
+ */
+ public List getNameSpaceBindings() {
+ return this.nameSpaceBindings;
+ }
+
+ /**
+ * Overwrites the <code>NameSpaceBinding</code> list in the
+ * <code>ApplicationServer</code> name space bindings container.
+ *
+ * @param nameSpaceBindings the new <code>NameSpaceBinding</code> list.
+ */
+ public void setNameSpaceBindings(LinkedList nameSpaceBindings) {
+ this.nameSpaceBindings = nameSpaceBindings;
+ }
+
+ /**
+ * Gets the <code>NameSpaceBinding</code> identified by a given name in the
+ * <code>ApplicationServer</code> name space bindings container.
+ *
+ * @param name the <code>NameSpaceBinding</code> name.
+ * @return the <code>NameSpaceBinding</code> found or null if not found.
+ */
+ public NameSpaceBinding getNameSpaceBinding(String name) {
+ for (Iterator nameSpaceBindingIterator = this.getNameSpaceBindings().iterator(); nameSpaceBindingIterator.hasNext();) {
+ NameSpaceBinding nameSpaceBinding = (NameSpaceBinding) nameSpaceBindingIterator.next();
+ if (nameSpaceBinding.getName().equals(name)) {
+ return nameSpaceBinding;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>SharedLibrary</code> in the
+ * <code>ApplicationServer</code> shared libraries container.
+ *
+ * @param sharedLibrary the <code>SharedLibrary</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>SharedLibrary</code> name already exists in the application server.
+ */
+ public void addSharedLibrary(SharedLibrary sharedLibrary) throws ModelObjectAlreadyExistsException {
+ if (this.getSharedLibrary(sharedLibrary.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Shared library name already exists in the JZEE server.");
+ }
+ this.sharedLibraries.add(sharedLibrary);
+ }
+
+ /**
+ * Gets the <code>SharedLibrary</code> list in the
+ * <code>ApplicationServer</code> shared libraries container.
+ *
+ * @return the <code>SharedLibrary</code> list.
+ */
+ public List getSharedLibraries() {
+ return this.sharedLibraries;
+ }
+
+ /**
+ * Overwrites the <code>SharedLibrary</code> list in the
+ * <code>ApplicationServer</code> shared libraries container.
+ *
+ * @param sharedLibraries the new <code>SharedLibrary</code> list.
+ */
+ public void setSharedLibraries(LinkedList sharedLibraries) {
+ this.sharedLibraries = sharedLibraries;
+ }
+
+ /**
+ * Gets the <code>SharedLibrary</code> identified by a given name in the
+ * <code>ApplicationServer</code> shared libraries container.
+ *
+ * @param name the <code>SharedLibrary</code> name.
+ * @return the <code>SharedLibrary</code> found or null if not found.
+ */
+ public SharedLibrary getSharedLibrary(String name) {
+ for (Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext();) {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ if (sharedLibrary.getName().equals(name)) {
+ return sharedLibrary;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>Application</code> in the <code>ApplicationServer</code>
+ * applications container.
+ *
+ * @param application the <code>Application</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>Application</code> name already exists in the application server.
+ */
+ public void addApplication(Application application) throws ModelObjectAlreadyExistsException {
+ if (this.getApplication(application.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("JZEE application name already exists in the JZEE server.");
+ }
+ this.applications.add(application);
+ }
+
+ /**
+ * Gets the <code>Application</code> list in the
+ * <code>ApplicationServer</code> applications container.
+ *
+ * @return the <code>Application</code> list.
+ */
+ public List getApplications() {
+ return this.applications;
+ }
+
+ /**
+ * Overwrites the <code>Application</code> list in the
+ * <code>ApplicationServer</code> applications container.
+ *
+ * @param applications the new <code>Application</code> list.
+ */
+ public void setApplications(LinkedList applications) {
+ this.applications = applications;
+ }
+
+ /**
+ * Gets the <code>Application</code> identified by a given name in the
+ * <code>ApplicationServer</code> applications container.
+ *
+ * @param name the <code>Application</code> name.
+ * @return the <code>Application</code> found or null if not found.
+ */
+ public Application getApplication(String name) {
+ for (Iterator applicationIterator = this.getApplications().iterator(); applicationIterator.hasNext();) {
+ Application application = (Application) applicationIterator.next();
+ if (application.getName().equals(name)) {
+ return application;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Adds a new <code>Cache</code> in the <code>ApplicationServer</code> caches
+ * container.
+ *
+ * @param cache the <code>Cache</code> to add.
+ * @throws ModelObjectAlreadyExistsException if the <code>Cache</code> path already exists in the application server.
+ */
+ public void addCache(Cache cache) throws ModelObjectAlreadyExistsException {
+ if (this.getCache(cache.getPath()) != null) {
+ throw new ModelObjectAlreadyExistsException("Cache path already exists in the J2EE server.");
+ }
+ this.caches.add(cache);
+ }
+
+ /**
+ * Gets the <code>Cache</code> list in the <code>ApplicationServer</code>
+ * caches container.
+ *
+ * @return the <code>Cache</code> list.
+ */
+ public List getCaches() {
+ return this.caches;
+ }
+
+ /**
+ * Overwrites the <code>Cache</code> list in the
+ * <code>ApplicationServer</code> caches container.
+ *
+ * @param caches the new <code>Cache</code> list.
+ */
+ public void setCaches(LinkedList caches) {
+ this.caches = caches;
+ }
+
+ /**
+ * Gets the <code>Cache</code> identified by a given path in the
+ * <code>ApplicationServer</code> caches container.
+ *
+ * @param path the <code>Cache</code> path.
+ * @return the <code>Cache</code> found or null if not found.
+ */
+ public Cache getCache(String path) {
+ for (Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext();) {
+ Cache cache = (Cache) cacheIterator.next();
+ if (cache.getPath().equals(path)) {
+ return cache;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ ApplicationServer clone = new ApplicationServer();
+ clone.setName(this.getName());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setClassname(this.getClassname());
+ clone.setJmxurl(this.getJmxurl());
+ clone.setAdminuser(this.getAdminuser());
+ clone.setAdminpassword(this.getAdminpassword());
+ clone.setUpdateRequireRestart(this.getUpdateRequireRestart());
+ clone.setUpdateRequireCacheCleaning(this.isUpdateRequireCacheCleaning());
+ clone.setUsejmxstop(this.isUsejmxstop());
+ clone.setDeletecomponents(this.isDeletecomponents());
+ clone.setStartupcommand(this.getStartupcommand());
+ clone.setShutdowncommand(this.getShutdowncommand());
+ clone.setAgent(this.getAgent());
+ for (Iterator connectionPoolIterator = this.connectionPools.iterator(); connectionPoolIterator.hasNext();) {
+ ConnectionPool connectionPool = (ConnectionPool) connectionPoolIterator.next();
+ clone.connectionPools.add((ConnectionPool) connectionPool.clone());
+ }
+ for (Iterator dataSourceIterator = this.dataSources.iterator(); dataSourceIterator.hasNext();) {
+ DataSource dataSource = (DataSource) dataSourceIterator.next();
+ clone.dataSources.add((DataSource) dataSource.clone());
+ }
+ for (Iterator jmsConnectionFactoryIterator = this.jmsConnectionFactories.iterator(); jmsConnectionFactoryIterator
+ .hasNext();) {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ clone.jmsConnectionFactories.add((JMSConnectionFactory) jmsConnectionFactory.clone());
+ }
+ for (Iterator jmsServerIterator = this.jmsServers.iterator(); jmsServerIterator.hasNext();) {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ clone.jmsServers.add((JMSServer) jmsServer.clone());
+ }
+ for (Iterator nameSpaceBindingIterator = this.nameSpaceBindings.iterator(); nameSpaceBindingIterator.hasNext();) {
+ NameSpaceBinding nameSpaceBinding = (NameSpaceBinding) nameSpaceBindingIterator.next();
+ clone.nameSpaceBindings.add((NameSpaceBinding) nameSpaceBinding.clone());
+ }
+ for (Iterator sharedLibraryIterator = this.sharedLibraries.iterator(); sharedLibraryIterator.hasNext();) {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ clone.sharedLibraries.add((SharedLibrary) sharedLibrary.clone());
+ }
+ for (Iterator applicationIterator = this.applications.iterator(); applicationIterator.hasNext();) {
+ Application application = (Application) applicationIterator.next();
+ clone.applications.add((Application) application.clone());
+ }
+ for (Iterator cacheIterator = this.caches.iterator(); cacheIterator.hasNext();) {
+ Cache cache = (Cache) cacheIterator.next();
+ clone.caches.add((Cache) cache.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>ApplicationServer</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "applicationserver");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("classname", this.getClassname());
+ element.setAttribute("jmxurl", this.getJmxurl());
+ element.setAttribute("adminuser", this.getAdminuser());
+ element.setAttribute("adminpassword", this.getAdminpassword());
+ element.setAttribute("updateRequireRestart", new Boolean(this.getUpdateRequireRestart()).toString());
+ element.setAttribute("updateRequireCacheCleaning", new Boolean(this.isUpdateRequireCacheCleaning()).toString());
+ element.setAttribute("usejmxstop", new Boolean(this.isUsejmxstop()).toString());
+ element.setAttribute("deletecomponents", new Boolean(this.isDeletecomponents()).toString());
+ element.setAttribute("agent", this.getAgent());
+ // add startup command
+ ElementImpl startupcommand = new ElementImpl(document, "startupcommand");
+ CDATASectionImpl startupcommandContent = new CDATASectionImpl(document, this.getStartupcommand());
+ startupcommand.appendChild(startupcommandContent);
+ element.appendChild(startupcommand);
+ // add shutdown command
+ ElementImpl shutdowncommand = new ElementImpl(document, "shutdowncommand");
+ CDATASectionImpl shutdowncommandContent = new CDATASectionImpl(document, this.getShutdowncommand());
+ shutdowncommand.appendChild(shutdowncommandContent);
+ element.appendChild(shutdowncommand);
+ // connectionpools
+ ElementImpl connectionpools = new ElementImpl(document, "connectionpools");
+ for (Iterator connectionPoolIterator = this.getConnectionPools().iterator(); connectionPoolIterator.hasNext();) {
+ ConnectionPool connectionPool = (ConnectionPool) connectionPoolIterator.next();
+ connectionpools.appendChild(connectionPool.toDOMElement(document));
+ }
+ element.appendChild(connectionpools);
+ // datasources
+ ElementImpl datasources = new ElementImpl(document, "datasources");
+ for (Iterator dataSourceIterator = this.getDataSources().iterator(); dataSourceIterator.hasNext();) {
+ DataSource dataSource = (DataSource) dataSourceIterator.next();
+ datasources.appendChild(dataSource.toDOMElement(document));
+ }
+ element.appendChild(datasources);
+ // jmsconnectionfactories
+ ElementImpl jmsconnectionfactories = new ElementImpl(document, "jmsconnectionfactories");
+ for (Iterator jmsConnectionFactoryIterator = this.getJMSConnectionFactories().iterator(); jmsConnectionFactoryIterator
+ .hasNext();) {
+ JMSConnectionFactory jmsConnectionFactory = (JMSConnectionFactory) jmsConnectionFactoryIterator.next();
+ jmsconnectionfactories.appendChild(jmsConnectionFactory.toDOMElement(document));
+ }
+ element.appendChild(jmsconnectionfactories);
+ // jmsservers
+ ElementImpl jmsservers = new ElementImpl(document, "jmsservers");
+ for (Iterator jmsServerIterator = this.getJMSServers().iterator(); jmsServerIterator.hasNext();) {
+ JMSServer jmsServer = (JMSServer) jmsServerIterator.next();
+ jmsservers.appendChild(jmsServer.toDOMElement(document));
+ }
+ element.appendChild(jmsservers);
+ // namespacebindings
+ ElementImpl namespacebindings = new ElementImpl(document, "namespacebindings");
+ for (Iterator nameSpaceBindingIterator = this.getNameSpaceBindings().iterator(); nameSpaceBindingIterator
+ .hasNext();) {
+ NameSpaceBinding nameSpaceBinding = (NameSpaceBinding) nameSpaceBindingIterator.next();
+ namespacebindings.appendChild(nameSpaceBinding.toDOMElement(document));
+ }
+ element.appendChild(namespacebindings);
+ // sharedlibraries
+ ElementImpl sharedlibraries = new ElementImpl(document, "sharedlibrairies");
+ for (Iterator sharedLibraryIterator = this.getSharedLibraries().iterator(); sharedLibraryIterator.hasNext();) {
+ SharedLibrary sharedLibrary = (SharedLibrary) sharedLibraryIterator.next();
+ sharedlibraries.appendChild(sharedLibrary.toDOMElement(document));
+ }
+ element.appendChild(sharedlibraries);
+ // applications
+ ElementImpl applications = new ElementImpl(document, "applications");
+ for (Iterator applicationIterator = this.getApplications().iterator(); applicationIterator.hasNext();) {
+ Application application = (Application) applicationIterator.next();
+ applications.appendChild(application.toDOMElement(document));
+ }
+ element.appendChild(applications);
+ // caches
+ ElementImpl caches = new ElementImpl(document, "caches");
+ for (Iterator cacheIterator = this.getCaches().iterator(); cacheIterator.hasNext();) {
+ Cache cache = (Cache) cacheIterator.next();
+ caches.appendChild(cache.toDOMElement(document));
+ }
+ element.appendChild(caches);
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherApplicationServer) {
+ return this.getName().compareTo(((ApplicationServer)anotherApplicationServer).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServers.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServers.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServers.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ApplicationServers.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>applicationservers</code> tag in the Kalumet DOM.
+ */
+public class ApplicationServers implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -4940898204749451109L;
+
+ private boolean cluster;
+ private LinkedList applicationServers;
+
+ public ApplicationServers() {
+ this.applicationServers = new LinkedList();
+ }
+
+ public boolean isCluster() {
+ return this.cluster;
+ }
+
+ public void setCluster(boolean cluster) {
+ this.cluster = cluster;
+ }
+
+ /**
+ * Adds a new <code>ApplicationServer</code> in the
+ * <code>ApplicationServers</code> container.
+ *
+ * @param applicationServer the <code>ApplicationServer</code> to add.
+ */
+ public void addApplicationServer(ApplicationServer applicationServer) throws ModelObjectAlreadyExistsException {
+ if (this.getApplicationServer(applicationServer.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("J2EE server name already exists in the environment.");
+ }
+ this.applicationServers.add(applicationServer);
+ }
+
+ /**
+ * Gets the <code>ApplicationServer</code> list in the
+ * <code>ApplicationServers</code> container.
+ *
+ * @return the <code>ApplicationServer</code> list.
+ */
+ public List getApplicationServers() {
+ return this.applicationServers;
+ }
+
+ /**
+ * Overwrites the <code>ApplicationServer</code> list in the
+ * <code>ApplicationServers</code> container.
+ *
+ * @param applicationServers the new <code>ApplicationServer</code> list.
+ */
+ public void setApplicationServers(LinkedList applicationServers) {
+ this.applicationServers = applicationServers;
+ }
+
+ /**
+ * Gets the <code>ApplicationServer</code> identified by a given name in the
+ * <code>ApplicationServers</code> container.
+ *
+ * @param name the <code>ApplicationServer</code> name.
+ * @return the <code>ApplicationServer</code> found or null if no found.
+ */
+ public ApplicationServer getApplicationServer(String name) {
+ for (Iterator applicationServerIterator = this.getApplicationServers().iterator(); applicationServerIterator.hasNext();) {
+ ApplicationServer applicationServer = (ApplicationServer) applicationServerIterator.next();
+ if (applicationServer.getName().equals(name)) {
+ return applicationServer;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ ApplicationServers clone = new ApplicationServers();
+ clone.setCluster(this.isCluster());
+ for (Iterator applicationServerIterator = this.applicationServers.iterator(); applicationServerIterator.hasNext(); ) {
+ ApplicationServer applicationServer = (ApplicationServer) applicationServerIterator.next();
+ clone.applicationServers.add((ApplicationServer)applicationServer.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>ApplicationServers</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "applicationservers");
+ element.setAttribute("cluster", new Boolean(this.isCluster()).toString());
+ // add applicationserver child nodes
+ for (Iterator applicationServerIterator = this.getApplicationServers().iterator(); applicationServerIterator.hasNext();) {
+ ApplicationServer applicationServer = (ApplicationServer) applicationServerIterator.next();
+ element.appendChild(applicationServer.toDOMElement(document));
+ }
+ return element;
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Archive.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Archive.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Archive.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Archive.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>archive</code> tag in the Kalumet DOM.
+ */
+public class Archive implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = 7125281479795326133L;
+
+ private String name;
+ private String uri;
+ private String classloaderorder;
+ private String classloaderpolicy;
+ private String vhost;
+ private String path;
+ private String context;
+ private boolean active;
+ private boolean blocker;
+ private String agent;
+
+ public Archive() { }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getClassloaderorder() {
+ return classloaderorder;
+ }
+
+ public void setClassloaderorder(String classloaderorder) {
+ this.classloaderorder = classloaderorder;
+ }
+
+ public String getClassloaderpolicy() {
+ return classloaderpolicy;
+ }
+
+ public void setClassloaderpolicy(String classloaderpolicy) {
+ this.classloaderpolicy = classloaderpolicy;
+ }
+
+ public String getVhost() {
+ return this.vhost;
+ }
+
+ public void setVhost(String vhost) {
+ this.vhost = vhost;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getContext() {
+ return this.context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Archive clone = new Archive();
+ clone.setName(this.getName());
+ clone.setUri(this.getUri());
+ clone.setClassloaderorder(this.getClassloaderorder());
+ clone.setClassloaderpolicy(this.getClassloaderpolicy());
+ clone.setVhost(this.getVhost());
+ clone.setPath(this.getPath());
+ clone.setContext(this.getContext());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setAgent(this.getAgent());
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Archive</code> specific POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "archive");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("uri", this.getUri());
+ element.setAttribute("classloaderorder", this.getClassloaderorder());
+ element.setAttribute("classloaderpolicy", this.getClassloaderpolicy());
+ element.setAttribute("vhost", this.getVhost());
+ element.setAttribute("path", this.getPath());
+ element.setAttribute("context", this.getContext());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("agent", this.getAgent());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherArchive) {
+ return this.getName().compareTo(((Archive)anotherArchive).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Cache.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Cache.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Cache.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Cache.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>cache</code> tag in the Kalumet XML configuration
+ * file.
+ */
+public class Cache implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = 1931779797709903317L;
+
+ private String path;
+
+ public Cache() { }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Cache clone = new Cache();
+ clone.setPath(this.getPath());
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>Cache</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "cache");
+ element.setAttribute("path", this.getPath());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherCache) {
+ return this.getPath().compareTo(((Cache)anotherCache).getPath());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Command.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Command.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Command.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/Command.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CDATASectionImpl;
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent a <code>command</code> tag, mainly inside <code>software</code>.
+ */
+public class Command implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -3671135569540426579L;
+
+ private String name;
+ private boolean active;
+ private boolean blocker;
+ private String agent;
+ private String command;
+
+ public Command() { }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public boolean isBlocker() {
+ return blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ Command clone = new Command();
+ clone.setName(this.getName());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setAgent(this.getAgent());
+ clone.setCommand(this.getCommand());
+ return clone;
+ }
+
+ /**
+ * Transforms a <code>command</code> into a XML DOM element.
+ *
+ * @param document the DOM document.
+ * @return the <code>command</code> DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "command");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("agent", this.getAgent());
+ CDATASectionImpl content = new CDATASectionImpl(document, this.getCommand());
+ element.appendChild(content);
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherCommand) {
+ return this.getName().compareTo(((Command)anotherCommand).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConfigurationFile.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represents the <code>configurationfile</code> tag in the Kalumet DOM.
+ */
+public class ConfigurationFile implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -1898011382653346087L;
+
+ private String name;
+ private String uri;
+ private String path;
+ private boolean active;
+ private boolean blocker;
+ private String agent;
+ private LinkedList mappings;
+
+ public ConfigurationFile() {
+ this.mappings = new LinkedList();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUri() {
+ return this.uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getPath() {
+ return this.path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ /**
+ * Add a new <code>Mapping</code> in the <code>ConfigurationFile</code>
+ * mappings container.
+ *
+ * @param mapping the <code>Mapping</code> to add.
+ */
+ public void addMapping(Mapping mapping) throws ModelObjectAlreadyExistsException {
+ if (this.getMapping(mapping.getKey()) != null) {
+ throw new ModelObjectAlreadyExistsException("Mapping key already exists in the configuration file.");
+ }
+ this.mappings.add(mapping);
+ }
+
+ /**
+ * Get the <code>Mapping</code> list in the <code>ConfigurationFile</code>
+ * mappings container.
+ *
+ * @return the <code>Mapping</code> list.
+ */
+ public List getMappings() {
+ return this.mappings;
+ }
+
+ /**
+ * Set the <code>Mapping</code> list in the
+ * <code>ConfigurationFile</code> mappings container.
+ *
+ * @param mappings the new <code>Mapping</code> list.
+ */
+ public void setMappings(LinkedList mappings) {
+ this.mappings = mappings;
+ }
+
+ /**
+ * Get the <code>Mapping</code> identified by a given key in the
+ * <code>ConfigurationFile</code> mappings container.
+ *
+ * @param key the <code>Mapping</code> key.
+ * @return the <code>Mapping</code> found or null if no <code>Mapping</code> found.
+ */
+ public Mapping getMapping(String key) {
+ for (Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext();) {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ if (mapping.getKey().equals(key)) {
+ return mapping;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ ConfigurationFile clone = new ConfigurationFile();
+ clone.setName(this.getName());
+ clone.setUri(this.getUri());
+ clone.setPath(this.getPath());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setAgent(this.getAgent());
+ for (Iterator mappingIterator = this.mappings.iterator(); mappingIterator.hasNext();) {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ clone.mappings.add((Mapping) mapping.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>ConfigurationFile</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "configurationfile");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("uri", this.getUri());
+ element.setAttribute("path", this.getPath());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("agent", this.getAgent());
+ // mappings
+ ElementImpl mappings = new ElementImpl(document, "mappings");
+ for (Iterator mappingIterator = this.getMappings().iterator(); mappingIterator.hasNext();) {
+ Mapping mapping = (Mapping) mappingIterator.next();
+ mappings.appendChild(mapping.toDOMElement(document));
+ }
+ element.appendChild(mappings);
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherConfigurationFile) {
+ return this.getName().compareTo(((ConfigurationFile)anotherConfigurationFile).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConnectionPool.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConnectionPool.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConnectionPool.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ConnectionPool.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>connectionpool</code> tag in the Kalumet XML
+ * configuration file.
+ */
+public class ConnectionPool implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = 8052573645587249685L;
+
+ private String name;
+ private String driver;
+ private String helperclass;
+ private int increment;
+ private int initial;
+ private int maximal;
+ private String user;
+ private String password;
+ private String url;
+ private String classpath;
+ private boolean active;
+ private boolean blocker;
+
+ public ConnectionPool() { }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDriver() {
+ return this.driver;
+ }
+
+ public void setDriver(String driver) {
+ this.driver = driver;
+ }
+
+ public String getHelperclass() {
+ return this.helperclass;
+ }
+
+ public void setHelperclass(String helperclass) {
+ this.helperclass = helperclass;
+ }
+
+ public int getIncrement() {
+ return this.increment;
+ }
+
+ public void setIncrement(int increment) {
+ this.increment = increment;
+ }
+
+ public int getInitial() {
+ return this.initial;
+ }
+
+ public void setInitial(int initial) {
+ this.initial = initial;
+ }
+
+ public int getMaximal() {
+ return this.maximal;
+ }
+
+ public void setMaximal(int maximal) {
+ this.maximal = maximal;
+ }
+
+ public String getUser() {
+ return this.user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUrl() {
+ return this.url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getClasspath() {
+ return this.classpath;
+ }
+
+ public void setClasspath(String classpath) {
+ this.classpath = classpath;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ ConnectionPool clone = new ConnectionPool();
+ clone.setName(this.getName());
+ clone.setDriver(this.getDriver());
+ clone.setHelperclass(this.getHelperclass());
+ clone.setIncrement(this.getIncrement());
+ clone.setInitial(this.getInitial());
+ clone.setMaximal(this.getMaximal());
+ clone.setUser(this.getUser());
+ clone.setPassword(this.getPassword());
+ clone.setUrl(this.getUrl());
+ clone.setClasspath(this.getClasspath());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ return clone;
+ }
+
+ /**
+ * Transform the <code>ConnectionPool</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "connectionpool");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("driver", this.getDriver());
+ element.setAttribute("helperclass", this.getHelperclass());
+ element.setAttribute("increment", new Integer(this.getIncrement()).toString());
+ element.setAttribute("initial", new Integer(this.getInitial()).toString());
+ element.setAttribute("maximal", new Integer(this.getMaximal()).toString());
+ element.setAttribute("user", this.getUser());
+ element.setAttribute("password", this.getPassword());
+ element.setAttribute("url", this.getUrl());
+ element.setAttribute("classpath", this.getClasspath());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isActive()).toString());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherConnectionPool) {
+ return this.getName().compareTo(((ConnectionPool)anotherConnectionPool).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ContentManager.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ContentManager.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ContentManager.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/ContentManager.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>contentmanager</code> tag in the Kalumet DOM.
+ */
+public class ContentManager implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -6772514401403559365L;
+
+ private String name;
+ private String classname;
+ private boolean active;
+ private boolean blocker;
+ private String agent;
+ private LinkedList properties;
+
+ public ContentManager() {
+ this.properties = new LinkedList();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getClassname() {
+ return this.classname;
+ }
+
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public String getAgent() {
+ return agent;
+ }
+
+ public void setAgent(String agent) {
+ this.agent = agent;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ /**
+ * Add a new <code>Property</code> in the <code>ContentManager</code>
+ * properties container.
+ *
+ * @param property the <code>Property</code> to add.
+ */
+ public void addProperty(Property property) throws ModelObjectAlreadyExistsException {
+ if (this.getProperty(property.getName()) != null) {
+ throw new ModelObjectAlreadyExistsException("Property name already exists in content manager.");
+ }
+ this.properties.add(property);
+ }
+
+ /**
+ * Get the <code>Property</code> list in the <code>ContentManager</code>
+ * properties container.
+ *
+ * @return the <code>Property</code> list.
+ */
+ public List getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * Set the <code>Property</code> list in the
+ * <code>ContentManager</code> properties container.
+ *
+ * @param properties the new <code>Property</code> list.
+ */
+ public void setProperties(LinkedList properties) {
+ this.properties = properties;
+ }
+
+ /**
+ * Get the <code>Property</code> identified by a given name in the
+ * <code>ContentManager</code> properties container.
+ *
+ * @param name the <code>Property</code> name.
+ * @return the <code>Property</code> found or null if no <code>Property</code> found.
+ */
+ public Property getProperty(String name) {
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext();) {
+ Property property = (Property) propertyIterator.next();
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ ContentManager clone = new ContentManager();
+ clone.setName(this.getName());
+ clone.setClassname(this.getClassname());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ clone.setAgent(this.getAgent());
+ for (Iterator propertyIterator = this.properties.iterator(); propertyIterator.hasNext();) {
+ Property property = (Property) propertyIterator.next();
+ clone.properties.add((Property) property.clone());
+ }
+ return clone;
+ }
+
+ /**
+ * Transform the <code>ContentManager</code> POJO to a DOM element.
+ *
+ * @param document the core XML document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "contentmanager");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("classname", this.getClassname());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ element.setAttribute("agent", this.getAgent());
+ // properties
+ ElementImpl properties = new ElementImpl(document, "properties");
+ for (Iterator propertyIterator = this.getProperties().iterator(); propertyIterator.hasNext();) {
+ Property property = (Property) propertyIterator.next();
+ properties.appendChild(property.toDOMElement(document));
+ }
+ element.appendChild(properties);
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherContentManager) {
+ return this.getName().compareTo(((ContentManager)anotherContentManager).getName());
+ }
+
+}
\ No newline at end of file
Added: incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/DataSource.java
URL: http://svn.apache.org/viewvc/incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/DataSource.java?rev=1187711&view=auto
==============================================================================
--- incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/DataSource.java (added)
+++ incubator/kalumet/trunk/common/src/main/java/org/apache/kalumet/model/DataSource.java Sat Oct 22 13:10:01 2011
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.kalumet.model;
+
+import java.io.Serializable;
+
+import org.apache.xerces.dom.CoreDocumentImpl;
+import org.apache.xerces.dom.ElementImpl;
+import org.w3c.dom.Element;
+
+/**
+ * Represent the <code>datasource</code> tag in the Kalumet configuration DOM.
+ */
+public class DataSource implements Serializable, Cloneable, Comparable {
+
+ private static final long serialVersionUID = -6850328756411047364L;
+
+ private String name;
+ private String pool;
+ private boolean active;
+ private boolean blocker;
+
+ public DataSource() { }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPool() {
+ return this.pool;
+ }
+
+ public void setPool(String pool) {
+ this.pool = pool;
+ }
+
+ public boolean isActive() {
+ return this.active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public boolean isBlocker() {
+ return this.blocker;
+ }
+
+ public void setBlocker(boolean blocker) {
+ this.blocker = blocker;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public Object clone() throws CloneNotSupportedException {
+ DataSource clone = new DataSource();
+ clone.setName(this.getName());
+ clone.setPool(this.getPool());
+ clone.setActive(this.isActive());
+ clone.setBlocker(this.isBlocker());
+ return clone;
+ }
+
+ /**
+ * Transforms the <code>DataSource</code> POJO to a DOM element.
+ *
+ * @param document the DOM document.
+ * @return the DOM element.
+ */
+ protected Element toDOMElement(CoreDocumentImpl document) {
+ ElementImpl element = new ElementImpl(document, "datasource");
+ element.setAttribute("name", this.getName());
+ element.setAttribute("pool", this.getPool());
+ element.setAttribute("active", new Boolean(this.isActive()).toString());
+ element.setAttribute("blocker", new Boolean(this.isBlocker()).toString());
+ return element;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object anotherDataSource) {
+ return this.getName().compareTo(((DataSource)anotherDataSource).getName());
+ }
+
+}
\ No newline at end of file