You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by do...@apache.org on 2008/01/12 23:39:33 UTC
svn commit: r611500 - in /felix/sandbox/donsez/wireadminbinder/src:
main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java
main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java
site/readme.html
Author: donsez
Date: Sat Jan 12 14:39:30 2008
New Revision: 611500
URL: http://svn.apache.org/viewvc?rev=611500&view=rev
Log:
add a Extender manager to implement the extender model for wired applications
Added:
felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java (with props)
Modified:
felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java
felix/sandbox/donsez/wireadminbinder/src/site/readme.html
Modified: felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java?rev=611500&r1=611499&r2=611500&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java (original)
+++ felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java Sat Jan 12 14:39:30 2008
@@ -46,6 +46,8 @@
*/
public class BaseActivator implements BundleActivator, ServiceListener {
+ public static final String WAB_MANIFEST_ENTRY="WireAdminBinder-Metadata";
+
// this bundle's context
private BundleContext bundleContext;
@@ -165,10 +167,10 @@
*/
private void loadWireApps() {
String descriptorLocations = (String) bundleContext.getBundle()
- .getHeaders().get("WireAdminBinder-Metadata");
+ .getHeaders().get(WAB_MANIFEST_ENTRY);
if (descriptorLocations != null) {
- error("WireAdminBinder-Metadata entry not found in the manifest",
+ error(WAB_MANIFEST_ENTRY+" entry not found in the manifest",
null);
return;
}
Added: felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java?rev=611500&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java (added)
+++ felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java Sat Jan 12 14:39:30 2008
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.felix.sandbox.wireadminbinder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+
+/**
+ * This extender starts and stops WireAdminBinder applications located in other bundles according the extended model.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Extender implements BundleActivator, BundleListener {
+
+ private Map<Bundle,BaseActivator> baseActivators=new HashMap<Bundle,BaseActivator>();
+
+ public Extender() {
+ }
+
+ /**
+ *
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ // TODO init a trace system
+
+ bundleContext.addBundleListener(this);
+ Bundle[] bundles=bundleContext.getBundles();
+ for (int i = 0; i < bundles.length; i++) {
+ enablesBundle(bundles[i]);
+ }
+ }
+
+
+ public void stop(BundleContext bundleContext) {
+ Bundle[] bundles=bundleContext.getBundles();
+ for (int i = 0; i < bundles.length; i++) {
+ disposesBundle(bundles[i]);
+ }
+ bundleContext.removeBundleListener(this);
+ }
+
+ public void bundleChanged(BundleEvent bundleEvent) {
+ switch(bundleEvent.getType()){
+ case Bundle.ACTIVE: {
+ enablesBundle(bundleEvent.getBundle());
+ } break;
+ case Bundle.STOPPING: {
+ disposesBundle(bundleEvent.getBundle());
+ } break;
+ }
+ }
+
+ private void enablesBundle(Bundle bundle){
+ BundleContext context=bundle.getBundleContext();
+ if(context==null){
+ // TODO log something
+ return;
+ }
+ if(bundle.getHeaders().get(BaseActivator.WAB_MANIFEST_ENTRY)!=null) {
+ synchronized (baseActivators) {
+ if(!baseActivators.containsKey(bundle)) {
+ BaseActivator baseActivator=new BaseActivator();
+ try {
+ baseActivator.start(context);
+ baseActivators.put(bundle,baseActivator);
+ } catch (Exception e) {
+ // TODO log something
+ }
+ }
+ }
+ }
+ }
+
+ private void disposesBundle(Bundle bundle){
+ BundleContext context=bundle.getBundleContext();
+ if(context==null){
+ // TODO log something
+ return;
+ }
+ synchronized (baseActivators) {
+ BaseActivator baseActivator=baseActivators.remove(bundle);
+ if(baseActivator!=null) baseActivator.stop(bundle.getBundleContext());
+ }
+ }
+
+}
Propchange: felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/Extender.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: felix/sandbox/donsez/wireadminbinder/src/site/readme.html
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/site/readme.html?rev=611500&r1=611499&r2=611500&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/site/readme.html (original)
+++ felix/sandbox/donsez/wireadminbinder/src/site/readme.html Sat Jan 12 14:39:30 2008
@@ -6,7 +6,7 @@
<!-- Start of Bundle Documentation -->
<hr width="100%" size="2">
-<h1><i><a name="org.osgi.felix.sandbox.wireadminbinder"></a><font color="#0000aa">WireAdmin Binder</font></i></h1>
+<h1><i><a name="org.osgi.felix.sandbox.wireadminbinder"></a><font color="#0000aa">WireAdminBinder</font></i></h1>
<p>
<b>Description</b><br>
@@ -114,6 +114,7 @@
<p id="todo">
<b>TODO (contributions are welcome)</b><br>
<ul>
+<li>2008-01-12: add a extended model to start and stop wired applications described in other bundles manifest</li>
<li>2007-12-19: add consumersFilter and producersFilter elements to set LDAP filters in CDATA section</li>
<li>2007-12-19: add consumerPid and producerPid attributes in wireset elements to simplify PID setting</li>
<li>2007-12-19: add wireapp lifecycle control in wiresets</li>