geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1031366 - in /geronimo/server/trunk/plugins/myfaces/geronimo-myfaces: ./ src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ src/main/java/org/apache/geronimo/...
Date Fri, 05 Nov 2010 00:12:19 GMT
Author: djencks
Date: Fri Nov  5 00:12:19 2010
New Revision: 1031366

URL: http://svn.apache.org/viewvc?rev=1031366&view=rev
Log:
GERONIMO-5050, GERONIMO-5561 Add a bundle tracker to look up META-INF/faces-config.xml files
in other bundles such as openwebbeans-jsf.

Added:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java
      - copied, changed from r939034, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
  (contents, props changed)
      - copied, changed from r939034, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ConfigRegistry.java
Modified:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/pom.xml
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/pom.xml?rev=1031366&r1=1031365&r2=1031366&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/pom.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/pom.xml Fri Nov  5 00:12:19 2010
@@ -109,5 +109,23 @@
         </dependency>
 
     </dependencies>
-
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <!--<Export-Package>org.apache.geronimo.osgi.registry.api;version=1.0</Export-Package>-->
+                        <!--<Import-Package>*</Import-Package>-->
+                        <!--<Private-Package>org.apache.geronimo.myfaces.config.resource.osgi</Private-Package>-->
+                        <!--<Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>-->
+                        <Bundle-Activator>org.apache.geronimo.myfaces.config.resource.osgi.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
 </project>

Copied: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java
(from r939034, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java?p2=geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java&p1=geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java&r1=939034&r2=1031366&rev=1031366&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/Activator.java
Fri Nov  5 00:12:19 2010
@@ -16,11 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.geronimo.osgi.registry;
+package org.apache.geronimo.myfaces.config.resource.osgi;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -31,7 +32,6 @@ import org.osgi.util.tracker.BundleTrack
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
-import org.apache.geronimo.osgi.registry.api.ProviderRegistry;
 
 /**
  * The activator that starts and manages the life-cycle of
@@ -43,7 +43,7 @@ public class Activator implements Bundle
     // service tracker for a logging service
     protected ServiceTracker lst;
     // Our provider registry
-    protected ProviderRegistryImpl registry;
+    protected ConfigRegistryImpl registry;
     // The service registration for the provider registry
     protected ServiceRegistration registryRegistration;
     // our bundle context
@@ -58,13 +58,11 @@ public class Activator implements Bundle
         lst = new LogServiceTracker(context, LogService.class.getName(), null);
         lst.open();
 
-        registry = new ProviderRegistryImpl(this);
+        registry = new ConfigRegistryImpl(this);
         // register this as a service
-        registryRegistration = context.registerService(ProviderRegistry.class.getName(),
registry, null);
+        registryRegistration = context.registerService(ConfigRegistry.class.getName(), registry,
null);
 
-        org.osgi.framework.ServiceReference ref = context.getServiceReference(ProviderRegistry.class.getName());
-
-	    bt = new BundleTracker(context, Bundle.ACTIVE, new ProviderBundleTrackerCustomizer(this,
context.getBundle(), registry));
+	    bt = new BundleTracker(context, Bundle.ACTIVE, new ConfigBundleTrackerCustomizer(this,
context.getBundle(), registry));
 	    bt.open();
 	}
 

Copied: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
(from r939034, geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java?p2=geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java&p1=geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java&r1=939034&r2=1031366&rev=1031366&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
Fri Nov  5 00:12:19 2010
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.geronimo.osgi.registry;
+package org.apache.geronimo.myfaces.config.resource.osgi;
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
@@ -24,15 +24,15 @@ import org.osgi.framework.ServiceRegistr
 import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.BundleTrackerCustomizer;
 
-public class ProviderBundleTrackerCustomizer implements BundleTrackerCustomizer {
+public class ConfigBundleTrackerCustomizer implements BundleTrackerCustomizer {
     // our base Activator (used as a service source)
     private Activator activator;
     // the bundle hosting this registry
     private Bundle registryBundle;
     // the registry we interact with
-    private ProviderRegistryImpl registry;
+    private ConfigRegistryImpl registry;
 
-    public ProviderBundleTrackerCustomizer(Activator a, Bundle b, ProviderRegistryImpl r)
{
+    public ConfigBundleTrackerCustomizer(Activator a, Bundle b, ConfigRegistryImpl r) {
         activator = a;
         registryBundle = b;
         registry = r;
@@ -48,7 +48,7 @@ public class ProviderBundleTrackerCustom
      */
     @Override
     public Object addingBundle(Bundle bundle, BundleEvent event) {
-        log(LogService.LOG_DEBUG, "Bundle Considered for class providers: " + bundle.getSymbolicName());
+        log(LogService.LOG_DEBUG, "Bundle Considered for META-INF/faces-config.xml: " + bundle.getSymbolicName());
         if (bundle.equals(registryBundle)) {
             return null;
         }

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigBundleTrackerCustomizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java?rev=1031366&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
(added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/ConfigRegistryImpl.java
Fri Nov  5 00:12:19 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.geronimo.myfaces.config.resource.osgi;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
+import org.osgi.framework.Bundle;
+import org.osgi.service.log.LogService;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ConfigRegistryImpl implements ConfigRegistry {
+    private final Activator activator;
+
+    private final Set<URL> urls = new HashSet<URL>();
+
+    public ConfigRegistryImpl(Activator activator) {
+        this.activator = activator;
+    }
+
+    public Object addBundle(Bundle bundle) {
+        log(LogService.LOG_DEBUG, "examining bundle for META-INF/faces-config.xml " + bundle.getSymbolicName());
+        URL url = bundle.getEntry("META-INF/faces-config.xml");
+        if (url != null) {
+            log(LogService.LOG_DEBUG, "found META-INF/faces-config.xml");
+            urls.add(url);
+        }
+        return url;
+    }
+
+    public void removeBundle(Bundle bundle, Object object) {
+        log(LogService.LOG_DEBUG, "unregistering bundle for META-INF/faces-config.xml " +
bundle.getSymbolicName() + " url: " + object);
+        if (object != null) {
+            urls.remove((URL)object);
+        }
+    }
+
+    @Override
+    public Set<URL> getRegisteredConfigUrls() {
+        return Collections.unmodifiableSet(urls);
+    }
+
+    private void log(int level, String message) {
+        activator.log(level, message);
+    }
+
+    private void log(int level, String message, Throwable th) {
+        activator.log(level, message, th);
+    }
+
+
+}

Added: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ConfigRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ConfigRegistry.java?rev=1031366&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ConfigRegistry.java
(added)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/config/resource/osgi/api/ConfigRegistry.java
Fri Nov  5 00:12:19 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.geronimo.myfaces.config.resource.osgi.api;
+
+import java.net.URL;
+import java.util.Set;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface ConfigRegistry {
+    Set<URL> getRegisteredConfigUrls();
+}

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java?rev=1031366&r1=1031365&r2=1031366&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
Fri Nov  5 00:12:19 2010
@@ -35,9 +35,12 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.geronimo.myfaces.config.annotation.GeronimoAnnotationProviderFactory;
 import org.apache.geronimo.myfaces.config.resource.ConfigurationResource;
 import org.apache.geronimo.myfaces.config.resource.GeronimoFacesConfigResourceProviderFactory;
+import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
 import org.apache.myfaces.spi.AnnotationProviderFactory;
 import org.apache.myfaces.spi.FacesConfigResourceProviderFactory;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 
 /**
  * @version $Rev$ $Date$
@@ -57,7 +60,8 @@ public class MyFacesWebAppContext implem
 
     public MyFacesWebAppContext(@ParamAttribute(name = "annotationClassSetMap") Map<Class<?
extends Annotation>, Set<Class<?>>> annotationClassSetMap,
             @ParamAttribute(name = "metaInfConfigurationResources") Set<ConfigurationResource>
metaInfConfigurationResources, @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
-            @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader)
{
+            @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
+            @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext)
{
         this.annotationClassSetMap = annotationClassSetMap;
         this.bundle = bundle;
         this.classLoader = classLoader;
@@ -69,6 +73,10 @@ public class MyFacesWebAppContext implem
         } catch (MalformedURLException e) {
             throw new IllegalArgumentException(e);
         }
+        ServiceReference ref = bundleContext.getServiceReference(ConfigRegistry.class.getName());
+        ConfigRegistry configRegistry = (ConfigRegistry) bundleContext.getService(ref);
+        this.metaInfConfigurationResources.addAll(configRegistry.getRegisteredConfigUrls());
+        bundleContext.ungetService(ref);
     }
 
     public Map<Class<? extends Annotation>, Set<Class<?>>> getAnnotationClassSetMap()
{



Mime
View raw message