You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/24 19:06:44 UTC
svn commit: r797561 [2/9] - in /felix/trunk: org.osgi.compendium/
org.osgi.compendium/src/main/java/info/dmtree/
org.osgi.compendium/src/main/java/info/dmtree/notification/
org.osgi.compendium/src/main/java/info/dmtree/notification/spi/
org.osgi.compen...
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationContext.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationContext.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationContext.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationContext.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.application/src/org/osgi/application/ApplicationContext.java,v 1.15 2006/07/11 13:19:02 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,26 +22,26 @@
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
-
/**
* <code>ApplicationContext</code> is the access point for an OSGi-aware
* application to the features of the OSGi Service Platform. Each application
* instance will have its own <code>ApplicationContext</code> instance, which
* will not be reused after destorying the corresponding application instace.
* <p>
- * Application instances can obtain their <code>ApplicationContext</code>
- * using the {@link Framework#getApplicationContext} method.
+ * Application instances can obtain their <code>ApplicationContext</code> using
+ * the {@link Framework#getApplicationContext} method.
* <p>
- * The lifecycle of an <code>ApplicationContext</code> instance is bound to
- * the lifecycle of the corresponding application instance. The
+ * The lifecycle of an <code>ApplicationContext</code> instance is bound to the
+ * lifecycle of the corresponding application instance. The
* <code>ApplicationContext</code> becomes available when the application is
* started and it is invalidated when the application instance is stopped (i.e.
- * the "stop" method of the application activator object returned).
- * All method calls (except {@link #getApplicationId()} and
- * {@link #getInstanceId()}) to an invalidated context object result an
- * <code>IllegalStateException</code>.
+ * the "stop" method of the application activator object returned). All method
+ * calls (except {@link #getApplicationId()} and {@link #getInstanceId()}) to an
+ * invalidated context object result an <code>IllegalStateException</code>.
*
* @see org.osgi.application.Framework
+ *
+ * @version $Revision: 5673 $
*/
public interface ApplicationContext {
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceEvent.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceEvent.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceEvent.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceEvent.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.application/src/org/osgi/application/ApplicationServiceEvent.java,v 1.6 2006/07/11 13:19:02 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +38,7 @@
* @see org.osgi.framework.ServiceEvent
* @see ApplicationServiceListener
*
- * @version $Revision: 1.6 $
+ * @version $Revision: 5673 $
*/
public class ApplicationServiceEvent extends ServiceEvent {
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceListener.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceListener.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/ApplicationServiceListener.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.application/src/org/osgi/application/ApplicationServiceListener.java,v 1.6 2006/07/12 21:21:34 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +52,7 @@
* objects is further filtered according to package sources as defined in
* {@link ServiceReference#isAssignableTo(Bundle, String)}.
*
- * @version $Revision: 1.6 $
+ * @version $Revision: 5673 $
* @see ApplicationServiceEvent
* @see ServicePermission
*/
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/Framework.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/Framework.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/Framework.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/Framework.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.application/src/org/osgi/application/Framework.java,v 1.9 2006/07/11 13:19:02 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +19,10 @@
import java.util.Hashtable;
/**
- * Using this class, OSGi-aware applications can obtain their {@link ApplicationContext}.
- *
+ * Using this class, OSGi-aware applications can obtain their
+ * {@link ApplicationContext}.
+ *
+ * @version $Revision: 5673 $
*/
public final class Framework {
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/package.html?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/package.html (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/package.html Fri Jul 24 17:06:37 2009
@@ -0,0 +1,10 @@
+<!-- $Revision: 6204 $ -->
+<BODY>
+<p>Foreign Application Package Version 1.0.
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.application; version="[1.0,2.0)"
+</pre>
+</BODY>
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/packageinfo?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/packageinfo (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/application/packageinfo Fri Jul 24 17:06:37 2009
@@ -0,0 +1 @@
+version 1.0
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationAdminPermission.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationAdminPermission.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationAdminPermission.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationAdminPermission.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationAdminPermission.java,v 1.34 2006/07/12 21:22:11 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2009). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,21 +17,27 @@
package org.osgi.service.application;
import java.security.Permission;
-import java.util.*;
-
-import org.osgi.framework.*;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
/**
- * This class implements permissions for manipulating applications and
- * their instances.
+ * This class implements permissions for manipulating applications and their
+ * instances.
* <P>
* ApplicationAdminPermission can be targeted to applications that matches the
* specified filter.
* <P>
* ApplicationAdminPermission may be granted for different actions:
- * <code>lifecycle</code>, <code>schedule</code> and <code>lock</code>.
- * The permission <code>schedule</code> implies the permission
+ * <code>lifecycle</code>, <code>schedule</code> and <code>lock</code>. The
+ * permission <code>schedule</code> implies the permission
* <code>lifecycle</code>.
+ *
+ * @version $Revision: 6860 $
*/
public class ApplicationAdminPermission extends Permission {
private static final long serialVersionUID = 1L;
@@ -146,7 +150,7 @@
try {
newPerm = new ApplicationAdminPermission( this.filter, this.actions );
}catch( InvalidSyntaxException e ) {
- throw new RuntimeException( "Internal error" ); /* this can never happen */
+ throw new RuntimeException(e); /* this can never happen */
}
}
else
@@ -303,6 +307,9 @@
private String pattern;
private ApplicationDescriptor appDesc;
+ /**
+ * @param pattern
+ */
public SignerWrapper(String pattern) {
this.pattern = pattern;
}
@@ -333,71 +340,9 @@
}
private Filter getFilter() {
- String transformedFilter = filter;
-
if (appliedFilter == null) {
try {
- int pos = filter.indexOf("signer"); //$NON-NLS-1$
- if (pos != -1){
-
- //there may be a signer attribute
- StringBuffer filterBuf = new StringBuffer(filter);
- int numAsteriskFound = 0; //use as offset to replace in buffer
-
- int walkbackPos; //temp pos
-
- //find occurences of (signer= and escape out *'s
- while (pos != -1) {
-
- //walk back and look for '(' to see if this is an attr
- walkbackPos = pos-1;
-
- //consume whitespace
- while(walkbackPos >= 0 && Character.isWhitespace(filter.charAt(walkbackPos))) {
- walkbackPos--;
- }
- if (walkbackPos <0) {
- //filter is invalid - FilterImpl will throw error
- break;
- }
-
- //check to see if we have unescaped '('
- if (filter.charAt(walkbackPos) != '(' || (walkbackPos > 0 && filter.charAt(walkbackPos-1) == '\\')) {
- //'(' was escaped or not there
- pos = filter.indexOf("signer",pos+6); //$NON-NLS-1$
- continue;
- }
- pos+=6; //skip over 'signer'
-
- //found signer - consume whitespace before '='
- while (Character.isWhitespace(filter.charAt(pos))) {
- pos++;
- }
-
- //look for '='
- if (filter.charAt(pos) != '=') {
- //attr was signerx - keep looking
- pos = filter.indexOf("signer",pos); //$NON-NLS-1$
- continue;
- }
- pos++; //skip over '='
-
- //found signer value - escape '*'s
- while (!(filter.charAt(pos) == ')' && filter.charAt(pos-1) != '\\')) {
- if (filter.charAt(pos) == '*') {
- filterBuf.insert(pos+numAsteriskFound,'\\');
- numAsteriskFound++;
- }
- pos++;
- }
-
- //end of signer value - look for more?
- pos = filter.indexOf("signer",pos); //$NON-NLS-1$
- } //end while (pos != -1)
- transformedFilter = filterBuf.toString();
- } //end if (pos != -1)
-
- appliedFilter = FrameworkUtil.createFilter( transformedFilter );
+ appliedFilter = FrameworkUtil.createFilter(filter);
} catch (InvalidSyntaxException e) {
//we will return null
}
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationDescriptor.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationDescriptor.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationDescriptor.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationDescriptor.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationDescriptor.java,v 1.61 2006/07/10 12:02:31 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2009). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +18,9 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.security.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
import java.util.Map;
import org.osgi.framework.Constants;
@@ -30,6 +30,8 @@
* An OSGi service that represents an installed application and stores
* information about it. The application descriptor can be used for instance
* creation.
+ *
+ * @version $Revision: 6860 $
*/
public abstract class ApplicationDescriptor {
@@ -263,8 +265,9 @@
* The following steps are made:
* <UL>
* <LI>Check for the appropriate permission.
- * <LI>Check the locking state of the application. If locked then return
- * null otherwise continue.
+ * <LI>Check the locking state of the application. If locked then throw
+ * an {@link ApplicationException} with the reason code
+ * {@link ApplicationException#APPLICATION_LOCKED}.
* <LI>Calls the <code>launchSpecific()</code> method to create and start an application
* instance.
* <LI>Returns the <code>ApplicationHandle</code> returned by the
@@ -290,7 +293,7 @@
* <code>org.osgi.</code>.</li>
* </ul>
* <P>
- * The method is synchonous, it return only when the application instance was
+ * The method is synchronous, it return only when the application instance was
* successfully started or the attempt to start it failed.
* <P>
* This method never returns <code>null</code>. If launching an application fails,
@@ -386,7 +389,9 @@
* <p>
* The <code>Map</code> argument of the method contains startup
* arguments for the application. The keys used in the Map must be non-null,
- * non-empty <code>String<code> objects.
+ * non-empty <code>String<code> objects. The argument values must be
+ * of primitive types, wrapper classes of primitive types, <code>String</code>
+ * or arrays or collections of these.
* <p>
* The created schedules have a unique identifier within the scope of this
* <code>ApplicationDescriptor</code>. This identifier can be specified
@@ -428,6 +433,9 @@
* <li> {@link ApplicationException#APPLICATION_SCHEDULING_FAILED}
* if the scheduling failed due to some internal reason
* (e.g. persistent storage error).
+ * <li> {@link ApplicationException#APPLICATION_INVALID_STARTUP_ARGUMENT}
+ * if the specified startup argument doesn't satisfy the
+ * type or value constraints of startup arguments.
* </ul>
* @throws SecurityException
* if the caller doesn't have "schedule"
@@ -594,7 +602,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -614,7 +622,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -634,7 +642,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -654,7 +662,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -682,7 +690,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
@@ -705,7 +713,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
}
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationException.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationException.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationException.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationException.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationException.java,v 1.10 2006/07/10 11:49:12 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2005, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2005, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,28 +17,37 @@
package org.osgi.service.application;
/**
- * This exception is used to indicate problems related to application
- * lifecycle management.
+ * This exception is used to indicate problems related to application lifecycle
+ * management.
*
- * <code>ApplicationException</code> object is created by the Application Admin to denote
- * an exception condition in the lifecycle of an application.
- * <code>ApplicationException</code>s should not be created by developers.
- * <br/>
- * <code>ApplicationException</code>s are associated with an error code. This code
- * describes the type of problem reported in this exception. The possible codes are:
+ * <code>ApplicationException</code> object is created by the Application Admin
+ * to denote an exception condition in the lifecycle of an application.
+ * <code>ApplicationException</code>s should not be created by developers. <br/>
+ * <code>ApplicationException</code>s are associated with an error code. This
+ * code describes the type of problem reported in this exception. The possible
+ * codes are:
* <ul>
- * <li> {@link #APPLICATION_LOCKED} - The application couldn't be launched because it is locked.</li>
- * <li> {@link #APPLICATION_NOT_LAUNCHABLE} - The application is not in launchable state.</li>
- * <li> {@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the application or its
- * container during launch.</li>
+ * <li> {@link #APPLICATION_LOCKED} - The application couldn't be launched
+ * because it is locked.</li>
+ * <li> {@link #APPLICATION_NOT_LAUNCHABLE} - The application is not in
+ * launchable state.</li>
+ * <li> {@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the
+ * application or its container during launch.</li>
* <li> {@link #APPLICATION_SCHEDULING_FAILED} - The scheduling of an application
- * failed.
+ * failed.
+ * <li> {@link #APPLICATION_DUPLICATE_SCHEDULE_ID} - The application scheduling
+ * failed because the specified identifier is already in use.
+ * <li> {@link #APPLICATION_EXITVALUE_NOT_AVAILABLE} - The exit value is not
+ * available for an application instance because the instance has not
+ * terminated.
+ * <li> {@link #APPLICATION_INVALID_STARTUP_ARGUMENT} - One of the specified
+ * startup arguments is invalid, for example its type is not permitted.
* </ul>
*
+ * @version $Revision: 6083 $
*/
public class ApplicationException extends Exception {
private static final long serialVersionUID = -7173190453622508207L;
- private final Throwable cause;
private final int errorCode;
/**
@@ -54,16 +61,17 @@
* attribute is false.
*/
public static final int APPLICATION_NOT_LAUNCHABLE = 0x02;
-
+
/**
- * An exception was thrown by the application or the corresponding
- * container during launch. The exception is available in {@link #getCause()}.
+ * An exception was thrown by the application or the corresponding container
+ * during launch. The exception is available from <code>getCause()</code>.
*/
public static final int APPLICATION_INTERNAL_ERROR = 0x03;
/**
* The application schedule could not be created due to some internal error
- * (for example, the schedule information couldn't be saved).
+ * (for example, the schedule information couldn't be saved due to some
+ * storage error).
*/
public static final int APPLICATION_SCHEDULING_FAILED = 0x04;
@@ -74,11 +82,28 @@
public static final int APPLICATION_DUPLICATE_SCHEDULE_ID = 0x05;
/**
+ * The exit value is not available for an application instance because the
+ * instance has not terminated.
+ *
+ * @since 1.1
+ */
+ public static final int APPLICATION_EXITVALUE_NOT_AVAILABLE = 0x06;
+
+ /**
+ * One of the specified startup arguments is invalid, for example its
+ * type is not permitted.
+ *
+ * @since 1.1
+ */
+ public static final int APPLICATION_INVALID_STARTUP_ARGUMENT = 0x07;
+
+ /**
* Creates an <code>ApplicationException</code> with the specified error code.
* @param errorCode The code of the error
*/
public ApplicationException(int errorCode) {
- this(errorCode,(Throwable) null);
+ super();
+ this.errorCode = errorCode;
}
/**
@@ -88,8 +113,7 @@
* @param cause The cause of this exception.
*/
public ApplicationException(int errorCode, Throwable cause) {
- super();
- this.cause = cause;
+ super(cause);
this.errorCode = errorCode;
}
@@ -99,7 +123,8 @@
* @param message The associated message
*/
public ApplicationException(int errorCode, String message) {
- this(errorCode, message,null);
+ super(message);
+ this.errorCode = errorCode;
}
/**
@@ -110,24 +135,24 @@
* @param cause The cause of this exception.
*/
public ApplicationException(int errorCode, String message, Throwable cause) {
- super(message);
- this.cause = cause;
+ super(message, cause);
this.errorCode = errorCode;
}
/**
- * Returns the cause of this exception or <code>null</code> if no cause
- * was specified when this exception was created.
+ * Returns the cause of this exception or <code>null</code> if no cause was
+ * set.
*
- * @return The cause of this exception or <code>null</code> if no cause
- * was specified.
+ * @return The cause of this exception or <code>null</code> if no cause was
+ * set.
*/
public Throwable getCause() {
- return cause;
+ return super.getCause();
}
/**
- * Returns the error code associcated with this exception.
+ * Returns the error code associated with this exception.
+ *
* @return The error code of this exception.
*/
public int getErrorCode() {
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationHandle.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationHandle.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationHandle.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ApplicationHandle.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationHandle.java,v 1.41 2006/07/10 12:02:31 hargrave Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +18,9 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.security.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
import org.osgi.framework.Constants;
@@ -29,6 +29,8 @@
* of an application. It provides the functionality to query and manipulate the
* lifecycle state of the represented application instance. It defines constants
* for the lifecycle states.
+ *
+ * @version $Revision: 5901 $
*/
public abstract class ApplicationHandle {
/*
@@ -50,11 +52,19 @@
public final static String APPLICATION_DESCRIPTOR = "application.descriptor";
/**
- * The property key for the state of this appliction instance.
+ * The property key for the state of this application instance.
*/
public final static String APPLICATION_STATE = "application.state";
/**
+ * The property key for the supports exit value property of this application
+ * instance.
+ *
+ * @since 1.1
+ */
+ public final static String APPLICATION_SUPPORTS_EXITVALUE = "application.supports.exitvalue";
+
+ /**
* The application instance is running. This is the initial state of a newly
* created application instance.
*/
@@ -137,6 +147,45 @@
public abstract String getState();
/**
+ * Returns the exit value for the application instance. The timeout
+ * specifies how the method behaves when the application has not yet
+ * terminated. A negative, zero or positive value may be used.
+ * <ul>
+ * <li> negative - The method does not wait for termination. If the
+ * application has not terminated then an <code>ApplicationException</code>
+ * is thrown.</li>
+ *
+ * <li> zero - The method waits until the application terminates.</li>
+ *
+ * <li> positive - The method waits until the application terminates or the
+ * timeout expires. If the timeout expires and the application has not
+ * terminated then an <code>ApplicationException</code> is thrown.</li>
+ * </ul>
+ * <p>
+ * The default implementation throws an
+ * <code>UnsupportedOperationException</code>. The application model should
+ * override this method if exit values are supported.
+ * </p>
+ *
+ * @param timeout The maximum time in milliseconds to wait for the
+ * application to timeout.
+ * @return The exit value for the application instance. The value is
+ * application specific.
+ * @throws UnsupportedOperationException If the application model does not
+ * support exit values.
+ * @throws InterruptedException If the thread is interrupted while waiting
+ * for the timeout.
+ * @throws ApplicationException If the application has not terminated. The
+ * error code will be
+ * {@link ApplicationException#APPLICATION_EXITVALUE_NOT_AVAILABLE}.
+ *
+ * @since 1.1
+ */
+ public Object getExitValue(long timeout) throws ApplicationException, InterruptedException{
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Returns the unique identifier of this instance. This value is also
* available as a service property of this application handle's service.pid.
*
@@ -181,7 +230,7 @@
}catch( SecurityException se ) {
descriptor.isLaunchableSpecific(); /* check whether the bundle was uninstalled */
/* if yes, throws IllegalStateException */
- throw se; /* otherwise throw the catched SecurityException */
+ throw se; /* otherwise throw the caught SecurityException */
}
destroySpecific();
}
@@ -265,7 +314,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
void destroy() {
@@ -284,7 +333,7 @@
throw e;
}
catch (Throwable e) {
- throw new RuntimeException(e.toString());
+ throw new RuntimeException(e);
}
}
}
Modified: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ScheduledApplication.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ScheduledApplication.java?rev=797561&r1=797560&r2=797561&view=diff
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ScheduledApplication.java (original)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/ScheduledApplication.java Fri Jul 24 17:06:37 2009
@@ -1,7 +1,5 @@
/*
- * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ScheduledApplication.java,v 1.20 2006/07/06 14:59:29 sboshev Exp $
- *
- * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2004, 2008). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +27,12 @@
* Each <code>ScheduledApplication</code> instance has an identifier which is
* unique within the scope of the application being scheduled.
* <p>
- * <code>ScheduledApplication</code> instances are registered as services.
- * The {@link #APPLICATION_PID} service property contains the PID of the
- * application being scheduled, the {@link #SCHEDULE_ID} service property
- * contains the schedule identifier.
+ * <code>ScheduledApplication</code> instances are registered as services. The
+ * {@link #APPLICATION_PID} service property contains the PID of the application
+ * being scheduled, the {@link #SCHEDULE_ID} service property contains the
+ * schedule identifier.
+ *
+ * @version $Revision: 5673 $
*/
public interface ScheduledApplication {
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/package.html?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/package.html (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/package.html Fri Jul 24 17:06:37 2009
@@ -0,0 +1,11 @@
+<!-- $Revision: 6204 $ -->
+<BODY>
+<p>Application Package Version 1.1.
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:
+<pre>
+Import-Package: org.osgi.service.application; version="[1.1,2.0)"
+</pre>
+</BODY>
+
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/packageinfo?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/packageinfo (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/application/packageinfo Fri Jul 24 17:06:37 2009
@@ -0,0 +1 @@
+version 1.1
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+
+/**
+ * A Blueprint Container represents the managed state of a Blueprint bundle.
+ *
+ * A Blueprint Container provides access to all managed components. These are
+ * the beans, services, and service references. Only bundles in the
+ * <code>ACTIVE</code> state (and also the <code>STARTING</code> state for
+ * bundles awaiting lazy activation) can have an associated Blueprint Container.
+ * A given Bundle Context has at most one associated Blueprint Container.
+ *
+ * A Blueprint Container can be obtained by injecting the predefined
+ * "blueprintContainer" component id. The Blueprint Container is also
+ * registered as a service and its managed components can be queried.
+ *
+ * @ThreadSafe
+ * @version $Revision: 7556 $
+ */
+public interface BlueprintContainer {
+ /**
+ * Returns the set of component ids managed by this Blueprint Container.
+ *
+ * @return An immutable Set of Strings, containing the ids of all of the
+ * components managed within this Blueprint Container.
+ */
+ Set/* <String> */getComponentIds();
+
+ /**
+ * Return the component instance for the specified component id.
+ *
+ * If the component's manager has not yet been activated, calling this
+ * operation will atomically activate it. If the component has singleton
+ * scope, the activation will cause the component instance to be created and
+ * initialized. If the component has prototype scope, then each call to this
+ * method will return a new component instance.
+ *
+ * @param id The component id for the requested component instance.
+ * @return A component instance for the component with the specified
+ * component id.
+ * @throws NoSuchComponentException If no component with the specified
+ * component id is managed by this Blueprint Container.
+ */
+ Object getComponentInstance(String id);
+
+ /**
+ * Return the Component Metadata object for the component with the specified
+ * component id.
+ *
+ * @param id The component id for the requested Component Metadata.
+ * @return The Component Metadata object for the component with the
+ * specified component id.
+ * @throws NoSuchComponentException If no component with the specified
+ * component id is managed by this Blueprint Container.
+ */
+ ComponentMetadata getComponentMetadata(String id);
+
+ /**
+ * Return all {@link ComponentMetadata} objects of the specified Component
+ * Metadata type. The supported Component Metadata types are
+ * {@link ComponentMetadata} (which returns the Component Metadata for all
+ * defined manager types), {@link BeanMetadata} ,
+ * {@link ServiceReferenceMetadata} (which returns both
+ * {@link ReferenceMetadata} and {@link ReferenceListMetadata} objects), and
+ * {@link ServiceMetadata}. The collection will include all Component
+ * Metadata objects of the requested type, including components that are
+ * declared inline.
+ *
+ * @param type The super type or type of the requested Component Metadata
+ * objects.
+ * @return An immutable collection of Component Metadata objects of the
+ * specified type.
+ */
+ /* <T extends ComponentMetadata> */Collection/* <T> */getMetadata(
+ Class/* <T> */type);
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintEvent.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A Blueprint Event.
+ *
+ * <p>
+ * <code>BlueprintEvent</code> objects are delivered to all registered
+ * {@link BlueprintListener} services. Blueprint Events must be asynchronously
+ * delivered in chronological order with respect to each listener.
+ *
+ * <p>
+ * In addition, after a Blueprint Listener is registered, the Blueprint extender
+ * will synchronously send to this Blueprint Listener the last Blueprint Event
+ * for each ready Blueprint bundle managed by this extender. This
+ * <em>replay</em> of Blueprint Events is designed so that the new Blueprint
+ * Listener can be informed of the state of each Blueprint bundle. Blueprint
+ * Events sent during this replay will have the {@link #isReplay()} flag set.
+ * The Blueprint extender must ensure that this replay phase does not interfere
+ * with new Blueprint Events so that the chronological order of all Blueprint
+ * Events received by the Blueprint Listener is preserved. If the last Blueprint
+ * Event for a given Blueprint bundle is {@link #DESTROYED}, the extender must
+ * not send it during this replay phase.
+ *
+ * <p>
+ * A type code is used to identify the type of event. The following event types
+ * are defined:
+ * <ul>
+ * <li>{@link #CREATING}</li>
+ * <li>{@link #CREATED}</li>
+ * <li>{@link #DESTROYING}</li>
+ * <li>{@link #DESTROYED}</li>
+ * <li>{@link #FAILURE}</li>
+ * <li>{@link #GRACE_PERIOD}</li>
+ * <li>{@link #WAITING}</li>
+ * </ul>
+ *
+ * <p>
+ * In addition to calling the registered {@link BlueprintListener} services, the
+ * Blueprint extender must also send those events to the Event Admin service, if
+ * it is available.
+ *
+ * @see BlueprintListener
+ * @see EventConstants
+ * @Immutable
+ * @version $Revision: 7591 $
+ */
+public class BlueprintEvent {
+
+ /**
+ * The Blueprint extender has started creating a Blueprint Container for the
+ * bundle.
+ */
+ public static final int CREATING = 1;
+ /**
+ * The Blueprint extender has created a Blueprint Container for the bundle.
+ * This event is sent after the Blueprint Container has been registered as a
+ * service.
+ */
+ public static final int CREATED = 2;
+ /**
+ * The Blueprint extender has started destroying the Blueprint Container for
+ * the bundle.
+ */
+ public static final int DESTROYING = 3;
+ /**
+ * The Blueprint Container for the bundle has been completely destroyed.
+ * This event is sent after the Blueprint Container has been unregistered as
+ * a service.
+ */
+ public static final int DESTROYED = 4;
+ /**
+ * The Blueprint Container creation for the bundle has failed. If this event
+ * is sent after a timeout in the Grace Period, the
+ * {@link #getDependencies()} method must return an array of missing
+ * mandatory dependencies. The event must also contain the cause of the
+ * failure as a <code>Throwable</code> through the {@link #getCause()}
+ * method.
+ */
+ public static final int FAILURE = 5;
+ /**
+ * The Blueprint Container has entered the grace period. The list of missing
+ * dependencies must be made available through the
+ * {@link #getDependencies()} method. During the grace period, a
+ * {@link #GRACE_PERIOD} event is sent each time the set of unsatisfied
+ * dependencies changes.
+ */
+ public static final int GRACE_PERIOD = 6;
+ /**
+ * The Blueprint Container is waiting on the availability of a service to
+ * satisfy an invocation on a referenced service. The missing dependency
+ * must be made available through the {@link #getDependencies()} method
+ * which will return an array containing one filter object as a String.
+ */
+ public static final int WAITING = 7;
+
+ /**
+ * Type of this event.
+ *
+ * @see #getType()
+ */
+ private final int type;
+ /**
+ * The time when the event occurred.
+ *
+ * @see #getTimestamp()
+ */
+ private final long timestamp;
+ /**
+ * The Blueprint bundle.
+ *
+ * @see #getBundle()
+ */
+ private final Bundle bundle;
+ /**
+ * The Blueprint extender bundle.
+ *
+ * @see #getExtenderBundle()
+ */
+ private final Bundle extenderBundle;
+ /**
+ * An array containing filters identifying the missing dependencies. Must
+ * not be <code>null</code> when the event type requires it.
+ *
+ * @see #getDependencies()
+ */
+ private final String[] dependencies;
+ /**
+ * Cause of the failure.
+ *
+ * @see #getCause()
+ */
+ private final Throwable cause;
+ /**
+ * Indicate if this event is a replay event or not.
+ *
+ * @see #isReplay()
+ */
+ private final boolean replay;
+
+ /**
+ * Create a simple <code>BlueprintEvent</code> object.
+ *
+ * @param type The type of this event.
+ * @param bundle The Blueprint bundle associated with this event. This
+ * parameter must not be <code>null</code>.
+ * @param extenderBundle The Blueprint extender bundle that is generating
+ * this event. This parameter must not be <code>null</code>.
+ */
+ public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle) {
+ this(type, bundle, extenderBundle, null, null);
+ }
+
+ /**
+ * Create a <code>BlueprintEvent</code> object associated with a set of
+ * dependencies.
+ *
+ * @param type The type of this event.
+ * @param bundle The Blueprint bundle associated with this event. This
+ * parameter must not be <code>null</code>.
+ * @param extenderBundle The Blueprint extender bundle that is generating
+ * this event. This parameter must not be <code>null</code>.
+ * @param dependencies An array of <code>String</code> filters for each
+ * dependency associated with this event. Must be a non-empty array
+ * for event types {@link #GRACE_PERIOD} and {@link #WAITING}. It is
+ * optional for event type {@link #FAILURE}. Must be
+ * <code>null</code> for other event types.
+ */
+ public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
+ String[] dependencies) {
+ this(type, bundle, extenderBundle, dependencies, null);
+ }
+
+ /**
+ * Create a <code>BlueprintEvent</code> object associated with a failure
+ * cause.
+ *
+ * @param type The type of this event.
+ * @param bundle The Blueprint bundle associated with this event. This
+ * parameter must not be <code>null</code>.
+ * @param extenderBundle The Blueprint extender bundle that is generating
+ * this event. This parameter must not be <code>null</code>.
+ * @param cause A <code>Throwable</code> object describing the root cause of
+ * the event. May be <code>null</code>.
+ */
+ public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
+ Throwable cause) {
+ this(type, bundle, extenderBundle, null, cause);
+ }
+
+ /**
+ * Create a <code>BlueprintEvent</code> object associated with a failure
+ * cause and a set of dependencies.
+ *
+ * @param type The type of this event.
+ * @param bundle The Blueprint bundle associated with this event. This
+ * parameter must not be <code>null</code>.
+ * @param extenderBundle The Blueprint extender bundle that is generating
+ * this event. This parameter must not be <code>null</code>.
+ * @param dependencies An array of <code>String</code> filters for each
+ * dependency associated with this event. Must be a non-empty array
+ * for event types {@link #GRACE_PERIOD} and {@link #WAITING}. It is
+ * optional for event type {@link #FAILURE}. Must be
+ * <code>null</code> for other event types.
+ * @param cause A <code>Throwable</code> object describing the root cause of
+ * this event. May be <code>null</code>.
+ */
+ public BlueprintEvent(int type, Bundle bundle, Bundle extenderBundle,
+ String[] dependencies, Throwable cause) {
+ this.type = type;
+ this.timestamp = System.currentTimeMillis();
+ this.bundle = bundle;
+ this.extenderBundle = extenderBundle;
+ this.dependencies = dependencies;
+ this.cause = cause;
+ this.replay = false;
+ if (bundle == null) {
+ throw new NullPointerException("bundle must not be null");
+ }
+ if (extenderBundle == null) {
+ throw new NullPointerException("extenderBundle must not be null");
+ }
+ switch (type) {
+ case WAITING :
+ case GRACE_PERIOD :
+ if (dependencies == null) {
+ throw new NullPointerException(
+ "dependencies must not be null");
+ }
+ if (dependencies.length == 0) {
+ throw new IllegalArgumentException(
+ "dependencies must not be length zero");
+ }
+ break;
+ case FAILURE :
+ if ((dependencies != null) && (dependencies.length == 0)) {
+ throw new IllegalArgumentException(
+ "dependencies must not be length zero");
+ }
+ break;
+ default :
+ if (dependencies != null) {
+ throw new IllegalArgumentException(
+ "dependencies must be null");
+ }
+ break;
+ }
+ }
+
+ /**
+ * Create a new <code>BlueprintEvent</code> from the specified
+ * <code>BlueprintEvent</code>. The <code>timestamp</code> property will be
+ * copied from the original event and only the replay property will be
+ * overridden with the given value.
+ *
+ * @param event The original <code>BlueprintEvent</code> to copy. Must not
+ * be <code>null</code>.
+ * @param replay <code>true</code> if this event should be used as a replay
+ * event.
+ */
+ public BlueprintEvent(BlueprintEvent event, boolean replay) {
+ this.type = event.type;
+ this.timestamp = event.timestamp;
+ this.bundle = event.bundle;
+ this.extenderBundle = event.extenderBundle;
+ this.dependencies = event.dependencies;
+ this.cause = event.cause;
+ this.replay = replay;
+ }
+
+ /**
+ * Return the type of this event.
+ * <p>
+ * The type values are:
+ * <ul>
+ * <li>{@link #CREATING}</li>
+ * <li>{@link #CREATED}</li>
+ * <li>{@link #DESTROYING}</li>
+ * <li>{@link #DESTROYED}</li>
+ * <li>{@link #FAILURE}</li>
+ * <li>{@link #GRACE_PERIOD}</li>
+ * <li>{@link #WAITING}</li>
+ * </ul>
+ *
+ * @return The type of this event.
+ */
+ public int getType() {
+ return type;
+ }
+
+ /**
+ * Return the time at which this event was created.
+ *
+ * @return The time at which this event was created.
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Return the Blueprint bundle associated with this event.
+ *
+ * @return The Blueprint bundle associated with this event.
+ */
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ /**
+ * Return the Blueprint extender bundle that is generating this event.
+ *
+ * @return The Blueprint extender bundle that is generating this event.
+ */
+ public Bundle getExtenderBundle() {
+ return extenderBundle;
+ }
+
+ /**
+ * Return the filters identifying the missing dependencies that caused this
+ * event.
+ *
+ * @return The filters identifying the missing dependencies that caused this
+ * event if the event type is one of {@link #WAITING},
+ * {@link #GRACE_PERIOD} or {@link #FAILURE} or <code>null</code>
+ * for the other event types.
+ */
+ public String[] getDependencies() {
+ return dependencies == null ? null : (String[]) dependencies.clone();
+ }
+
+ /**
+ * Return the cause for this {@link #FAILURE} event.
+ *
+ * @return The cause of the failure for this event. May be <code>null</code>
+ * .
+ */
+ public Throwable getCause() {
+ return cause;
+ }
+
+ /**
+ * Return whether this event is a replay event.
+ *
+ * @return <code>true</code> if this event is a replay event and
+ * <code>false</code> otherwise.
+ */
+ public boolean isReplay() {
+ return replay;
+ }
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/BlueprintListener.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * A <code>BlueprintEvent</code> Listener.
+ *
+ * <p>
+ * To receive Blueprint Events, a bundle must register a Blueprint Listener
+ * service.
+ *
+ * After a Blueprint Listener is registered, the Blueprint extender must
+ * synchronously send to this Blueprint Listener the last Blueprint Event for
+ * each ready Blueprint bundle managed by this extender. This replay of
+ * Blueprint Events is designed so that the new Blueprint Listener can be
+ * informed of the state of each Blueprint bundle. Blueprint Events sent during
+ * this replay will have the {@link BlueprintEvent#isReplay() isReplay()} flag
+ * set. The Blueprint extender must ensure that this replay phase does not
+ * interfere with new Blueprint Events so that the chronological order of all
+ * Blueprint Events received by the Blueprint Listener is preserved. If the last
+ * Blueprint Event for a given Blueprint bundle is
+ * {@link BlueprintEvent#DESTROYED DESTROYED}, the extender must not send it
+ * during this replay phase.
+ *
+ * @see BlueprintEvent
+ * @ThreadSafe
+ * @version $Revision: 7564 $
+ */
+public interface BlueprintListener {
+
+ /**
+ * Receives notifications of a Blueprint Event.
+ *
+ * Implementers should quickly process the event and return.
+ *
+ * @param event The {@link BlueprintEvent}.
+ */
+ void blueprintEvent(BlueprintEvent event);
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * A Blueprint exception indicating that a component definition is in error.
+ *
+ * This exception is thrown when a configuration-related error occurs during
+ * creation of a Blueprint Container.
+ *
+ * @version $Revision: 7556 $
+ */
+public class ComponentDefinitionException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a Component Definition Exception with no message or exception
+ * cause.
+ */
+ public ComponentDefinitionException() {
+ super();
+ }
+
+ /**
+ * Creates a Component Definition Exception with the specified message
+ *
+ * @param explanation The associated message.
+ */
+ public ComponentDefinitionException(String explanation) {
+ super(explanation);
+ }
+
+ /**
+ * Creates a Component Definition Exception with the specified message and
+ * exception cause.
+ *
+ * @param explanation The associated message.
+ * @param cause The cause of this exception.
+ */
+ public ComponentDefinitionException(String explanation, Throwable cause) {
+ super(explanation, cause);
+ }
+
+ /**
+ * Creates a Component Definition Exception with the exception cause.
+ *
+ * @param cause The cause of this exception.
+ */
+ public ComponentDefinitionException(Throwable cause) {
+ super(cause);
+ }
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/Converter.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/Converter.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/Converter.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/Converter.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * Type converter to convert an object to a target type.
+ *
+ * @ThreadSafe
+ * @version $Revision: 7564 $
+ */
+public interface Converter {
+
+ /**
+ * Return if this converter is able to convert the specified object to the
+ * specified type.
+ *
+ * @param sourceObject The source object <code>s</code> to convert.
+ * @param targetType The target type <code>T</code>.
+ *
+ * @return <code>true</code> if the conversion is possible,
+ * <code>false</code> otherwise.
+ */
+ boolean canConvert(Object sourceObject, ReifiedType targetType);
+
+ /**
+ * Convert the specified object to an instance of the specified type.
+ *
+ * @param sourceObject The source object <code>s</code> to convert.
+ * @param targetType The target type <code>T</code>.
+ * @return An instance with a type that is assignable from targetType's raw
+ * class
+ * @throws Exception If the conversion cannot succeed. This exception should
+ * not be thrown when the {@link #canConvert canConvert} method has
+ * returned <code>true</code>.
+ */
+ Object convert(Object sourceObject, ReifiedType targetType)
+ throws Exception;
+}
\ No newline at end of file
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/EventConstants.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/EventConstants.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/EventConstants.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/EventConstants.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * Event property names used in Event Admin events published by a Blueprint
+ * Container.
+ *
+ * <p>
+ * Each type of event is sent to a different topic:
+ *
+ * <p>
+ * <code>org/osgi/service/blueprint/container/</code><em><event-type></em>
+ *
+ * <p>
+ * where <em><event-type></em> can have the values
+ * {@link BlueprintEvent#CREATING CREATING}, {@link BlueprintEvent#CREATED
+ * CREATED}, {@link BlueprintEvent#DESTROYING DESTROYING},
+ * {@link BlueprintEvent#DESTROYED DESTROYED}, {@link BlueprintEvent#FAILURE
+ * FAILURE}, {@link BlueprintEvent#GRACE_PERIOD GRACE_PERIOD}, or
+ * {@link BlueprintEvent#WAITING WAITING}.
+ *
+ * <p>
+ * Such events have the following properties:
+ * <ul>
+ * <li>{@link #TYPE type}</li>
+ * <li>{@link #EVENT event}</li>
+ * <li>{@link #TIMESTAMP timestamp}</li>
+ * <li>{@link #BUNDLE bundle}</li>
+ * <li>{@link #BUNDLE_SYMBOLICNAME bundle.symbolicName}</li>
+ * <li>{@link #BUNDLE_ID bundle.id}</li>
+ * <li>{@link #BUNDLE_VERSION bundle.version}</li>
+ * <li>{@link #EXTENDER_BUNDLE_SYMBOLICNAME extender.bundle.symbolicName}</li>
+ * <li>{@link #EXTENDER_BUNDLE_ID extender.bundle.id}</li>
+ * <li>{@link #EXTENDER_BUNDLE_VERSION extender.bundle.version}</li>
+ * <li>{@link #DEPENDENCIES dependencies}</li>
+ * <li>{@link #CAUSE cause}</li>
+ * </ul>
+ *
+ * @Immutable
+ * @version $Revision: 7564 $
+ */
+public class EventConstants {
+ private EventConstants() {
+ // non-instantiable class
+ }
+
+ /**
+ * The type of the event that has been issued. This property is of type
+ * <code>Integer</code> and can take one of the values defined in
+ * {@link BlueprintEvent}.
+ */
+ public static final String TYPE = "type";
+
+ /**
+ * The <code>BlueprintEvent</code> object that caused this event. This
+ * property is of type {@link BlueprintEvent}.
+ */
+ public static final String EVENT = "event";
+
+ /**
+ * The time the event was created. This property is of type
+ * <code>Long</code>.
+ */
+ public static final String TIMESTAMP = "timestamp";
+
+ /**
+ * The Blueprint bundle associated with this event. This property is of type
+ * <code>Bundle</code>.
+ */
+ public static final String BUNDLE = "bundle";
+
+ /**
+ * The bundle id of the Blueprint bundle associated with this event. This
+ * property is of type <code>Long</code>.
+ */
+ public static final String BUNDLE_ID = "bundle.id";
+
+ /**
+ * The bundle symbolic name of the Blueprint bundle associated with this
+ * event. This property is of type <code>String</code>.
+ */
+ public static final String BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
+
+ /**
+ * The bundle version of the Blueprint bundle associated with this event.
+ * This property is of type <code>Version</code>.
+ */
+ public static final String BUNDLE_VERSION = "bundle.version";
+
+ /**
+ * The Blueprint extender bundle that is generating this event. This
+ * property is of type <code>Bundle</code>.
+ */
+ public static final String EXTENDER_BUNDLE = "extender.bundle";
+
+ /**
+ * The bundle id of the Blueprint extender bundle that is generating this
+ * event. This property is of type <code>Long</code>.
+ */
+ public static final String EXTENDER_BUNDLE_ID = "extender.bundle.id";
+
+ /**
+ * The bundle symbolic of the Blueprint extender bundle that is generating
+ * this event. This property is of type <code>String</code>.
+ */
+ public static final String EXTENDER_BUNDLE_SYMBOLICNAME = "extender.bundle.symbolicName";
+
+ /**
+ * The bundle version of the Blueprint extender bundle that is generating
+ * this event. This property is of type <code>Version</code>.
+ */
+ public static final String EXTENDER_BUNDLE_VERSION = "extender.bundle.version";
+
+ /**
+ * The filters identifying the missing dependencies that caused this event
+ * for a {@link BlueprintEvent#FAILURE FAILURE},
+ * {@link BlueprintEvent#GRACE_PERIOD GRACE_PERIOD}, or
+ * {@link BlueprintEvent#WAITING WAITING} event. This property type is an
+ * array of <code>String</code>.
+ */
+ public static final String DEPENDENCIES = "dependencies";
+
+ /**
+ * The cause for a {@link BlueprintEvent#FAILURE FAILURE} event. This
+ * property is of type <code>Throwable</code>.
+ */
+ public static final String CAUSE = "cause";
+
+ /**
+ * Topic prefix for all events issued by the Blueprint Container
+ */
+ public static final String TOPIC_BLUEPRINT_EVENTS = "org/osgi/service/blueprint/container";
+
+ /**
+ * Topic for Blueprint Container CREATING events
+ */
+ public static final String TOPIC_CREATING = TOPIC_BLUEPRINT_EVENTS
+ + "/CREATING";
+
+ /**
+ * Topic for Blueprint Container CREATED events
+ */
+ public static final String TOPIC_CREATED = TOPIC_BLUEPRINT_EVENTS
+ + "/CREATED";
+
+ /**
+ * Topic for Blueprint Container DESTROYING events
+ */
+ public static final String TOPIC_DESTROYING = TOPIC_BLUEPRINT_EVENTS
+ + "/DESTROYING";
+
+ /**
+ * Topic for Blueprint Container DESTROYED events
+ */
+ public static final String TOPIC_DESTROYED = TOPIC_BLUEPRINT_EVENTS
+ + "/DESTROYED";
+
+ /**
+ * Topic for Blueprint Container FAILURE events
+ */
+ public static final String TOPIC_FAILURE = TOPIC_BLUEPRINT_EVENTS
+ + "/FAILURE";
+
+ /**
+ * Topic for Blueprint Container GRACE_PERIOD events
+ */
+ public static final String TOPIC_GRACE_PERIOD = TOPIC_BLUEPRINT_EVENTS
+ + "/GRACE_PERIOD";
+
+ /**
+ * Topic for Blueprint Container WAITING events
+ */
+ public static final String TOPIC_WAITING = TOPIC_BLUEPRINT_EVENTS
+ + "/WAITING";
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/NoSuchComponentException.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/NoSuchComponentException.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/NoSuchComponentException.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/NoSuchComponentException.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * A Blueprint exception indicating that a component does not exist in a
+ * Blueprint Container.
+ *
+ * This exception is thrown when an attempt is made to create a component
+ * instance or lookup Component Metadata using a component id that does not
+ * exist in the Blueprint Container.
+ *
+ * @version $Revision: 7556 $
+ */
+public class NoSuchComponentException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+ /**
+ * The requested component id that generated the exception.
+ */
+ private final String componentId;
+
+ /**
+ * Create a No Such Component Exception for a non-existent component.
+ *
+ * @param msg The associated message.
+ * @param id The id of the non-existent component.
+ */
+ public NoSuchComponentException(String msg, String id) {
+ super(msg);
+ this.componentId = id;
+ }
+
+ /**
+ * Create a No Such Component Exception for a non-existent component.
+ *
+ * @param id The id of the non-existent component.
+ */
+ public NoSuchComponentException(String id) {
+ super("No component with id '" + (id == null ? "<null>" : id)
+ + "' could be found");
+ this.componentId = id;
+ }
+
+ /**
+ * Returns the id of the non-existent component.
+ *
+ * @return The id of the non-existent component.
+ */
+ public String getComponentId() {
+ return componentId;
+ }
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ReifiedType.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ReifiedType.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ReifiedType.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ReifiedType.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+/**
+ * Provides access to a concrete type and its optional generic type parameters.
+ *
+ * <p>
+ * Java 5 and later support generic types. These types consist of a raw class
+ * with type parameters. This class models such a <code>Type</code> class but
+ * ensures that the type is <em>reified</em>. Reification means that the Type
+ * graph associated with a Java 5 <code>Type</code> instance is traversed until
+ * the type becomes a concrete class. This class is available with the
+ * {@link #getRawClass()} method. The optional type parameters are recursively
+ * represented as Reified Types.
+ *
+ * <p>
+ * In Java 1.4, a class has by definition no type parameters. This class
+ * implementation provides the Reified Type for Java 1.4 by making the raw class
+ * the Java 1.4 class and using a Reified Type based on the <code>Object</code>
+ * class for any requested type parameter.
+ *
+ * <p>
+ * A Blueprint extender implementations can subclass this class and provide
+ * access to the generic type parameter graph for conversion. Such a subclass
+ * must <em>reify</em> the different Java 5 <code>Type</code> instances into the
+ * reified form. That is, a form where the raw Class is available with its
+ * optional type parameters as Reified Types.
+ *
+ * @Immutable
+ * @version $Revision: 7564 $
+ */
+public class ReifiedType {
+ private final static ReifiedType OBJECT = new ReifiedType(Object.class);
+
+ private final Class clazz;
+
+ /**
+ * Create a Reified Type for a raw Java class without any generic type
+ * parameters. Subclasses can provide the optional generic type parameter
+ * information. Without subclassing, this instance has no type parameters.
+ *
+ * @param clazz The raw class of the Reified Type.
+ */
+ public ReifiedType(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ /**
+ * Return the raw class represented by this type.
+ *
+ * The raw class represents the concrete class that is associated with a
+ * type declaration. This class could have been deduced from the generics
+ * type parameter graph of the declaration. For example, in the following
+ * example:
+ *
+ * <pre>
+ * Map<String, ? extends Metadata>
+ * </pre>
+ *
+ * The raw class is the Map class.
+ *
+ * @return The raw class represented by this type.
+ */
+ public Class getRawClass() {
+ return clazz;
+ }
+
+ /**
+ * Return a type parameter for this type.
+ *
+ * The type parameter refers to a parameter in a generic type declaration
+ * given by the zero-based index <code>i</code>.
+ *
+ * For example, in the following example:
+ *
+ * <pre>
+ * Map<String, ? extends Metadata>
+ * </pre>
+ *
+ * type parameter 0 is <code>String</code>, and type parameter 1 is
+ * <code>Metadata</code>.
+ *
+ * <p>
+ * This implementation returns a Reified Type that has <code>Object</code>
+ * as class. Any object is assignable to Object and therefore no conversion
+ * is then necessary. This is compatible with versions of Java language
+ * prior to Java 5.
+ *
+ * This method should be overridden by a subclass that provides access to
+ * the generic type parameter information for Java 5 and later.
+ *
+ * @param i The zero-based index of the requested type parameter.
+ * @return The <code>ReifiedType</code> for the generic type parameter at
+ * the specified index.
+ */
+ public ReifiedType getActualTypeArgument(int i) {
+ return OBJECT;
+ }
+
+ /**
+ * Return the number of type parameters for this type.
+ *
+ * <p>
+ * This implementation returns <code>0</code>. This method should be
+ * overridden by a subclass that provides access to the generic type
+ * parameter information for Java 5 and later.
+ *
+ * @return The number of type parameters for this type.
+ */
+ public int size() {
+ return 0;
+ }
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ServiceUnavailableException.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ServiceUnavailableException.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ServiceUnavailableException.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/ServiceUnavailableException.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.container;
+
+import org.osgi.framework.ServiceException;
+
+/**
+ * A Blueprint exception indicating that a service is unavailable.
+ *
+ * This exception is thrown when an invocation is made on a service reference
+ * and a backing service is not available.
+ *
+ * @version $Revision: 7556 $
+ */
+public class ServiceUnavailableException extends ServiceException {
+ private static final long serialVersionUID = 1L;
+ /**
+ * The filter string associated with the exception.
+ */
+ private final String filter;
+
+ /**
+ * Creates a Service Unavailable Exception with the specified message.
+ *
+ * @param message The associated message.
+ * @param filter The filter used for the service lookup.
+ */
+ public ServiceUnavailableException(String message, String filter) {
+ super(message, UNREGISTERED);
+ this.filter = filter;
+ }
+
+ /**
+ * Creates a Service Unavailable Exception with the specified message and
+ * exception cause.
+ *
+ * @param message The associated message.
+ * @param filter The filter used for the service lookup.
+ * @param cause The cause of this exception.
+ */
+ public ServiceUnavailableException(String message, String filter,
+ Throwable cause) {
+ super(message, UNREGISTERED, cause);
+ this.filter = filter;
+ }
+
+ /**
+ * Returns the filter expression that a service would have needed to satisfy
+ * in order for the invocation to proceed.
+ *
+ * @return The failing filter.
+ */
+ public String getFilter() {
+ return this.filter;
+ }
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/package.html
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/package.html?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/package.html (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/package.html Fri Jul 24 17:06:37 2009
@@ -0,0 +1,21 @@
+<!-- $Revision: 7556 $ -->
+<BODY>
+<p>Blueprint Container Package Version 1.0.</p>
+<p>Bundles wishing to use this package must list the package
+in the Import-Package header of the bundle's manifest.
+For example:</p>
+<pre>
+Import-Package: org.osgi.service.blueprint.container; version="[1.0,2.0)"
+</pre>
+<p>
+ This package defines the primary interface to a Blueprint Container,
+ <code>BlueprintContainer</code>. An instance of this type is available
+ inside a Blueprint Container as an implicitly defined component with the name
+ "blueprintContainer".
+</p>
+<p>
+ This package also declares the supporting exception types, listener, and constants for working with a Blueprint
+ Container.
+</p>
+</BODY>
+
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/packageinfo?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/packageinfo (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/container/packageinfo Fri Jul 24 17:06:37 2009
@@ -0,0 +1 @@
+version 1.0
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanArgument.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanArgument.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanArgument.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanArgument.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.reflect;
+
+/**
+ * Metadata for a factory method or constructor argument of a bean. The
+ * arguments of a bean are obtained from {@link BeanMetadata#getArguments()}.
+ *
+ * This is specified by the <code>argument</code> elements of a bean.
+ *
+ * @ThreadSafe
+ * @version $Revision: 7563 $
+ */
+public interface BeanArgument {
+
+ /**
+ * Return the Metadata for the argument value.
+ *
+ * This is specified by the <code>value</code> attribute.
+ *
+ * @return The Metadata for the argument value.
+ */
+ Metadata getValue();
+
+ /**
+ * Return the name of the value type to match the argument and convert the
+ * value into when invoking the constructor or factory method.
+ *
+ * This is specified by the <code>type</code> attribute.
+ *
+ * @return The name of the value type to convert the value into, or
+ * <code>null</code> if no type is specified.
+ */
+ String getValueType();
+
+ /**
+ * Return the zero-based index into the parameter list of the factory method
+ * or constructor to be invoked for this argument. This is determined by
+ * specifying the <code>index</code> attribute for the bean. If not
+ * explicitly set, this will return -1 and the initial ordering is defined
+ * by its position in the {@link BeanMetadata#getArguments()} list.
+ *
+ * This is specified by the <code>index</code> attribute.
+ *
+ * @return The zero-based index of the parameter, or -1 if no index is
+ * specified.
+ */
+ int getIndex();
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanMetadata.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanMetadata.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanMetadata.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.reflect;
+
+import java.util.List;
+
+/**
+ * Metadata for a Bean component.
+ *
+ * <p>
+ * This is specified by the <code>bean</code> element.
+ *
+ * @ThreadSafe
+ * @version $Revision: 7563 $
+ */
+public interface BeanMetadata extends Target, ComponentMetadata {
+
+ /**
+ * The bean has <code>singleton</code> scope.
+ *
+ * @see #getScope()
+ */
+ static final String SCOPE_SINGLETON = "singleton";
+
+ /**
+ * The bean has <code>prototype</code> scope.
+ *
+ * @see #getScope()
+ */
+ static final String SCOPE_PROTOTYPE = "prototype";
+
+ /**
+ * Return the name of the class specified for the bean.
+ *
+ * This is specified by the <code>class</code> attribute of the bean
+ * definition.
+ *
+ * @return The name of the class specified for the bean. If no class is
+ * specified in the bean definition, because the a factory component
+ * is used instead, then this method will return <code>null</code>.
+ */
+ String getClassName();
+
+ /**
+ * Return the name of the init method specified for the bean.
+ *
+ * This is specified by the <code>init-method</code> attribute of the bean
+ * definition.
+ *
+ * @return The name of the init method specified for the bean, or
+ * <code>null</code> if no init method is specified.
+ */
+ String getInitMethod();
+
+ /**
+ * Return the name of the destroy method specified for the bean.
+ *
+ * This is specified by the <code>destroy-method</code> attribute of the
+ * bean definition.
+ *
+ * @return The name of the destroy method specified for the bean, or
+ * <code>null</code> if no destroy method is specified.
+ */
+ String getDestroyMethod();
+
+ /**
+ * Return the arguments for the factory method or constructor of the bean.
+ *
+ * This is specified by the child <code>argument<code> elements.
+ *
+ * @return An immutable List of {@link BeanArgument} objects for the factory
+ * method or constructor of the bean. The List is empty if no
+ * arguments are specified for the bean.
+ */
+ List/* <BeanArgument> */getArguments();
+
+ /**
+ * Return the properties for the bean.
+ *
+ * This is specified by the child <code>property</code> elements.
+ *
+ * @return An immutable List of {@link BeanProperty} objects, with one entry
+ * for each property to be injected in the bean. The List is empty
+ * if no property injection is specified for the bean.
+ *
+ */
+ List /* <BeanProperty> */getProperties();
+
+ /**
+ * Return the name of the factory method for the bean.
+ *
+ * This is specified by the <code>factory-method</code> attribute of the
+ * bean.
+ *
+ * @return The name of the factory method of the bean or <code>null</code>
+ * if no factory method is specified for the bean.
+ */
+ String getFactoryMethod();
+
+ /**
+ * Return the Metadata for the factory component on which to invoke the
+ * factory method for the bean.
+ *
+ * This is specified by the <code>factory-ref</code> attribute of the bean.
+ *
+ * <p>
+ * When a factory method and factory component have been specified for the
+ * bean, this method returns the factory component on which to invoke the
+ * factory method for the bean. When no factory component has been specified
+ * this method will return <code>null</code>.
+ *
+ * When a factory method has been specified for the bean but a factory
+ * component has not been specified, the factory method must be invoked as a
+ * static method on the bean's class.
+ *
+ * @return The Metadata for the factory component on which to invoke the
+ * factory method for the bean or <code>null</code> if no factory
+ * component is specified.
+ */
+ Target getFactoryComponent();
+
+ /**
+ * Return the scope for the bean.
+ *
+ * @return The scope for the bean.
+ * @see #SCOPE_SINGLETON
+ * @see #SCOPE_PROTOTYPE
+ */
+ String getScope();
+}
Added: felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanProperty.java
URL: http://svn.apache.org/viewvc/felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanProperty.java?rev=797561&view=auto
==============================================================================
--- felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanProperty.java (added)
+++ felix/trunk/org.osgi.compendium/src/main/java/org/osgi/service/blueprint/reflect/BeanProperty.java Fri Jul 24 17:06:37 2009
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * 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.osgi.service.blueprint.reflect;
+
+/**
+ * Metadata for a property to be injected into a bean. The properties of a bean
+ * are obtained from {@link BeanMetadata#getProperties()}.
+ *
+ * This is specified by the <code>property</code> elements of a bean. Properties
+ * are defined according to the Java Beans conventions.
+ *
+ * @ThreadSafe
+ * @version $Revision: 7563 $
+ */
+public interface BeanProperty {
+
+ /**
+ * Return the name of the property to be injected. The name follows Java
+ * Beans conventions.
+ *
+ * This is specified by the <code>name</code> attribute.
+ *
+ * @return The name of the property to be injected.
+ */
+ String getName();
+
+ /**
+ * Return the Metadata for the value to be injected into a bean.
+ *
+ * This is specified by the <code>value</code> attribute or in inlined text.
+ *
+ * @return The Metadata for the value to be injected into a bean.
+ */
+ Metadata getValue();
+}