summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2006-03-31 04:29:47 +0000
committerBernard Normier <bernard@zeroc.com>2006-03-31 04:29:47 +0000
commit66a0681bdb76416f73c242d40c228ba61182ec2c (patch)
tree8cfd2ab1a6049e79e76ecc0fcc72bae322e7ef5c /cpp
parentfixing IceSSL properties (diff)
downloadice-66a0681bdb76416f73c242d40c228ba61182ec2c.tar.bz2
ice-66a0681bdb76416f73c242d40c228ba61182ec2c.tar.xz
ice-66a0681bdb76416f73c242d40c228ba61182ec2c.zip
Added --server option to icegridadmin
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/slice/IceGrid/FileParser.ice59
-rw-r--r--cpp/src/IceGrid/Client.cpp18
-rwxr-xr-xcpp/src/IceGrid/FileParserI.cpp30
-rwxr-xr-xcpp/src/IceGrid/FileParserI.h23
-rw-r--r--cpp/src/IceGrid/Makefile3
-rwxr-xr-xcpp/src/IceGrid/icegridadmin.dsp39
6 files changed, 171 insertions, 1 deletions
diff --git a/cpp/slice/IceGrid/FileParser.ice b/cpp/slice/IceGrid/FileParser.ice
new file mode 100755
index 00000000000..d4cfab57bc5
--- /dev/null
+++ b/cpp/slice/IceGrid/FileParser.ice
@@ -0,0 +1,59 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_GRID_FILE_PARSER_ICE
+#define ICE_GRID_FILE_PARSER_ICE
+
+#include <IceGrid/Admin.ice>
+
+module IceGrid
+{
+
+/**
+ *
+ * This exception is raised when a file-parsing fails
+ *
+ **/
+exception ParseException
+{
+ string reason;
+};
+
+/**
+ *
+ * icegridadmin provides a FileParser object to transform XML files
+ * into ApplicationDescriptor objects (structs).
+ *
+ **/
+
+interface FileParser
+{
+
+ /**
+ *
+ * Parse a file
+ *
+ * @param file Full pathname to the file.
+ *
+ * @param adminProxy An Admin proxy, used only to retrieve default templates when needed.
+ * May be null.
+ *
+ * @returns The application descriptor.
+ *
+ * @throws ParseException Raised if an error occured during parsing.
+ *
+ **/
+
+ idempotent ApplicationDescriptor parse(string xmlFile, Admin* adminProxy)
+ throws ParseException;
+};
+
+};
+
+#endif
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 4edd7b01536..ef613e541a1 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -12,6 +12,7 @@
#include <Ice/Application.h>
#include <Ice/SliceChecksums.h>
#include <IceGrid/Parser.h>
+#include <IceGrid/FileParserI.h>
#include <fstream>
using namespace std;
@@ -47,6 +48,7 @@ Client::usage()
"-IDIR Put DIR in the include file search path.\n"
"-e COMMANDS Execute COMMANDS.\n"
"-d, --debug Print debug messages.\n"
+ "-s, --server Start icegridadmin as a server (to parse XML files).\n"
;
}
@@ -65,6 +67,7 @@ Client::run(int argc, char* argv[])
opts.addOpt("I", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
opts.addOpt("e", "", IceUtil::Options::NeedArg, "", IceUtil::Options::Repeat);
opts.addOpt("d", "debug");
+ opts.addOpt("s", "server");
vector<string> args;
try
@@ -88,6 +91,21 @@ Client::run(int argc, char* argv[])
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
+
+ if(opts.isSet("s") || opts.isSet("server"))
+ {
+ ObjectAdapterPtr adapter =
+ communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
+ adapter->activate();
+ ObjectPrx proxy = adapter->
+ add(new FileParserI, Ice::stringToIdentity("FileParser"));
+ cout << proxy << endl;
+
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
+ }
+
+
if(opts.isSet("D"))
{
vector<string> optargs = opts.argVec("D");
diff --git a/cpp/src/IceGrid/FileParserI.cpp b/cpp/src/IceGrid/FileParserI.cpp
new file mode 100755
index 00000000000..a4284521449
--- /dev/null
+++ b/cpp/src/IceGrid/FileParserI.cpp
@@ -0,0 +1,30 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceGrid/FileParserI.h>
+#include <IceGrid/DescriptorParser.h>
+#include <IceXML/Parser.h>
+#include <Ice/ObjectAdapter.h>
+
+using namespace std;
+using namespace IceGrid;
+
+ApplicationDescriptor
+FileParserI::parse(const string& file, const AdminPrx& admin, const Ice::Current& current)
+{
+ try
+ {
+ return DescriptorParser::parseDescriptor(file, Ice::StringSeq(), map<string, string>(),
+ current.adapter->getCommunicator(), admin);
+ }
+ catch(const IceXML::ParserException& e)
+ {
+ throw ParseException(e.reason());
+ }
+}
diff --git a/cpp/src/IceGrid/FileParserI.h b/cpp/src/IceGrid/FileParserI.h
new file mode 100755
index 00000000000..1d81beeb7f1
--- /dev/null
+++ b/cpp/src/IceGrid/FileParserI.h
@@ -0,0 +1,23 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_GRID_FILE_PARSERI_H
+#define ICE_GRID_FILE_PARSERI_H
+
+#include <IceGrid/FileParser.h>
+
+class FileParserI : public IceGrid::FileParser
+{
+public:
+
+ IceGrid::ApplicationDescriptor
+ parse(const std::string& file, const IceGrid::AdminPrx& admin, const Ice::Current&);
+};
+
+#endif
diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile
index dd7a64f13cc..4d5b98fe6d5 100644
--- a/cpp/src/IceGrid/Makefile
+++ b/cpp/src/IceGrid/Makefile
@@ -32,6 +32,8 @@ ADMIN_OBJS = Grammar.o \
DescriptorParser.o \
DescriptorBuilder.o \
DescriptorHelper.o \
+ FileParser.o \
+ FileParserI.o \
Util.o \
Internal.o \
Client.o
@@ -89,6 +91,7 @@ SRCS = $(LIB_OBJS:.o=.cpp) \
SLICE_SRCS = $(SDIR)/Admin.ice \
$(SDIR)/Exception.ice \
+ $(SDIR)/FileParser.ice \
$(SDIR)/Query.ice \
$(SDIR)/Observer.ice \
$(SDIR)/Descriptor.ice \
diff --git a/cpp/src/IceGrid/icegridadmin.dsp b/cpp/src/IceGrid/icegridadmin.dsp
index 3a420560490..1a986e5da51 100755
--- a/cpp/src/IceGrid/icegridadmin.dsp
+++ b/cpp/src/IceGrid/icegridadmin.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /WX /GR /GX /O2 /I ".." /I "../../include" /I "dummyinclude" /D "_CONSOLE" /D "NDEBUG" /D "WIN32_LEAN_AND_MEAN" /FD /Zm200 /c
-# SUBTRACT CPP /Z<none> /Fr /YX
+# SUBTRACT CPP /Fr /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -127,6 +127,10 @@ SOURCE=.\DescriptorParser.cpp
# End Source File
# Begin Source File
+SOURCE=.\FileParser.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Grammar.cpp
# End Source File
# Begin Source File
@@ -147,6 +151,10 @@ SOURCE=.\Util.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=.\FileParser.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Grammar.h
# End Source File
# Begin Source File
@@ -159,6 +167,35 @@ SOURCE=.\Parser.h
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
+SOURCE=..\..\slice\IceGrid\FileParser.ice
+
+!IF "$(CFG)" == "icegridadmin - Win32 Release"
+
+USERDEP__FILEP="..\..\bin\slice2cpp.exe" "..\..\lib\slice.lib"
+# Begin Custom Build
+InputPath=..\..\slice\IceGrid\FileParser.ice
+
+"FileParser.h FileParser.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ..\..\bin\slice2cpp.exe --ice --include-dir IceGrid -I../../slice $(InputPath)
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "icegridadmin - Win32 Debug"
+
+USERDEP__FILEP="..\..\bin\slice2cpp.exe" "..\..\lib\sliced.lib"
+# Begin Custom Build
+InputPath=..\..\slice\IceGrid\FileParser.ice
+
+"FileParser.h FileParser.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ ..\..\bin\slice2cpp.exe --ice --include-dir IceGrid -I../../slice $(InputPath)
+
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\Grammar.y
!IF "$(CFG)" == "icegridadmin - Win32 Release"