You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/08/26 09:23:44 UTC

svn commit: r437107 - in /incubator/tuscany/cpp/sca: deploy/include/tuscany/sca/extension/ projects/tuscany_sca/ projects/tuscany_sca/tuscany_sca/ runtime/core/src/tuscany/sca/core/ runtime/core/src/tuscany/sca/extension/

Author: robbinspg
Date: Sat Aug 26 00:23:43 2006
New Revision: 437107

URL: http://svn.apache.org/viewvc?rev=437107&view=rev
Log:
First pass at extension loading

Added:
    incubator/tuscany/cpp/sca/deploy/include/tuscany/sca/extension/
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp   (with props)
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h   (with props)
Modified:
    incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb
    incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt
    incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h

Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb?rev=437107&r1=437106&r2=437107&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt?rev=437107&r1=437106&r2=437107&view=diff
==============================================================================
Binary files - no diff available.

Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp?rev=437107&r1=437106&r2=437107&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp (original)
+++ incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp Sat Aug 26 00:23:43 2006
@@ -57,7 +57,7 @@
 # ADD LINK32 axis2_engine.lib tuscany_sdo_axiom.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tuscany_sdo.lib axis2_parser.lib axis2_util.lib axiom.lib /nologo /dll /machine:I386 /libpath:"$(TUSCANY_SDOCPP)\lib" /libpath:"$(AXIS2C_HOME)\lib"
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
-PostBuild_Cmds=del ..\..\..\deploy\bin\tuscany_sca.*	del ..\..\..\deploy\lib\*.lib	copy ..\..\..\runtime\core\src\osoa\sca\*.h ..\..\..\deploy\include\osoa\sca	copy ..\..\..\runtime\core\src\tuscany\sca\core\*.h ..\..\..\deploy\include\tuscany\sca\core	copy ..\..\..\runtime\core\src\tuscany\sca\model\*.h ..\..\..\deploy\include\tuscany\sca\model	copy ..\..\..\runtime\core\src\tuscany\sca\util\*.h ..\..\..\deploy\include\tuscany\sca\util	copy ..\..\..\runtime\core\src\tuscany\sca\ws\*.h ..\..\..\deploy\include\tuscany\sca\ws	copy Release\tuscany_sca.dll ..\..\..\deploy\bin	copy Release\tuscany_sca.lib ..\..\..\deploy\lib	copy ..\..\..\xsd\*.* ..\..\..\deploy\xsd
+PostBuild_Cmds=del ..\..\..\deploy\bin\tuscany_sca.*	del ..\..\..\deploy\lib\*.lib	copy ..\..\..\runtime\core\src\osoa\sca\*.h ..\..\..\deploy\include\osoa\sca	copy ..\..\..\runtime\core\src\tuscany\sca\core\*.h ..\..\..\deploy\include\tuscany\sca\core	copy ..\..\..\runtime\core\src\tuscany\sca\model\*.h ..\..\..\deploy\include\tuscany\sca\model	copy ..\..\..\runtime\core\src\tuscany\sca\extension\*.h ..\..\..\deploy\include\tuscany\sca\extension	copy ..\..\..\runtime\core\src\tuscany\sca\util\*.h ..\..\..\deploy\include\tuscany\sca\util	copy ..\..\..\runtime\core\src\tuscany\sca\ws\*.h ..\..\..\deploy\include\tuscany\sca\ws	copy Release\tuscany_sca.dll ..\..\..\deploy\bin	copy Release\tuscany_sca.lib ..\..\..\deploy\lib	copy ..\..\..\xsd\*.* ..\..\..\deploy\xsd
 # End Special Build Tool
 
 !ELSEIF  "$(CFG)" == "tuscany_sca - Win32 Debug"
@@ -88,7 +88,7 @@
 # ADD LINK32 axis2_engine.lib tuscany_sdo_axiom.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tuscany_sdo.lib axis2_parser.lib axis2_util.lib axiom.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"$(TUSCANY_SDOCPP)\lib" /libpath:"$(AXIS2C_HOME)\lib"
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
-PostBuild_Cmds=del ..\..\..\deploy\bin\tuscany_sca.*	del ..\..\..\deploy\lib\*.lib	copy ..\..\..\runtime\core\src\osoa\sca\*.h ..\..\..\deploy\include\osoa\sca	copy ..\..\..\runtime\core\src\tuscany\sca\core\*.h ..\..\..\deploy\include\tuscany\sca\core	copy ..\..\..\runtime\core\src\tuscany\sca\model\*.h ..\..\..\deploy\include\tuscany\sca\model	copy ..\..\..\runtime\core\src\tuscany\sca\util\*.h ..\..\..\deploy\include\tuscany\sca\util	copy ..\..\..\runtime\core\src\tuscany\sca\ws\*.h ..\..\..\deploy\include\tuscany\sca\ws	copy Debug\tuscany_sca.dll ..\..\..\deploy\bin	copy Debug\tuscany_sca.pdb ..\..\..\deploy\bin	copy Debug\tuscany_sca.lib ..\..\..\deploy\lib	copy ..\..\..\xsd\*.* ..\..\..\deploy\xsd
+PostBuild_Cmds=del ..\..\..\deploy\bin\tuscany_sca.*	del ..\..\..\deploy\lib\*.lib	copy ..\..\..\runtime\core\src\osoa\sca\*.h ..\..\..\deploy\include\osoa\sca	copy ..\..\..\runtime\core\src\tuscany\sca\core\*.h ..\..\..\deploy\include\tuscany\sca\core	copy ..\..\..\runtime\core\src\tuscany\sca\model\*.h ..\..\..\deploy\include\tuscany\sca\model	copy ..\..\..\runtime\core\src\tuscany\sca\extension\*.h ..\..\..\deploy\include\tuscany\sca\extension	copy ..\..\..\runtime\core\src\tuscany\sca\util\*.h ..\..\..\deploy\include\tuscany\sca\util	copy ..\..\..\runtime\core\src\tuscany\sca\ws\*.h ..\..\..\deploy\include\tuscany\sca\ws	copy Debug\tuscany_sca.dll ..\..\..\deploy\bin	copy Debug\tuscany_sca.pdb ..\..\..\deploy\bin	copy Debug\tuscany_sca.lib ..\..\..\deploy\lib	copy ..\..\..\xsd\*.* ..\..\..\deploy\xsd
 # End Special Build Tool
 
 !ENDIF 
@@ -482,6 +482,18 @@
 # Begin Source File
 
 SOURCE=..\..\..\runtime\core\src\tuscany\sca\ws\WSServiceProxy.h
+# End Source File
+# End Group
+# Begin Group "extension"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\runtime\core\src\tuscany\sca\extension\ImplementationExtension.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\runtime\core\src\tuscany\sca\extension\ImplementationExtension.h
 # End Source File
 # End Group
 # End Group

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp?rev=437107&r1=437106&r2=437107&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp Sat Aug 26 00:23:43 2006
@@ -77,7 +77,7 @@
         // Constructor for the SCARuntime class. This will be a singleton that
         // holds all the information about the current runtime.
         // ===================================================================
-        SCARuntime::SCARuntime() : system(new System()), defaultComposite(0)
+        SCARuntime::SCARuntime() : system(0), defaultComposite(0)
         { 
             LOGENTRY(1, "SCARuntime::constructor");
             
@@ -95,6 +95,10 @@
                 SCARoot = root;
             }
             
+            // load extensions
+            loadExtensions();
+            loadImplementationExtensions();
+
             LOGEXIT(1, "SCARuntime::constructor");
         }
 
@@ -140,8 +144,6 @@
 
                     systemRoot = systemRootEnv;
                 }
-
-                instance->load(systemRoot);
             }
             
             LOGEXIT(1, "SCARuntime::getInstance");
@@ -172,25 +174,107 @@
         // ======================================
         // Load up all the details of the runtime
         // ======================================
-        void SCARuntime::load(const string& configurationRoot)
+        void SCARuntime::load()
         {
             LOGENTRY(1, "SCARuntime::load");
             
-            LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str());
+            LOGINFO_1(2,"configuration root: %s", systemRoot.c_str());
             
             ModelLoader loader(system);
             // Load details of the composite
-            loader.load(configurationRoot);
+            loader.load(systemRoot);
             
             LOGEXIT(1, "SCARuntime::load");
         }
         
         
+        // ======================================
+        // Load up extensions to the runtime
+        // ======================================
+        void SCARuntime::loadExtensions()
+        {
+            LOGENTRY(1, "SCARuntime::loadExtensions");
+
+            string extensionsRoot = SCARoot + "/extensions";
+
+#if defined(WIN32)  || defined (_WINDOWS)
+            string pattern = "*.dll";
+#else
+            string pattern = "*.so";
+#endif
+
+            Files files(extensionsRoot, pattern, false);
+            for (unsigned int i=0; i < files.size(); i++)
+            {
+                try
+                {
+                    extensionsList.push_back(Library(files[i].getFileName()));                    
+                }
+                catch (ServiceRuntimeException &)
+                {
+                    LOGERROR_1(0, "SCARuntime::loadExtensions failed to load extension library: %s", files[i].getFileName().c_str());
+                }
+            }
+            
+            LOGEXIT(1, "SCARuntime::loadExtensions");
+        }
+
+        // ======================================
+        // Find implemenation extension handlers 
+        // ======================================
+        void SCARuntime::loadImplementationExtensions()
+        {
+            LOGENTRY(1, "SCARuntime::loadImplementationExtensions");
+
+            
+            for (EXTENSIONS_LIST::iterator iter = extensionsList.begin();
+                 iter != extensionsList.end();
+                 iter++)
+            {
+                TUSCANY_IMPLEMENTATION_EXTENSION_FACTORY impl = 
+                    (TUSCANY_IMPLEMENTATION_EXTENSION_FACTORY)iter->getSymbol("tuscany_sca_extension_getImplementation");
+                if (impl)
+                {
+                    ImplementationExtension* extension = impl();
+                    if (extension)
+                    {
+                        registerImplementationExtension(*extension);
+                    }
+                }
+            }
+            
+            LOGEXIT(1, "SCARuntime::loadImplementationExtensions");
+        }
+        
+        // ======================================
+        // register an implementationExtension 
+        // ======================================
+        void SCARuntime::registerImplementationExtension(ImplementationExtension& extension)
+        {
+            LOGENTRY(1, "SCARuntime::registerImplementationExtension");
+            implementationExtensions[extension.getImplementationTypeQName()] = &extension;          
+            LOGEXIT(1, "SCARuntime::registerImplementationExtension");
+        }
+        
+        // ======================================
+        // find an implementationExtension 
+        // ======================================
+        ImplementationExtension* SCARuntime::getImplementationExtension(const string& extensionTypeQName)
+        {
+            return implementationExtensions[extensionTypeQName];
+        }
+        
+        
         // ===================================
         // Return the top of the runtime model
         // ===================================
         System* SCARuntime::getSystem()
         {
+            if (!system)
+            {
+                system = new System();
+                load();
+            }
             return system;
         }
 
@@ -315,7 +399,7 @@
                 // ---------------------------
                 // Subsystem must be specified
                 // ---------------------------
-                Subsystem* subsystem = system->findSubsystem(subsystemName);
+                Subsystem* subsystem = getSystem()->findSubsystem(subsystemName);
                 if (!subsystem)
                 {
                     message = "Default subsystem \'" + subsystemName + "\' not found";

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h?rev=437107&r1=437106&r2=437107&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h Sat Aug 26 00:23:43 2006
@@ -29,6 +29,9 @@
 #include "tuscany/sca/model/System.h"
 using namespace tuscany::sca::model;
 
+#include "tuscany/sca/extension/ImplementationExtension.h"
+#include "tuscany/sca/util/Library.h"
+
 #if defined(WIN32)  || defined (_WINDOWS)
 #include <windows.h>
 #else
@@ -38,6 +41,7 @@
 #include <stack>
 #include <string>
 #include <map>
+#include <list>
 using namespace std;
 
 namespace tuscany
@@ -62,6 +66,14 @@
             SCA_API static void releaseInstance();
           
             /**
+             * Load the SCA configuration from the scdl files (sca.composite, 
+             * *.fragment, etc).
+             * This will create the runtime model from which the SCA runtime
+             * will operate.
+             */
+            SCA_API void load();
+
+            /**
              * Set the system root
              * @param root The path to the deployed system.
              */
@@ -93,18 +105,18 @@
              * the System.
              * @return The configured SCA system.
              */
-            System* getSystem();
+            SCA_API System* getSystem();
 
             /**
              * The directory in which the Tuscany runtime has been installed.
              */
-            const string& getInstallRoot() {return SCARoot;}
+            SCA_API const string& getInstallRoot() {return SCARoot;}
 
             /**
              * Return the current component for this thread.
              * @return The current component for this thread.
              */
-            Component* getCurrentComponent();
+            SCA_API Component* getCurrentComponent();
 
             /**
              * Get the current composite. The current composite will either
@@ -113,7 +125,11 @@
              * component. There will not be a current component if a client of
              * the SCA runtime is making a call into the SCA runtime.
              */
-            Composite* getCurrentComposite();
+            SCA_API Composite* getCurrentComposite();
+
+            SCA_API void registerImplementationExtension(ImplementationExtension& extension);
+
+            SCA_API ImplementationExtension* getImplementationExtension(const string& typeQname);
 
         private:
             /**
@@ -124,17 +140,6 @@
             virtual ~SCARuntime();            
 
             /**
-             * Load the SCA configuration from the scdl files (sca.composite, 
-             * *.fragment, etc).
-             * This will create the runtime model from which the SCA runtime
-             * will operate.
-             * @param configurationRoot The path to the configuration of the 
-             * SCA runtime. Under this root will be the configuration and packages
-             * directories.
-             */
-            void load(const string& configurationRoot);
-
-            /**
              * The single instance of this class.
              */
             static SCARuntime* instance;
@@ -182,6 +187,18 @@
              * A map of threads to components.
              */
             COMPONENTS_MAP components;
+ 
+            typedef map<string, ImplementationExtension*> IMPLEMENTATIONS_MAP;
+
+            IMPLEMENTATIONS_MAP implementationExtensions;
+
+            // Runtime Extensions
+            void loadExtensions();
+            void loadImplementationExtensions();
+
+            typedef list<Library> EXTENSIONS_LIST;
+            EXTENSIONS_LIST extensionsList;
+
         };
 
         

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp?rev=437107&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp Sat Aug 26 00:23:43 2006
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+#include "tuscany/sca/util/Logging.h"
+namespace tuscany
+{
+    namespace sca
+    {
+        // ===================================================================
+        // Constructor for the ImplementationExtension class. 
+        // ===================================================================
+        ImplementationExtension::ImplementationExtension()
+        { 
+            LOGENTRY(1, "ImplementationExtension::constructor");        
+            LOGEXIT(1, "ImplementationExtension::constructor");
+        }
+
+        // ===================================================================
+        // Destructor for the ImplementationExtension class.
+        // ===================================================================
+        ImplementationExtension::~ImplementationExtension()
+        { 
+            LOGENTRY(1, "ImplementationExtension::destructor");;           
+            LOGEXIT(1, "ImplementationExtension::destructor");
+        }
+
+                
+    } // End namespace sca
+} // End namespace tuscany

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h?rev=437107&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h Sat Aug 26 00:23:43 2006
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef tuscany_sca_extension_implementationextension_h
+#define tuscany_sca_extension_implementationextension_h
+
+#include "osoa/sca/export.h"
+#include <string>
+using std::string;
+
+#include <tuscany/sca/model/Component.h>
+#include <tuscany/sca/model/Service.h>
+#include <tuscany/sca/core/ServiceWrapper.h>
+
+#include <commonj/sdo/SDO.h>
+
+namespace tuscany
+{
+    namespace sca
+    {
+        class SCA_API ImplementationExtension 
+        {
+        public:
+            /**
+            * Default constructor
+            */
+            ImplementationExtension();            
+            
+            /**
+            * Destructor
+            */
+            virtual ~ImplementationExtension();            
+                      
+            /**
+            * return the name of the extension (e.g. "cpp" "php")
+            */
+            virtual const string& getExtensionName() = 0;
+                      
+            /**
+            * return the QName of schema elemant for this implementation extension
+            * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+            */
+            virtual const string& getImplementationTypeQName() = 0;
+
+            virtual void loadModelElement(commonj::sdo::DataObjectPtr scdlImplementation, model::Component* component) = 0;
+
+            virtual ServiceWrapper* getServiceWrapper(model::Service* service) = 0;
+         };
+
+        
+    } // End namespace sca
+} // End namespace tuscany
+
+
+typedef tuscany::sca::ImplementationExtension* (* TUSCANY_IMPLEMENTATION_EXTENSION_FACTORY) ();
+
+#endif // tuscany_sca_extension_implementationextension_h
+

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org