留言板

Multiple Service.xml in Single Plugin

Kailas Lokhande,修改在11 年前。

Multiple Service.xml in Single Plugin

New Member 帖子: 10 加入日期: 12-11-7 最近的帖子
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
thumbnail
David H Nebinger,修改在11 年前。

RE: Multiple Service.xml in Single Plugin (答复)

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
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:

 <!--
 The service-builder-import allows you to split up a large Service Builder file
 into smaller files by aggregrating the smaller Service Builder into one file.
 Note that there can be at most one author element among all the files. There can
 also only be one and only one namespace element among all the files.

 The attribute file is interpreted as relative to the file that is importing it.
 -->
 <!--ELEMENT service-builder-import (#PCDATA)-->

 <!--
 Set the comments in the service-builder-import element.
 -->
 <!--ATTLIST service-builder-import
	file CDATA #REQUIRED
 -->
Kailas Lokhande,修改在11 年前。

RE: Multiple Service.xml in Single Plugin

New Member 帖子: 10 加入日期: 12-11-7 最近的帖子
Yes David, SB does not honor package declarations. But atleast I can have separate service.xml for entities .
Thanks for great help.
thumbnail
meera prince,修改在11 年前。

RE: Multiple Service.xml in Single Plugin

Liferay Legend 帖子: 1111 加入日期: 11-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/
D. U.,修改在10 年前。

RE: Multiple Service.xml in Single Plugin

New Member 帖子: 14 加入日期: 13-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:

<!--?xml version="1.0" encoding="UTF-8"?-->

<service-builder package-path="com.foo.bar.importer">
	<author>D.U.</author>
	<namespace>My_Project</namespace>
	
	<entity name="FooBarImporter" local-service="true" remote-service="true" human-name="Foo Bar Importer" />
	<entity name="XmlConverter" local-service="true" remote-service="false" human-name="XmlConverter" />

</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?
thumbnail
David H Nebinger,修改在10 年前。

RE: Multiple Service.xml in Single Plugin

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
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.,修改在10 年前。

RE: Multiple Service.xml in Single Plugin

New Member 帖子: 14 加入日期: 13-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.*.
thumbnail
David H Nebinger,修改在10 年前。

RE: Multiple Service.xml in Single Plugin

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
That's right, you cannot generate into different packages. If you want different packages, you need separate plugins.