|
| 1 | +/* |
| 2 | + * Copyright 2025-present MongoDB, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.mongodb.hibernate.internal.extension; |
| 18 | + |
| 19 | +import static com.mongodb.hibernate.internal.MongoConstants.MONGO_CONNECTION_PROVIDER_SHORT_NAME; |
| 20 | +import static com.mongodb.hibernate.internal.MongoConstants.MONGO_DIALECT_SHORT_NAME; |
| 21 | + |
| 22 | +import com.mongodb.hibernate.dialect.MongoDialect; |
| 23 | +import com.mongodb.hibernate.jdbc.MongoConnectionProvider; |
| 24 | +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; |
| 25 | +import org.hibernate.boot.registry.selector.spi.StrategySelector; |
| 26 | +import org.hibernate.dialect.Dialect; |
| 27 | +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
| 28 | +import org.hibernate.service.spi.ServiceContributor; |
| 29 | + |
| 30 | +public final class MongoStrategyContributor implements ServiceContributor { |
| 31 | + |
| 32 | + @Override |
| 33 | + public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) { |
| 34 | + var selector = serviceRegistryBuilder.getBootstrapServiceRegistry().requireService(StrategySelector.class); |
| 35 | + selector.registerStrategyImplementor(Dialect.class, MONGO_DIALECT_SHORT_NAME, MongoDialect.class); |
| 36 | + selector.registerStrategyImplementor( |
| 37 | + ConnectionProvider.class, MONGO_CONNECTION_PROVIDER_SHORT_NAME, MongoConnectionProvider.class); |
| 38 | + } |
| 39 | +} |
0 commit comments