org.springframework.osgi.bundle
Class BundleFactoryBean

java.lang.Object
  extended by org.springframework.osgi.bundle.BundleFactoryBean
All Implemented Interfaces:
DisposableBean, FactoryBean, InitializingBean, ResourceLoaderAware, BundleContextAware

public class BundleFactoryBean
extends Object
implements FactoryBean, BundleContextAware, InitializingBean, DisposableBean, ResourceLoaderAware

Install Bundles using a FactoryBean. This allows customers to use Spring to drive bundle management. Bundles states can be modified using the state parameter. Most commonly this is set to "start". Please see BundleAction and the relationship between the actions.

Pay attention when installing bundles dynamically since classes can be loaded aggressively.

Author:
Andy Piper, Costin Leau
See Also:
BundleAction

Constructor Summary
BundleFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 BundleAction getAction()
          Returns the action.
 Bundle getBundle()
          Returns the bundle with which the class interacts.
 BundleAction getDestroyAction()
          Returns the destroyAction.
 String getLocation()
          Return the given location.
 Object getObject()
           
 Class getObjectType()
           
 Resource getResource()
          Return the Resource object (if a ResourceLoader is available) from the given location (if any).
 int getStartLevel()
           
 String getSymbolicName()
          Return the given bundle symbolic name.
 boolean isSingleton()
           
 void setAction(BundleAction action)
          Action to execute at startup.
 void setBundle(Bundle bundle)
          Set the backing bundle used by this class.
 void setBundleContext(BundleContext context)
          Set the BundleContext that this bean runs in.
 void setClassloader(ClassLoader classloader)
          Deprecated. use setClassLoader(ClassLoader) instead.
 void setClassLoader(ClassLoader classloader)
           
 void setDestroyAction(BundleAction action)
          Action to execute at shutdown.
 void setLocation(String url)
          Set the bundle location (optional operation).
 void setPushBundleAsContextClassLoader(boolean pushBundleAsContextClassLoader)
          Determines whether invocations on the remote service should be performed in the context of the target bundle's ClassLoader.
 void setResourceLoader(ResourceLoader resourceLoader)
           
 void setStartLevel(int startLevel)
           
 void setSymbolicName(String symbolicName)
          Set the bundle symbolic name (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleFactoryBean

public BundleFactoryBean()
Method Detail

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean

getObject

public Object getObject()
                 throws Exception
Specified by:
getObject in interface FactoryBean
Throws:
Exception

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

getResource

public Resource getResource()
Return the Resource object (if a ResourceLoader is available) from the given location (if any).

Returns:
Resource object for the given location

getLocation

public String getLocation()
Return the given location.

Returns:
bundle location

setLocation

public void setLocation(String url)
Set the bundle location (optional operation).

Parameters:
url - bundle location (normally an URL or a Spring Resource)

getSymbolicName

public String getSymbolicName()
Return the given bundle symbolic name.

Returns:
bundle symbolic name

setSymbolicName

public void setSymbolicName(String symbolicName)
Set the bundle symbolic name (optional operation).

Parameters:
symbolicName - bundle symbolic name

setBundleContext

public void setBundleContext(BundleContext context)
Description copied from interface: BundleContextAware
Set the BundleContext that this bean runs in. Normally this can be used to initialize an object.

Specified by:
setBundleContext in interface BundleContextAware
Parameters:
context - the BundleContext object to be used by this object

getAction

public BundleAction getAction()
Returns the action.

Returns:
Returns the action

setAction

public void setAction(BundleAction action)
Action to execute at startup.

Parameters:
action - action to execute at startup

getDestroyAction

public BundleAction getDestroyAction()
Returns the destroyAction.

Returns:
Returns the destroyAction

setDestroyAction

public void setDestroyAction(BundleAction action)
Action to execute at shutdown.

Parameters:
action - action to execute at shutdown

getStartLevel

public int getStartLevel()

setStartLevel

public void setStartLevel(int startLevel)

setPushBundleAsContextClassLoader

public void setPushBundleAsContextClassLoader(boolean pushBundleAsContextClassLoader)
Determines whether invocations on the remote service should be performed in the context of the target bundle's ClassLoader. The default is false.

Parameters:
pushBundleAsContextClassLoader -

setClassloader

public void setClassloader(ClassLoader classloader)
Deprecated. use setClassLoader(ClassLoader) instead.

Parameters:
classloader -

setClassLoader

public void setClassLoader(ClassLoader classloader)

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Specified by:
setResourceLoader in interface ResourceLoaderAware

getBundle

public Bundle getBundle()
Returns the bundle with which the class interacts.

Returns:
Returns the bundle

setBundle

public void setBundle(Bundle bundle)
Set the backing bundle used by this class. Allows programmatic configuration of already retrieved/created bundle.

Parameters:
bundle - The bundle to set.


Copyright © 2006-2007 Spring Framework. All Rights Reserved.