Foren

Refer to external props

Ben Smart, geändert vor 9 Jahren.

Refer to external props

Junior Member Beiträge: 79 Beitrittsdatum: 09.01.10 Neueste Beiträge
Hi,

How do I refer to an external property file in a hook? I want something like this

<hook>
    <portal-properties>${liferay.home}/external.properties</portal-properties>
</hook>


How do I pass liferay home as the above code gives error

Thanks
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Refer to external props

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
You cannot. A portal properties hook includes the properties file right into the hook itself, it is not external.
thumbnail
Prakash Khanchandani, geändert vor 9 Jahren.

RE: Refer to external props (Antwort)

Expert Beiträge: 329 Beitrittsdatum: 10.02.11 Neueste Beiträge
Hook in liferay means to override or change the functionality liferay has, not hooking into some custom made code/file. Only liferay's properties that too not all can be hooked.

Do you want to read the value of external.properties file in your hook and accordingly do some customization? If you can tell us what exactly you want to do, may be a little detail then we might be able to suggest some alternatives.

As for the current question David Nebinger has already answered it.

Thanks,
Prakash
Ben Smart, geändert vor 9 Jahren.

RE: Refer to external props

Junior Member Beiträge: 79 Beitrittsdatum: 09.01.10 Neueste Beiträge
I want to keep some env specific props entry in a separate file. I am using a hook to do the upgrade for each release and I want to read the env entries from an external props file.
If I cannot change the hook props file, how do I include this file in portal-ext? Should the new file also be in same location as portal -ext and should be referred by -D arg in the tomcat start up?

Thanks
thumbnail
Prakash Khanchandani, geändert vor 9 Jahren.

RE: Refer to external props (Antwort)

Expert Beiträge: 329 Beitrittsdatum: 10.02.11 Neueste Beiträge
I can think of two ways:
  • Simplest way is to include all your properties in portal-ext.properties instead of having a separate file
  • Another way is as liferay suggests in its portal.properties (which is what you also pointed to):
    
        #
        # Additional property files can be used by setting the "external-properties"
        # system property.
        #
        # A common use case is to keep legacy property values when upgrading to
        # newer versions of Liferay. To enable:
        #
        #     java ... -Dexternal-properties=portal-legacy-5.1.properties
        #
        # The read order will now be: portal.properties, then portal-ext.properties,
        # and then portal-legacy-5.1.properties.
        #
        include-and-override=${external-properties}
        include-and-override=${liferay.home}/${external-properties}

Ben Smart:
Should the new file also be in same location as portal -ext and should be referred by -D arg in the tomcat start up?

Yes. this is what liferay suggest you do, read the comment pasted above for the properties in portal.properties

Hope this helps.
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: Refer to external props (Antwort)

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Right, use the -Dexternal-properties= environment setting to have Liferay pull in an environment-specific file. The value that you use here can be anything, and not having a property file won't hurt any. But when you create and populate the file w/ settings, those will be processed to be separate environmental files.
Ben Smart, geändert vor 9 Jahren.

RE: Refer to external props

Junior Member Beiträge: 79 Beitrittsdatum: 09.01.10 Neueste Beiträge
Thank you for your suggestions