1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Remove API parts scheduled to be removed in Smack 4.3

This commit is contained in:
Florian Schmaus 2017-08-16 14:31:46 +02:00
parent 80eaaf2d71
commit ba323b51f9
11 changed files with 39 additions and 158 deletions

View file

@ -75,7 +75,7 @@ public interface BytestreamManager {
*
* @param initiatorJID the JID of the user the listener should be removed
*/
public void removeIncomingBytestreamListener(String initiatorJID);
public void removeIncomingBytestreamListener(Jid initiatorJID);
/**
* Establishes a bytestream with the given user and returns the session to send/receive data

View file

@ -282,9 +282,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @param initiatorJID the JID of the user the listener should be removed
*/
@Override
// TODO: Change argument to Jid in Smack 4.3.
@SuppressWarnings("CollectionIncompatibleType")
public void removeIncomingBytestreamListener(String initiatorJID) {
public void removeIncomingBytestreamListener(Jid initiatorJID) {
this.userListeners.remove(initiatorJID);
}

View file

@ -245,10 +245,8 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*
* @param initiatorJID the JID of the user the listener should be removed
*/
// TODO: Change parameter to Jid in Smack 4.3.
@Override
@SuppressWarnings("CollectionIncompatibleType")
public void removeIncomingBytestreamListener(String initiatorJID) {
public void removeIncomingBytestreamListener(Jid initiatorJID) {
this.userListeners.remove(initiatorJID);
}

View file

@ -408,9 +408,7 @@ public final class EntityCapsManager extends Manager {
* @param user
* the user (Full JID)
*/
// TODO: Change parameter type to Jid in Smack 4.3.
@SuppressWarnings("CollectionIncompatibleType")
public static void removeUserCapsNode(String user) {
public static void removeUserCapsNode(Jid user) {
// While JID_TO_NODEVER_CHACHE has the generic types <Jid, NodeVerHash>, it is ok to call remove with String
// arguments, since the same Jid and String representations would be equal and have the same hash code.
JID_TO_NODEVER_CACHE.remove(user);

View file

@ -205,15 +205,8 @@ public final class AdHocCommandManager extends Manager {
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
registerCommand(node, name, new LocalCommandFactory() {
@Override
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
try {
return clazz.getConstructor().newInstance();
}
catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) {
// TODO: Throw those method in Smack 4.3.
throw new IllegalStateException(e);
}
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
return clazz.getConstructor().newInstance();
}
});
}
@ -361,7 +354,15 @@ public final class AdHocCommandManager extends Manager {
try {
// Create a new instance of the command with the
// corresponding sessioid
LocalCommand command = newInstanceOfCmd(commandNode, sessionId);
LocalCommand command;
try {
command = newInstanceOfCmd(commandNode, sessionId);
}
catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
XMPPError.Builder xmppError = XMPPError.getBuilder().setCondition(XMPPError.Condition.internal_server_error).setDescriptiveEnText(e.getMessage());
return respondError(response, xmppError);
}
response.setType(IQ.Type.result);
command.setData(response);
@ -627,26 +628,22 @@ public final class AdHocCommandManager extends Manager {
* @param sessionID the session id of this execution.
* @return the command instance to execute.
* @throws XMPPErrorException if there is problem creating the new instance.
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InstantiationException
*/
@SuppressWarnings("deprecation")
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID) throws XMPPErrorException
{
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, SecurityException {
AdHocCommandInfo commandInfo = commands.get(commandNode);
LocalCommand command;
try {
command = commandInfo.getCommandInstance();
command.setSessionID(sessionID);
command.setName(commandInfo.getName());
command.setNode(commandInfo.getNode());
}
catch (InstantiationException e) {
throw new XMPPErrorException(XMPPError.getBuilder(
XMPPError.Condition.internal_server_error));
}
catch (IllegalAccessException e) {
throw new XMPPErrorException(XMPPError.getBuilder(
XMPPError.Condition.internal_server_error));
}
LocalCommand command = commandInfo.getCommandInstance();
command.setSessionID(sessionID);
command.setName(commandInfo.getName());
command.setNode(commandInfo.getNode());
return command;
}
@ -680,7 +677,7 @@ public final class AdHocCommandManager extends Manager {
}
public LocalCommand getCommandInstance() throws InstantiationException,
IllegalAccessException
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
{
return factory.getInstance();
}

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.commands;
import java.lang.reflect.InvocationTargetException;
/**
* A factory for creating local commands. It's useful in cases where instantiation
* of a command is more complicated than just using the default constructor. For example,
@ -34,7 +36,11 @@ public interface LocalCommandFactory {
* @return a LocalCommand instance.
* @throws InstantiationException if creating an instance failed.
* @throws IllegalAccessException if creating an instance is not allowed.
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
*/
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException;
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException;
}