Kaydet (Commit) 6115248d authored tarafından Kay Ramme's avatar Kay Ramme

add parametrized defaultBootstrap_InitialComponentContext (#88338#)

üst 3dfb38a4
......@@ -2,9 +2,9 @@
*
* $RCSfile: bootstrap.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: dbo $ $Date: 2001-08-27 10:00:48 $
* last change: $Author: kr $ $Date: 2001-09-03 14:28:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -137,6 +137,11 @@ bootstrap_InitialComponentContext(
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
defaultBootstrap_InitialComponentContext(const ::rtl::OUString & iniFile) SAL_THROW( (::com::sun::star::uno::Exception) );
} // end namespace cppu
#endif
......
......@@ -231,6 +231,7 @@ __1cDcomDsunEstarIregistrycG__RTTI__1nDcomDsunEstarIregistryYInvalidRegistryExce
__1cDcomDsunEstarIregistrycU__RTTI__1nDcomDsunEstarIregistrybLCannotRegisterImplementationException__;
__1cEcppuZcomponent_writeInfoHelper6Fpv1pkn0ATImplementationEntry__C_;
__1cEcppubAcomponent_getFactoryHelper6Fpkcpv3pkn0ATImplementationEntry__3_;
__1cEcppubOdefaultBootstrap_InitialComponentContext6FrknDrtlIOUString__nDcomDsunEstarDunoJReference4n0GRXComponentContext____;
local:
*;
};
......
......@@ -178,6 +178,7 @@ component_getDescriptionFunc
?addListener@?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@cppu@@QAEXABVType@uno@star@sun@com@@ABV?$Reference@VXInterface@uno@star@sun@com@@@4567@@Z
?component_writeInfoHelper@cppu@@YAEPAX0QBUImplementationEntry@1@@Z
?component_getFactoryHelper@cppu@@YAPAXPBDPAX1QBUImplementationEntry@1@@Z
?defaultBootstrap_InitialComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@@Z
local:
*;
};
......@@ -2,9 +2,9 @@
*
* $RCSfile: servicefactory.cxx,v $
*
* $Revision: 1.23 $
* $Revision: 1.24 $
*
* last change: $Author: kr $ $Date: 2001-07-25 09:14:51 $
* last change: $Author: kr $ $Date: 2001-09-03 14:28:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -81,8 +81,11 @@
#include <rtl/ustrbuf.hxx>
#endif
#include <string.h>
#include <osl/security.hxx>
#include <rtl/bootstrap.hxx>
#include <cppuhelper/shlib.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/component_context.hxx>
......@@ -421,32 +424,21 @@ Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext(
//==================================================================================================
static OUString findBoostrapArgument(const OUString & arg_name, sal_Bool * pFallenBack) SAL_THROW(()) {
static OUString findBoostrapArgument(const Bootstrap & bootstrap, const OUString & arg_name, sal_Bool * pFallenBack) SAL_THROW(()) {
OUString result;
OUString prefixed_arg_name = OUString(RTL_CONSTASCII_USTRINGPARAM("UNO_"));
prefixed_arg_name += arg_name.toAsciiUpperCase();
if(!rtl_bootstrap_get(prefixed_arg_name.pData, &result.pData, NULL)) // environment not set -> try relative to executable
if(!bootstrap.getFrom(prefixed_arg_name, result)) // environment not set -> try relative to executable
{
if(pFallenBack)
*pFallenBack = sal_True;
OUString fileName;
osl_getExecutableFile(&fileName.pData);
// get rid of a potential executable extension
OUString progExt = OUString::createFromAscii(".bin");
if(fileName.getLength() > progExt.getLength()
&& fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt))
fileName = fileName.copy(0, fileName.getLength() - progExt.getLength());
progExt = OUString::createFromAscii(".exe");
if(fileName.getLength() > progExt.getLength()
&& fileName.copy(fileName.getLength() - progExt.getLength()).equalsIgnoreAsciiCase(progExt))
fileName = fileName.copy(0, fileName.getLength() - progExt.getLength());
bootstrap.getIniName(fileName);
result = fileName;
result = fileName.copy(0, fileName.getLength() - strlen(SAL_CONFIGFILE(""))); // cut the rc extension
result += OUString(RTL_CONSTASCII_USTRINGPARAM("_"));
result += arg_name.toAsciiLowerCase();
result += OUString(RTL_CONSTASCII_USTRINGPARAM(".rdb"));
......@@ -454,7 +446,7 @@ static OUString findBoostrapArgument(const OUString & arg_name, sal_Bool * pFall
#ifdef DEBUG
OString result_dbg = OUStringToOString(result, RTL_TEXTENCODING_ASCII_US);
OString arg_name_dbg = OUStringToOString(arg_name, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("cppuhelper::createServiceFactoy - setting %s relative to executable: %s\n",
OSL_TRACE("cppuhelper::findBoostrapArgument - setting %s relative to executable: %s\n",
arg_name_dbg.getStr(),
result_dbg.getStr());
#endif
......@@ -467,7 +459,7 @@ static OUString findBoostrapArgument(const OUString & arg_name, sal_Bool * pFall
#ifdef DEBUG
OString prefixed_arg_name_dbg = OUStringToOString(prefixed_arg_name, RTL_TEXTENCODING_ASCII_US);
OString result_dbg = OUStringToOString(result, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE("cppuhelper::createServiceFactoy - found %s in env: %s",
OSL_TRACE("cppuhelper::findBoostrapArgument - found %s in env: %s",
prefixed_arg_name_dbg.getStr(),
result_dbg.getStr());
#endif
......@@ -477,7 +469,8 @@ static OUString findBoostrapArgument(const OUString & arg_name, sal_Bool * pFall
}
static Reference<XSimpleRegistry> nestRegistries(const Reference<XSingleServiceFactory> & xSimRegFac,
static Reference<XSimpleRegistry> nestRegistries(const OUString baseDir,
const Reference<XSingleServiceFactory> & xSimRegFac,
const Reference<XSingleServiceFactory> & xNesRegFac,
OUString csl_rdbs,
const OUString & write_rdb,
......@@ -493,7 +486,10 @@ static Reference<XSimpleRegistry> nestRegistries(const Reference<XSingleServiceF
try
{
lastRegistry->open(write_rdb, sal_False, forceWrite_rdb);
OSL_TRACE("opening xxxxx");
lastRegistry->open(write_rdb, sal_False, forceWrite_rdb);
OSL_TRACE("opening yyyy");
}
catch (InvalidRegistryException & invalidRegistryException)
{
......@@ -508,11 +504,6 @@ static Reference<XSimpleRegistry> nestRegistries(const Reference<XSingleServiceF
lastRegistry = Reference<XSimpleRegistry>();
}
// get the directory of the executable
OUString exeDir;
osl_getExecutableFile(&exeDir.pData);
exeDir = exeDir.copy(0, exeDir.lastIndexOf('/') + 1);
do
{
index = csl_rdbs.indexOf((sal_Unicode)' ');
......@@ -523,7 +514,7 @@ static Reference<XSimpleRegistry> nestRegistries(const Reference<XSingleServiceF
{
Reference<XSimpleRegistry> simpleRegistry = Reference<XSimpleRegistry>::query(xSimRegFac->createInstance());
osl::FileBase::getAbsoluteFileURL(exeDir, rdb_name, rdb_name);
osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name);
simpleRegistry->open(rdb_name, sal_True, sal_False);
if(lastRegistry.is())
......@@ -562,13 +553,15 @@ static Reference<XSimpleRegistry> nestRegistries(const Reference<XSingleServiceF
*
* @return the XComponentContext
*/
Reference<XComponentContext> SAL_CALL defaultBootstrap_InitialComponentContext() SAL_THROW((Exception))
Reference<XComponentContext> SAL_CALL defaultBootstrap_InitialComponentContext(const OUString & iniFile) SAL_THROW((Exception))
{
OUString cls_uno_types = findBoostrapArgument(OUString(RTL_CONSTASCII_USTRINGPARAM("TYPES")), NULL);
OUString cls_uno_services = findBoostrapArgument(OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES")), NULL);
Bootstrap bootstrap(iniFile);
OUString cls_uno_types = findBoostrapArgument(bootstrap, OUString(RTL_CONSTASCII_USTRINGPARAM("TYPES")), NULL);
OUString cls_uno_services = findBoostrapArgument(bootstrap, OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES")), NULL);
sal_Bool fallenBack;
OUString write_rdb = findBoostrapArgument(OUString(RTL_CONSTASCII_USTRINGPARAM("WRITERDB")), &fallenBack);
OUString write_rdb = findBoostrapArgument(bootstrap, OUString(RTL_CONSTASCII_USTRINGPARAM("WRITERDB")), &fallenBack);
OUString bootstrapPath;
......@@ -595,10 +588,18 @@ Reference<XComponentContext> SAL_CALL defaultBootstrap_InitialComponentContext()
xEmptyKey),
UNO_QUERY);
Reference<XSimpleRegistry> types_xRegistry = nestRegistries(xSimRegFac, xNesRegFac, cls_uno_types, OUString(), sal_False);
Reference<XSimpleRegistry> services_xRegistry = nestRegistries(xSimRegFac, xNesRegFac, cls_uno_services, write_rdb, !fallenBack);
OUString iniDir;
bootstrap.getIniName(iniDir);
iniDir = iniDir.copy(0, iniDir.lastIndexOf('/'));
Reference<XSimpleRegistry> types_xRegistry = nestRegistries(iniDir, xSimRegFac, xNesRegFac, cls_uno_types, OUString(), sal_False);
Reference<XSimpleRegistry> services_xRegistry = nestRegistries(iniDir, xSimRegFac, xNesRegFac, cls_uno_services, write_rdb, !fallenBack);
return initializeSF(smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry, bootstrapPath);
}
Reference<XComponentContext> SAL_CALL defaultBootstrap_InitialComponentContext() SAL_THROW((Exception))
{
return defaultBootstrap_InitialComponentContext(OUString());
}
}
......@@ -5,9 +5,9 @@ eval 'exec perl -wS $0 ${1+"$@"}'
#
# $RCSfile: testdefaultbootstrapping.pl,v $
#
# $Revision: 1.2 $
# $Revision: 1.3 $
#
# last change: $Author: kr $ $Date: 2001-07-25 09:20:13 $
# last change: $Author: kr $ $Date: 2001-09-03 14:28:17 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
......@@ -214,6 +214,59 @@ sub testBeneathExe() {
}
}
sub testBeneathLib_rdb() {
my $_service = 'com.sun.star.script.Invocation';
use UNO;
my $_rdb_name;
if ($ENV{GUI} eq "WNT") {
$_rdb_name = "UNO" . "_services.rdb";
}
else {
$_rdb_name = "../lib/UNO" . "_services.rdb";
}
registerService($services{$_service}, $_rdb_name);
my $_rc = UNO::tryService($_service);
if (!$_rc) {
$comment = $comment. "beneath lib test not passed\n";
$state = 0;
}
unlink $_rdb_name;
}
sub testBeneathLib_rc() {
my $_service = 'com.sun.star.script.Invocation';
use UNO;
my $_rc_name;
if ($ENV{GUI} eq "WNT") {
$_rc_name = "UNO.ini";
}
else {
$_rc_name = "../lib/UNOrc";
}
my $_rdb_name = "../lib/test.rdb";
my $_handle;
open $_handle, ">" . $_rc_name;
print $_handle "UNO_SERVICES=" . $_rdb_name . "\n";
close $_handle;
registerService($services{$_service}, $_rdb_name);
my $_rc = UNO::tryService($_service);
if (!$_rc) {
$comment = $comment. "beneath lib rc test not passed\n";
$state = 0;
}
unlink $_rdb_name;
unlink $_rc_name;
}
sub testAllAvailable() {
# test that all services are reachable through different rdbs
......@@ -235,6 +288,8 @@ registerServices();
testIndirection();
testBeneathExe();
testBeneathLib_rc();
testBeneathLib_rdb();
testAllAvailable();
print "**************************\n";
......@@ -243,7 +298,7 @@ if($state) {
}
else {
print "**** tests NOT passed ****\n";
print "Commnent:", $comment, "\n";
print "Commnent:\n", $comment, "\n";
}
print "**************************\n";
......
package UNO;
require 5.005_62;
use strict;
use warnings;
require Exporter;
require DynaLoader;
our @ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use UNO ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.01';
bootstrap UNO $VERSION;
# Preloaded methods go here.
1;
__END__
# Below is stub documentation for your module. You better edit it!
=head1 NAME
UNO - Perl extension for blah blah blah
=head1 SYNOPSIS
use UNO;
blah blah blah
=head1 DESCRIPTION
Stub documentation for UNO, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.
Blah blah blah.
=head2 EXPORT
None by default.
=head1 AUTHOR
A. U. Thor, a.u.thor@a.galaxy.far.far.away
=head1 SEE ALSO
perl(1).
=cut
UDK_3_0_0 {
global:
boot_UNO;
local:
*;
};
/*************************************************************************
*
* $RCSfile: defbootstrap_lib.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: kr $ $Date: 2001-09-03 14:28:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <cstdio>
#include <osl/module.hxx>
#include <rtl/process.h>
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
using namespace ::cppu;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::rtl;
static sal_Bool tryService(const char * serviceName)
{
// use micro deployment to create initial context
OUString libraryFileUrl;
::osl::Module::getUrlFromAddress((void *)tryService, libraryFileUrl);
OUString iniName = libraryFileUrl.copy(0, libraryFileUrl.lastIndexOf((sal_Unicode)'.')); // cut the library extension
iniName += OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_CONFIGFILE(""))); // add the rc file extension
#ifdef DEBUG
OString sIniName = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "defbootstrap.cxx:tryService: using ini: %s\n", sIniName.getStr());
#endif
sal_Bool result = sal_True;
try {
Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(iniName);
Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY);
OUString arg = OUString::createFromAscii(serviceName);
Reference<XInterface> xInterface = smgr->createInstance(arg);
#ifdef DEBUG
fprintf(stderr, "got the %s service %p\n", serviceName, xInterface.get());
#endif
result = result && (xInterface.get() != 0);
}
catch(Exception & exception) {
OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US);
fprintf(stderr, "an exception occurred: %s\n", message.getStr());
}
#ifdef DEBUG
OSL_TRACE("---------------------------------- %i", result);
#endif
return result;
}
XS(XS_UNO_tryService)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: UNO::tryService(input)");
{
const char * input = (const char *)SvPV(ST(0),PL_na);
int RETVAL;
dXSTARG;
RETVAL = tryService(input);
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
extern "C" {
XS(boot_UNO)
{
dXSARGS;
char* file = __FILE__;
/* XS_VERSION_BOOTCHECK ;*/
newXS("UNO::tryService", XS_UNO_tryService, file);
XSRETURN_YES;
}
}
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: kr $ $Date: 2001-09-03 14:28:17 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=cppuhelper
TARGET=defbootstrap
NO_BSYMBOLIC=TRUE
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
.INCLUDE : use_perl.mk
# --- Files --------------------------------------------------------
#CFLAGS += -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC -I/develop6/update/dev/solenv/unxlngi3/lib/perl5/5.6.0/i686-linux/CORE/
#CFLAGS += -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -KPIC -I/develop6/update/dev/solenv/unxsols2/lib/perl5/5.6.0/sun4-solaris/CORE
SLOFILES= $(SLO)$/defbootstrap_lib.obj
SHL1TARGET=$(TARGET)
SHL1STDLIBS= \
$(PERLLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALLIB)
SHL1DEPN=
SHL1IMPLIB=i$(TARGET)
SHL1LIBS=$(SLB)$/$(TARGET).lib
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
SHL1VERSIONMAP=defbootstrap.map
.IF "$(GUI)"=="WNT"
UNODLL=$(DLLDEST)$/UNO.dll
.ELSE
UNODLL=$(DLLDEST)$/UNO.so
.ENDIF
# --- Targets ------------------------------------------------------
.IF "$(depend)" == ""
ALL: \
ALLTAR \
$(UNODLL) \
$(BIN)$/UNO.pm
.ENDIF
$(BIN)$/UNO.pm: UNO.pm
cp UNO.pm $@
$(UNODLL): $(SHL1TARGETN)
cp $(SHL1TARGETN) $@
.INCLUDE : target.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment