| 1 | // Copyright 2004-2007 Jean-Francois Poilpret |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package net.sourceforge.hivetranse.transaction.hibernate3; |
| 16 | |
| 17 | import java.util.ArrayList; |
| 18 | import java.util.List; |
| 19 | import java.util.Properties; |
| 20 | |
| 21 | import org.apache.hivemind.Resource; |
| 22 | import org.apache.hivemind.impl.BaseLocatable; |
| 23 | import org.apache.hivemind.util.ToStringBuilder; |
| 24 | import org.hibernate.Interceptor; |
| 25 | import org.hibernate.cfg.NamingStrategy; |
| 26 | |
| 27 | import net.sourceforge.hiveutils.collections.NameValuePair; |
| 28 | |
| 29 | /** |
| 30 | * Represents a configuration parameter to the <code>SessionProxyFactory</code> |
| 31 | * configured for building a <code>Session</code> service. |
| 32 | * Each instance defines a Hibernate configuration file. |
| 33 | * Optionally, the instance can embed additional properties to be set |
| 34 | * individually before Hibernate <code>SessionFactory</code> is built. |
| 35 | * |
| 36 | * @author Jean-Francois Poilpret |
| 37 | */ |
| 38 | public class SessionFactoryContribution extends BaseLocatable |
| 39 | { |
| 40 | public void setConfig(Resource config) |
| 41 | { |
| 42 | _config = config; |
| 43 | } |
| 44 | public Resource getConfig() |
| 45 | { |
| 46 | return _config; |
| 47 | } |
| 48 | |
| 49 | public void setSettings(List settings) |
| 50 | { |
| 51 | _settings = settings; |
| 52 | } |
| 53 | public List getSettings() |
| 54 | { |
| 55 | return _settings; |
| 56 | } |
| 57 | |
| 58 | public void setInterceptor(Interceptor interceptor) |
| 59 | { |
| 60 | _interceptor = interceptor; |
| 61 | } |
| 62 | public Interceptor getInterceptor() |
| 63 | { |
| 64 | return _interceptor; |
| 65 | } |
| 66 | |
| 67 | public void setNamingStrategy(NamingStrategy namingStrategy) |
| 68 | { |
| 69 | _namingStrategy = namingStrategy; |
| 70 | } |
| 71 | public NamingStrategy getNamingStrategy() |
| 72 | { |
| 73 | return _namingStrategy; |
| 74 | } |
| 75 | |
| 76 | public void addProperty(NameValuePair property) |
| 77 | { |
| 78 | _properties.setProperty(property.getName(), property.getValue()); |
| 79 | } |
| 80 | |
| 81 | public Properties getProperties() |
| 82 | { |
| 83 | return _properties; |
| 84 | } |
| 85 | |
| 86 | public String toString() |
| 87 | { |
| 88 | ToStringBuilder builder = new ToStringBuilder(this); |
| 89 | builder.append("config", _config); |
| 90 | return builder.toString(); |
| 91 | } |
| 92 | |
| 93 | private Resource _config; |
| 94 | private List _settings = new ArrayList(); |
| 95 | private Properties _properties = new Properties(); |
| 96 | private Interceptor _interceptor; |
| 97 | private NamingStrategy _namingStrategy; |
| 98 | } |