Java Doc for ScriptFactoryPostProcessor.java in  » J2EE » spring-framework-2.5 » org » springframework » scripting » support » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.5 » org.springframework.scripting.support 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
      org.springframework.scripting.support.ScriptFactoryPostProcessor

ScriptFactoryPostProcessor
public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements BeanClassLoaderAware,BeanFactoryAware,ResourceLoaderAware,DisposableBean,Ordered(Code)
org.springframework.beans.factory.config.BeanPostProcessor that handles org.springframework.scripting.ScriptFactory definitions, replacing each factory with the actual scripted Java object generated by it.

This is similar to the org.springframework.beans.factory.FactoryBean mechanism, but is specifically tailored for scripts and not built into Spring's core container itself but rather implemented as an extension.

NOTE: The most important characteristic of this post-processor is that constructor arguments are applied to the org.springframework.scripting.ScriptFactory instance while bean property values are applied to the generated scripted object. Typically, constructor arguments include a script source locator and potentially script interfaces, while bean property values include references and config values to inject into the scripted object itself.

The following ScriptFactoryPostProcessor will automatically be applied to the two org.springframework.scripting.ScriptFactory definitions below. At runtime, the actual scripted objects will be exposed for "bshMessenger" and "groovyMessenger", rather than the org.springframework.scripting.ScriptFactory instances. Both of those are supposed to be castable to the example's Messenger interfaces here.

<bean class="org.springframework.scripting.support.ScriptFactoryPostProcessor"/>
 <bean id="bshMessenger" class="org.springframework.scripting.bsh.BshScriptFactory">
 <constructor-arg value="classpath:mypackage/Messenger.bsh"/>
 <constructor-arg value="mypackage.Messenger"/>
 <property name="message" value="Hello World!"/>
 </bean>
 <bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory">
 <constructor-arg value="classpath:mypackage/Messenger.groovy"/>
 <property name="message" value="Hello World!"/>
 </bean>

NOTE: Please note that the above excerpt from a Spring XML bean definition file uses just the <bean/>-style syntax (in an effort to illustrate using the ScriptFactoryPostProcessor itself). In reality, you would never create a <bean/> definition for a ScriptFactoryPostProcessor explicitly; rather you would import the tags from the 'lang' namespace and simply create scripted beans using the tags in that namespace... as part of doing so, a ScriptFactoryPostProcessor will implicitly be created for you.

The Spring reference documentation contains numerous examples of using tags in the 'lang' namespace; by way of an example, find below a Groovy-backed bean defined using the 'lang:groovy' tag.

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:lang="http://www.springframework.org/schema/lang">
 <!-- this is the bean definition for the Groovy-backed Messenger implementation -->
 <lang:groovy id="messenger" script-source="classpath:Messenger.groovy">
 <lang:property name="message" value="I Can Do The Frug" />
 </lang:groovy>
 <!-- an otherwise normal bean that will be injected by the Groovy-backed Messenger -->
 <bean id="bookingService" class="x.y.DefaultBookingService">
 <property name="messenger" ref="messenger" />
 </bean>
 </beans>

author:
   Juergen Hoeller
author:
   Rob Harrop
author:
   Rick Evans
author:
   Mark Fisher
since:
   2.0


Field Summary
final public static  StringINLINE_SCRIPT_PREFIX
     The org.springframework.core.io.Resource -style prefix that denotes an inline script.
final public static  StringREFRESH_CHECK_DELAY_ATTRIBUTE
    
final protected  Loglogger
    
final  DefaultListableBeanFactoryscriptBeanFactory
    


Method Summary
protected  ScriptSourceconvertToScriptSource(String scriptSourceLocator, ResourceLoader resourceLoader)
     Convert the given script source locator to a ScriptSource instance.
protected  ClasscreateCompositeInterface(Class[] interfaces)
     Create a composite interface Class for the given interfaces, implementing the given interfaces in one single Class.
protected  ClasscreateConfigInterface(BeanDefinition bd, Class[] interfaces)
     Create a config interface for the given bean definition, defining setter methods for the defined property values as well as an init method and a destroy method (if defined).
protected  ObjectcreateRefreshableProxy(TargetSource ts, Class[] interfaces)
     Create a refreshable proxy for the given AOP TargetSource.
protected  BeanDefinitioncreateScriptFactoryBeanDefinition(BeanDefinition bd)
     Create a ScriptFactory bean definition based on the given script definition, extracting only the definition data that is relevant for the ScriptFactory (that is, only bean class and constructor arguments).
protected  BeanDefinitioncreateScriptedObjectBeanDefinition(BeanDefinition bd, String scriptFactoryBeanName, ScriptSource scriptSource, Class[] interfaces)
     Create a bean definition for the scripted object, based on the given script definition, extracting the definition data that is relevant for the scripted object (that is, everything but bean class and constructor arguments).
public  voiddestroy()
     Destroy the inner bean factory (used for scripts) on shutdown.
public  intgetOrder()
    
protected  ScriptSourcegetScriptSource(String beanName, String scriptSourceLocator)
     Obtain a ScriptSource for the given bean, lazily creating it if not cached already.
public  ObjectpostProcessBeforeInstantiation(Class beanClass, String beanName)
    
public  ClasspredictBeanType(Class beanClass, String beanName)
    
protected  voidprepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName)
     Prepare the script beans in the internal BeanFactory that this post-processor uses.
protected  longresolveRefreshCheckDelay(BeanDefinition beanDefinition)
     Get the refresh check delay for the given ScriptFactory BeanDefinition . If the BeanDefinition has a org.springframework.core.AttributeAccessor metadata attribute under the key ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE which is a valid Number type, then this value is used.
public  voidsetBeanClassLoader(ClassLoader classLoader)
    
public  voidsetBeanFactory(BeanFactory beanFactory)
    
public  voidsetDefaultRefreshCheckDelay(long defaultRefreshCheckDelay)
     Set the delay between refresh checks, in milliseconds.
public  voidsetResourceLoader(ResourceLoader resourceLoader)
    

Field Detail
INLINE_SCRIPT_PREFIX
final public static String INLINE_SCRIPT_PREFIX(Code)
The org.springframework.core.io.Resource -style prefix that denotes an inline script.

An inline script is a script that is defined right there in the (typically XML) configuration, as opposed to being defined in an external file.




REFRESH_CHECK_DELAY_ATTRIBUTE
final public static String REFRESH_CHECK_DELAY_ATTRIBUTE(Code)



logger
final protected Log logger(Code)
Logger available to subclasses



scriptBeanFactory
final DefaultListableBeanFactory scriptBeanFactory(Code)





Method Detail
convertToScriptSource
protected ScriptSource convertToScriptSource(String scriptSourceLocator, ResourceLoader resourceLoader)(Code)
Convert the given script source locator to a ScriptSource instance.

By default, supported locators are Spring resource locations (such as "file:C:/myScript.bsh" or "classpath:myPackage/myScript.bsh") and inline scripts ("inline:myScriptText...").
Parameters:
  scriptSourceLocator - the script source locator
Parameters:
  resourceLoader - the ResourceLoader to use (if necessary) the ScriptSource instance




createCompositeInterface
protected Class createCompositeInterface(Class[] interfaces)(Code)
Create a composite interface Class for the given interfaces, implementing the given interfaces in one single Class.

The default implementation builds a JDK proxy class for the given interfaces.
Parameters:
  interfaces - the interfaces to merge the merged interface as Class
See Also:   java.lang.reflect.Proxy.getProxyClass




createConfigInterface
protected Class createConfigInterface(BeanDefinition bd, Class[] interfaces)(Code)
Create a config interface for the given bean definition, defining setter methods for the defined property values as well as an init method and a destroy method (if defined).

This implementation creates the interface via CGLIB's InterfaceMaker, determining the property types from the given interfaces (as far as possible).
Parameters:
  bd - the bean definition (property values etc) to create aconfig interface for
Parameters:
  interfaces - the interfaces to check against (might definegetters corresponding to the setters we're supposed to generate) the config interface
See Also:   net.sf.cglib.proxy.InterfaceMaker
See Also:   org.springframework.beans.BeanUtils.findPropertyType




createRefreshableProxy
protected Object createRefreshableProxy(TargetSource ts, Class[] interfaces)(Code)
Create a refreshable proxy for the given AOP TargetSource.
Parameters:
  ts - the refreshable TargetSource
Parameters:
  interfaces - the proxy interfaces (may be null toindicate proxying of all interfaces implemented by the target class) the generated proxy
See Also:   RefreshableScriptTargetSource



createScriptFactoryBeanDefinition
protected BeanDefinition createScriptFactoryBeanDefinition(BeanDefinition bd)(Code)
Create a ScriptFactory bean definition based on the given script definition, extracting only the definition data that is relevant for the ScriptFactory (that is, only bean class and constructor arguments).
Parameters:
  bd - the full script bean definition the extracted ScriptFactory bean definition
See Also:   org.springframework.scripting.ScriptFactory



createScriptedObjectBeanDefinition
protected BeanDefinition createScriptedObjectBeanDefinition(BeanDefinition bd, String scriptFactoryBeanName, ScriptSource scriptSource, Class[] interfaces)(Code)
Create a bean definition for the scripted object, based on the given script definition, extracting the definition data that is relevant for the scripted object (that is, everything but bean class and constructor arguments).
Parameters:
  bd - the full script bean definition
Parameters:
  scriptFactoryBeanName - the name of the internal ScriptFactory bean
Parameters:
  scriptSource - the ScriptSource for the scripted bean
Parameters:
  interfaces - the interfaces that the scripted bean is supposed to implement the extracted ScriptFactory bean definition
See Also:   org.springframework.scripting.ScriptFactory.getScriptedObject



destroy
public void destroy()(Code)
Destroy the inner bean factory (used for scripts) on shutdown.



getOrder
public int getOrder()(Code)



getScriptSource
protected ScriptSource getScriptSource(String beanName, String scriptSourceLocator)(Code)
Obtain a ScriptSource for the given bean, lazily creating it if not cached already.
Parameters:
  beanName - the name of the scripted bean
Parameters:
  scriptSourceLocator - the script source locator associated with the bean the corresponding ScriptSource instance
See Also:   ScriptFactoryPostProcessor.convertToScriptSource



postProcessBeforeInstantiation
public Object postProcessBeforeInstantiation(Class beanClass, String beanName)(Code)



predictBeanType
public Class predictBeanType(Class beanClass, String beanName)(Code)



prepareScriptBeans
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName)(Code)
Prepare the script beans in the internal BeanFactory that this post-processor uses. Each original bean definition will be split into a ScriptFactory definition and a scripted object definition.
Parameters:
  bd - the original bean definition in the main BeanFactory
Parameters:
  scriptFactoryBeanName - the name of the internal ScriptFactory bean
Parameters:
  scriptedObjectBeanName - the name of the internal scripted object bean



resolveRefreshCheckDelay
protected long resolveRefreshCheckDelay(BeanDefinition beanDefinition)(Code)
Get the refresh check delay for the given ScriptFactory BeanDefinition . If the BeanDefinition has a org.springframework.core.AttributeAccessor metadata attribute under the key ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE which is a valid Number type, then this value is used. Otherwise, the the ScriptFactoryPostProcessor.defaultRefreshCheckDelay value is used.
Parameters:
  beanDefinition - the BeanDefinition to check the refresh check delay



setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)(Code)



setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)(Code)



setDefaultRefreshCheckDelay
public void setDefaultRefreshCheckDelay(long defaultRefreshCheckDelay)(Code)
Set the delay between refresh checks, in milliseconds. Default is -1, indicating no refresh checks at all.

Note that an actual refresh will only happen when the org.springframework.scripting.ScriptSource indicates that it has been modified.
See Also:   org.springframework.scripting.ScriptSource.isModified




setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)(Code)



Methods inherited from org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException(Code)(Java Doc)
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException(Code)(Java Doc)
public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException(Code)(Java Doc)
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException(Code)(Java Doc)
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException(Code)(Java Doc)
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException(Code)(Java Doc)
public Class predictBeanType(Class beanClass, String beanName)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.