1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Enable OSGi compliance via 'DynamicImport-Package: *'

on package layer instead of Declarative Service (DS) approach.
Restructuring and cleanup of initialization process to ensure that all
internal config files are found by the corresponding bundle
classloaders.

SMACK-343
This commit is contained in:
Christoph Fiehe 2014-12-18 12:57:21 +01:00 committed by Florian Schmaus
parent 1f38e4ca0d
commit 665e7914f2
38 changed files with 46 additions and 191 deletions

View file

@ -1,3 +1,8 @@
// Note that this is also declared in the main build.gradle for
// subprojects, but since evaluationDependsOnChildren is enabled we
// need to declare it here too
apply plugin: 'osgi'
description = """\
Smack core components."""
@ -32,3 +37,9 @@ task createVersionResource(type: CreateFileTask) {
}
compileJava.dependsOn(createVersionResource)
jar {
manifest {
instruction 'DynamicImport-Package', '*'
}
}

View file

@ -1,31 +0,0 @@
/**
*
* Copyright 2014 Florian Schmaus
*
* 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.initializer;
import java.util.List;
public abstract class SimpleSmackInitializer implements SmackInitializer {
@Override
public abstract List<Exception> initialize();
@Override
public List<Exception> initialize(ClassLoader classLoader) {
return initialize();
}
}

View file

@ -1,36 +0,0 @@
/**
*
* Copyright 2014 Florian Schmaus
*
* 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.initializer;
import java.util.List;
public abstract class SmackAndOsgiInitializer implements SmackInitializer {
/**
* A simple wrapper around {@link #initialize} for OSGi, as the activate method of a component
* must have a void return type.
*/
public final void activate() {
initialize();
}
@Override
public List<Exception> initialize(ClassLoader classLoader) {
return initialize();
}
}

View file

@ -31,5 +31,4 @@ import org.jivesoftware.smack.SmackConfiguration;
*/
public interface SmackInitializer {
public List<Exception> initialize();
public List<Exception> initialize(ClassLoader classLoader);
}

View file

@ -34,17 +34,13 @@ import org.jivesoftware.smack.util.FileUtils;
*
* @author Florian Schmaus
*/
public abstract class UrlInitializer extends SmackAndOsgiInitializer {
public abstract class UrlInitializer implements SmackInitializer {
private static final Logger LOGGER = Logger.getLogger(UrlInitializer.class.getName());
@Override
public List<Exception> initialize() {
return initialize(this.getClass().getClassLoader());
}
@Override
public List<Exception> initialize(ClassLoader classLoader) {
InputStream is;
final ClassLoader classLoader = this.getClass().getClassLoader();
final List<Exception> exceptions = new LinkedList<Exception>();
final String providerUrl = getProvidersUrl();
if (providerUrl != null) {

View file

@ -11,10 +11,10 @@
<className>org.jivesoftware.smack.util.dns.javax.JavaxResolver</className>
<className>org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver</className>
<className>org.jivesoftware.smack.util.dns.dnsjava.DNSJavaResolver</className>
<className>org.jivesoftware.smack.initializer.extensions.ExtensionsInitializer</className>
<className>org.jivesoftware.smack.initializer.experimental.ExperimentalInitializer</className>
<className>org.jivesoftware.smack.initializer.legacy.LegacyInitializer</className>
<className>org.jivesoftware.smack.initializer.tcp.SmackTcpSmackInitializer</className>
<className>org.jivesoftware.smack.extensions.ExtensionsInitializer</className>
<className>org.jivesoftware.smack.experimental.ExperimentalInitializer</className>
<className>org.jivesoftware.smack.legacy.LegacyInitializer</className>
<className>org.jivesoftware.smack.tcp.TCPInitializer</className>
<className>org.jivesoftware.smack.sasl.javax.SASLJavaXSmackInitializer</className>
<className>org.jivesoftware.smack.sasl.provided.SASLProvidedSmackInitializer</className>
<className>org.jivesoftware.smack.android.AndroidSmackInitializer</className>