Skip to content

Commit a8ee1b6

Browse files
committed
OF-3161: Remove deprecated code
This removes most code that has been marked for removal in version 5.1.0 of Openfire.
1 parent 63ff43d commit a8ee1b6

File tree

11 files changed

+5
-1686
lines changed

11 files changed

+5
-1686
lines changed

xmppserver/src/main/java/org/jivesoftware/openfire/ConnectionCloseListener.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@
2828
*/
2929
public interface ConnectionCloseListener
3030
{
31-
/**
32-
* Called when a connection is being closed.
33-
*
34-
* @param handback The handback object associated with the connection listener during Connection.registerCloseListener()
35-
* @deprecated replaced by {@link #onConnectionClosing(Object)}
36-
*/
37-
@Deprecated(forRemoval = true) // Remove in or after Openfire 5.1.0
38-
default void onConnectionClose( Object handback ) {};
39-
4031
/**
4132
* Called when a connection is being closed.
4233
*
@@ -46,17 +37,5 @@ public interface ConnectionCloseListener
4637
* @param handback The handback object associated with the connection listener during Connection.registerCloseListener()
4738
* @return a Future representing pending completion of the event listener invocation.
4839
*/
49-
default CompletableFuture<Void> onConnectionClosing(@Nullable final Object handback)
50-
{
51-
// The default implementation is a blocking invocation of the method that is being replaced: onConnectionClose()
52-
// This is designed to facilitate a graceful migration, where pre-existing implementations of this interface
53-
// will continue to work without change. When the deprecated method is deleted, this default implementation
54-
// should also be removed.
55-
try {
56-
onConnectionClose(handback);
57-
} catch (Throwable t) {
58-
return CompletableFuture.failedFuture(t);
59-
}
60-
return CompletableFuture.completedFuture(null);
61-
}
40+
CompletableFuture<Void> onConnectionClosing(@Nullable final Object handback);
6241
}

xmppserver/src/main/java/org/jivesoftware/openfire/RoutingTable.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,6 @@ public interface RoutingTable {
162162
*/
163163
boolean hasClientRoute(JID jid);
164164

165-
/**
166-
* Returns true if an anonymous user with the specified full JID is currently logged.
167-
* When running inside of a cluster a true value will be returned as long as the
168-
* user is connected to any cluster node.
169-
*
170-
* @param jid the full JID of the anonymous user.
171-
* @return true if an anonymous user with the specified full JID is currently logged.
172-
* @deprecated Replaced by {@link SessionManager#isAnonymousClientSession(JID)}
173-
*/
174-
@Deprecated(forRemoval = true, since = "5.0.0") // Remove in or after Openfire 5.1.0
175-
boolean isAnonymousRoute(JID jid);
176-
177165
/**
178166
* Returns true if the specified address belongs to a route that is hosted by this JVM.
179167
* When running inside of a cluster each cluster node will host routes to local resources.

xmppserver/src/main/java/org/jivesoftware/openfire/SessionManager.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -868,22 +868,6 @@ public boolean isAnonymousClientSession(@Nonnull final JID address) {
868868
return session != null && session.isAnonymousUser();
869869
}
870870

871-
/**
872-
* @deprecated Replaced by {@link #isAnonymousClientSession(String)}
873-
*/
874-
@Deprecated(forRemoval = true, since = "5.0.0") // Remove in or after Openfire 5.1.0
875-
public boolean isAnonymousRoute(String username) {
876-
return isAnonymousClientSession(username);
877-
}
878-
879-
/**
880-
* @deprecated Replaced by {@link #isAnonymousClientSession(JID)}
881-
*/
882-
@Deprecated(forRemoval = true, since = "5.0.0") // Remove in or after Openfire 5.1.0
883-
public boolean isAnonymousRoute(JID address) {
884-
return isAnonymousClientSession(address);
885-
}
886-
887871
public boolean isActiveRoute(String username, String resource) {
888872
boolean hasRoute = false;
889873
Session session = routingTable.getClientRoute(new JID(username, serverName, resource));

xmppserver/src/main/java/org/jivesoftware/openfire/net/DNSUtil.java

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import javax.naming.directory.Attributes;
3333
import javax.naming.directory.DirContext;
3434
import javax.naming.directory.InitialDirContext;
35-
import java.io.Serializable;
3635
import java.util.*;
3736
import java.util.stream.Collectors;
3837

@@ -369,121 +368,4 @@ public static boolean isNameCoveredByPattern( String name, String pattern )
369368
}
370369
return false;
371370
}
372-
373-
/**
374-
* Encapsulates a hostname and port.
375-
*
376-
* @deprecated Replaced by {@link SrvRecord}
377-
*/
378-
@Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0
379-
public static class HostAddress implements Serializable {
380-
381-
private final SrvRecord delegate;
382-
383-
public HostAddress(String host, int port, boolean directTLS) {
384-
delegate = new SrvRecord(host, port, directTLS);
385-
}
386-
387-
public String getHost() {
388-
return delegate.getHostname();
389-
}
390-
391-
public int getPort() {
392-
return delegate.getPort();
393-
}
394-
395-
public boolean isDirectTLS() {
396-
return delegate.isDirectTLS();
397-
}
398-
399-
@Override
400-
public String toString() {
401-
return delegate.getHostname() + ":" + delegate.getHostname();
402-
}
403-
}
404-
405-
/**
406-
* @deprecated Replaced by {@link SrvRecord#prioritize(SrvRecord[])}
407-
*/
408-
@Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0
409-
public static List<WeightedHostAddress> prioritize(WeightedHostAddress[] records) {
410-
final List<WeightedHostAddress> result = new LinkedList<>();
411-
412-
// sort by priority (ascending)
413-
final Set<SrvRecord> delegates = Arrays.stream(records).map(WeightedHostAddress::getDelegate).collect(Collectors.toSet());
414-
final List<Set<SrvRecord>> prioritized = SrvRecord.prioritize(delegates);
415-
for (Set<SrvRecord> set : prioritized) {
416-
final LinkedHashSet<WeightedHostAddress> orderedSet = new LinkedHashSet<>(); // Retain the order in the set!
417-
for (final SrvRecord e : set) {
418-
orderedSet.add(new WeightedHostAddress(e));
419-
}
420-
result.addAll(orderedSet);
421-
}
422-
return result;
423-
}
424-
425-
@Deprecated(since = "5.0.0", forRemoval = true) // Remove in or after Openfire 5.1.0
426-
public static class WeightedHostAddress extends HostAddress
427-
{
428-
private final SrvRecord delegate;
429-
430-
static WeightedHostAddress from(HostAddress address) {
431-
if (address instanceof WeightedHostAddress) {
432-
return (WeightedHostAddress) address;
433-
}
434-
435-
return new WeightedHostAddress(address.getHost(), address.getPort(), address.isDirectTLS(), 0, 0);
436-
}
437-
438-
private WeightedHostAddress(@Nonnull final SrvRecord delegate) {
439-
this(delegate.getHostname(), delegate.getPort(), delegate.isDirectTLS(), delegate.getPriority(), delegate.getWeight());
440-
}
441-
442-
private WeightedHostAddress(String[] srvRecordEntries, boolean directTLS) {
443-
// Host entries in DNS should end with a ".".
444-
super(
445-
srvRecordEntries[srvRecordEntries.length-1].endsWith(".") ? srvRecordEntries[srvRecordEntries.length-1].substring(0, srvRecordEntries[srvRecordEntries.length-1].length()-1) : srvRecordEntries[srvRecordEntries.length-1],
446-
Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]),
447-
directTLS
448-
);
449-
delegate = new SrvRecord(super.getHost(), super.getPort(), super.isDirectTLS(), Integer.parseInt(srvRecordEntries[srvRecordEntries.length-3]), Integer.parseInt(srvRecordEntries[srvRecordEntries.length-4]));
450-
}
451-
452-
WeightedHostAddress(String host, int port, boolean directTLS, int priority, int weight) {
453-
super(host, port, directTLS);
454-
delegate = new SrvRecord(host, port, directTLS, priority, weight);
455-
}
456-
457-
public int getPriority() {
458-
return delegate.getPriority();
459-
}
460-
461-
public int getWeight() {
462-
return delegate.getWeight();
463-
}
464-
465-
SrvRecord getDelegate() {
466-
return delegate;
467-
}
468-
469-
@Override
470-
public boolean equals(Object o)
471-
{
472-
if (this == o) return true;
473-
if (o == null || getClass() != o.getClass()) return false;
474-
WeightedHostAddress that = (WeightedHostAddress) o;
475-
return Objects.equals(delegate, that.delegate);
476-
}
477-
478-
@Override
479-
public int hashCode()
480-
{
481-
return Objects.hashCode(delegate);
482-
}
483-
484-
@Override
485-
public String toString() {
486-
return "prio: " + delegate.getPriority() + ", weight: " + delegate.getWeight() + ", port: " + getPort() + ", host: " + getHost() + ", isDirectTLS: " + isDirectTLS();
487-
}
488-
}
489371
}

xmppserver/src/main/java/org/jivesoftware/openfire/session/LocalSession.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -421,43 +421,19 @@ public void process(Packet packet) {
421421
}
422422
}
423423

424-
/**
425-
* Returns true if the specified packet can be delivered to the entity. Subclasses will use different
426-
* criterias to determine of processing is allowed or not. For instance, client sessions will use
427-
* privacy lists while outgoing server sessions will always allow this action.
428-
*
429-
* @param packet the packet to analyze if it must be blocked.
430-
* @return false if the specified packet must be blocked.
431-
*/
432-
@Deprecated(forRemoval = true) // Remove in or after Openfire 5.1.0.
433-
boolean canProcess(Packet packet) {
434-
return true;
435-
}
436-
437424
/**
438425
* Returns true if the specified stanza can be delivered to the entity.
439426
*
440427
* Subclasses will use different criteria to determine of processing is allowed or not. For instance, client
441428
* sessions will use privacy lists while component sessions will always allow this action.
442429
*
443-
* When a stanza is cannot be delivered, an implementation must take responsibility for error handling. If, for
430+
* When a stanza cannot be delivered, an implementation must take responsibility for error handling. If, for
444431
* example, an error stanza is to be sent back to the sender, this is to be performed by the implementation.
445432
*
446433
* @param stanza the stanza to analyze if it must be blocked.
447434
* @return false if the specified stanza must be blocked.
448435
*/
449-
boolean canDeliver(@Nonnull final Packet stanza) {
450-
// This implementation exists only for backwards compatibility purposes. When #canProcess() is removed, this
451-
// implementation will also be removed (every subclass is then expected to provide its own implementation of
452-
// the #canDeliver interface method).
453-
final boolean canProcess = canProcess(stanza);
454-
455-
if (!canProcess) {
456-
LocalClientSession.returnPrivacyListErrorToSender(stanza);
457-
}
458-
459-
return canProcess;
460-
}
436+
abstract boolean canDeliver(@Nonnull final Packet stanza);
461437

462438
abstract void deliver(Packet packet) throws UnauthorizedException;
463439

xmppserver/src/main/java/org/jivesoftware/openfire/spi/RoutingTableImpl.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -895,15 +895,6 @@ public boolean hasClientRoute(JID jid) {
895895
}
896896
}
897897

898-
@Deprecated(forRemoval = true, since = "5.0.0") // Remove in or after Openfire 5.1.0 @Override
899-
public boolean isAnonymousRoute(JID jid) {
900-
if (jid.getNode() == null || jid.getResource() == null) {
901-
Log.trace("isAnonymousRoute() invoked with a JID that's not a full JID: {}", jid);
902-
return false;
903-
}
904-
return server.getSessionManager().isAnonymousClientSession(jid);
905-
}
906-
907898
@Override
908899
public boolean isLocalRoute(JID jid) {
909900
return localClientRoutingTable.isLocalRoute(jid) || localServerRoutingTable.isLocalRoute(jid) || localComponentRoutingTable.isLocalRoute(jid);

xmppserver/src/main/java/org/jivesoftware/openfire/update/Update.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ public class Update {
5050
*/
5151
private boolean downloaded;
5252

53-
@Deprecated(forRemoval = true) // Remove in or after Openfire 5.1.0
54-
public Update(String componentName, String latestVersion, String changelog, String url) {
55-
this.componentName = componentName;
56-
this.latestVersion = new Version(latestVersion);
57-
this.changelog = changelog;
58-
this.url = url;
59-
}
60-
6153
public Update(String componentName, Version latestVersion, String changelog, String url) {
6254
this.componentName = componentName;
6355
this.latestVersion = latestVersion;

xmppserver/src/main/java/org/jivesoftware/openfire/user/property/UserPropertyMultiProvider.java

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Ignite Realtime Foundation. All rights reserved
2+
* Copyright (C) 2024-2025 Ignite Realtime Foundation. All rights reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
1616
package org.jivesoftware.openfire.user.property;
1717

1818
import org.jivesoftware.openfire.user.UserNotFoundException;
19-
import org.jivesoftware.util.ClassUtils;
20-
import org.jivesoftware.util.JiveGlobals;
2119
import org.jivesoftware.util.SystemProperty;
2220
import org.slf4j.Logger;
2321
import org.slf4j.LoggerFactory;
@@ -37,41 +35,6 @@ public abstract class UserPropertyMultiProvider implements UserPropertyProvider
3735
{
3836
private final static Logger Log = LoggerFactory.getLogger(UserPropertyMultiProvider.class);
3937

40-
/**
41-
* Instantiates a UserPropertyProvider based on a property value (that is expected to be a class name). When the
42-
* property is not set, this method returns null. When the property is set, but an exception occurs while
43-
* instantiating the class, this method logs the error and returns null.
44-
*
45-
* UserPropertyProvider classes are required to have a public, no-argument constructor.
46-
*
47-
* @param propertyName A property name (cannot be null).
48-
* @return A user provider (can be null).
49-
* @deprecated Use {@link #instantiate(SystemProperty)} or {@link #instantiate(SystemProperty, SystemProperty)} instead.
50-
*/
51-
@Deprecated(forRemoval = true, since = "5.0.0") // TODO Remove in or after Openfire 5.1.0
52-
public static UserPropertyProvider instantiate( String propertyName )
53-
{
54-
final String className = JiveGlobals.getProperty( propertyName );
55-
if ( className == null )
56-
{
57-
Log.debug( "Property '{}' is undefined. Skipping.", propertyName );
58-
return null;
59-
}
60-
Log.debug( "About to to instantiate an UserPropertyProvider '{}' based on the value of property '{}'.", className, propertyName );
61-
try
62-
{
63-
final Class c = ClassUtils.forName( className );
64-
final UserPropertyProvider provider = (UserPropertyProvider) c.newInstance();
65-
Log.debug( "Instantiated UserPropertyProvider '{}'", className );
66-
return provider;
67-
}
68-
catch ( Exception e )
69-
{
70-
Log.error( "Unable to load UserPropertyProvider '{}'. Users in this provider will be disabled.", className, e );
71-
return null;
72-
}
73-
}
74-
7538
/**
7639
* Instantiates a UserPropertyProvider based on Class-based system property. When the property is not set, this
7740
* method returns null. When the property is set, but an exception occurs while instantiating the class, this method

0 commit comments

Comments
 (0)