1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Do not use a reflection based initializer for core elements

like Message.Body from smack-core.
This commit is contained in:
Florian Schmaus 2018-05-09 12:37:51 +02:00
parent 09c6a9e2bc
commit ad932caf78
5 changed files with 7 additions and 37 deletions

View file

@ -1,27 +0,0 @@
/**
*
* Copyright 2018 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.smack;
import org.jivesoftware.smack.initializer.UrlInitializer;
public class CoreInitializer extends UrlInitializer {
@Override
protected String getProvidersUri() {
return "classpath:org.jivesoftware.smack/core.providers";
}
}

View file

@ -29,7 +29,9 @@ import java.util.logging.Logger;
import org.jivesoftware.smack.compression.Java7ZlibInputOutputStream; import org.jivesoftware.smack.compression.Java7ZlibInputOutputStream;
import org.jivesoftware.smack.initializer.SmackInitializer; import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.packet.Bind; import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.packet.Message.Body;
import org.jivesoftware.smack.provider.BindIQProvider; import org.jivesoftware.smack.provider.BindIQProvider;
import org.jivesoftware.smack.provider.BodyElementProvider;
import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.sasl.core.SASLAnonymous; import org.jivesoftware.smack.sasl.core.SASLAnonymous;
import org.jivesoftware.smack.sasl.core.SASLXOauth2Mechanism; import org.jivesoftware.smack.sasl.core.SASLXOauth2Mechanism;
@ -116,6 +118,7 @@ public final class SmackInitialization {
SASLAuthentication.registerSASLMechanism(new SASLAnonymous()); SASLAuthentication.registerSASLMechanism(new SASLAnonymous());
ProviderManager.addIQProvider(Bind.ELEMENT, Bind.NAMESPACE, new BindIQProvider()); ProviderManager.addIQProvider(Bind.ELEMENT, Bind.NAMESPACE, new BindIQProvider());
ProviderManager.addExtensionProvider(Body.ELEMENT, Body.NAMESPACE, new BodyElementProvider());
SmackConfiguration.smackInitialized = true; SmackConfiguration.smackInitialized = true;
} }

View file

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.compress.packet.Compress; import org.jivesoftware.smack.compress.packet.Compress;
import org.jivesoftware.smack.packet.EmptyResultIQ; import org.jivesoftware.smack.packet.EmptyResultIQ;
import org.jivesoftware.smack.packet.ErrorIQ; import org.jivesoftware.smack.packet.ErrorIQ;
@ -71,6 +72,9 @@ public class PacketParserUtils {
public static final boolean XML_PULL_PARSER_SUPPORTS_ROUNDTRIP; public static final boolean XML_PULL_PARSER_SUPPORTS_ROUNDTRIP;
static { static {
// Ensure that Smack is initialized.
SmackConfiguration.getVersion();
XmlPullParser xmlPullParser; XmlPullParser xmlPullParser;
boolean roundtrip = false; boolean roundtrip = false;
try { try {

View file

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<!-- Providers for core elements -->
<smackProviders>
<extensionProvider>
<elementName>body</elementName>
<namespace>jabber:client</namespace>
<className>org.jivesoftware.smack.provider.BodyElementProvider</className>
</extensionProvider>
</smackProviders>

View file

@ -5,7 +5,6 @@
<startupClasses> <startupClasses>
<className>org.jivesoftware.smack.initializer.VmArgInitializer</className> <className>org.jivesoftware.smack.initializer.VmArgInitializer</className>
<className>org.jivesoftware.smack.ReconnectionManager</className> <className>org.jivesoftware.smack.ReconnectionManager</className>
<className>org.jivesoftware.smack.CoreInitializer</className>
</startupClasses> </startupClasses>
<optionalStartupClasses> <optionalStartupClasses>