Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) OSGi Alliance (2005, 2010). 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.application;
Using this class, OSGi-aware applications can obtain their ApplicationContext.

Version:
$Id: 68f0c39e8c8c0ea02ae2c20154bba8bf1e6ba7bc $
public final class Framework {
    private Framework() { }
    
    private static Hashtable appContextHash;
    
    
This method needs an argument, an object that represents the application instance. An application consists of a set of object, however there is a single object, which is used by the corresponding application container to manage the lifecycle on the application instance. The lifetime of this object equals the lifetime of the application instance; therefore, it is suitable to represent the instance.

The returned ApplicationContext object is singleton for the specified application instance. Subsequent calls to this method with the same application instance must return the same context object

Parameters:
applicationInstance is the activator object of an application instance
Returns:
the ApplicationContext of the specified application instance.
Throws:
java.lang.NullPointerException If applicationInstance is null
java.lang.IllegalArgumentException if called with an object that is not the activator object of an application.
    public static ApplicationContext getApplicationContext(Object applicationInstance) {
    	  ifapplicationInstance == null )
    		  throw new NullPointerException"Instance cannot be null!" );
    	  ApplicationContext appContext = (ApplicationContext).getapplicationInstance );
    	  ifappContext == null )
    		  throw new IllegalArgumentException"ApplicationContext not found!" );
        return appContext;        
    }
New to GrepCode? Check out our FAQ X