Thread: [Japi-cvs] SF.net SVN: japi:[656] libs/registry/trunk
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-10-07 18:18:31
|
Revision: 656
http://japi.svn.sourceforge.net/japi/?rev=656&view=rev
Author: christianhujer
Date: 2008-10-07 18:18:30 +0000 (Tue, 07 Oct 2008)
Log Message:
-----------
Added doc and tst directories.
Modified Paths:
--------------
libs/registry/trunk/libs-registry.iml
Added Paths:
-----------
libs/registry/trunk/src/doc/
libs/registry/trunk/src/tst/
Modified: libs/registry/trunk/libs-registry.iml
===================================================================
--- libs/registry/trunk/libs-registry.iml 2008-10-07 18:17:32 UTC (rev 655)
+++ libs/registry/trunk/libs-registry.iml 2008-10-07 18:18:30 UTC (rev 656)
@@ -3,7 +3,9 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/doc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/prj" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/tst" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-02-14 21:18:56
|
Revision: 809
http://japi.svn.sourceforge.net/japi/?rev=809&view=rev
Author: christianhujer
Date: 2009-02-14 21:18:53 +0000 (Sat, 14 Feb 2009)
Log Message:
-----------
Updated copyright statements in source code.
Modified Paths:
--------------
libs/registry/trunk/build.xml
libs/registry/trunk/module.properties
libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java
libs/registry/trunk/src/prj/net/sf/japi/registry/NamedService.java
Modified: libs/registry/trunk/build.xml
===================================================================
--- libs/registry/trunk/build.xml 2009-02-14 21:18:19 UTC (rev 808)
+++ libs/registry/trunk/build.xml 2009-02-14 21:18:53 UTC (rev 809)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ JAPI libs-registry is a library for handling multiple interface implementations.
- ~ Copyright (C) 2007 Christian Hujer.
+ ~ Copyright (C) 2009 Christian Hujer.
~
~ This library is free software; you can redistribute it and/or
~ modify it under the terms of the GNU Lesser General Public
Modified: libs/registry/trunk/module.properties
===================================================================
--- libs/registry/trunk/module.properties 2009-02-14 21:18:19 UTC (rev 808)
+++ libs/registry/trunk/module.properties 2009-02-14 21:18:53 UTC (rev 809)
@@ -1,6 +1,5 @@
#
-# JAPI libs-registry is a library for providing a framework implementation lookup mechanism.
-# Copyright (C) 2007 Christian Hujer.
+# Copyright (C) 2009 Christian Hujer.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Modified: libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java
===================================================================
--- libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java 2009-02-14 21:18:19 UTC (rev 808)
+++ libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java 2009-02-14 21:18:53 UTC (rev 809)
@@ -1,6 +1,5 @@
/*
- * JAPI libs-registry is a library for providing a framework implementation lookup mechanism.
- * Copyright (C) 2007 Christian Hujer.
+ * Copyright (C) 2009 Christian Hujer.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: libs/registry/trunk/src/prj/net/sf/japi/registry/NamedService.java
===================================================================
--- libs/registry/trunk/src/prj/net/sf/japi/registry/NamedService.java 2009-02-14 21:18:19 UTC (rev 808)
+++ libs/registry/trunk/src/prj/net/sf/japi/registry/NamedService.java 2009-02-14 21:18:53 UTC (rev 809)
@@ -1,6 +1,5 @@
/*
- * JAPI libs-registry is a library for providing a framework implementation lookup mechanism.
- * Copyright (C) 2007 Christian Hujer.
+ * Copyright (C) 2009 Christian Hujer.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-09-11 19:53:25
|
Revision: 1375
http://japi.svn.sourceforge.net/japi/?rev=1375&view=rev
Author: christianhujer
Date: 2009-09-11 19:53:17 +0000 (Fri, 11 Sep 2009)
Log Message:
-----------
Make registry compatible with 1.6 and 1.5 at the same time.
Modified Paths:
--------------
libs/registry/trunk/build.xml
libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java
Modified: libs/registry/trunk/build.xml
===================================================================
--- libs/registry/trunk/build.xml 2009-07-26 10:41:50 UTC (rev 1374)
+++ libs/registry/trunk/build.xml 2009-09-11 19:53:17 UTC (rev 1375)
@@ -21,6 +21,8 @@
]>
<project name="japi lib registry" default="all">
+ <property name="javaversion" value="1.5" />
+
&commonBuild;
</project>
Modified: libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java
===================================================================
--- libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java 2009-07-26 10:41:50 UTC (rev 1374)
+++ libs/registry/trunk/src/prj/net/sf/japi/registry/NamedRegistry.java 2009-09-11 19:53:17 UTC (rev 1375)
@@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.ServiceLoader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import sun.misc.Service;
@@ -46,7 +47,7 @@
* @return Implementation or <code>null</code> if none found.
*/
@Nullable public static <T extends NamedService> T getInstance(@NotNull final Class<T> service, @NotNull final String name) {
- for (final Iterator<T> it = Service.providers(service); it.hasNext();) {
+ for (final Iterator<T> it = instanceIterator(service); it.hasNext();) {
final T t = it.next();
if (t.getName().equals(name)) {
return t;
@@ -65,7 +66,7 @@
*/
@NotNull public static <T> Collection<T> getAllInstances(@NotNull final Class<T> service) {
final List<T> instances = new ArrayList<T>();
- for (final Iterator<T> it = Service.providers(service); it.hasNext();) {
+ for (final Iterator<T> it = instanceIterator(service); it.hasNext();) {
instances.add(it.next());
}
return instances;
@@ -79,7 +80,7 @@
* @return Implementation or <code>null</code> if none found.
*/
@Nullable public static <T extends NamedService> T getInstance(@NotNull final Class<T> service, @NotNull final String name, @NotNull final ClassLoader classLoader) {
- for (final Iterator<T> it = Service.providers(service, classLoader); it.hasNext();) {
+ for (final Iterator<T> it = instanceIterator(service, classLoader); it.hasNext();) {
final T t = it.next();
if (t.getName().equals(name)) {
return t;
@@ -98,11 +99,39 @@
* @return List with all implementations, empty collection if none found.
*/
@NotNull public static <T> Collection<T> getAllInstances(@NotNull final Class<T> service, @NotNull final ClassLoader classLoader) {
- final List<T> instances = new ArrayList<T>();
- for (final Iterator<T> it = Service.providers(service, classLoader); it.hasNext();) {
+ final Collection<T> instances = new ArrayList<T>();
+ for (final Iterator<T> it = instanceIterator(service, classLoader); it.hasNext();) {
instances.add(it.next());
}
return instances;
}
-} // class NamedRegistry
+ /**
+ * Returns a Service iterator.
+ * On JDK1.6 and later, the Iterator is created using {@link ServiceLoader}, on earlier platforms it is created using {@link Service}.
+ * @param service Class for which to return a service iterator.
+ * @return Iterator for {@code service}.
+ */
+ @NotNull public static <T> Iterator<T> instanceIterator(@NotNull final Class<T> service) {
+ try {
+ return ServiceLoader.load(service).iterator();
+ } catch (final NoClassDefFoundError e) {
+ return Service.providers(service);
+ }
+ }
+
+ /**
+ * Returns a Service iterator.
+ * On JDK1.6 and later, the Iterator is created using {@link ServiceLoader}, on earlier platforms it is created using {@link Service}.
+ * @param service Class for which to return a service iterator.
+ * @param classLoader ClassLoader to use.
+ * @return Iterator for {@code service}.
+ */
+ @NotNull public static <T> Iterator<T> instanceIterator(@NotNull final Class<T> service, @NotNull final ClassLoader classLoader) {
+ try {
+ return ServiceLoader.load(service, classLoader).iterator();
+ } catch (final NoClassDefFoundError e) {
+ return Service.providers(service, classLoader);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|