felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santil...@apache.org
Subject svn commit: r430562 [3/6] - in /incubator/felix/sandbox/santillan/org.apache.felix.jmood: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/jmood/ src/main/java/...
Date Thu, 10 Aug 2006 22:16:02 GMT
Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/BundleInfo.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/BundleInfo.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/BundleInfo.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/BundleInfo.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,171 @@
+/*
+ *   Copyright 2005 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.jmood.core.instrumentation;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+public class BundleInfo implements Serializable {
+    
+    //mgmt attributes
+    private int startLevel;
+    private String state;
+    private ServiceInfo[] registeredServices; 
+    private ServiceInfo[] servicesInUse;
+    private Hashtable headers;
+    private long bundleId;
+    private PackageInfo[] exportedPackages; 
+    private PackageInfo[] importedPackages;
+    private BundleInfo[] fragments;
+    private BundleInfo[] hosts;
+    private BundleInfo[] requiredBundles;
+    private BundleInfo[] requiringBundles;
+    private long lastModified;
+    private String symbolicName;
+    //private String version; //Included in the headers except for required bundles
+    private boolean bundlePersistentlyStarted;
+    private boolean removalPending;
+    private boolean required; 
+    private boolean fragment; 
+//    private R4Permission[] permissions;//TODO This should include conditional permz as well as regular ones
+//    private R4Configuration[] configurations; //TODO
+    
+    public BundleInfo() {
+    }
+    
+    
+    ////////////GETTERS'n'SETTERS////////////////////////
+    public boolean isFragment() {
+        return fragment;
+    }
+
+
+    protected void setFragment(boolean fragment) {
+        this.fragment = fragment;
+    }
+
+
+    public long getLastModified() {
+        return lastModified;
+    }
+
+
+    protected void setLastModified(long lastModified) {
+        this.lastModified = lastModified;
+    }
+
+
+    public boolean isRequired() {
+        return required;
+    }
+
+
+    protected void setRequired(boolean required) {
+        this.required = required;
+    }
+    public long getBundleId() {
+        return bundleId;
+    }
+    protected void setBundleId(long bundleId) {
+        this.bundleId = bundleId;
+    }
+    public boolean isBundlePersistentlyStarted() {
+        return bundlePersistentlyStarted;
+    }
+    protected void setBundlePersistentlyStarted(boolean bundlePersistentlyStarted) {
+        this.bundlePersistentlyStarted = bundlePersistentlyStarted;
+    }
+    public PackageInfo[] getExportedPackages() {
+        return exportedPackages;
+    }
+    protected void setExportedPackages(PackageInfo[] exportedPackages) {
+        this.exportedPackages = exportedPackages;
+    }
+    public BundleInfo[] getFragments() {
+        return fragments;
+    }
+    protected void setFragments(BundleInfo[] fragments) {
+        this.fragments = fragments;
+    }
+    public Hashtable getHeaders() {
+        return headers;
+    }
+    protected void setHeaders(Hashtable headers) {
+        this.headers = headers;
+    }
+    public BundleInfo[] getHosts() {
+        return hosts;
+    }
+    protected void setHosts(BundleInfo[] hosts) {
+        this.hosts = hosts;
+    }
+    public PackageInfo[] getImportedPackages() {
+        return importedPackages;
+    }
+    protected void setImportedPackages(PackageInfo[] importedPackages) {
+        this.importedPackages = importedPackages;
+    }
+    public ServiceInfo[] getRegisteredServices() {
+        return registeredServices;
+    }
+    protected void setRegisteredServices(ServiceInfo[] registeredServices) {
+        this.registeredServices = registeredServices;
+    }
+    public boolean isRemovalPending() {
+        return removalPending;
+    }
+    protected void setRemovalPending(boolean removalPending) {
+        this.removalPending = removalPending;
+    }
+    public BundleInfo[] getRequiredBundles() {
+        return requiredBundles;
+    }
+    protected void setRequiredBundles(BundleInfo[] requiredBundles) {
+        this.requiredBundles = requiredBundles;
+    }
+    public BundleInfo[] getRequiringBundles() {
+        return requiringBundles;
+    }
+    protected void setRequiringBundles(BundleInfo[] requiringBundles) {
+        this.requiringBundles = requiringBundles;
+    }
+    public ServiceInfo[] getServicesInUse() {
+        return servicesInUse;
+    }
+    protected void setServicesInUse(ServiceInfo[] servicesInUse) {
+        this.servicesInUse = servicesInUse;
+    }
+    public int getStartLevel() {
+        return startLevel;
+    }
+    protected void setStartLevel(int startLevel) {
+        this.startLevel = startLevel;
+    }
+    public String getState() {
+        return state;
+    }
+    protected void setState(String state) {
+        this.state = state;
+    }
+    public String getSymbolicName() {
+        return symbolicName;
+    }
+    protected void setSymbolicName(String symbolicName) {
+        this.symbolicName = symbolicName;
+    }
+    
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/FrameworkSnapshot.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/FrameworkSnapshot.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/FrameworkSnapshot.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/FrameworkSnapshot.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,245 @@
+/*
+ *   Copyright 2005 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.jmood.core.instrumentation;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.apache.felix.jmood.AgentContext;
+import org.apache.felix.jmood.core.ServiceNotAvailableException;
+import org.apache.felix.jmood.utils.InstrumentationSupport;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+
+public class FrameworkSnapshot {
+	private Hashtable bundles = new Hashtable(); //<Long, BundleInfo>
+
+	private Hashtable services = new Hashtable();//<Long, ServiceInfo>
+
+	private Hashtable packages = new Hashtable();//<String, PackageInfo>
+
+	private AgentContext ac;
+
+	private long timestamp;
+
+	public FrameworkSnapshot(AgentContext ac) {
+		super();
+		this.ac = ac;
+		this.populate();
+	}
+
+	public long getShotTime() {
+		return timestamp;
+	}
+
+	public void refreshSnapshot() {
+		bundles = new Hashtable();
+		services = new Hashtable();
+		packages = new Hashtable();
+		this.populate();
+		ac.debug("factory-bundles found: " + bundles.size());
+		ac.debug("factory-services found: " + services.size());
+		ac.debug("factory-packages found: " + packages.size());
+
+	}
+
+	public BundleInfo[] getAllBundles() {
+		Enumeration b = bundles.elements();
+		BundleInfo[] binfo = new BundleInfo[bundles.size()];
+		for (int i = 0; i < binfo.length; i++) {
+			binfo[i] = (BundleInfo) b.nextElement();
+		}
+		return binfo;
+	}
+
+	public ServiceInfo[] getAllServiceInfo() {
+		Enumeration s = services.elements();
+		ServiceInfo[] sinfo = new ServiceInfo[services.size()];
+		for (int i = 0; i < sinfo.length; i++) {
+			sinfo[i] = (ServiceInfo) s.nextElement();
+		}
+		return sinfo;
+	}
+
+	public PackageInfo[] getAllPackageInfo() {
+		Enumeration p = packages.elements();
+		PackageInfo[] pinfo = new PackageInfo[packages.size()];
+		for (int i = 0; i < pinfo.length; i++) {
+			pinfo[i] = (PackageInfo) p.nextElement();
+		}
+		return pinfo;
+	}
+
+	// ///////////PRIVATE METHODS//////////////////////////
+
+	private void populate() {
+		Bundle[] bundles = ac.getBundleContext().getBundles();
+		BundleInfo[] binfo = new BundleInfo[bundles.length];
+		for (int i = 0; i < binfo.length; i++) {
+			binfo[i] = getBundleInfo(bundles[i]);
+		}
+		this.timestamp = System.currentTimeMillis();
+	}
+
+private BundleInfo getBundleInfo(Bundle bundle) {
+        if (bundle==null) return null;
+        ac.debug("creating R4 bundleinfo:  "+bundle.getSymbolicName());
+        Long key = new Long(bundle.getBundleId());
+        if (bundles.containsKey(key))
+            return (BundleInfo) bundles.get(key);
+        BundleInfo b = new BundleInfo();
+        b.setBundleId(bundle.getBundleId());
+        bundles.put(key, b);
+        try{
+            b.setFragments(this.getFragments(bundle));
+            b.setHeaders(InstrumentationSupport.getHashtable(bundle.getHeaders()));
+            b.setLastModified(bundle.getLastModified());
+            b.setRegisteredServices(this.getSvcsInfo(bundle.getRegisteredServices()));
+        	b.setBundlePersistentlyStarted(InstrumentationSupport.isBundlePersistentlyStarted(bundle, ac));
+        	b.setStartLevel(InstrumentationSupport.getBundleStartLevel(bundle, ac));
+        	b.setExportedPackages(this.getPkgInfo(InstrumentationSupport.getExportedPackages(bundle, ac)));
+        	b.setFragment(InstrumentationSupport.isFragment(bundle, ac));
+        	b.setRequired(InstrumentationSupport.isBundleRequired(bundle, ac));
+        	b.setRemovalPending(InstrumentationSupport.isRequiredBundleRemovalPending(bundle, ac));
+        	b.setRequiredBundles(this.getBundleDependencies(bundle));
+        	b.setRequiringBundles(this.getBInfos(InstrumentationSupport.getRequiringBundles(bundle, ac)));
+        	b.setImportedPackages(this.getImportedPackages(bundle));
+        }catch(ServiceNotAvailableException sae){
+        	//Not needed, since they are default values, placed for clarity
+        	b.setBundlePersistentlyStarted(false);
+        	b.setStartLevel(-1);
+        	b.setExportedPackages(null);
+        	b.setFragment(false);
+        	b.setRequired(false);
+        	b.setRemovalPending(false);
+            b.setRequiredBundles(null);
+            b.setRequiringBundles(null);
+            b.setImportedPackages(null);
+            ac.warning(sae.getMessage());
+        }
+        b.setServicesInUse(this.getSvcsInfo(bundle.getServicesInUse()));
+        b.setState(InstrumentationSupport.getState(bundle.getState()));
+        b.setSymbolicName(bundle.getSymbolicName());
+        return b;
+    }	private ServiceInfo getServiceInfo(ServiceReference svc) {
+		if (svc == null)
+			return null;
+		ac.debug("Creating R4service for service id "
+				+ svc.getProperty(Constants.SERVICE_ID));
+		Long key = (Long) svc.getProperty(Constants.SERVICE_ID);
+		if (services.containsKey(key))
+			return (ServiceInfo) services.get(key);
+		ServiceInfo s = new ServiceInfo();
+		services.put(key, s);
+
+		// now we set the atts
+		s.setBundle(this.getBundleInfo(svc.getBundle()));
+		Bundle[] using = svc.getUsingBundles();
+		if (using != null) {
+			BundleInfo[] r4Using = new BundleInfo[using.length];
+			for (int i = 0; i < r4Using.length; i++) {
+				r4Using[i] = getBundleInfo(using[i]);
+			}
+			s.setUsingBundles(r4Using);
+		}
+		Hashtable props = new Hashtable();//<String, Object>
+		String[] keys=svc.getPropertyKeys();
+		for (int i=0; i<keys.length;i++) {
+			props.put(keys[i], svc.getProperty(keys[i]));
+		}
+		s.setProperties(props);
+		return s;
+
+	}
+
+	private PackageInfo getPackageInfo(ExportedPackage pkg) {
+		if (pkg == null)
+			return null;
+		ac.debug("Creating PackageInfo for package " + pkg.getName());
+		String key = pkg.getName();
+		if (packages.containsKey(key))
+			return (PackageInfo) packages.get(key);
+		PackageInfo p = new PackageInfo();
+		packages.put(key, p);
+		p.setExportingBundle(getBundleInfo(pkg.getExportingBundle()));
+		Bundle[] importing = pkg.getImportingBundles();
+		if (importing != null) {
+			BundleInfo[] r4importing = new BundleInfo[importing.length];
+			for (int i = 0; i < r4importing.length; i++) {
+				r4importing[i] = getBundleInfo(importing[i]);
+			}
+			p.setImportingBundles(r4importing);
+		}
+		p.setName(pkg.getName());
+		p.setRemovalPending(pkg.isRemovalPending());
+		p.setVersion(pkg.getVersion().toString());
+		return p;
+	}
+
+	private BundleInfo[] getFragments(Bundle bundle) throws ServiceNotAvailableException{
+		Bundle[] fragments = ac.getPackageadmin().getFragments(bundle);
+		if (fragments == null)
+			return null;
+		BundleInfo[] r4fragments = new BundleInfo[fragments.length];
+		for (int i = 0; i < fragments.length; i++) {
+			r4fragments[i] = getBundleInfo(fragments[i]);
+		}
+		return r4fragments;
+	}
+
+	private ServiceInfo[] getSvcsInfo(ServiceReference[] svcs) {
+		if (svcs == null)
+			return null;
+		ServiceInfo[] r4svcs = new ServiceInfo[svcs.length];
+		for (int i = 0; i < svcs.length; i++) {
+			r4svcs[i] = getServiceInfo(svcs[i]);
+		}
+		return r4svcs;
+	}
+
+	private PackageInfo[] getImportedPackages(Bundle bundle) throws ServiceNotAvailableException {
+			return this.getPkgInfo(InstrumentationSupport.getImportedPackages(bundle, ac));
+	}
+
+	private PackageInfo[] getPkgInfo(ExportedPackage[] pkgs) {
+		if (pkgs == null)
+			return null;
+		PackageInfo[] r4pkgs = new PackageInfo[pkgs.length];
+		for (int i = 0; i < pkgs.length; i++) {
+			r4pkgs[i] = getPackageInfo(pkgs[i]);
+		}
+		return r4pkgs;
+	}
+
+
+	private BundleInfo[] getBundleDependencies(Bundle bundle) throws ServiceNotAvailableException {
+			Bundle[] required = InstrumentationSupport.getBundleDependencies(bundle, ac);
+			return this.getBInfos(required); 
+		}
+	private BundleInfo[] getBInfos(Bundle[] bundles){
+		if(bundles==null) return null;
+		BundleInfo[] info = new BundleInfo[bundles.length];
+		for (int i = 0; i < info.length; i++) {
+			info[i] = getBundleInfo(bundles[i]);
+		}
+		return info;
+		
+	}
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/PackageInfo.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/PackageInfo.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/PackageInfo.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/PackageInfo.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,72 @@
+/*
+ *   Copyright 2005 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.jmood.core.instrumentation;
+
+import java.io.Serializable;
+
+public class PackageInfo implements Serializable{
+    private BundleInfo exportingBundle;
+    private BundleInfo [] importingBundles;
+    private String name;
+    private String version;
+    private boolean removalPending;
+    
+    public PackageInfo() {
+        super();
+    }
+
+    public BundleInfo getExportingBundle() {
+        return exportingBundle;
+    }
+
+    protected void setExportingBundle(BundleInfo exportingBundle) {
+        this.exportingBundle = exportingBundle;
+    }
+
+    public BundleInfo[] getImportingBundles() {
+        return importingBundles;
+    }
+
+    protected void setImportingBundles(BundleInfo[] importingBundles) {
+        this.importingBundles = importingBundles;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    protected void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isRemovalPending() {
+        return removalPending;
+    }
+
+    protected void setRemovalPending(boolean removalPending) {
+        this.removalPending = removalPending;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    protected void setVersion(String version) {
+        this.version = version;
+    }
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/ServiceInfo.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/ServiceInfo.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/ServiceInfo.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/core/instrumentation/ServiceInfo.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,49 @@
+/*
+ *   Copyright 2005 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.jmood.core.instrumentation;
+
+import java.io.Serializable;
+import java.util.Hashtable;
+
+public class ServiceInfo implements Serializable{
+    private BundleInfo bundle;
+    private BundleInfo[] usingBundles;
+    private Hashtable properties;
+    public ServiceInfo() {
+        super();
+        // TODO Auto-generated constructor stub
+    }
+    public BundleInfo getBundle() {
+        return bundle;
+    }
+    protected void setBundle(BundleInfo bundle) {
+        this.bundle = bundle;
+    }
+    public Hashtable getProperties() {
+        return properties;
+    }
+    protected void setProperties(Hashtable properties) {
+        this.properties = properties;
+    }
+    public BundleInfo[] getUsingBundles() {
+        return usingBundles;
+    }
+    protected void setUsingBundles(BundleInfo[] usingBundles) {
+        this.usingBundles = usingBundles;
+    }
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/CompositeDataItemNames.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/CompositeDataItemNames.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/CompositeDataItemNames.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/CompositeDataItemNames.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,64 @@
+/*
+ *   Copyright 2005 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.jmood.utils;
+
+public interface CompositeDataItemNames {
+	public static final String BUNDLE_ID="BundleId";
+	public static final String BUNDLE_LOCATION="BundleLocation";
+	public static final String EVENT_TYPE="Type";
+	public static final String ENCODED_SERVICE="Service";
+	public static final String ENCODED_EXCEPTION="Throwable";
+	public static final String ENCODED_ROLE="Role";
+	public static final String OBJECT_CLASS="objectClass";
+	public static final String CLASSNAME="ClassName";
+	public static final String FILENAME="FileName";
+	public static final String LINE_NUMBER="LineNumber";
+	public static final String METHOD_NAME="MethodName";
+	public static final String IS_NATIVE_METHOD="isNativeMethod";
+	public static final String EXCEPTION_MESSAGE="Message";
+	public static final String STACK_TRACE="StackTrace";
+	public static final String KEYS_FOR_STRING_VALUES="KeysForStringValues";
+	public static final String KEYS_FOR_BYTEARRAY_VALUES="KeysForByteArrayValues";
+	public static final String STRING_VALUES="StringValues";
+	public static final String BYTEARRAY_VALUES="ByteArrayValues";
+	public static final String ENCODED_CREDENTIALS="credentials";
+	public static final String ROLE_NAME="name";
+	public static final String ROLE_TYPE="type";
+	public static final String ROLE_ENCODED_PROPERTIES="properties";
+	public static final String ENCODED_USER="User";
+	public static final String GROUP_MEMBERS="members";
+	public static final String GROUP_REQUIRED_MEMBERS="requiredMembers";
+	public static final String USER_NAME="UserName";
+	public static final String ROLE_NAMES="RoleNames";
+	public static final String LOG_LEVEL="Level";
+	public static final String LOG_MESSAGE="Message";
+	public static final String LOG_TIME="Time";
+	public static final String[] AUTHORIZATION={USER_NAME,ROLE_NAMES};
+	public static final String[] BUNDLE_EVENT={BUNDLE_ID,BUNDLE_LOCATION, EVENT_TYPE};
+	public static final String[] SERVICE_EVENT={ENCODED_SERVICE, EVENT_TYPE};
+	public static final String[] USER_EVENT={EVENT_TYPE, ENCODED_ROLE, ENCODED_SERVICE};
+	public static final String[] FRAMEWORK_EVENT={BUNDLE_ID,BUNDLE_LOCATION, ENCODED_EXCEPTION,EVENT_TYPE };
+	public static final String[] SERVICE={BUNDLE_ID,BUNDLE_LOCATION,OBJECT_CLASS};
+	public static final String[] STACK_TRACE_ELEMENT={CLASSNAME,FILENAME,LINE_NUMBER,METHOD_NAME,IS_NATIVE_METHOD};
+	public static final String[] EXCEPTION={EXCEPTION_MESSAGE,STACK_TRACE};
+	public static final String[] ROLE_PROPERTIES={KEYS_FOR_STRING_VALUES,KEYS_FOR_BYTEARRAY_VALUES,STRING_VALUES,BYTEARRAY_VALUES};
+	public static final String[] USER_CREDENTIALS=ROLE_PROPERTIES;
+	public static final String[] USER={ENCODED_ROLE,ENCODED_CREDENTIALS};
+	public static final String[] ROLE={ROLE_NAME,ROLE_TYPE,ROLE_ENCODED_PROPERTIES};
+	public static final String[] GROUP={ENCODED_USER,GROUP_MEMBERS,GROUP_REQUIRED_MEMBERS};
+	public static final String[] LOG_ENTRY={BUNDLE_ID,BUNDLE_LOCATION, ENCODED_EXCEPTION,LOG_LEVEL,LOG_MESSAGE,ENCODED_SERVICE,LOG_TIME};
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/InstrumentationSupport.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/InstrumentationSupport.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/InstrumentationSupport.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/InstrumentationSupport.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,293 @@
+/*
+ *   Copyright 2005 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.jmood.utils;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.felix.jmood.AgentContext;
+import org.apache.felix.jmood.core.BundleNotAvailableException;
+import org.apache.felix.jmood.core.ServiceNotAvailableException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+
+/**
+ * This class contains helper methods 
+ * 
+ *
+ */
+public class InstrumentationSupport {
+	private AgentContext ac;
+	public InstrumentationSupport(AgentContext ac){
+		this.ac=ac;
+	}
+    /**
+     * <p>For each BundleInfo, this method returns the symbolic name String, which we define as the concatenation of  
+     * the getSymbolicName of the <code>Bundle</code> interface and the bundle version as specified 
+     * in the bundle header. Both parts are divided by a semicolon. An example would be:</p>
+     * <p>
+     * <code>com.acme.foo;1.0.0</code>
+     * </p>
+     * @param bundles The <code>Bundle</code> array to be converted
+     * @return The String array
+     * @see org.osgi.framework.Bundle#getSymbolicName()
+     */
+    public static String[] getSymbolicNames(Bundle[] bundles) {
+        if(bundles==null) return null;
+        String[] names=new String[bundles.length];
+        for (int i = 0; i < names.length; i++) {
+            names[i]=getSymbolicName(bundles[i]);
+        }
+        return names;
+    }
+    public static String getSymbolicName(Bundle bundle){
+        return bundle.getSymbolicName()+";"+bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+    	
+    }
+
+    /**
+     * <p>
+     * 
+     * OSGi exported packages can be uniquely identified by the tuple (packageName, packageVersion). 
+     * This methods returns a String array representing those packages with the following syntax:
+     * </p>
+     * <p>
+     * <i>packageName</i>;<i>packageVersion</i> 
+     * </p><p>
+     * where packageName is as returned by the method <i>getName()</i> and packageVersion as returned by the method <i>getVersion()</i>
+     * in package admin's <code>ExportedPackage</code> class.
+     * </p>
+     * @param packages The <code>ExportedPackage</code> array to be converted
+     * @return The String array
+     * @see org.osgi.service.packageadmin.ExportedPackage
+     */
+    public static String[] getPackageNames(ExportedPackage[] packages) {
+        if (packages==null) return null;
+        String[] names=new String[packages.length];
+        for (int i = 0; i < names.length; i++) {
+            names[i]=getPackageName(packages[i]);
+        }
+        return names;
+    
+    }
+	public static String getPackageName(ExportedPackage pkg) {
+		return pkg.getName()+";"+pkg.getVersion().toString();
+	}
+
+
+    /**
+     * <p>
+     * OSGi Services can be registered under more than one interface (objectClass in 
+     * the spec). Services have a mandatory unique service id (as defined in the SERVICE_ID property of the org.osgi.framework.Constants interface), during their lifetime (i.e, until they are 
+     * garbage collected). To show this information in a consistent way, we use the following String representation
+     * of the service:
+     * </p>
+     * <p>
+     * <i>objectClass1</i>[;<i>objectClass2</i>[;<i>objectClass3</i>...]]:<i>service.id</i> 
+     * </p><p>
+     * where objectClass1..objectClassN are the elements of the mandatory objectClass array
+     * included in the service property dictionary (and set by the framework at registration time. The property name is defined in <code>org.osgi.framework.Constants#OBJECTCLASS</code> 
+     * </p>
+     * @param services The <code>ServiceReference</code> array to be converted
+     * @return The String array
+     * @see org.osgi.framework.Constants#OBJECTCLASS
+     * @see org.osgi.framework.Constants#SERVICE_ID
+     * @see org.osgi.framework.ServiceReference
+     */
+    public static String[] getServiceNames(ServiceReference[] services) {
+        if(services==null) return null;
+        String[] names=new String[services.length];
+        for (int i = 0; i < names.length; i++) {
+            String[] objectClass=(String[])services[i].getProperty(Constants.OBJECTCLASS);
+            //We asume that the framework always returns a non-empty, non-null array.
+            StringBuffer sb=new StringBuffer(objectClass[0]);
+            for (int j = 1; j < objectClass.length; j++) {
+                sb.append(";");
+                sb.append(objectClass[j]);
+            }
+            sb.append(services[i].getProperty(Constants.SERVICE_ID));
+            names[i]=sb.toString();
+        }
+        return names;
+    }
+    public static ExportedPackage[] getImportedPackages(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException {
+        Vector imported = new Vector();
+        Bundle[] allBundles = ac.getBundleContext().getBundles();
+        for (int i=0; i<allBundles.length;i++) {
+        	Bundle b=allBundles[i];
+            ExportedPackage[] eps=ac.getPackageadmin()
+            .getExportedPackages(b);
+            if(eps==null) continue;
+            exported: for (int j=0;j<eps.length;j++) {
+            	ExportedPackage ep = eps[j];
+                Bundle[] imp=ep.getImportingBundles();
+                if(imp==null) continue;
+                for (int k=0;k<imp.length;k++) {
+                	Bundle b2 =imp[k];
+                    if (b2.getBundleId() == bundle.getBundleId()) {
+                        imported.add(ep);
+                        continue exported;
+                    }
+                }
+            }
+        }
+        if (imported.size() == 0)
+            return null;
+        else return (ExportedPackage[])imported.toArray(new ExportedPackage[imported.size()]);
+
+    }
+    public static Bundle[] getRequiringBundles(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException{
+        if (bundle==null) throw new IllegalArgumentException("Bundle argument should not be null");
+        if (bundle.getSymbolicName()==null) return null;
+        RequiredBundle[] required=ac.getPackageadmin().getRequiredBundles(bundle.getSymbolicName());
+        if (required==null) return null;
+            RequiredBundle b=null;
+            for (int i=0;i<required.length;i++) {
+                if(bundle.getBundleId()==required[i].getBundle().getBundleId()) {
+                    b=required[i];
+                    break;
+                }
+            }
+            if(b==null) {
+                ac.error(InstrumentationSupport.class.getName()+": required bundle should not be null!!!!", new Exception());
+                return null;
+            }
+            return b.getRequiringBundles();
+    }
+    public static Bundle[] getBundleDependencies(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException{
+        Bundle[] all=ac.getBundleContext().getBundles();
+        Vector required=new Vector();
+        for (int i = 0; i < all.length; i++) {
+            Bundle[] requiring=getRequiringBundles(all[i], ac);
+            if (requiring==null) continue;
+            for (int j = 0; j < requiring.length; j++) {
+            	//If the solicited bundle is requiring the bundle all[i] we mark it as required
+				if (requiring[j].getBundleId()==bundle.getBundleId()) required.add(all[i]);
+			}
+        }
+        if (required.size()==0) return null;
+        return (Bundle[])required.toArray(new Bundle[required.size()]);
+    }
+    public static boolean isBundleRequired(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException {
+    	if (getRequiredBundle(bundle, ac)==null) return false;
+    	return true;
+    }
+    public static boolean isRequiredBundleRemovalPending(Bundle bundle, AgentContext ac)throws ServiceNotAvailableException{
+    	RequiredBundle r=getRequiredBundle(bundle, ac);
+    	if (r==null) return false;
+    	return r.isRemovalPending();
+    }
+    public static RequiredBundle getRequiredBundle(Bundle bundle, AgentContext ac)throws ServiceNotAvailableException{
+        RequiredBundle[] required=ac.getPackageadmin().getRequiredBundles(bundle.getSymbolicName());
+        if(required==null) return null;
+        for (int i = 0; i < required.length; i++) {
+			if (required[i].getBundle().getBundleId()==bundle.getBundleId()) return required[i];
+		}
+    	return null;
+    }
+	public static String getState(int state) {
+		switch (state) {
+		case Bundle.ACTIVE:
+			return "ACTIVE";
+		case Bundle.INSTALLED:
+			return "INSTALLED";
+		case Bundle.RESOLVED:
+			return "RESOLVED";
+		case Bundle.STARTING:
+			return "STARTING";
+		case Bundle.STOPPING:
+			return "STOPPING";
+		case Bundle.UNINSTALLED:
+			return "UNINSTALLED";
+		}
+		return null;
+	}
+	public static boolean isBundlePersistentlyStarted(Bundle bundle, AgentContext ac)throws ServiceNotAvailableException{
+            // BUG in KNOPFLERFISH: isPersistentlyStarted throws NPE if called
+			// on System bundle
+            // Workaround: system bundle should always be persistently started, return true
+            if (bundle.getBundleId()==0) return true;
+            else
+            return ac.getStartLevel().isBundlePersistentlyStarted(bundle);
+            // End workaround
+	}
+
+	public static int getBundleStartLevel(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException {
+        return ac.getStartLevel().getBundleStartLevel(bundle);
+	}
+
+	public static ExportedPackage[] getExportedPackages(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException{
+	        return ac.getPackageadmin().getExportedPackages(bundle);
+	}
+
+	public static boolean isFragment(Bundle bundle, AgentContext ac) throws ServiceNotAvailableException{
+        if(ac.getPackageadmin().getBundleType(bundle)==PackageAdmin.BUNDLE_TYPE_FRAGMENT) return true;
+    	return false;
+	}
+	public static Hashtable getHashtable(Dictionary dic){
+			Hashtable ht = new Hashtable();
+			for (Enumeration keys = dic.keys(); keys.hasMoreElements();) {
+				Object key = keys.nextElement();
+				// Not inmutable, but unlikely to change
+				ht.put(key, dic.get(key));
+			}
+			return ht;
+		}
+    public static long getBundleId(String symbolicName, AgentContext ac) throws BundleNotAvailableException{
+        if(symbolicName==null) throw new IllegalArgumentException("Symbolic name cannot be null");
+        String  [] s=symbolicName.split(";");
+        if(s==null||s.length==0) throw new BundleNotAvailableException("Could not find bundle identified by "+symbolicName);
+    	Bundle[] bundles=ac.getBundleContext().getBundles();
+        long id=-1;
+        Vector candidates=new Vector();
+        for(int i=0;i<bundles.length;i++) {
+        	//First find all bundles with symbolicName
+        	String name=bundles[i].getSymbolicName();
+        	if(name==null) continue;
+        	if (s[0].equals(name)){ 
+            	candidates.add(new Long(bundles[i].getBundleId()));
+            }
+        }
+        //now search the one that matches the version
+        for(int i=0; i< candidates.size();i++){
+        	long cId=((Long)candidates.elementAt(i)).longValue();
+        	Bundle c=ac.getBundleContext().getBundle(cId);
+        	String version=(String)c.getHeaders().get(Constants.BUNDLE_VERSION);
+        	if(s.length==1){//no version available
+        		ac.debug("no version available for "+symbolicName);
+        		if(candidates.size()>1) throw new BundleNotAvailableException("could not distinguish among multiple candidates");
+        		if(candidates.size()==1) {
+        			id=cId;
+        			break;
+        		}
+        	}
+        	if (version.equals(s[1])) id=cId;
+        }
+        if(id==-1) throw new BundleNotAvailableException("No " + symbolicName+ "installed");
+        return id;
+    }
+
+
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGi2JMXCodec.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGi2JMXCodec.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGi2JMXCodec.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGi2JMXCodec.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,304 @@
+/*
+ *   Copyright 2005 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.jmood.utils;
+import java.util.*;
+import javax.management.openmbean.*;
+import org.osgi.service.useradmin.*;
+import org.osgi.service.log.*;
+import org.osgi.framework.*;
+
+/**
+ * This class's task is to be in charge of all needed type conversions
+ * inside the management agent. This involves translating osgi-defined types
+ * to jmx's open types. It implements methods for obtaining open instances. 
+ * This class implements the singleton pattern.
+ *
+ */
+public class OSGi2JMXCodec {
+	public static CompositeData encodeBundleEvent(BundleEvent event) throws Exception{
+		if(event==null) return null;
+		String[] itemNames=CompositeDataItemNames.BUNDLE_EVENT;
+		Object[] itemValues=new Object [3];
+		itemValues[0]=new Integer((int)event.getBundle().getBundleId());
+		itemValues[1]=event.getBundle().getLocation();
+		itemValues[2]=new Integer(event.getType());
+		return new CompositeDataSupport(
+			OSGiTypes.BUNDLEEVENT,
+			itemNames,
+			itemValues);
+	}
+	public static CompositeData encodeServiceEvent(ServiceEvent event) throws Exception{
+		if(event==null) return null;
+		String[] itemNames=CompositeDataItemNames.SERVICE_EVENT;
+		Object[] itemValues=new Object[2];
+		itemValues[0]=encodeService(event.getServiceReference());
+		itemValues[1]=new Integer(event.getType());
+		return new CompositeDataSupport(
+						OSGiTypes.SERVICEEVENT,
+						itemNames,
+						itemValues);
+		
+	}
+	public static CompositeData encodeFrameworkEvent(FrameworkEvent event) throws Exception{
+		if(event==null) return null;
+		String[] itemNames=CompositeDataItemNames.FRAMEWORK_EVENT;
+		Object[] itemValues=new Object[4];
+		itemValues[0]=new Integer((int)event.getBundle().getBundleId());
+		itemValues[1]=event.getBundle().getLocation();
+				if (event.getThrowable()==null) itemValues[2]=null;
+				else itemValues[2]=encodeException(event.getThrowable());
+				itemValues[3]=new Integer(event.getType());
+			return new CompositeDataSupport(
+						OSGiTypes.FRAMEWORKEVENT,
+						itemNames,
+						itemValues);
+
+	}
+	public static CompositeData encodeUserAdminEvent(UserAdminEvent event) throws Exception{
+		//type: better as a String or as a number? for the moment number.
+		//FUTURE WORK Enable some bulk methods in most used parts: optimization issue
+		if(event==null) return null;
+		String [] itemNames =CompositeDataItemNames.USER_EVENT;
+		Object[] itemValues=new Object[3];
+		itemValues[0]=new Integer(event.getType());
+		itemValues[1]=encodeRole(event.getRole());
+		itemValues[2]=encodeService(event.getServiceReference());
+		return new CompositeDataSupport(
+			OSGiTypes.USERADMINEVENT,
+			itemNames,
+			itemValues);
+		}
+	public static CompositeData[] encodeLog(Enumeration enumeration) throws Exception{
+		if(enumeration==null) return null;
+			Vector vector=new Vector();
+			while(enumeration.hasMoreElements()){
+				vector.add(encodeLogEntry((LogEntry)enumeration.nextElement()));
+			}
+			CompositeData[] value=new CompositeData[vector.size()];
+			vector.copyInto(value);
+			return value;
+	}
+	public static CompositeData encodeUser(User user) throws Exception {
+		if(user==null) return null;
+			String[] itemNames = CompositeDataItemNames.USER;
+			Object[] itemValues = new Object[2];
+			itemValues[0] = encodeRole((Role)user);
+			itemValues[1] =
+				OSGi2JMXCodec.encodeUserCredentials(user.getCredentials());
+			return new CompositeDataSupport(
+				OSGiTypes.USER,
+				itemNames,
+				itemValues);
+	}
+	public static CompositeData encodeRole(Role role) throws Exception {
+		if (role==null) return null;
+		Object[] itemValues = new Object[3];
+		itemValues[0] = role.getName();
+		itemValues[1] = new Integer(role.getType());
+		itemValues[2] =
+			OSGi2JMXCodec.encodeRoleProperties(role.getProperties());
+		CompositeData cdata =
+			new CompositeDataSupport(
+				OSGiTypes.ROLE,
+		 CompositeDataItemNames.ROLE,
+		 		itemValues);
+		return cdata;
+	}
+	public static CompositeData encodeGroup(Group group) throws Exception {
+		if(group==null) return null;
+		String[] itemNames = CompositeDataItemNames.GROUP;
+		Object[] itemValues = new Object[3];
+		itemValues[0] = encodeUser((User)group);
+		Role[] members = group.getMembers();
+		String[] membersNames;
+		if (members!=null){		
+				membersNames = new String[members.length];
+		for (int i = 0; i < members.length; i++)
+			membersNames[i] = members[i].getName();
+		}
+		else{ 
+		 membersNames=new String[0];
+		}
+		itemValues[1] = membersNames;
+		Role[] requiredMembers = group.getRequiredMembers();
+		String [] requiredMembersNames;
+		if(requiredMembers!=null){
+			requiredMembersNames = new String[requiredMembers.length];
+			for (int i = 0; i < requiredMembers.length; i++)
+				requiredMembersNames[i] = requiredMembers[i].getName();
+		}else requiredMembersNames=new String[0];
+		itemValues[2] = requiredMembersNames;
+		return new CompositeDataSupport(OSGiTypes.GROUP, itemNames, itemValues);
+	}
+	public static CompositeData encodeAuthorization(Authorization authorization)
+		throws Exception {
+			if(authorization==null) return null;
+		Object[] itemValues = new Object[2];
+		String[] itemNames = CompositeDataItemNames.AUTHORIZATION;
+		itemValues[0] = authorization.getName();
+		itemValues[1] = authorization.getRoles();
+		return new CompositeDataSupport(
+			OSGiTypes.AUTHORIZATION,
+			itemNames,
+			itemValues);
+	}
+	public static CompositeData encodeLogEntry(LogEntry entry)
+		throws Exception {
+			if (entry==null) return null;
+		String[] itemNames = CompositeDataItemNames.LOG_ENTRY;
+		Object[] itemValues = new Object[7];
+		itemValues[0] = new Integer((int) entry.getBundle().getBundleId());
+		itemValues[1] =entry.getBundle().getLocation();
+		itemValues[2] = OSGi2JMXCodec.encodeException(entry.getException());
+		itemValues[3] = new Integer(entry.getLevel());
+		itemValues[4] = entry.getMessage();
+		itemValues[5] =
+			OSGi2JMXCodec.encodeService(entry.getServiceReference());
+		itemValues[6] = new Integer((int) entry.getTime());
+		return new CompositeDataSupport(
+			OSGiTypes.LOGENTRY,
+			itemNames,
+			itemValues);
+	}
+	public static CompositeData encodeRoleProperties(Dictionary RoleProperties)
+		throws Exception {
+		if (RoleProperties==null) return null;
+		if(RoleProperties.isEmpty()) return null;
+		Enumeration propkeys= RoleProperties.keys();
+		Vector  byteKeys=new Vector();
+		Vector byteValues=new Vector();
+		Vector StringKeys=new Vector();
+		Vector StringValues=new Vector();
+		while(propkeys.hasMoreElements()){
+			Object key=propkeys.nextElement();
+			Object value= RoleProperties.get(key);
+			if ( value instanceof byte[] ) {
+				byteKeys.add(key);
+				byteValues.add(value);
+				}
+				else if (value instanceof String) {
+					 StringKeys.add(key);
+					 StringValues.add(value);
+			}
+		}
+		Byte[][] bvalues=new Byte[byteValues.size()][];
+		for(int i=0; i<byteValues.size();i++){
+			byte[] array=(byte[])byteValues.elementAt(i);
+			bvalues[i]=OSGi2JMXCodec.byte2Byte(array);
+		}
+		Object[] propsItemValues = new Object[4];
+		String[] bkeys = new String[byteKeys.size()];
+		byteKeys.copyInto(bkeys);
+		//byteValues.copyInto(bvalues);
+		String[] skeys = new String[StringKeys.size()];
+		StringKeys.copyInto(skeys);
+		String[] svalues = new String[StringValues.size()];
+		StringValues.copyInto(svalues);
+		propsItemValues[1] = bkeys;
+		propsItemValues[3] = bvalues;
+		propsItemValues[0] =skeys;
+		propsItemValues[2]=svalues;
+		return new CompositeDataSupport(
+			OSGiTypes.ROLEPROPERTIES,
+			CompositeDataItemNames.ROLE_PROPERTIES,
+			propsItemValues);
+	}
+	public static CompositeData encodeUserCredentials(Dictionary credentials)
+		throws Exception {
+			if (credentials==null) return null;
+			if(credentials.isEmpty())return null;
+		String[] itemNames = CompositeDataItemNames.USER_CREDENTIALS;
+		//For the moment, user credentials and role properties have the same structure...
+		CompositeData cdata=OSGi2JMXCodec.encodeRoleProperties(credentials);
+		Object[] values=cdata.getAll(CompositeDataItemNames.USER_CREDENTIALS);
+		return new CompositeDataSupport(
+			OSGiTypes.USERCREDENTIALS,
+			itemNames,
+			values);
+	}
+	public static CompositeData encodeService(ServiceReference service)
+		throws Exception {
+			if(service==null) return null;
+		Object[] itemValues = new Object[3];
+		String[] itemNames = CompositeDataItemNames.SERVICE;
+		int id;
+		String[] objectClass;
+		String BundleLocation;
+		if(service==null){
+			id=-1;
+			objectClass=new String[1];
+			objectClass[0]="No service related to this log entry";
+			BundleLocation="none";
+		}else {
+			id=(int) service.getBundle().getBundleId();
+			objectClass= (String[])service.getProperty(itemNames[1]);
+			BundleLocation=service.getBundle().getLocation();
+		}
+		itemValues[0] = new Integer(id);
+		itemValues[1] =BundleLocation;
+		itemValues[2] =objectClass;
+		return new CompositeDataSupport(
+			OSGiTypes.SERVICE,
+			itemNames,
+			itemValues);
+	}
+	public static CompositeData encodeException(Throwable throwable)
+		throws Exception {
+		if (throwable==null) return null;
+		Object[] itemValues = new Object[2];
+		String[] itemNames = CompositeDataItemNames.EXCEPTION;
+		String message;
+		if (throwable==null) message="This log entry has not an associated exception"; 
+		else message= throwable.getMessage();
+		itemValues[0] =message;
+		StackTraceElement[] stack=throwable.getStackTrace();
+		if(stack==null) itemValues[1]=null;
+		else{
+		CompositeData[] cstack=new CompositeData[stack.length];
+		for (int i=0;i<stack.length;i++) cstack[i]=encodeStackTraceElement(stack[i]);
+		itemValues[1]=cstack;
+		} 
+		return new CompositeDataSupport(
+			OSGiTypes.EXCEPTION,
+			itemNames,
+			itemValues);
+	}
+	public static CompositeData encodeStackTraceElement(StackTraceElement element) throws Exception{
+		Object[] itemValues = new Object[5];
+		String[] itemNames = CompositeDataItemNames.STACK_TRACE_ELEMENT;
+		itemValues[0]=element.getClassName();
+		itemValues[1]=element.getFileName();
+		itemValues[2]=new Integer(element.getLineNumber());
+		itemValues[3]=element.getMethodName();
+		itemValues[4]=new Boolean(element.isNativeMethod());
+		return new CompositeDataSupport(
+			OSGiTypes.STACKTRACE_ELEMENT,
+			itemNames,
+			itemValues);
+	}
+	public static byte[] Byte2byte(Byte[] bytes){
+		byte[] result=new byte[ bytes.length];
+		for(int i=0;i<bytes.length;i++) result[i]=bytes[i].byteValue();
+		return result;
+	}
+	public static Byte[] byte2Byte(byte[] bytes){
+		Byte[] result=new Byte[ bytes.length];
+		for(int i=0;i<bytes.length;i++) result[i]=new Byte(bytes[i]);
+		return result;
+
+	}
+}
\ No newline at end of file

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGiTypes.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGiTypes.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGiTypes.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/OSGiTypes.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,482 @@
+/*
+ *   Copyright 2005 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.jmood.utils;
+import javax.management.openmbean.*;
+/**
+ * This class defines open types in a static way for the management agent. An open type instance defines the structure of an open data.
+ * For more information on open types and open data see jmx specification.
+ *
+ */
+public class OSGiTypes {
+	public final static CompositeType USER;
+	public final static CompositeType ROLE;
+	public final static CompositeType GROUP;
+	public final static CompositeType USERADMINEVENT;
+	public final static CompositeType AUTHORIZATION;
+	public final static CompositeType LOGENTRY;
+	public final static CompositeType ROLEPROPERTIES;
+	public final static CompositeType USERCREDENTIALS;
+	public final static CompositeType SERVICE;
+	public final static CompositeType EXCEPTION;
+	public final static CompositeType BUNDLEEVENT;
+	public final static CompositeType SERVICEEVENT;
+	public final static CompositeType FRAMEWORKEVENT;
+	public final static CompositeType STACKTRACE_ELEMENT;
+	protected static OpenType[] DICTIONARYITEMTYPES = null;
+	//protected static String[] RoleItemNames = null;
+	//protected static String[] RolePropertiesItemNames = null;
+
+	static {
+		try {
+			DICTIONARYITEMTYPES = new OpenType[4];
+			DICTIONARYITEMTYPES[0] = new ArrayType(1, SimpleType.STRING);
+			DICTIONARYITEMTYPES[1] = new ArrayType(1, SimpleType.STRING);
+			DICTIONARYITEMTYPES[2] = new ArrayType(1, SimpleType.STRING);
+			DICTIONARYITEMTYPES[3] = new ArrayType(2, SimpleType.BYTE);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		STACKTRACE_ELEMENT=createStackTraceElementType();	
+		ROLEPROPERTIES = createRolePropertiesType();
+		USERCREDENTIALS = createUserCredentialsType();
+		SERVICE = createServiceType();
+		EXCEPTION = createExceptionType();
+		ROLE = createRoleType();
+		USER = createUserType();
+		GROUP = createGroupType();
+		AUTHORIZATION = createAuthorizationType();
+		LOGENTRY = createLogEntryType();
+		USERADMINEVENT=createUserAdminEventType();
+		BUNDLEEVENT=createBundleEventType();
+		SERVICEEVENT=createServiceEventType();
+		FRAMEWORKEVENT=createFrameworkEventType();
+	}
+		private static CompositeType createBundleEventType(){
+			String description="This type encapsulates OSGi bundle events";
+			String[] itemNames=CompositeDataItemNames.BUNDLE_EVENT;
+			OpenType[] itemTypes=new OpenType[3];
+			String[] itemDescriptions=new String[3];
+		/*	itemNames[0]="BundleId";
+			itemNames[1]="BundleLocation";
+			itemNames[2]="Type";*/
+			itemTypes[0]=SimpleType.INTEGER;
+			itemTypes[1]=SimpleType.STRING;
+			itemTypes[2]=SimpleType.INTEGER;
+			itemDescriptions[0]="The ID of the bundle that generated this event";
+			itemDescriptions[1]="The location of the bundle that generated this event";
+			itemDescriptions[2]="The type of the event: {INSTALLED=1, STARTED=2, STOPPED=4, UPDATED=8, UNINSTALLED=16}";
+			try {
+				return new CompositeType(
+					"BundleEvent",
+					description,
+					itemNames,
+					itemDescriptions,
+					itemTypes);
+			} catch (OpenDataException e) {
+				e.printStackTrace();
+				return null;
+			}
+			
+		}
+		private static CompositeType createServiceEventType(){
+						String description="This type encapsulates OSGi service events";
+						String[] itemNames=CompositeDataItemNames.SERVICE_EVENT;
+						OpenType[] itemTypes=new OpenType[2];
+						String[] itemDescriptions=new String[2];
+						/*itemNames[0]="Service";
+						itemNames[1]="Type";
+						*/
+						itemTypes[0]=SERVICE;
+						itemTypes[1]=SimpleType.INTEGER;
+						itemDescriptions[0]="The service associated with this event";
+						itemDescriptions[1]="The type of the event: {REGISTERED=1, MODIFIED=2 UNREGISTERING=3}";
+						try {
+							return new CompositeType(
+								"ServiceEvent",
+								description,
+								itemNames,
+								itemDescriptions,
+								itemTypes);
+						} catch (OpenDataException e) {
+							e.printStackTrace();
+							return null;
+						}
+			
+		}
+		private static CompositeType createFrameworkEventType(){
+			String description="This type encapsulates OSGi framework events";
+			String[] itemNames=CompositeDataItemNames.FRAMEWORK_EVENT;
+			OpenType[] itemTypes=new OpenType[4];
+			String[] itemDescriptions=new String[4];
+			/*itemNames[0]="BundleId";
+			itemNames[1] ="BundleLocation";
+			itemNames[2]="Throwable";
+			itemNames[3]="Type";
+			*/
+			itemTypes[0]=SimpleType.INTEGER;
+			itemTypes[1]=SimpleType.STRING;
+			itemTypes[2]= EXCEPTION;
+			itemTypes[3]=SimpleType.INTEGER;
+			itemDescriptions[0]="The id of the bundle that os related to this event";
+			itemDescriptions[1]="The location of the bundle that os related to this event";
+			itemDescriptions[2]="The associated exception";
+			itemDescriptions[3]="The type of the event: {STARTED=1, ERROR=2, PACKAGES_REFRESHED=4, STARTLEVEL_CHANGED=8}";
+			try {
+				return new CompositeType(
+					"FrameworkEvent",
+					description,
+					itemNames,
+					itemDescriptions,
+					itemTypes);
+			} catch (OpenDataException e) {
+				e.printStackTrace();
+				return null;
+			}
+		}
+		private static CompositeType createUserAdminEventType(){
+			String description="This type encapsulates OSGi user admin events";
+			String[] itemNames=CompositeDataItemNames.USER_EVENT;
+			OpenType[] itemTypes=new OpenType[3];
+			String[] itemDescriptions=new String[3];
+			/*itemNames[0]="Type";
+			itemNames[1]="Role";
+			itemNames[2]="Service";
+			*/
+			itemTypes[0]=SimpleType.INTEGER;
+			itemTypes[1]=ROLE;
+			itemTypes[2]=SERVICE;
+			itemDescriptions[0]="The type of the event: {ROLE_CREATED= 1, ROLE_CHANGED=2, ROLE_REMOVED=4}";
+			itemDescriptions[1]="The role associated with this event";
+			itemDescriptions[2]="The UserAdmin service associated with this event. In some gateways, there might be more than one service available.";
+			try {
+				return new CompositeType(
+					"UserAdminEvent",
+					description,
+					itemNames,
+					itemDescriptions,
+					itemTypes);
+			} catch (OpenDataException e) {
+				e.printStackTrace();
+				return null;
+			}
+		}
+		private static CompositeType createServiceType() {
+		String description =
+			"The mapping of the service information for log entries";
+		String[] ServiceItemNames = CompositeDataItemNames.SERVICE;
+		/*ServiceItemNames[0] = "BundleId";
+		ServiceItemNames[1] = "BundleLocation";
+		ServiceItemNames[2] = "objectClass";*/
+		String[] itemDescriptions = new String[3];
+		itemDescriptions[0] =
+			"The id of the bundle which registered the service";
+		itemDescriptions[1] ="The location of the bundle that registered the service";
+		itemDescriptions[2] =
+			"An string array containing the interfaces under which the service has been registered";
+		OpenType[] itemTypes = new OpenType[3];
+		itemTypes[0] = SimpleType.INTEGER;
+		itemTypes[1] =SimpleType.STRING;
+		try {
+			itemTypes[2] = new ArrayType(1, SimpleType.STRING);
+			return new CompositeType(
+				"Service",
+				description,
+				ServiceItemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createStackTraceElementType() {
+		//classname,filename,int linenumber,string method name,boolean isNativeMethod	
+		String description = "The mapping for of stack trace's elements";
+		String[] itemNames =CompositeDataItemNames.STACK_TRACE_ELEMENT;
+		/*itemNames[0] = "ClassName";
+		itemNames[1]="FileName";
+		itemNames[2]="LineNumber";
+		itemNames[3]="MethodName";
+		itemNames[4]="isNativeMethod";*/
+		String[] itemDescriptions = new String[5];
+		itemDescriptions[0] = "the class where occured";
+		itemDescriptions[1]="the file name";
+		itemDescriptions[2] = "the line number";
+		itemDescriptions[3] = "the method name";
+		itemDescriptions[4] = "True if it is a native method";
+		OpenType[] itemTypes = new OpenType[5];
+		itemTypes[0] = SimpleType.STRING;
+		itemTypes[1] = SimpleType.STRING;
+		itemTypes[2] = SimpleType.INTEGER;
+		itemTypes[3] = SimpleType.STRING;
+		itemTypes[4] = SimpleType.BOOLEAN;
+		try {
+			return new CompositeType(
+				"Exception",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createExceptionType() {
+		String description = "The exception mapping for logging purposes";
+		String[] itemNames = CompositeDataItemNames.EXCEPTION;
+		/*itemNames[0] = "Message";
+		itemNames[1]="StackTrace";*/
+		String[] itemDescriptions = new String[2];
+		itemDescriptions[0] = "The exception's message";
+		itemDescriptions[1]="The exception's stack trace";
+		OpenType[] itemTypes = new OpenType[2];
+		itemTypes[0] = SimpleType.STRING;
+		try {
+			itemTypes[1] = new ArrayType(1, STACKTRACE_ELEMENT);
+			return new CompositeType(
+				"Exception",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+	private static CompositeType createRolePropertiesType() {
+		String description =
+			"The properties dictionary mapping of a Role. It has four fields: KeysForStringValues, KeysForByteArrayValues, StringValues, ByteArrayValues";
+		String[] RolePropertiesItemNames = CompositeDataItemNames.ROLE_PROPERTIES;
+		/*RolePropertiesItemNames[0] = "KeysForStringValues";
+		RolePropertiesItemNames[1] = "KeysForByteArrayValues";
+		RolePropertiesItemNames[3] = "ByteArrayValues";
+		RolePropertiesItemNames[2] = "StringValues";*/
+		String[] itemDescriptions = new String[4];
+		itemDescriptions[0] =
+			"A string array containing the keys for the properties which are Strings";
+		itemDescriptions[1] =
+			"A string array containing the keys for the properties which are byte[]";
+		itemDescriptions[2] =
+			"A string array containing the values of the properties which are Strings";
+		itemDescriptions[3] =
+			"A 2D-array containing the values of the properties which are byte[]. byte[i] is the i-nth Byte[], whose key is at KeysForByteArrayValues[i]";
+		try {
+			return new CompositeType(
+				"RoleProperties",
+				description,
+				RolePropertiesItemNames,
+				itemDescriptions,
+				DICTIONARYITEMTYPES);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	private static CompositeType createUserCredentialsType() {
+		//BUG possibly problems here with indexes which is which. review
+		String description = "The credentials for a user";
+		String[] itemNames = CompositeDataItemNames.USER_CREDENTIALS;
+		/*itemNames[0] = "KeysForStringValues";
+		itemNames[1] = "KeysForByteArrayValues";
+		itemNames[3] = "ByteArrayValues";
+		itemNames[2] = "StringValues";
+		*/
+		String[] itemDescriptions = new String[4];
+		itemDescriptions[0] =
+			"A string array containing the keys for the credentials which are Strings";
+		itemDescriptions[1] =
+			"A string array containing the keys for the credentials which are byte[]";
+		itemDescriptions[2] =
+			"A string array containing the values of the credentials which are Strings";
+		itemDescriptions[3] =
+			"A 2D-array containing the values of the credentials which are byte[]. byte[i] is the i-nth Byte[], whose key is at KeysForByteArrayValues[i]";
+		try {
+
+		return new CompositeType(
+				"UserCredentials",
+				description,
+				itemNames,
+				itemDescriptions,
+				OSGiTypes.DICTIONARYITEMTYPES);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	private static CompositeType createUserType() {
+		//public CompositeType(String typeName, String description, String[] itemNames, String[] itemDescriptions, OpenType[] itemTypes)		
+		String description =
+			"Mapping of org.osgi.service.useradmin.User for remote management purposes. User extends Role";
+		String[] itemNames = CompositeDataItemNames.USER;
+		/*itemNames[0] = "Role";
+		itemNames[1] = "credentials";*/
+		String[] itemDescriptions = new String[2];
+		itemDescriptions[0] = "The role object that is extended by this user object";
+		itemDescriptions[1] = "The credentials for this user";
+		OpenType[] itemTypes = new OpenType[2];
+		itemTypes[0] = ROLE;
+		itemTypes[1] = USERCREDENTIALS;
+		try {
+
+			return new CompositeType(
+				"User",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createRoleType() {
+		createRolePropertiesType();
+		String description =
+			"Mapping of org.osgi.service.useradmin.Role for remote management purposes. User and Group extend Role";
+		String []RoleItemNames = CompositeDataItemNames.ROLE;
+		/*RoleItemNames[0] = "name";
+		RoleItemNames[1] = "type";
+		RoleItemNames[2] = "properties";*/
+		String[] itemDescriptions = new String[3];
+		itemDescriptions[0] =
+			"The name of the role. Can be either a group or a user";
+		itemDescriptions[1] =
+			"An integer representing type of the role: {0=Role,1=user,2=group}";
+		itemDescriptions[2] =
+			"A properties list as defined by org.osgi.service.useradmin.Role";
+		OpenType[] itemTypes = new OpenType[3];
+		itemTypes[0] = SimpleType.STRING;
+		itemTypes[1] = SimpleType.INTEGER;
+		itemTypes[2] = ROLEPROPERTIES;
+		try {
+
+			return new CompositeType(
+				"Role",
+				description,
+				RoleItemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createGroupType() {
+		String description =
+			"Mapping of org.osgi.service.useradmin.Group for remote management purposes. Group extends User which in turn extends Role";
+		String[] itemNames = CompositeDataItemNames.GROUP;
+		/*itemNames[0] = "User";
+		itemNames[1] = "members";
+		itemNames[2] = "requiredMembers";
+		*/
+		String[] itemDescriptions = new String[3];
+		itemDescriptions[0] = "The user object that is extended by this group object";
+		itemDescriptions[1] = "The members of this group";
+		itemDescriptions[2] = "The required members for this group";
+		OpenType[] itemTypes = new OpenType[3];
+		itemTypes[0] = USER;
+		try {
+			itemTypes[1] = new ArrayType(1, SimpleType.STRING);
+			itemTypes[2] = new ArrayType(1, SimpleType.STRING);
+			return new CompositeType(
+				"Group",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createAuthorizationType() {
+		String description =
+			"An authorization object defines which roles has a user got";
+		String[] itemNames = CompositeDataItemNames.AUTHORIZATION;
+		/*itemNames[0] = "UserName";
+		itemNames[1] = "RoleNames";*/
+		String[] itemDescriptions = new String[2];
+		itemDescriptions[0] = "The user name for this authorization object";
+		itemDescriptions[1] =
+			"The names of the roles encapsulated by this auth object";
+		OpenType[] itemTypes = new OpenType[2];
+		itemTypes[0] = SimpleType.STRING;
+		try {
+			itemTypes[1] = new ArrayType(1, SimpleType.STRING);
+			return new CompositeType(
+				"Authorization",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	private static CompositeType createLogEntryType() {
+		String description =
+			"A log entry type encapsulates a org.osgi.service.log.LogEntry";
+		String[] itemNames = CompositeDataItemNames.LOG_ENTRY;
+		/*itemNames[0] = "BundleId";
+		itemNames[1] = "BundleLocation";
+		itemNames[2] = "Throwable";
+		itemNames[3] = "Level";
+		itemNames[4] = "Message";
+		itemNames[5] = "ServiceReference";
+		itemNames[6] = "Time";*/
+		String[] itemDescriptions = new String[7];
+		itemDescriptions[0] =
+			"The id for the bundle that generated the log entry";
+		itemDescriptions[1] =
+					"The location of the bundle that generated the log entry";
+		itemDescriptions[2] =
+			"The ExceptionType that caused the error, or null if there was none";
+		itemDescriptions[3] = "The level of entry: DEBUG, INFO, ERROR, WARNING";
+		itemDescriptions[4] = "The log message";
+		itemDescriptions[5] =
+			"The service that generated the log entry, or null if not available";
+		itemDescriptions[6] = "The time at which the exception occurred";
+		OpenType[] itemTypes = new OpenType[7];
+		itemTypes[0] = SimpleType.INTEGER;
+		itemTypes[1]=SimpleType.STRING;
+		itemTypes[2] = EXCEPTION;
+		itemTypes[3] = SimpleType.INTEGER;
+		itemTypes[4] = SimpleType.STRING;
+		
+		try {
+			itemTypes[5] = SERVICE;
+			itemTypes[6] = SimpleType.INTEGER;
+			return new CompositeType(
+				"LogEntry",
+				description,
+				itemNames,
+				itemDescriptions,
+				itemTypes);
+		} catch (OpenDataException e) {
+			e.printStackTrace();
+			return null;
+		}
+	}
+	
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/ObjectNames.java
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/ObjectNames.java?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/ObjectNames.java (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/java/org/apache/felix/jmood/utils/ObjectNames.java Thu Aug 10 15:15:58 2006
@@ -0,0 +1,51 @@
+/*
+ *   Copyright 2005 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.jmood.utils;
+
+/**
+ * This interface holds the <code>ObjectName</code>s under which the
+ * core MBeans (<code>CoreControllerMBean</code>, <code>ManagedBundleMBean</code>, 
+ * <code>ManagedServiceMBean</code>) and <code>ManagedPackageMBean</code>
+ * Note that service, bundle and package data mbeans are created dynamically
+ * and need a dynamic property to be added to the objectName.
+ *
+ */
+public interface ObjectNames {
+    public static final String CORE= "osgi.core";
+    public static final String COMPENDIUM="osgi.compendium";
+    public static final String CORE_CONTROLLER=CORE+":type=controller";
+    public static final String FRAMEWORK=CORE+":type=framework";
+    public static final String BUNDLE=CORE+":type=bundle, symbolicName=";
+    public static final String SERVICE=CORE+":type=service, service.id=";
+    public static final String CM_SERVICE=COMPENDIUM+":service=cm, type=manager";
+    public static final String CM_OBJECT=COMPENDIUM+":service=cm, type=object,"; 
+    public static final String LOG_SERVICE = COMPENDIUM+":service=log";
+    public static final String UA_SERVICE = COMPENDIUM+":service=useradmin"; 
+
+    /**
+     * package mbean object names also contain a version property to 
+     * avoid <code>InstanceAlreadyExistsException</code> when two
+     * versions of the same package co-exist.  
+     */
+    public static final String PACKAGE=CORE+":type=package, name=";
+    public static final String ALLBUNDLES=CORE+":type=bundle,*";
+    public static final String ALLSERVICES=CORE+":type=service,*";
+    public static final String ALLPACKAGES=CORE+":type=package,*";
+    public static final String ALL_CM_OBJECT=COMPENDIUM+":service=cm, type=object,*";
+    
+}

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/agent.properties
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/agent.properties?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/agent.properties (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/agent.properties Thu Aug 10 15:15:58 2006
@@ -0,0 +1,2 @@
+java.security.policy=simple.policy
+policy.embedded=true
\ No newline at end of file

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/config.properties
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/config.properties?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/config.properties (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/config.properties Thu Aug 10 15:15:58 2006
@@ -0,0 +1,333 @@
+#
+# Framework config properties.
+#
+org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \
+ org.osgi.service.packageadmin; version=1.2.0, \
+ org.osgi.service.startlevel; version=1.0.0, \
+ org.osgi.service.url; version=1.0.0, \
+ org.osgi.service.permissionadmin; version=1.0.0, \
+ org.osgi.service.useradmin; version=1.0.0, \
+ org.osgi.service.cm; version=1.0.0, \
+ org.osgi.service.log, \
+ org.osgi.util.tracker, \
+ ${jre-${java.specification.version}}
+
+#org.osgi.framework.bootdelegation=sun.*,com.sun.*
+#felix.cache.profile=foo
+#repo=${settings.localRepository} #Somehow, it does not get substituted
+repo="/C:/Documents and Settings/mili/.m2/repository"
+
+version=${pom.version}
+felix.auto.start.1= \
+ file:${repo}/org/apache/felix/org.apache.felix.shell/0.8.0-SNAPSHOT/org.apache.felix.shell-0.8.0-SNAPSHOT.jar \
+ file:${repo}/repository/org/apache/felix/org.apache.felix.shell.tui/0.8.0-SNAPSHOT/org.apache.felix.shell.tui-0.8.0-SNAPSHOT.jar \
+ file:${repo}/org/apache/felix/org.apache.felix.jmood/0.8.0-SNAPSHOT/org.apache.felix.jmood-0.8.0-SNAPSHOT.jar \
+ 
+felix.startlevel.framework=1
+felix.startlevel.bundle=1
+#framework.service.urlhandlers=false
+
+#
+# Bundle config properties.
+#
+org.osgi.service.http.port=8080
+obr.shell.telnet=on
+#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=repository
+
+
+#
+# Java platform package export properties.
+#
+jre-1.3= \
+ javax.accessibility; \
+ javax.accessibility.resources; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.basic.resources; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.metal.resources; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ version="1.3.0"
+
+jre-1.4= \
+ javax.accessibility; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ org.apache.crimson.jaxp; \
+ org.apache.crimson.parser; \
+ org.apache.crimson.parser.resources; \
+ org.apache.crimson.tree; \
+ org.apache.crimson.tree.resources; \
+ org.apache.crimson.util; \
+ org.apache.xalan; \
+ org.apache.xalan.client; \
+ org.apache.xalan.extensions; \
+ org.apache.xalan.lib; \
+ org.apache.xalan.lib.sql; \
+ org.apache.xalan.processor; \
+ org.apache.xalan.res; \
+ org.apache.xalan.serialize; \
+ org.apache.xalan.templates; \
+ org.apache.xalan.trace; \
+ org.apache.xalan.transformer; \
+ org.apache.xalan.xslt; \
+ org.apache.xml.dtm; \
+ org.apache.xml.dtm.ref; \
+ org.apache.xml.dtm.ref.dom2dtm; \
+ org.apache.xml.dtm.ref.sax2dtm; \
+ org.apache.xml.utils; \
+ org.apache.xml.utils.res; \
+ org.apache.xml.utils.synthetic; \
+ org.apache.xml.utils.synthetic.reflection; \
+ org.apache.xpath; \
+ org.apache.xpath.axes; \
+ org.apache.xpath.compiler; \
+ org.apache.xpath.functions; \
+ org.apache.xpath.objects; \
+ org.apache.xpath.operations; \
+ org.apache.xpath.patterns; \
+ org.apache.xpath.res; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.4.0"
+
+jre-1.5= \
+ javax.accessibility; \
+ javax.activity; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.5.0"

Added: incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/descriptor.xml
URL: http://svn.apache.org/viewvc/incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/descriptor.xml?rev=430562&view=auto
==============================================================================
--- incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/descriptor.xml (added)
+++ incubator/felix/sandbox/santillan/org.apache.felix.jmood/src/main/resources/descriptor.xml Thu Aug 10 15:15:58 2006
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<dependencies xmlns:xsi="http://www.w3c.org/2001/XMLSchema-Instance">
+      <source>
+         <priority>
+           <type>optional</type>
+            <level>12</level>
+         </priority>
+         <name>jmood</name>         
+         <version>0.8</version>
+         <provider>
+           <name>UPM</name>
+           <id>3</id>
+         </provider>
+         <container>
+           <name>jmood</name>
+	   <version>0.8</version>
+           <url>http://cauca.dit.upm.es:9000/testing/jmood.jar</url>
+	   <metadata-url>http://maquina.dit.upm.es:9000/testing/metadata/jmood.xml</metadata-url>
+         </container>
+      </source>
+      <endPoint>
+         <level>application</level>
+         <kind>and</kind>                 
+         <container>
+           <name>OSGi-service</name>
+           <version>1.0</version>
+           <url>http://maquina.dit.upm.es:9000/testing/osgi-service.jar</url>
+           <metadata-url>http://cauca.dit.upm.es:9000/osgi-service.xml</metadata-url>
+         </container>
+         <description>Bundle containing all the standard services definitions</description>
+      </endPoint>													
+	  <endPoint>
+         <level>application</level>
+         <kind>and</kind>                 
+         <container>
+           <name>OSGi-util</name>
+           <version>1.0</version>
+           <url>http://maquina.dit.upm.es:9000/testing/osgi-util.jar</url>
+           <metadata-url>http://cauca.dit.upm.es:9000/osgi-util.xml</metadata-url>
+         </container>
+         <description>Bundle containing all the standard osgi utils</description>
+      </endPoint>													
+       <endPoint>
+         <level>application</level>
+         <kind>and</kind>
+         <container>
+           <name>telvent-bundle</name>
+           <version>1.0</version>
+           <url>http://maquina.dit.upm.es:9000/testing/telvent-bundle.jar</url>
+           <metadata-url>http://maquina.dit.upm.es:9000/testing/metadata/telvent-bundle.xml</metadata-url>
+         </container>
+         <description>This is a dependency to Telvent's Axis wrapper</description>
+       </endPoint>												   
+      </dependencies>



Mime
View raw message