1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.eclipse.aether.named.hazelcast;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import com.hazelcast.client.HazelcastClient;
26 import com.hazelcast.core.HazelcastInstance;
27
28 /**
29 * {@link HazelcastSemaphoreNamedLockFactory} using {@link DirectHazelcastSemaphoreProvider} and Hazelcast client. The
30 * client must be configured to connect to some existing cluster (w/ proper configuration applied).
31 *
32 * @deprecated Hazelcast support will be dropped.
33 */
34 @Deprecated
35 @Singleton
36 @Named(HazelcastClientCPSemaphoreNamedLockFactory.NAME)
37 public class HazelcastClientCPSemaphoreNamedLockFactory extends HazelcastSemaphoreNamedLockFactory {
38 public static final String NAME = "semaphore-hazelcast-client";
39
40 /**
41 * The default constructor: creates own instance of Hazelcast client using standard Hazelcast configuration
42 * discovery, but refuses to run on Hazelcast built-in defaults: an explicit operator-provided configuration
43 * (the {@code hazelcast.client.config} system property, or a {@code hazelcast-client.xml}/{@code
44 * hazelcast-client.yaml}/{@code hazelcast-client.yml} file on the classpath or in the working directory) is
45 * required, as the built-in defaults connect to an unauthenticated default-named cluster.
46 */
47 @Inject
48 public HazelcastClientCPSemaphoreNamedLockFactory() {
49 this(createConfiguredHazelcastClient(), true);
50 }
51
52 private static HazelcastInstance createConfiguredHazelcastClient() {
53 requireExplicitHazelcastConfig(
54 "hazelcast.client.config",
55 HazelcastClientCPSemaphoreNamedLockFactory.class.getClassLoader(),
56 "hazelcast-client.xml",
57 "hazelcast-client.yaml",
58 "hazelcast-client.yml");
59 return HazelcastClient.newHazelcastClient();
60 }
61
62 /**
63 * Constructor for customization.
64 */
65 public HazelcastClientCPSemaphoreNamedLockFactory(HazelcastInstance hazelcastInstance, boolean manageHazelcast) {
66 super(hazelcastInstance, manageHazelcast, new DirectHazelcastSemaphoreProvider());
67 }
68 }