portals-wsrp4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete <pdjunkem...@yahoo.com>
Subject Re: how to configure wsrp4j persistence to a directory outside WAR
Date Thu, 09 Jun 2005 19:14:48 GMT
You are right about editing the source code.  But
instead of just changing the default hard coded paths
I've updated the code to accept a property override.

Here is a summary of what I did.  Maybe the wsrp4j
project could be updated to include support for this
idea?  The issue surrounds the use of the WEB-INF to
host dynamically created files.  When you register a
portlet files are created/updated.  Depending on the
situation, you may not want to keep this in the EAR,
but rather separately so that the file changes can be
managed separately from the source code.

Pluto changes:
======================================

WSRPWeb/WEB-INF/config/services/ConfigService.properties
	aggregation.base.dir = wsrp/aggregation/

The following service classes and their properties
files had to be modified to handle relative locations:

PortletEntityRegistryServiceFileImpl

WEB-INF/config/services/PageEntityRegistryService.properties
		#PortletEntityRegistry overrides
		#mapping.files.workingdir.path = true would mean
using the workingdir as the default path
		mapping.files.workingdir.path = true
		#mapping.configfile location of
portletentitymapping.xml
		mapping.configfile =
wsrp/data/xml/portletentitymapping.xml
		#registry.configfile = location of
portletentityregistry.xml
		registry.configfile =
wsrp/data/portletentityregistry.xml
PortletDefinitionRegistryServiceFileImpl

WEB-INF/config/services/PortletDefinitionRegistryService.properties
		# Portlet registry 
		#mapping.files.workingdir.path = true would mean
using the workingdir as the default path
		mapping.files.workingdir.path = true
		#relative to appserver working directory
		mapping.portletxml.configfile =
wsrp/data/xml/portletdefinitionmapping.xml
		mapping.webxml.configfile =
wsrp/data/xml/servletdefinitionmapping.xml
PageRegistryServiceFileImpl

WEB-INF/config/services/PageRegistryService.properties
		#PageRegistry overrides
		#mapping.files.workingdir.path = true would mean
using the workingdir as the default path
		mapping.files.workingdir.path = true
		#mapping.configfile location of
pageregistrymapping.xml
		mapping.configfile =
wsrp/data/xml/pageregistrymapping.xml
		#registry.configfile = location of pageregistry.xml
		registry.configfile = wsrp/data/pageregistry.xml




Sample code that is simaler across the three services:
    // default configuration values
    public final static String CONFIG_FILE            
 = "WEB-INF/data/portletentityregistry.xml";
    public final static String DEFAULT_MAPPING        
 = "WEB-INF/data/xml/portletentitymapping.xml";
    // configuration keys
    protected final static String CONFIG_MAPPING      
   = "mapping.configfile";
    protected final static String CONFIG_FILE_PROPERTY
= "registry.configfile";

	// configuration location
	private final static String
CONFIG_MAPPING_WORKINGDIR_PATH =
"mapping.files.workingdir.path";
	private static boolean _useWorkingDir = false;
    private String _config_file = null;
    
		_useWorkingDir =
(properties.getBoolean(CONFIG_MAPPING_WORKINGDIR_PATH)
== Boolean.TRUE);
        _config_file =
properties.getString(CONFIG_FILE_PROPERTY,
CONFIG_FILE);
        File f = new File(_config_file);
        if (!f.isAbsolute()) {
			if (_useWorkingDir) {
				
				//using the File object allows for paths relative
to the working directory of an app server
				_config_file = f.getAbsolutePath();
			} else {
				_config_file =
servletContext.getRealPath(_config_file);
			}
        }

        String _mapping =
properties.getString(CONFIG_MAPPING, DEFAULT_MAPPING);
        f = new File(_mapping);
        if (!f.isAbsolute()) {
			if (_useWorkingDir) {
				
				//using the File object allows for paths relative
to the working directory of an app server
				_mapping = f.getAbsolutePath();
			} else {
				_mapping = servletContext.getRealPath(_mapping);
			}
        }



WSRP changes:
======================================

Change this code to allow support for relative
directories:

ServerPersistentInformationProviderImpl
	change ServerPersistentInformationProviderImpl(String
offsetPath)
			if (ROOT_DIR == null)
			{
				// ROOT_DIR is static, so it only needs to be
setup once for all
				// instances of PersistentStore objects
				ROOT_DIR = offsetPath + File.separator +
PERSISTENT_DIR;
				
				//As in the () constructor should get the REAL or
ABSOLUTE PATH, so that 
				//relative paths can be used in the configuration
file
				File tFile = new File (ROOT_DIR);
				ROOT_DIR = tFile.getAbsolutePath();
			}

In WAR JavaSource\WSRPServices.properties
	wsrp.persistence.path = wsrp
Can be relative or absolute.  If absolute, in windows
the format must be as follows:
	wsrp.persistence.path = c:\\data\\wsrp


--- Elliot Metsger <emetsger@jhu.edu> wrote:

> Right now you'll need to edit source code... I'm at
> a conference right 
> now but IIRC the paths are embedded.
> 
> Diego Louzán wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > We are looking forward at redesigning the
> persistence code for allowing
> > pluggable persistence methods. I personally
> haven't studied the Castor
> > persistence provided by WSRP4J, maybe one of the
> original contributors can
> > solve your doubts. If I have some spare time these
> days I'll take a look, but I
> > can't promise anything.
> > 
> > Regards.
> > Diego.
> > 
> > Pete wrote:
> > 
> >>I'd like to configure WSRP4J (and Pluto) to use
> their
> >>persistence directories outside of the WAR/EAR -
> >>specifically a directory relative the working
> >>directory of the appserver (Websphere).
> >>
> >>For Pluto I have made these configuration changes:
> >>wsrp/WEB-INF/config/services.properties
> >>Add these lines:
> >>aggregation.base.dir = aggregation/
> >>mapping.portletxml.configfile =
> >>data/xml/portletdefinitionmapping.xml
> >>mapping.webxml.configfile =
> >>data/xml/servletdefinitionmapping.xml
> >>
> >>For WSRP specifically there did not appear to be
> >>support for changing the location of the
> persistence
> >>directory out of the WAR so I tried to change the
> code
> >>as follows:
> >>ServerPersistentFactory interface should have a
> >>"setProperties" method.
> >>Then PersistentAccess.getServerPersistentFactory()
> >>should pass WSRPServices.properties (pFactories)
> on to
> >>the instantiated ServerPersistentFactory.
> >>Then ServerPersistentFactoryImpl.setProperties()
> can
> >>setPath() on the ServerPersistentFactoryImpl as
> >>specified in the WSRPServices.properties file (for
> >>example wsrp.persistence.path = file:/c:/wsrp)
> >>
> >>I really don't know if I'm doing the right thing. 
> Can
> >>anyone help?  Do I even need to change the code
> for
> >>WSRP4J to do this?  My attempt at a code change
> >>appears to have failed, and I'm trying to debug,
> but
> >>not getting very far.
> >>
> >>Pete
> >>
> >>
> >>
> >>
> >>		
> >>__________________________________ 
> >>Discover Yahoo! 
> >>Have fun online with music videos, cool games, IM
> and more. Check it out! 
> >>http://discover.yahoo.com/online.html
> > 
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.2.6 (GNU/Linux)
> > 
> >
>
iD8DBQFCqBtQgyzZYflJelERAmP3AJ4wCnBrVkLuGw6+erdu37GmLenA7ACfQ7CZ
> > E1FvLfB+zlQVQHVvexdilic=
> > =Bftb
> > -----END PGP SIGNATURE-----
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Mime
View raw message