<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.rmi.server;

import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.RMISocketFactory;
import java.util.ArrayList;
import java.util.List;

import javax.jcr.Item;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.jcr.lock.Lock;
import javax.jcr.nodetype.ItemDefinition;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeIterator;
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.ObservationManager;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.jcr.query.Row;
import javax.jcr.query.RowIterator;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;

import org.apache.jackrabbit.rmi.remote.ArrayIterator;
import org.apache.jackrabbit.rmi.remote.BufferIterator;
import org.apache.jackrabbit.rmi.remote.RemoteEventCollection;
import org.apache.jackrabbit.rmi.remote.RemoteItem;
import org.apache.jackrabbit.rmi.remote.RemoteItemDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteIterator;
import org.apache.jackrabbit.rmi.remote.RemoteLock;
import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
import org.apache.jackrabbit.rmi.remote.RemoteNode;
import org.apache.jackrabbit.rmi.remote.RemoteNodeDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
import org.apache.jackrabbit.rmi.remote.RemoteNodeTypeManager;
import org.apache.jackrabbit.rmi.remote.RemoteObservationManager;
import org.apache.jackrabbit.rmi.remote.RemoteProperty;
import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteQuery;
import org.apache.jackrabbit.rmi.remote.RemoteQueryManager;
import org.apache.jackrabbit.rmi.remote.RemoteQueryResult;
import org.apache.jackrabbit.rmi.remote.RemoteRepository;
import org.apache.jackrabbit.rmi.remote.RemoteRow;
import org.apache.jackrabbit.rmi.remote.RemoteSession;
import org.apache.jackrabbit.rmi.remote.RemoteVersion;
import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
import org.apache.jackrabbit.rmi.server.iterator.ServerNodeIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerNodeTypeIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerPropertyIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerRowIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerVersionIterator;

/**
 * Default implementation of the
 * {@link RemoteAdapterFactory RemoteAdapterFactory} interface.
 * This factory uses the server adapters defined in this package as
 * the default adapter implementations. Subclasses can override or extend
 * the default adapters by implementing the corresponding factory methods.
 * <p>
 * The <code>bufferSize</code> property can be used to configure the
 * size of the buffer used by iterators to speed up iterator traversal
 * over the network.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class ServerAdapterFactory implements RemoteAdapterFactory {

    /** The default iterator buffer size. */
    private static final int DEFAULT_BUFFER_SIZE = 100;

    /** The buffer size of iterators created by this factory. */
    private int bufferSize = DEFAULT_BUFFER_SIZE;

    private int port = 0;

    private RMIClientSocketFactory clientSocketFactory = null;

    private RMIServerSocketFactory serverSocketFactory = null;

    /**
     * Returns the iterator buffer size.
     *
     * @return iterator buffer size
     */
    public int getBufferSize() {
        return bufferSize;
    }

    /**
     * Sets the iterator buffer size.
     *
     * @param bufferSize iterator buffer size
     */
    public void setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
    }

    /**
     * Returns the RMI port to use.
     *
     * @return RMI port number
     * @since 1.3
     */
    public int getPort() {
        return port;
    }

    /**
     * Sets the RMI port to use.
     *
     * @param port RMI port number
     * @since 1.3
     */
    public void setPort(int port) {
        this.port = port;
    }

    /**
     * Returns the RMI client socket factory to use.
     *
     * @return RMI client socket factory
     * @since 1.3
     */
    public RMIClientSocketFactory getClientSocketFactory() {
        RMIClientSocketFactory factory = clientSocketFactory;
        if (factory == null) {
            factory = RMISocketFactory.getSocketFactory();
        }
        if (factory == null) {
            factory = RMISocketFactory.getDefaultSocketFactory();
        }
        return factory;
    }

    /**
     * Sets the RMI client socket factory to use.
     *
     * @param factory RMI client socket factory,
     *                or <code>null</code> to use the default
     * @since 1.3
     */
    public void setClientSocketFactory(RMIClientSocketFactory factory) {
        clientSocketFactory = factory;
    }

    /**
     * Returns the RMI server socket factory to use.
     *
     * @return RMI server socket factory
     * @since 1.3
     */
    public RMIServerSocketFactory getServerSocketFactory() {
        RMIServerSocketFactory factory = serverSocketFactory;
        if (factory == null) {
            factory = RMISocketFactory.getSocketFactory();
        }
        if (factory == null) {
            factory = RMISocketFactory.getDefaultSocketFactory();
        }
        return factory;
    }

    /**
     * Sets the RMI server socket factory to use.
     *
     * @param factory RMI server socket factory,
     *                or <code>null</code> to use the default
     * @since 1.3
     */
    public void setServerSocketFactory(RMIServerSocketFactory factory) {
        serverSocketFactory = factory;
    }

    /**
     * Creates a {@link ServerRepository ServerRepository} instance.
     * {@inheritDoc}
     */
    public RemoteRepository getRemoteRepository(Repository repository)
            throws RemoteException {
        return new ServerRepository(repository, this);
    }
<commit_msg>JCR-781: Use null as the default socket factories. (This might cause trouble...)<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.rmi.server;

import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.util.ArrayList;
import java.util.List;

import javax.jcr.Item;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.jcr.lock.Lock;
import javax.jcr.nodetype.ItemDefinition;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeIterator;
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.ObservationManager;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.jcr.query.Row;
import javax.jcr.query.RowIterator;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;

import org.apache.jackrabbit.rmi.remote.ArrayIterator;
import org.apache.jackrabbit.rmi.remote.BufferIterator;
import org.apache.jackrabbit.rmi.remote.RemoteEventCollection;
import org.apache.jackrabbit.rmi.remote.RemoteItem;
import org.apache.jackrabbit.rmi.remote.RemoteItemDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteIterator;
import org.apache.jackrabbit.rmi.remote.RemoteLock;
import org.apache.jackrabbit.rmi.remote.RemoteNamespaceRegistry;
import org.apache.jackrabbit.rmi.remote.RemoteNode;
import org.apache.jackrabbit.rmi.remote.RemoteNodeDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteNodeType;
import org.apache.jackrabbit.rmi.remote.RemoteNodeTypeManager;
import org.apache.jackrabbit.rmi.remote.RemoteObservationManager;
import org.apache.jackrabbit.rmi.remote.RemoteProperty;
import org.apache.jackrabbit.rmi.remote.RemotePropertyDefinition;
import org.apache.jackrabbit.rmi.remote.RemoteQuery;
import org.apache.jackrabbit.rmi.remote.RemoteQueryManager;
import org.apache.jackrabbit.rmi.remote.RemoteQueryResult;
import org.apache.jackrabbit.rmi.remote.RemoteRepository;
import org.apache.jackrabbit.rmi.remote.RemoteRow;
import org.apache.jackrabbit.rmi.remote.RemoteSession;
import org.apache.jackrabbit.rmi.remote.RemoteVersion;
import org.apache.jackrabbit.rmi.remote.RemoteVersionHistory;
import org.apache.jackrabbit.rmi.remote.RemoteWorkspace;
import org.apache.jackrabbit.rmi.server.iterator.ServerNodeIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerNodeTypeIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerPropertyIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerRowIterator;
import org.apache.jackrabbit.rmi.server.iterator.ServerVersionIterator;

/**
 * Default implementation of the
 * {@link RemoteAdapterFactory RemoteAdapterFactory} interface.
 * This factory uses the server adapters defined in this package as
 * the default adapter implementations. Subclasses can override or extend
 * the default adapters by implementing the corresponding factory methods.
 * <p>
 * The <code>bufferSize</code> property can be used to configure the
 * size of the buffer used by iterators to speed up iterator traversal
 * over the network.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class ServerAdapterFactory implements RemoteAdapterFactory {

    /** The default iterator buffer size. */
    private static final int DEFAULT_BUFFER_SIZE = 100;

    /** The buffer size of iterators created by this factory. */
    private int bufferSize = DEFAULT_BUFFER_SIZE;

    private int port = 0;

    private RMIClientSocketFactory clientSocketFactory = null;

    private RMIServerSocketFactory serverSocketFactory = null;

    /**
     * Returns the iterator buffer size.
     *
     * @return iterator buffer size
     */
    public int getBufferSize() {
        return bufferSize;
    }

    /**
     * Sets the iterator buffer size.
     *
     * @param bufferSize iterator buffer size
     */
    public void setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
    }

    /**
     * Returns the RMI port to use.
     *
     * @return RMI port number
     * @since 1.3
     */
    public int getPort() {
        return port;
    }

    /**
     * Sets the RMI port to use.
     *
     * @param port RMI port number
     * @since 1.3
     */
    public void setPort(int port) {
        this.port = port;
    }

    /**
     * Returns the RMI client socket factory to use.
     *
     * @return RMI client socket factory
     * @since 1.3
     */
    public RMIClientSocketFactory getClientSocketFactory() {
        return clientSocketFactory;
    }

    /**
     * Sets the RMI client socket factory to use.
     *
     * @param factory RMI client socket factory,
     *                or <code>null</code> to use the default
     * @since 1.3
     */
    public void setClientSocketFactory(RMIClientSocketFactory factory) {
        clientSocketFactory = factory;
    }

    /**
     * Returns the RMI server socket factory to use.
     *
     * @return RMI server socket factory
     * @since 1.3
     */
    public RMIServerSocketFactory getServerSocketFactory() {
        return serverSocketFactory;
    }

    /**
     * Sets the RMI server socket factory to use.
     *
     * @param factory RMI server socket factory,
     *                or <code>null</code> to use the default
     * @since 1.3
     */
    public void setServerSocketFactory(RMIServerSocketFactory factory) {
        serverSocketFactory = factory;
    }

    /**
     * Creates a {@link ServerRepository ServerRepository} instance.
     * {@inheritDoc}
     */
    public RemoteRepository getRemoteRepository(Repository repository)
            throws RemoteException {
        return new ServerRepository(repository, this);
    }

{'fraction_non_alphanumeric': 0.0866778149386845, 'fraction_numerical': 0.002996098104793757, 'mean_word_length': 3.597373478539398, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2502382', 'n_tokens_mistral': 4098, 'n_tokens_neox': 3959, 'n_words': 1089}