- 浏览: 3502821 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
wanglf1207:
EJB的确是个不错的产品,只是因为用起来有点门槛,招来太多人吐 ...
weblogic-ejb-jar.xml的元素解析 -
qwfys200:
总结的不错。
Spring Web Flow 2.0 入门 -
u011577913:
u011577913 写道也能给我发一份翻译文档? 邮件437 ...
Hazelcast 参考文档-4 -
u011577913:
也能给我发一份翻译文档?
Hazelcast 参考文档-4 -
songzj001:
DbUnit入门实战
Grails and EJB 3 Session Beans
A while back I was working on a Grails project that needed to integrate with an EJB2 application via session beans. So, when my current project had a similar need I thought 'piece of cake!'. As it happens it was a piece of cake that wasn't that easy to get at.
The
problem came about because we were working with EJB3 this time. I had
heard that it should work the same but it doesn't. I eventually found
that it is still extremely easy to do (this is Grails we're talking
about after all) it's just different.
For starters the Spring class that we used to connect to an EJB2 session bean, SimpleRemoteStatelessSessionProxyFactoryBean
(I wonder if there is a TinyURL! for class names) was not working with
EJB3. Several people on the forums said that it should, but our
application did not believe them. It turns out that there is a Spring
class that does work with EJB3 and it even has a shorter name! The JndiObjectFactoryBean
is a general purpose Factory for looking up JNDI objects and making them available to other beans. The JndiObjectFactoryBean
will even use the JndiTemplate
that I had setup before, though I'll show it again so you don't have to hunt it down.
So now we should be in business. Except that it didn't work. When using the SimpleRemoteStatelessSessionProxyFactoryBean
we could just use the Session Bean's simple interface name, which was also its JNDI name. That was not working with the JndiObjectFactoryBean
.
This critter wanted a fully qualified, certified and USDA approved JNDI
name. The bummer here is that this is vendor specific. So the rest of
this will work for BEAORACLE WebLogic but it might be completely
different for your app server.
First we have to make sure that the EJB3 session bean has the mappedName
attribute in the @Stateless
annotation. (In our case ...mappedName="CoverageSession"
)
That makes up the first part of the JNDI name. Then we add a # symbol
and top it off with the fully qualified name of the Remote Interface.
So we ended up with something like this for our JNDI name: CoverageSession#org.blah.app.ejb.session.ICoverageSessionRemote
Once we gave it that mouthful it was happy.
Here I'll show a slightly modified version of our resources.groovy file:
beans = { ejbJndi(org.springframework.jndi.JndiTemplate){ environment = [ "java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory", "java.naming.provider.url" : "t3://some.enterprise.server:7001" "java.naming.security.principal" : "dave", "java.naming.security.credentials" : "1234" ]} coverageSession(org.springframework.jndi.JndiObjectFactoryBean){ jndiName = "CoverageSession#org.blah.app.ejb.session.ICoverageSessionRemote" jndiTemplate = ref("ejbJndi") } }
Now
we can inject the session bean into a Grails Service and we can call
its methods to retrieve and save EJB3 entities from that portion of the
application that was written before we began using Grails and it all
just works and I'm happy!
I'm still hoping to be able to convert
the entire application to Grails before we go production but in case we
can't the ability to integrate Grails with all of our existing Java
technologies is a big help.
发表评论
-
说明SOA监管(SOA Governance)实例(收录备查)
2012-12-19 11:35 1750SOA 已经不是单纯技术问 ... -
Injecting Spring Beans into Java Servlets
2012-11-01 10:21 1936If you are working in a Java ... -
用 HttpServletResponseWrapper 实现 Etag 过滤器
2012-07-09 16:58 3759原文出处:http://blog.chenlb.com/200 ... -
Eclipse Indigo - Cannot install Android ADT Plugin
2012-02-29 01:17 3884When I try to install the And ... -
Eclipse Indigo - Cannot install Android ADT Plugin
2012-02-29 01:13 1988When I try to install the And ... -
[转]mybatis下的分页,支持所有的数据库
2011-07-21 13:21 14841大 家都知道,mybatis的自带分页方法只是逻 ... -
Java framework for text- & console-based forms?
2011-07-21 01:06 1711charva jcurses JNA , ... -
JNA(Java Native Access)学习入门
2011-07-21 01:04 22625Java Native Access 项目 在 ... -
使用IntrospectorCleanupListener 解决quartz引起的内存泄漏
2011-04-20 11:59 13362"在服务器运行过程中,Spring不停的运行的计划任 ... -
DBCP代码研读以及就数据库连接失效的解决
2011-03-31 11:03 3765问题 网上很多评论说DBCP有很多BUG,但是都没有指明是什 ... -
ContextLoaderListener
2010-12-06 15:58 8464(1) org.springframework.web.c ... -
Servlet3.0新功能: 异步处理
2010-12-06 15:22 3181J2EE 6和Glassfish 3V正式发 ... -
Servlet3.0引入的新特性
2010-12-06 15:20 3058Servlet3.0规范的新特性主要是为了3个目的: ... -
100個節點上運行群集亞馬遜EC2上Hazelcast
2010-12-03 23:59 3318本文的目的,適是给妳湮示的細節集群的100個節點。此湮示記錄, ... -
Spring Properties Reloaded
2010-12-02 14:54 4372Spring Properties Reloaded Som ... -
为spring2.5中的jpetstore增加perf4j监控
2010-09-02 13:51 2646perf4j是一款类似于log4j的性能检测工具. 它 ... -
语义网的学习资源大汇集(备忘)
2010-06-23 22:48 1734网上资源 http:/ ... -
使用 JOLAP 实现复杂分析查询
2010-06-06 13:42 1963Shashank Tiwari 在本文中对 ... -
HTML5 Canvas for Internet Explorer
2010-06-04 21:16 1857Canvascape http://www.benjoff ... -
大型网站架构演变和知识体系
2010-06-01 23:47 1970架构演变第一步:物 ...
相关推荐
grails3-memcached-session 这实现了Memcached会话管理器以将会话存储在memcached中。 请注意,memcached会话未写入磁盘,因此重新启动memcached会清除所有会话! 坚持不懈 使用MSM 描述的故障转移策略。 使用...
grails1.0开发框架3 类似于ruby on rails的框架。
标题中的“grails3 CAS链接接数据库”表明我们要讨论的是如何在Grails 3框架下集成CAS(Central Authentication Service)并实现与数据库的连接。Grails是一个基于Groovy语言的开源Web应用框架,而CAS是一种广泛使用...
3. **插件系统**:Grails 插件是一组可重用的功能模块,可以快速增强应用程序的功能,如Spring Security、Asset Pipeline等。 4. **命令行工具**:Grails 提供强大的命令行工具,支持创建项目、运行应用、生成代码...
在本文中,我们将深入探讨如何在Grails框架中配置MongoDB数据库,并实现用户登录系统。Grails是一款基于Groovy语言的、高效的Web应用开发框架,它借鉴了Ruby on Rails的许多优秀特性。MongoDB则是一种流行的NoSQL...
3. **GORM(Grails Object-Relational Mapping)**:Grails的内置ORM工具,允许开发者以声明式的方式操作数据库,支持SQL的CRUD操作,简化了数据持久化的过程。GORM支持多种数据库,如MySQL、PostgreSQL等。 4. **...
**3. 数据库配置** Grails默认使用H2内存数据库,如需使用MySQL,需修改`Config.groovy`中的数据库配置。添加如下代码: ```groovy dataSource { pooled = true driverClassName = "com.mysql.jdbc.Driver" ...
3. **安装Groovy Eclipse插件** - Groovy Eclipse插件是Grails在Eclipse中开发的关键,可以从其官方网址(http://groovy.codehaus.org/Eclipse+Plugin)下载。 - 插件安装可以通过Eclipse的Software Update功能或...
3. Controller:控制器层接收用户请求,调用模型进行业务处理,并决定视图如何显示结果。 三、Grails命令行工具 Grails提供了一套强大的命令行工具,用于快速创建项目、生成控制器、领域类、服务等。例如,`grails...
Grails 3版本作为该框架的更新迭代产物,同样支持邮件发送服务。 首先,要在Grails 3中开发邮件发送功能,你需要遵循以下步骤: 1. 新建一个Grails项目。在创建项目的过程中,你需要按照Grails框架的约定设置好...
3. **配置Grails环境**:安装插件后,需要在Eclipse中配置Grails的路径,这样Eclipse才能找到Grails命令行工具。这通常在"Eclipse Preferences" -> "Grails"中设置。 4. **创建Grails项目**:现在,你可以通过...
《Grails权威指南 中文版》是一本专注于Grails框架和Groovy语言的中文版技术书籍。本书的作者是Grails项目负责人Graeme Keith Rocher,他将自己对于Grails框架的深刻理解和使用经验编纂成书,以便向读者全面介绍这一...
3. **插件生态系统**:Grails拥有丰富的插件生态系统,这些插件覆盖了从安全性到缓存等各种功能,极大地提升了开发效率。 4. **RESTful Web服务**:Grails支持RESTful Web服务,方便了不同平台间的交互和数据交换。 ...
描述中的"javascript and ajax using in grails"强调了JavaScript在Grails应用中的重要性。JavaScript是实现Ajax交互的主要语言,通常用于处理用户交互和动态更新页面。Grails提供了与jQuery等流行JavaScript库集成...
Grails Persistence with GORM and GSQL
3. Convention over Configuration(CoC):Grails的核心理念之一就是“约定优于配置”,这意味着开发者在很多情况下不需要写大量的配置文件,框架会自动根据约定进行工作。 二、Grails中文文档的价值 1. 学习入口...
**Grails 框架与过滤器(Grails Filters)详解** Grails 是一个基于 Groovy 语言的、用于构建动态Web应用的开源框架。它提供了丰富的特性,简化了Java平台上的开发工作,如自动代码生成、元编程支持以及灵活的数据...