[hibernate-commits] Hibernate SVN: r11450 - trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed May 2 02:07:08 EDT 2007
Author: max.ross
Date: 2007-05-02 02:07:08 -0400 (Wed, 02 May 2007)
New Revision: 11450
Added:
trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ConfigurationToShardConfigurationAdapter.java
trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ShardConfiguration.java
Log:
Add the ShardConfiguration interface and an impl that adapts the standard Configuration to this interface.
Added: trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ConfigurationToShardConfigurationAdapter.java
===================================================================
--- trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ConfigurationToShardConfigurationAdapter.java (rev 0)
+++ trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ConfigurationToShardConfigurationAdapter.java 2007-05-02 06:07:08 UTC (rev 11450)
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2007 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.hibernate.shards.cfg;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+
+/**
+ * Adapt a {@link Configuration} to the {@link ShardConfiguration} interface.
+ *
+ * @author maxr at google.com (Max Ross)
+ */
+public class ConfigurationToShardConfigurationAdapter implements ShardConfiguration {
+
+ private final Configuration config;
+
+ public ConfigurationToShardConfigurationAdapter(Configuration config) {
+ this.config = config;
+ }
+
+ public String getShardUrl() {
+ return config.getProperty(Environment.URL);
+ }
+
+ public String getShardUser() {
+ return config.getProperty(Environment.USER);
+ }
+
+ public String getShardPassword() {
+ return config.getProperty(Environment.PASS);
+ }
+
+ public String getShardSessionFactoryName() {
+ return config.getProperty(Environment.SESSION_FACTORY_NAME);
+ }
+
+ public Integer getShardId() {
+ return Integer.parseInt(config.getProperty(ShardedEnvironment.SHARD_ID_PROPERTY));
+ }
+}
Added: trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ShardConfiguration.java
===================================================================
--- trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ShardConfiguration.java (rev 0)
+++ trunk/HibernateExt/shards/src/java/org/hibernate/shards/cfg/ShardConfiguration.java 2007-05-02 06:07:08 UTC (rev 11450)
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2007 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.hibernate.shards.cfg;
+
+/**
+ * Describes the configuration properties that can vary across the {@link org.hibernate.SessionFactory}
+ * instances contained within your {@link org.hibernate.shards.session.ShardedSessionFactory}.
+ *
+ * @author maxr at google.com (Max Ross)
+ */
+public interface ShardConfiguration {
+
+ /**
+ * @return the url of the shard
+ */
+ String getShardUrl();
+
+ /**
+ * @return the user that will be sent to the shard for authentication
+ */
+ String getShardUser();
+
+ /**
+ * @return the password that will be sent to the shard for authentication
+ */
+ String getShardPassword();
+
+ /**
+ * @return the name that the {@link org.hibernate.SessionFactory} created from
+ * this config will have
+ */
+ String getShardSessionFactoryName();
+
+ /**
+ * @return unique id of the shard
+ */
+ Integer getShardId();
+}
More information about the hibernate-commits
mailing list