Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Philipp Michael
Hook and Ext Plugin per portal instance
March 21, 2011 4:22 AM
Answer

Philipp Michael

Rank: New Member

Posts: 22

Join Date: January 19, 2011

Recent Posts

Hey everybody,

I'm wondering if it is possible to install a hook or an ext plugin only on a portal instance instead of the entire server. I have made some changes on a Liferay portlet and this should only effect a specific instance. Is there a way to setup this within the control panel? Or do I have to make some changes via plugins sdk?

Please help.

Regards
Philipp
Hitoshi Ozawa
RE: Hook and Ext Plugin per portal instance
March 21, 2011 4:56 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

ext plugin is actually changing Liferay itself so it will be effective on all instances on a server. I think it depends on what kind of hook you're creating.

What is the reason for not just setting up Liferay on another vm?
Philipp Michael
RE: Hook and Ext Plugin per portal instance
March 21, 2011 5:56 AM
Answer

Philipp Michael

Rank: New Member

Posts: 22

Join Date: January 19, 2011

Recent Posts

Thanks for your quick reply. The reason why we are not setting up Liferay on another VM is, that we only have one port available.

Changes I have made via hooks:

- language properties (added some values)
- custom jsps (modified the markup e.g. of asset publisher or journal content search -> those changes are mostly only necessary and volitional for one portal instance)
- portlet properties (bugfixing e.g. for rss portlet javascript bug)

Especially custom jsps should only take affect on a specific instance.
Baptiste Grenier
RE: Hook and Ext Plugin per portal instance
March 21, 2011 11:01 AM
Answer

Baptiste Grenier

Rank: Regular Member

Posts: 100

Join Date: June 30, 2009

Recent Posts

I don't think that it's possible, but in you customs jsps you could test the companyId/organizationId/...Id in order to apply or not the custom changes (either inline or either by having a jsp calling the original jsp or a customized one).
Hitoshi Ozawa
RE: Hook and Ext Plugin per portal instance
March 21, 2011 2:59 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

- language properties (added some values)


Do you want to show different messages per instance? If not, this shouldn't be a problem.

- custom jsps (modified the markup e.g. of asset publisher or journal content search -> those changes are mostly only necessary and volitional for one portal instance)


Why don't you just create a new jsp files for each instance? It's difficult to have different model for each instance, but if it's just a jsp file in a portlet, it seems it possible to create a jsp file or a portlet for each instance.

- portlet properties (bugfixing e.g. for rss portlet javascript bug)

If this is just a bug fix, you probably want the bug fix for all instances so this shouldn't be a problem.
Philipp Michael
RE: Hook and Ext Plugin per portal instance
March 25, 2011 7:44 AM
Answer

Philipp Michael

Rank: New Member

Posts: 22

Join Date: January 19, 2011

Recent Posts

Thank you Baptiste and Hitoshi for your suggestions. Now I'm using a switch to solve this. For example, the abstracts.jsp of the asset publihser portlet looks like this:

 1<c:choose>
 2    <c:when test="<%= company.getWebId().equals(instanceOneWebId) %>">
 3        <liferay-util:include page="/html/portlet/asset_publisher/display/abstracts_one.jsp" />
 4    </c:when>
 5    <c:when test="<%= company.getWebId().equals(instanceTwoWebId) %>">
 6        <liferay-util:include page="/html/portlet/asset_publisher/display/abstracts_two.jsp" />
 7    </c:when>
 8    <c:otherwise>
 9        <liferay-util:include page="/html/portlet/asset_publisher/display/abstracts_default.jsp" />
10    </c:otherwise>
11</c:choose>


I want to set those webids in the portal properties. How I can access this new custom properties in my jsp files?
Brian Scott Schupbach
RE: Hook and Ext Plugin per portal instance
May 10, 2012 1:58 PM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 331

Join Date: October 23, 2008

Recent Posts

It would be a nice feature to be able to apply hooks on a per portal instance basis. You can disable certain portlets and themes per instance but you can't for hooks. There should be a section in "Portlet Configuration" that would allow you to disable hooks on a per instance basis.

What is the reason for not just setting up Liferay on another vm?


The reason why you would try to avoid this is the reason why portal instances were created to begin with. Increased time involved in Maintenance, updates, resources, etc.. Also if you are an enterprise customer this sort of setup won't support certain enterprise licenses.
Hitoshi Ozawa
RE: Hook and Ext Plugin per portal instance
May 10, 2012 3:38 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

The reason why you would try to avoid this is the reason why portal instances were created to begin with. Increased time involved in Maintenance, updates, resources, etc..


Making hook per instance seems to increate maintenance, update, resource, etc time. It seems better to just one hook with a switch to logic based on instance id inside it. It may be nice to be able to setup a hook contain multiple logics for each instance and have liferay portal do the selection on which logic to use based on a property file.

How about posting a suggestion to the "Suggestion forum"?
Brian Scott Schupbach
RE: Hook and Ext Plugin per portal instance
May 10, 2012 3:49 PM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 331

Join Date: October 23, 2008

Recent Posts

I don't think making a hook per instance would increase maintenance and resources...maybe I wasn't being clear enough.

For example one my first portal instance uses active directory to login. The 2nd portal instance does not use active directory and is open for public users to sign up. I actually want to write a login hook in the 2nd instance so I can grab roles and authenticate with another system we have. If I write the hook it will be applied to both instances..which will be bad because the 1st instance uses active directory and isn't connected at all with the system I am trying to grab roles from. To make the hook work I'll have to write logic to test for each instance.

My suggestion is that hooks should work the same way themes and portlets work. You can disable them on a per instance basis. If that were the case I could write a login hook, deploy it, and have it enabled in one instance and disabled in another. Then I wouldn't have to write in logic in the hook or create a separate vm with a separate database and code base.

That's a good idea. I'll submit it as a suggestion. Thanks!
Hitoshi Ozawa
RE: Hook and Ext Plugin per portal instance
May 10, 2012 8:21 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

You can disable them on a per instance basis.


That's the point I'm making. It's available for use, but you're disabling it on a per portal instance. This is different from having to write a different hook (war file) for each portal instance if several portal instances needs to use them.