felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlean...@apache.org
Subject svn commit: r1786633 - in /felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl: Activator.java SchematizerImpl.java
Date Mon, 13 Mar 2017 07:07:13 GMT
Author: dleangen
Date: Mon Mar 13 07:07:13 2017
New Revision: 1786633

URL: http://svn.apache.org/viewvc?rev=1786633&view=rev
Log:
FELIX-5588: Schematizer service now implements ServiceFactory<Schematizer>

Modified:
    felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Activator.java
    felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java

Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Activator.java?rev=1786633&r1=1786632&r2=1786633&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Activator.java
(original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/Activator.java
Mon Mar 13 07:07:13 2017
@@ -23,6 +23,7 @@ import org.apache.felix.schematizer.Sche
 import org.apache.felix.serializer.impl.json.JsonSerializerImpl;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
 import org.osgi.service.serializer.Serializer;
 
 public class Activator implements BundleActivator {
@@ -35,7 +36,7 @@ public class Activator implements Bundle
         jsonProps.put("provider", "felix");
         context.registerService(Serializer.class, new JsonSerializerImpl(), jsonProps);
 
-        context.registerService(Schematizer.class, new SchematizerImpl(), null);
+        context.registerService(Schematizer.class, (ServiceFactory<Schematizer>)new
SchematizerImpl(), null);
     }
 
     @Override

Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java?rev=1786633&r1=1786632&r2=1786633&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
(original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/schematizer/impl/SchematizerImpl.java
Mon Mar 13 07:07:13 2017
@@ -44,16 +44,35 @@ import org.apache.felix.schematizer.Sche
 import org.apache.felix.schematizer.Schematizer;
 import org.apache.felix.schematizer.TypeRule;
 import org.osgi.dto.DTO;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.util.converter.StandardConverter;
 import org.osgi.util.converter.TypeReference;
 
-public class SchematizerImpl implements Schematizer {
+public class SchematizerImpl implements Schematizer, ServiceFactory<Schematizer> {
 
     private final Map<String, SchemaImpl> schemas = new HashMap<>();
     private volatile Map<String, Map<String, Object>> typeRules = new HashMap<>();
     private final List<ClassLoader> classloaders = new ArrayList<>();
 
     @Override
+    public Schematizer getService( Bundle bundle, ServiceRegistration<Schematizer>
registration ) {
+        return this;
+    }
+
+    @Override
+    public void ungetService(Bundle bundle, ServiceRegistration<Schematizer> registration,
Schematizer service) {
+        // For now, a brutish, simplistic version. If there is any change to the environment,
just
+        // wipe the state and start over.
+        //
+        // TODO: something more precise, which will remove only the classes that are no longer
valid (if that is possible).
+        schemas.clear();
+        typeRules.clear();
+        classloaders.clear();
+    }
+
+    @Override
     public Optional<Schema> get(String name) {
         if (!schemas.containsKey(name)) {
             SchemaImpl schema = schematize(name, "");



Mime
View raw message