summaryrefslogtreecommitdiff
path: root/jvmfwk
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-03-18 15:58:02 +0100
committerJan Holesovsky <kendy@suse.cz>2011-03-18 15:58:02 +0100
commit980b7de55c897cb38f5706164a053f38c1b35d88 (patch)
tree34b80af4ad8b97fc5c31768be1073d91dc659c46 /jvmfwk
parent2475c0b62d65f9db542d4fd0a0792795a39185a2 (diff)
parentc953ef4b46ced010ed3ebd77c4dd11174da60dd1 (diff)
Merge remote-tracking branch 'origin/integration/dev300_m101'
Conflicts: bridges/source/remote/urp/urp_environment.cxx bridges/source/remote/urp/urp_propertyobject.cxx bridges/source/remote/urp/urp_reader.cxx remotebridges/source/factory/bridgefactory.cxx stoc/source/corereflection/crefl.cxx stoc/source/javavm/javavm.cxx stoc/source/simpleregistry/simpleregistry.cxx
Diffstat (limited to 'jvmfwk')
-rw-r--r--jvmfwk/source/elements.cxx90
-rw-r--r--jvmfwk/source/elements.hxx28
2 files changed, 101 insertions, 17 deletions
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index 6ef51d53d..131f6898a 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -50,16 +50,16 @@ using namespace osl;
namespace jfw
{
-rtl::OString getElementUpdated()
+rtl::OString getElement(::rtl::OString const & docPath,
+ xmlChar const * pathExpression, bool bThrowIfEmpty)
{
//Prepare the xml document and context
- rtl::OString sSettingsPath = jfw::getVendorSettingsPath();
- OSL_ASSERT(sSettingsPath.getLength() > 0);
- jfw::CXmlDocPtr doc(xmlParseFile(sSettingsPath.getStr()));
+ OSL_ASSERT(docPath.getLength() > 0);
+ jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr()));
if (doc == NULL)
throw FrameworkException(
JFW_E_ERROR,
- rtl::OString("[Java framework] Error in function getElementUpdated "
+ rtl::OString("[Java framework] Error in function getElement "
"(elements.cxx)"));
jfw::CXPathContextPtr context(xmlXPathNewContext(doc));
@@ -67,20 +67,42 @@ rtl::OString getElementUpdated()
(xmlChar*) NS_JAVA_FRAMEWORK) == -1)
throw FrameworkException(
JFW_E_ERROR,
- rtl::OString("[Java framework] Error in function getElementUpdated "
+ rtl::OString("[Java framework] Error in function getElement "
"(elements.cxx)"));
+
CXPathObjectPtr pathObj;
- pathObj = xmlXPathEvalExpression(
- (xmlChar*)"/jf:javaSelection/jf:updated/text()", context);
+ pathObj = xmlXPathEvalExpression(pathExpression, context);
+ rtl::OString sValue;
if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
- throw FrameworkException(
- JFW_E_ERROR,
- rtl::OString("[Java framework] Error in function getElementUpdated "
- "(elements.cxx)"));
- rtl::OString sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content;
+ {
+ if (bThrowIfEmpty)
+ throw FrameworkException(
+ JFW_E_ERROR,
+ rtl::OString("[Java framework] Error in function getElement "
+ "(elements.cxx)"));
+ }
+ else
+ {
+ sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content;
+ }
return sValue;
}
+rtl::OString getElementUpdated()
+{
+ return getElement(jfw::getVendorSettingsPath(),
+ (xmlChar*)"/jf:javaSelection/jf:updated/text()", true);
+}
+
+// Use only in INSTALL mode !!!
+rtl::OString getElementModified()
+{
+ //The modified element is only written in INSTALL mode.
+ //That is NodeJava::m_layer = INSTALL
+ return getElement(jfw::getInstallSettingsPath(),
+ (xmlChar*)"/jf:java/jf:modified/text()", false);
+}
+
void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
{
@@ -577,6 +599,21 @@ void NodeJava::write() const
xmlAddChild(jreLocationsNode, nodeCrLf);
}
}
+
+ if (INSTALL == m_layer)
+ {
+ //now write the current system time
+ ::TimeValue curTime = {0,0};
+ if (::osl_getSystemTime(& curTime))
+ {
+ rtl::OUString sSeconds =
+ rtl::OUString::valueOf((sal_Int64) curTime.Seconds);
+ xmlNewTextChild(
+ root,NULL, (xmlChar*) "modified", CXmlCharPtr(sSeconds));
+ xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n");
+ xmlAddChild(root, nodeCrLf);
+ }
+ }
if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1)
throw FrameworkException(JFW_E_ERROR, sExcMsg);
}
@@ -719,7 +756,7 @@ jfw::FileStatus NodeJava::checkSettingsFileStatus() const
File::RC rc_stat = item.getFileStatus(stat);
if (File::E_None == rc_stat)
{
- //ToDo we remove the file and create it shortly after. This
+ // This
//function may be called multiple times when a java is started.
//If the expiretime is too small then we may loop because everytime
//the file is deleted and we need to search for a java again.
@@ -730,16 +767,24 @@ jfw::FileStatus NodeJava::checkSettingsFileStatus() const
//that after removing the file and shortly later creating it again
//did not change the creation time. That is the newly created file
//had the creation time of the former file.
- ::TimeValue modTime = stat.getModifyTime();
::TimeValue curTime = {0,0};
+ ret = FILE_OK;
if (sal_True == ::osl_getSystemTime(& curTime))
{
- if ( curTime.Seconds - modTime.Seconds >
+ //get the modified time recorded in the <modified> element
+ sal_uInt32 modified = getModifiedTime();
+ OSL_ASSERT(modified <= curTime.Seconds);
+ //Only if modified has a valued then NodeJava::write was called,
+ //then the xml structure was filled with data.
+
+ if ( modified && curTime.Seconds - modified >
BootParams::getInstallDataExpiration())
{
#if OSL_DEBUG_LEVEL >=2
+ fprintf(stderr, "[Java framework] Settings file is %d seconds old. \n",
+ (int)( curTime.Seconds - modified));
rtl::OString s = rtl::OUStringToOString(sURL, osl_getThreadTextEncoding());
- fprintf(stderr, "[Java framework] Deleting settings file at \n%s\n", s.getStr());
+ fprintf(stderr, "[Java framework] Settings file is exspired. Deleting settings file at \n%s\n", s.getStr());
#endif
//delete file
File f(sURL);
@@ -1089,6 +1134,17 @@ JavaInfo * CNodeJavaInfo::makeJavaInfo() const
return pInfo;
}
+sal_uInt32 NodeJava::getModifiedTime() const
+{
+ sal_uInt32 ret = 0;
+ if (m_layer != INSTALL)
+ {
+ OSL_ASSERT(0);
+ return ret;
+ }
+ rtl::OString modTimeSeconds = getElementModified();
+ return (sal_uInt32) modTimeSeconds.toInt64();
+}
//================================================================================
MergedSettings::MergedSettings():
diff --git a/jvmfwk/source/elements.hxx b/jvmfwk/source/elements.hxx
index 4641d3bbe..4bb1c9f46 100644
--- a/jvmfwk/source/elements.hxx
+++ b/jvmfwk/source/elements.hxx
@@ -196,6 +196,34 @@ private:
*/
boost::optional< ::std::vector< ::rtl::OUString> > m_JRELocations;
+ /** Only in INSTALL mode. Then NodeJava.write writes a <modified> element
+ which contains the seconds value of the TimeValue (osl/time.h), obtained
+ with osl_getSystemTime.
+ It returns 0 if the value cannot be obtained.
+ This is used to fix the problem that the modified time of the settings
+ file is incorrect because it resides on an NFS volume where the NFS
+ server and NFS client do not have the same system time. For example if
+ the server time is ahead of the client time then checkSettingsFileStatus
+ deleted the settings. So even if javaldx determined a Java
+ (jfw_findAndSelectJRE) then jfw_startVM returned a JFW_E_NO_SELECT. Then
+ it looked again for a java by calling jfw_findAndSelectJRE, which
+ returned a JFW_E_NONE. But the following jfw_startVM returned again
+ JFW_E_NO_SELECT. So it looped. (see issue i114509)
+
+ NFS server and NFS client should have the same time. It is common
+ practise to enforce this in networks. We actually should not work
+ around a malconfigured network. We must however, make sure that we do
+ not loop. Maybe a better approach is, that:
+ - assume that mtime and system time are reliable
+ - checkSettingsFile uses system time and mtime of the settings file,
+ instset of using getModifiedTime.
+ - allow a small error margin
+ - jfw_startVM must return a JFW_E_EXPIRED_SETTINGS
+ - XJavaVM::startVM should prevent the loop by processing the new return+ value
+
+ */
+ sal_uInt32 getModifiedTime() const;
+
public:
NodeJava(Layer theLayer = USER_OR_INSTALL);