Smack/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferManager.java

58 lines
1.8 KiB
Java
Raw Normal View History

2017-05-30 18:20:54 +02:00
/**
*
* Copyright 2017 Paul Schaub
*
* Licensed 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.jivesoftware.smackx.jingle_filetransfer;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import java.util.WeakHashMap;
/**
* Manager for Jingle File Transfers.
*
* @author Paul Schaub
*/
public final class JingleFileTransferManager extends Manager {
public static final String NAMESPACE = "urn:xmpp:jingle:apps:file-transfer:5";
private static final WeakHashMap<XMPPConnection, JingleFileTransferManager> INSTANCES = new WeakHashMap<>();
/**
* Private constructor.
* @param connection connection
*/
private JingleFileTransferManager(XMPPConnection connection) {
super(connection);
}
/**
* Return a new instance of the FileTransferManager for the given connection.
*
* @param connection XMPPConnection we wish to get a FileTransferManager for.
* @return manager instance.
*/
public static JingleFileTransferManager getInstanceFor(XMPPConnection connection) {
JingleFileTransferManager manager = INSTANCES.get(connection);
if (manager == null) {
manager = new JingleFileTransferManager(connection);
INSTANCES.put(connection, manager);
}
return manager;
}
}