论坛

主页 » Liferay IDE » English

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Kailas Lokhande
Multiple Service.xml in Single Plugin
2013年2月13日 下午7:16
答复

Kailas Lokhande

等级: New Member

帖子: 10

加入日期: 2012年11月6日

最近的帖子

Hello Experts,

I have one plugin, which requires 5 entities. I want these 5 entities to be belongs to 5 different packages, for that I added 5 service.xml with different package path specified in it. And ran the service builder.
But I observed that service jar that gets created is not getting properly build.
I always get ClassCastException like com.model.impl.ClassAImpl cannot be cast to com.model.ClassA

Can anyone tell me what could be the solution?
And is there a way to run these 5 service.xml at single time?

I would really appreciate any word on this

Thanks,
Kailas Lokhande
David H Nebinger
RE: Multiple Service.xml in Single Plugin
2013年2月13日 下午7:37
答复

David H Nebinger

等级: Liferay Legend

帖子: 7027

加入日期: 2006年9月1日

最近的帖子

You might be able to use the import for the 4 additional files, but I don't know that SB will honor your package declarations.

According to the liferay-service-builder_6_1_0.dtd:

 1 <!--
 2 The service-builder-import allows you to split up a large Service Builder file
 3 into smaller files by aggregrating the smaller Service Builder into one file.
 4 Note that there can be at most one author element among all the files. There can
 5 also only be one and only one namespace element among all the files.
 6
 7 The attribute file is interpreted as relative to the file that is importing it.
 8 -->
 9 <!ELEMENT service-builder-import (#PCDATA)>
10
11 <!--
12 Set the comments in the service-builder-import element.
13 -->
14 <!ATTLIST service-builder-import
15    file CDATA #REQUIRED
16 >
Meera Prince
RE: Multiple Service.xml in Single Plugin
2013年2月13日 下午8:29
答复

Meera Prince

等级: Liferay Master

帖子: 814

加入日期: 2011年2月8日

最近的帖子

HI
<service-builder-import file="service1.xml" />
<service-builder-import file="service2.xml" />

https://www.liferay.com/community/forums/-/message_boards/message/14653303
http://www.liferay.com/community/forums/-/message_boards/message/13314225


Regards,
Meera Prince
http://www.liferaysavvy.com/
Kailas Lokhande
RE: Multiple Service.xml in Single Plugin
2013年2月13日 下午10:39
答复

Kailas Lokhande

等级: New Member

帖子: 10

加入日期: 2012年11月6日

最近的帖子

Yes David, SB does not honor package declarations. But atleast I can have separate service.xml for entities .
Thanks for great help.
D. U.
RE: Multiple Service.xml in Single Plugin
2014年1月6日 上午4:38
答复

D. U.

等级: New Member

帖子: 14

加入日期: 2013年11月25日

最近的帖子

This doesn't work for me.
I have a service.xml with the 'regular' stuff which is generated perfectly from ServiceBuilder. As suggested, I created another service.xml called service-importer.xml in which I defined two entities with no columns (because they don't need database access) to create these services into their own package-path:

 1<?xml version="1.0" encoding="UTF-8"?>
 2<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
 3<service-builder package-path="com.foo.bar.importer">
 4    <author>D.U.</author>
 5    <namespace>My_Project</namespace>
 6   
 7    <entity name="FooBarImporter" local-service="true" remote-service="true" human-name="Foo Bar Importer" />
 8    <entity name="XmlConverter" local-service="true" remote-service="false" human-name="XmlConverter" />
 9
10</service-builder>


When right-clicking on it chosing Liferay --> Build services in Eclipse the original service.xml is used from ServiceBuilder instead of service-importer.xml. Where do I go wrong?

My intention is to separate my services in distinct packages because I have more than one portlet in my project.
Furthermore, I want to use @Autowired for the XmlConverter entity to be used in a service. Is there something I have to consider?
David H Nebinger
RE: Multiple Service.xml in Single Plugin
2014年1月6日 上午7:09
答复

David H Nebinger

等级: Liferay Legend

帖子: 7027

加入日期: 2006年9月1日

最近的帖子

service.xml is always used. you use the import tag in service.xml to include the service-importer.xml.

you break service.xml into smaller files for management purposes. at the end of the day you're still building a single service layer so it always starts with service.xml and imports the additional files.
D. U.
RE: Multiple Service.xml in Single Plugin
2014年1月9日 下午11:52
答复

D. U.

等级: New Member

帖子: 14

加入日期: 2013年11月25日

最近的帖子

Well, but it seems as if I have no chance to generate into different packages!? My intention was to let ServiceBuilder generate the classes into the distinct packages of the portlets. For instance, for portlet 1 into com.foo.bar.portlet1.* and for portlet 2 into com.foo.bar.portlet2.*.
David H Nebinger
RE: Multiple Service.xml in Single Plugin
2014年1月10日 上午6:02
答复

David H Nebinger

等级: Liferay Legend

帖子: 7027

加入日期: 2006年9月1日

最近的帖子

That's right, you cannot generate into different packages. If you want different packages, you need separate plugins.