Skip to content

Commit

Permalink
Enable OSGi compliance via 'DynamicImport-Package: *'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Christoph Fiehe authored and Flowdalic committed Jan 3, 2015
1 parent 1f38e4c commit 665e791
Show file tree
Hide file tree
Showing 38 changed files with 46 additions and 191 deletions.
20 changes: 0 additions & 20 deletions build.gradle
Expand Up @@ -272,26 +272,6 @@ subprojects {
}
}

['smack-extensions', 'smack-experimental', 'smack-legacy'].each { name ->
project(":$name") {
jar {
manifest {
instruction 'Service-Component', "org.jivesoftware.smackx/$name-components.xml"
}
}
}
}

['smack-resolver-javax', 'smack-resolver-dnsjava', 'smack-resolver-minidns', 'smack-sasl-javax', 'smack-sasl-provided', 'smack-java7'] .each { name ->
project(":$name") {
jar {
manifest {
instruction 'Service-Component', "org.jivesoftware.smack/$name-components.xml"
}
}
}
}

subprojects*.jar {
manifest {
from sharedManifest
Expand Down
Expand Up @@ -20,13 +20,13 @@

import org.apache.http.conn.ssl.StrictHostnameVerifier;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.initializer.SimpleSmackInitializer;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smack.util.stringencoder.Base64UrlSafeEncoder;
import org.jivesoftware.smack.util.stringencoder.android.AndroidBase64Encoder;
import org.jivesoftware.smack.util.stringencoder.android.AndroidBase64UrlSafeEncoder;

public class AndroidSmackInitializer extends SimpleSmackInitializer {
public class AndroidSmackInitializer implements SmackInitializer {

@Override
public List<Exception> initialize() {
Expand Down
11 changes: 11 additions & 0 deletions smack-core/build.gradle
@@ -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."""

Expand Down Expand Up @@ -32,3 +37,9 @@ task createVersionResource(type: CreateFileTask) {
}

compileJava.dependsOn(createVersionResource)

jar {
manifest {
instruction 'DynamicImport-Package', '*'
}
}

This file was deleted.

This file was deleted.

Expand Up @@ -31,5 +31,4 @@
*/
public interface SmackInitializer {
public List<Exception> initialize();
public List<Exception> initialize(ClassLoader classLoader);
}
Expand Up @@ -34,17 +34,13 @@
*
* @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) {
Expand Down
Expand Up @@ -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>
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.initializer.experimental;
package org.jivesoftware.smack.experimental;

import org.jivesoftware.smack.initializer.UrlInitializer;

Expand All @@ -27,11 +27,11 @@ public class ExperimentalInitializer extends UrlInitializer {

@Override
protected String getProvidersUrl() {
return "classpath:org.jivesoftware.smackx/experimental.providers";
return "classpath:org.jivesoftware.smack.experimental/experimental.providers";
}

@Override
protected String getConfigUrl() {
return "classpath:org.jivesoftware.smackx/experimental.xml";
return "classpath:org.jivesoftware.smack.experimental/experimental.xml";
}
}

This file was deleted.

Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import org.jivesoftware.smack.initializer.experimental.ExperimentalInitializer;
import org.jivesoftware.smack.experimental.ExperimentalInitializer;
import org.junit.Test;

public class ExperimentalInitializerTest {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.initializer.extensions;
package org.jivesoftware.smack.extensions;

import org.jivesoftware.smack.initializer.UrlInitializer;

Expand All @@ -27,11 +27,11 @@ public class ExtensionsInitializer extends UrlInitializer {

@Override
protected String getProvidersUrl() {
return "classpath:org.jivesoftware.smackx/extensions.providers";
return "classpath:org.jivesoftware.smack.extensions/extensions.providers";
}

@Override
protected String getConfigUrl() {
return "classpath:org.jivesoftware.smackx/extensions.xml";
return "classpath:org.jivesoftware.smack.extensions/extensions.xml";
}
}

This file was deleted.

Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import org.jivesoftware.smack.initializer.extensions.ExtensionsInitializer;
import org.jivesoftware.smack.extensions.ExtensionsInitializer;
import org.junit.Test;

public class ExtensionsInitializerTest {
Expand Down
Expand Up @@ -16,7 +16,7 @@
*/
package org.jivesoftware.smackx;

import org.jivesoftware.smack.initializer.extensions.ExtensionsInitializer;
import org.jivesoftware.smack.extensions.ExtensionsInitializer;

public class InitExtensions {

Expand Down
Expand Up @@ -19,13 +19,13 @@
import java.util.List;

import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.initializer.SmackAndOsgiInitializer;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.stringencoder.Base64;
import org.jivesoftware.smack.util.stringencoder.Base64UrlSafeEncoder;
import org.jivesoftware.smack.util.stringencoder.java7.Java7Base64Encoder;
import org.jivesoftware.smack.util.stringencoder.java7.Java7Base64UrlSafeEncoder;

public class Java7SmackInitializer extends SmackAndOsgiInitializer {
public class Java7SmackInitializer implements SmackInitializer {

@Override
public List<Exception> initialize() {
Expand Down

This file was deleted.

Expand Up @@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.initializer.legacy;
package org.jivesoftware.smack.legacy;

import org.jivesoftware.smack.initializer.UrlInitializer;

public class LegacyInitializer extends UrlInitializer {

@Override
protected String getProvidersUrl() {
return "classpath:org.jivesoftware.smackx/legacy.providers";
return "classpath:org.jivesoftware.smack.legacy/legacy.providers";
}
}

This file was deleted.

Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import org.jivesoftware.smack.initializer.legacy.LegacyInitializer;
import org.jivesoftware.smack.legacy.LegacyInitializer;
import org.junit.Test;

public class LegacyInitializerTest {
Expand Down
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

import org.jivesoftware.smack.initializer.SmackAndOsgiInitializer;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.DNSResolver;
import org.jivesoftware.smack.util.dns.SRVRecord;
Expand All @@ -32,7 +32,7 @@
* This implementation uses the <a href="http://www.dnsjava.org/">dnsjava</a> implementation for resolving DNS addresses.
*
*/
public class DNSJavaResolver extends SmackAndOsgiInitializer implements DNSResolver {
public class DNSJavaResolver implements SmackInitializer, DNSResolver {

private static DNSJavaResolver instance = new DNSJavaResolver();

Expand Down

This file was deleted.

Expand Up @@ -27,7 +27,7 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import org.jivesoftware.smack.initializer.SmackAndOsgiInitializer;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.DNSResolver;
import org.jivesoftware.smack.util.dns.SRVRecord;
Expand All @@ -38,7 +38,7 @@
* @author Florian Schmaus
*
*/
public class JavaxResolver extends SmackAndOsgiInitializer implements DNSResolver {
public class JavaxResolver implements SmackInitializer, DNSResolver {

private static JavaxResolver instance;
private static DirContext dirContext;
Expand Down

This file was deleted.

Expand Up @@ -19,7 +19,7 @@
import java.util.LinkedList;
import java.util.List;

import org.jivesoftware.smack.initializer.SmackAndOsgiInitializer;
import org.jivesoftware.smack.initializer.SmackInitializer;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.dns.DNSResolver;
import org.jivesoftware.smack.util.dns.SRVRecord;
Expand All @@ -39,7 +39,7 @@
* This implementation uses the <a href="https://github.com/rtreffer/minidns/">minidns</a> implementation for
* resolving DNS addresses.
*/
public class MiniDnsResolver extends SmackAndOsgiInitializer implements DNSResolver {
public class MiniDnsResolver implements SmackInitializer, DNSResolver {

private static final long ONE_DAY = 24*60*60*1000;
private static final MiniDnsResolver instance = new MiniDnsResolver();
Expand Down

This file was deleted.

0 comments on commit 665e791

Please sign in to comment.