You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/14 00:13:00 UTC
svn commit: r1730281 - in
/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator:
Activator.java OSGiOMMetaFactoryLocator.java
PriorityBasedOMMetaFactoryLocator.java RegisteredImplementation.java
Author: veithen
Date: Sat Feb 13 23:13:00 2016
New Revision: 1730281
URL: http://svn.apache.org/viewvc?rev=1730281&view=rev
Log:
Use generics, which are supported by recent versions of the OSGi APIs.
Modified:
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/RegisteredImplementation.java
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java?rev=1730281&r1=1730280&r2=1730281&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/Activator.java Sat Feb 13 23:13:00 2016
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.locator;
+import java.util.List;
+
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMMetaFactoryLocator;
import org.apache.axiom.om.util.StAXUtils;
@@ -36,14 +38,14 @@ import org.osgi.util.tracker.BundleTrack
public class Activator implements BundleActivator {
private static final Log log = LogFactory.getLog(Activator.class);
- private BundleTracker tracker;
+ private BundleTracker<List<RegisteredImplementation>> tracker;
public void start(BundleContext context) throws Exception {
OSGiOMMetaFactoryLocator locator = new OSGiOMMetaFactoryLocator(context);
OMAbstractFactory.setMetaFactoryLocator(locator);
// Bundle.STARTING covers the case where the implementation bundle has
// "Bundle-ActivationPolicy: lazy".
- tracker = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE, locator);
+ tracker = new BundleTracker<List<RegisteredImplementation>>(context, Bundle.STARTING | Bundle.ACTIVE, locator);
tracker.open();
// In an OSGi environment, the thread context class loader is generally not set in a meaningful way.
// Therefore we should use singleton factories. Note that if the StAX API is provided by Geronimo's or
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java?rev=1730281&r1=1730280&r2=1730281&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/OSGiOMMetaFactoryLocator.java Sat Feb 13 23:13:00 2016
@@ -31,7 +31,7 @@ import org.osgi.framework.ServiceReferen
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.BundleTrackerCustomizer;
-final class OSGiOMMetaFactoryLocator extends PriorityBasedOMMetaFactoryLocator implements BundleTrackerCustomizer {
+final class OSGiOMMetaFactoryLocator extends PriorityBasedOMMetaFactoryLocator implements BundleTrackerCustomizer<List<RegisteredImplementation>> {
private final BundleContext apiBundleContext;
private final List<Implementation> implementations = new ArrayList<Implementation>();
@@ -44,7 +44,7 @@ final class OSGiOMMetaFactoryLocator ext
return super.getOMMetaFactory(feature);
}
- public Object addingBundle(Bundle bundle, BundleEvent event) {
+ public List<RegisteredImplementation> addingBundle(Bundle bundle, BundleEvent event) {
URL descriptorUrl = bundle.getEntry(ImplementationFactory.DESCRIPTOR_RESOURCE);
if (descriptorUrl != null) {
List<Implementation> discoveredImplementations = ImplementationFactory.parseDescriptor(new OSGiLoader(bundle), descriptorUrl);
@@ -57,8 +57,8 @@ final class OSGiOMMetaFactoryLocator ext
Hashtable<String,String> properties = new Hashtable<String,String>();
properties.put("implementationName", implementation.getName());
// TODO: we should add the features and priorities to the properties as well
- ServiceRegistration registration = bundle.getBundleContext().registerService(OMMetaFactory.class.getName(), implementation.getMetaFactory(), properties);
- ServiceReference reference = registration.getReference();
+ ServiceRegistration<OMMetaFactory> registration = bundle.getBundleContext().registerService(OMMetaFactory.class, implementation.getMetaFactory(), properties);
+ ServiceReference<OMMetaFactory> reference = registration.getReference();
// Let the OSGi runtime know that the axiom-api bundle is using the service
apiBundleContext.getService(reference);
registeredImplementations.add(new RegisteredImplementation(implementation, registration, reference));
@@ -69,11 +69,11 @@ final class OSGiOMMetaFactoryLocator ext
}
}
- public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+ public void modifiedBundle(Bundle bundle, BundleEvent event, List<RegisteredImplementation> object) {
}
- public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
- for (RegisteredImplementation registeredImplementation : ((List<RegisteredImplementation>)object)) {
+ public void removedBundle(Bundle bundle, BundleEvent event, List<RegisteredImplementation> object) {
+ for (RegisteredImplementation registeredImplementation : object) {
apiBundleContext.ungetService(registeredImplementation.getReference());
registeredImplementation.getRegistration().unregister();
synchronized (this) {
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java?rev=1730281&r1=1730280&r2=1730281&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/PriorityBasedOMMetaFactoryLocator.java Sat Feb 13 23:13:00 2016
@@ -41,7 +41,7 @@ class PriorityBasedOMMetaFactoryLocator
Feature feature = features[i];
String name = feature.getName();
int priority = feature.getPriority();
- Integer highestPriority = (Integer)priorityMap.get(name);
+ Integer highestPriority = priorityMap.get(name);
if (highestPriority == null || priority > highestPriority.intValue()) {
priorityMap.put(name, Integer.valueOf(priority));
factories.put(name, implementation.getMetaFactory());
@@ -61,6 +61,6 @@ class PriorityBasedOMMetaFactoryLocator
}
public OMMetaFactory getOMMetaFactory(String feature) {
- return (OMMetaFactory)factories.get(feature);
+ return factories.get(feature);
}
}
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/RegisteredImplementation.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/RegisteredImplementation.java?rev=1730281&r1=1730280&r2=1730281&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/RegisteredImplementation.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/locator/RegisteredImplementation.java Sat Feb 13 23:13:00 2016
@@ -18,16 +18,17 @@
*/
package org.apache.axiom.locator;
+import org.apache.axiom.om.OMMetaFactory;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
class RegisteredImplementation {
private final Implementation implementation;
- private final ServiceRegistration registration;
- private final ServiceReference reference;
+ private final ServiceRegistration<OMMetaFactory> registration;
+ private final ServiceReference<OMMetaFactory> reference;
RegisteredImplementation(Implementation implementation,
- ServiceRegistration registration, ServiceReference reference) {
+ ServiceRegistration<OMMetaFactory> registration, ServiceReference<OMMetaFactory> reference) {
this.implementation = implementation;
this.registration = registration;
this.reference = reference;
@@ -37,11 +38,11 @@ class RegisteredImplementation {
return implementation;
}
- ServiceRegistration getRegistration() {
+ ServiceRegistration<OMMetaFactory> getRegistration() {
return registration;
}
- ServiceReference getReference() {
+ ServiceReference<OMMetaFactory> getReference() {
return reference;
}
}