1 /*
2 * junixsocket
3 *
4 * Copyright 2009-2026 Christian Kohlschütter
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.newsclub.net.unix.rmi;
19
20 import java.io.IOException;
21 import java.io.Serializable;
22 import java.net.Socket;
23 import java.rmi.server.RMIClientSocketFactory;
24
25 import com.kohlschutter.annotations.compiletime.SuppressFBWarnings;
26
27 /**
28 * An implementation of {@link RMIClientSocketFactory}.
29 *
30 * @see AFRMISocketFactory
31 */
32 @SuppressFBWarnings("SING_SINGLETON_IMPLEMENTS_SERIALIZABLE")
33 public final class DefaultRMIClientSocketFactory implements RMIClientSocketFactory, Serializable {
34 private static final long serialVersionUID = 1L;
35
36 private static final DefaultRMIClientSocketFactory INSTANCE = new DefaultRMIClientSocketFactory();
37
38 private DefaultRMIClientSocketFactory() {
39 }
40
41 /**
42 * Returns the singleton instance for DefaultRMIClientSocketFactory.
43 *
44 * @return The singleton.
45 */
46 public static DefaultRMIClientSocketFactory getInstance() {
47 return INSTANCE;
48 }
49
50 @Override
51 @SuppressFBWarnings("UNENCRYPTED_SOCKET")
52 public Socket createSocket(String host, int port) throws IOException {
53 Socket socket = new Socket(host, port); // NOPMD.VariableCanBeInlined
54 // socket.setSoTimeout(60 * 60 * 1000);
55 // socket.setSoLinger(false, 0);
56 return socket;
57 }
58
59 // we must implement this (see RMIClientSocketFactory)
60 @Override
61 public boolean equals(Object obj) {
62 return obj instanceof DefaultRMIClientSocketFactory;
63 }
64
65 // we must implement this (see RMIClientSocketFactory)
66 @Override
67 public int hashCode() {
68 return 1;
69 }
70 }