pl.bristleback.server.bristle.integration.spring
Class SpringIntegrationUtil

java.lang.Object
  extended by pl.bristleback.server.bristle.integration.spring.SpringIntegrationUtil

public final class SpringIntegrationUtil
extends java.lang.Object

Util class which can enable integration with Spring dependency injection. To enable integration, one of existing application context setter methods must be invoked before jwebsocket framework starts. In current version, enabling Spring integration is tested only with web applications.

Created on: 2010-10-03 13:37:28

Author:
Wojciech Niemiec

Method Summary
static boolean containsBean(java.lang.String ref)
           
static org.springframework.context.ApplicationContext getApplicationContext()
          Gets previously loaded application context.
static java.lang.Object getSpringBean(java.lang.String ref)
          Gets spring bean from previously given application context.
static
<T> T
getSpringBean(java.lang.String ref, java.lang.Class<T> beanType)
          Gets spring bean from previously given application context.
static void setApplicationContext(org.springframework.context.ApplicationContext context)
          Directly sets application context.
static void setApplicationContextFromServlet(javax.servlet.ServletContext servletContext)
          Sets application context from given servlet context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getApplicationContext

public static org.springframework.context.ApplicationContext getApplicationContext()
Gets previously loaded application context. This method throws an exception if application context is not set yet.

Returns:
application context.

setApplicationContextFromServlet

public static void setApplicationContextFromServlet(javax.servlet.ServletContext servletContext)
Sets application context from given servlet context. Servlet context is available from several places, eg. in classes implementing ServletContextListener interface from javax.servlet package.

Parameters:
servletContext - servlet context.

setApplicationContext

public static void setApplicationContext(org.springframework.context.ApplicationContext context)
Directly sets application context. Method is not tested yet, although it should work properly.

Parameters:
context - application context

getSpringBean

public static java.lang.Object getSpringBean(java.lang.String ref)
Gets spring bean from previously given application context. Bean type is not checked. This method can be used from anywhere in application however it is not recommended.

Parameters:
ref - Spring reference name
Returns:
bean

containsBean

public static boolean containsBean(java.lang.String ref)

getSpringBean

public static <T> T getSpringBean(java.lang.String ref,
                                  java.lang.Class<T> beanType)
Gets spring bean from previously given application context. Bean type check is performed and method throws an exception if the type is not matching. This method can be used from anywhere in application however it is not recommended.

Parameters:
ref - Spring reference name
beanType - exact type of bean or parent.
Returns:
bean with proper type


Copyright © 2011. All Rights Reserved.