summaryrefslogtreecommitdiffstats
path: root/cpp/sca/tools
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /cpp/sca/tools
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/sca/tools')
-rw-r--r--cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.cpp478
-rw-r--r--cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.h86
-rw-r--r--cpp/sca/tools/TuscanyDriver/build.xml73
-rw-r--r--cpp/sca/tools/TuscanyDriver/main.cpp181
-rw-r--r--cpp/sca/tools/ant_cpptasks/build.xml75
-rw-r--r--cpp/sca/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java224
-rw-r--r--cpp/sca/tools/build.xml105
7 files changed, 1222 insertions, 0 deletions
diff --git a/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.cpp b/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.cpp
new file mode 100644
index 0000000000..2abdc16c28
--- /dev/null
+++ b/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.cpp
@@ -0,0 +1,478 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <list>
+
+#include <tuscany/sca/core/SCARuntime.h>
+#include <tuscany/sca/core/Exceptions.h>
+
+#include <tuscany/sca/model/Composite.h>
+#include <tuscany/sca/model/CompositeReference.h>
+#include <tuscany/sca/model/CompositeService.h>
+#include <tuscany/sca/model/Component.h>
+#include <tuscany/sca/model/Binding.h>
+#include <tuscany/sca/model/Service.h>
+#include <tuscany/sca/model/ServiceType.h>
+#include <tuscany/sca/model/WSDLDefinition.h>
+#include <tuscany/sca/model/WSDLOperation.h>
+#include <tuscany/sca/model/WSDLMessagePart.h>
+
+#include <commonj/sdo/SDORuntimeException.h>
+
+#include "TuscanyServiceLoader.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace toys
+ {
+
+ TuscanyServiceLoader::TuscanyServiceLoader( const std::string &installRoot,
+ const std::string &systemRoot,
+ const std::string &systemPath,
+ const std::string &baseURI,
+ const std::string &defaultComponent,
+ bool showModel, // defaults false
+ bool showWsdl ) : // defaults false
+ tuscanyRuntime_(0),
+ tuscanyInstallRoot_(installRoot),
+ tuscanySystemRoot_(systemRoot),
+ tuscanySystemPath_(systemPath),
+ tuscanyBaseURI_(baseURI),
+ tuscanyDefaultComponent_(defaultComponent),
+ showModel_(showModel),
+ showWsdl_(showWsdl)
+ {
+ }
+
+ TuscanyServiceLoader::~TuscanyServiceLoader()
+ {
+ }
+
+ void TuscanyServiceLoader::load( )
+ {
+ try
+ {
+ tuscanyRuntime_ =
+ tuscany::sca::SCARuntime::initializeSharedRuntime(
+ tuscanyInstallRoot_,
+ tuscanySystemRoot_,
+ tuscanySystemPath_,
+ tuscanyBaseURI_,
+ tuscanyDefaultComponent_ );
+
+ tuscany::sca::model::Composite* systemComposite = tuscanyRuntime_->getSystem();
+
+ // The system composite shouldnt ever have WSDL namespaces defined on it,
+ // Its basically a container of included composites
+
+ //
+ // Iterate through the System included composites
+ //
+ std::list<std::string> compositeNameList = systemComposite->getIncludedComposites();
+
+ if( compositeNameList.empty() )
+ {
+ log( "The SCARuntime system composite has no included composites.", DATA_BOTH );
+ }
+
+ std::stringstream logMsg;
+
+ std::list<std::string>::const_iterator cNameIter = compositeNameList.begin();
+ std::list<std::string>::const_iterator cNameIterEnd = compositeNameList.end();
+
+ // Iterate through the Composites included in the System Composite
+ for( ; cNameIter != cNameIterEnd; ++cNameIter )
+ {
+ tuscany::sca::model::Composite *includedComposite =
+ systemComposite->findIncludedComposite( *cNameIter );
+
+ if( 0 == includedComposite )
+ {
+ logMsg << "Skipping NULL System Included composite: " << *cNameIter;
+ log( logMsg, DATA_BOTH );
+
+ continue;
+ }
+
+ logMsg << "System Included composite: " << includedComposite->getName();
+ log( logMsg, DATA_BOTH );
+
+ if( showWsdl_ )
+ {
+ log( "WSDL Data:", DATA_WSDL );
+ getOperationsFromComposite( includedComposite );
+ }
+
+ if( showModel_ )
+ {
+ log( "MODEL Data:", DATA_WSDL );
+ getComponentsFromComposite( includedComposite );
+ }
+
+ log( "\nServices loaded correctly.\n", DATA_BOTH );
+ }
+ }
+ catch (const tuscany::sca::TuscanyRuntimeException &tuscanyE)
+ {
+ std::cerr << "Tuscany Runtime Exception: " << tuscanyE.getMessageText() << std::endl;
+ }
+ catch (const commonj::sdo::SDORuntimeException &sdoE)
+ {
+ std::cerr << "SDO Runtime Exception: " << sdoE.getMessageText() << std::endl;
+ }
+ catch (const std::exception &stdE)
+ {
+ std::cerr << "Standard Exception: " << stdE.what() << std::endl;
+ }
+ }
+
+ // private
+ void TuscanyServiceLoader::getOperationsFromComposite( tuscany::sca::model::Composite *composite )
+ {
+ std::stringstream logMsg;
+
+ std::list<std::string> namespaceList = composite->getWSDLNamespaces();
+ if( namespaceList.empty() )
+ {
+ logMsg << "Composite has no WSDLs to process: " << composite->getName();
+ log( logMsg, DATA_WSDL );
+
+ return;
+ }
+
+ std::list<std::string>::const_iterator nsIter = namespaceList.begin();
+ std::list<std::string>::const_iterator nsIterEnd = namespaceList.end();
+
+ // Iterate through the composite namespaces
+ for( ; nsIter != nsIterEnd; ++nsIter )
+ {
+ tuscany::sca::model::WSDLDefinition *wsdlDef = composite->findWSDLDefinition( *nsIter );
+ if( 0 == wsdlDef )
+ {
+ logMsg << "Skipping NULL WSDLDefinition for WSDL namespace: " << *nsIter;
+ log( logMsg, DATA_WSDL );
+
+ continue;
+ }
+
+ logMsg << "\t WSDL namespace: " << *nsIter;
+ log( logMsg, DATA_WSDL );
+
+ std::list<std::string> ptNameList = wsdlDef->getPortTypes();
+ if( ptNameList.empty() )
+ {
+ log( "Skipping WSDLDefinition with no PortTypes defined", DATA_WSDL );
+
+ continue;
+ }
+
+ std::list<std::string>::const_iterator ptIter = ptNameList.begin();
+ std::list<std::string>::const_iterator ptIterEnd = ptNameList.end();
+
+ // Iterate through the PortTypes in the WSDLDefinition
+ for( ; ptIter != ptIterEnd; ++ptIter )
+ {
+ logMsg << "\t\t PortType: " << *ptIter;
+ log( logMsg, DATA_WSDL );
+
+ std::list<std::string> operNameList = wsdlDef->getOperations( *ptIter );
+ if( operNameList.empty() )
+ {
+ log( "Skipping WSDL PortType with no operations defined", DATA_WSDL );
+
+ continue;
+ }
+
+ std::list<std::string>::const_iterator operNameIter = operNameList.begin();
+ std::list<std::string>::const_iterator operNameIterEnd = operNameList.end();
+
+ // Iterate through the Operations in the PortType
+ for( ; operNameIter != operNameIterEnd; ++operNameIter )
+ {
+ const tuscany::sca::model::WSDLOperation &wsdlOper =
+ wsdlDef->findOperation( *ptIter, *operNameIter );
+
+ logMsg
+ << "\t\t\t Operation Info: "
+ << "\n\t\t\t\t OperationName: " << wsdlOper.getOperationName()
+ << "\n\t\t\t\t SOAP Action: " << wsdlOper.getSoapAction()
+ << "\n\t\t\t\t Endpoint: " << wsdlOper.getEndpoint()
+ << "\n\t\t\t\t SOAP version: " << wsdlOper.getSoapVersion()
+ << "\n\t\t\t\t Document Style: " << wsdlOper.isDocumentStyle()
+ << "\n\t\t\t\t Wrapped Style: " << wsdlOper.isWrappedStyle()
+ << "\n\t\t\t\t In Encoded Style: " << wsdlOper.isInputEncoded()
+ << "\n\t\t\t\t Out Encoded Style: " << wsdlOper.isOutputEncoded()
+ << "\n\t\t\t\t InputMsgURI: " << wsdlOper.getInputMessageUri()
+ << "\n\t\t\t\t InputMsgName: " << wsdlOper.getInputMessageName()
+ << "\n\t\t\t\t OutputMsgURI: " << wsdlOper.getOutputMessageUri()
+ << "\n\t\t\t\t OutputMsgName: " << wsdlOper.getOutputMessageName();
+ log( logMsg, DATA_WSDL );
+
+ std::list<std::string> partList = wsdlOper.getInputMessagePartNames();
+ std::list<std::string>::const_iterator partListIter = partList.begin();
+ std::list<std::string>::const_iterator partListIterEnd = partList.end();
+ for( ; partListIter != partListIterEnd; ++partListIter )
+ {
+ tuscany::sca::model::WSDLMessagePart part =
+ wsdlOper.getInputMessagePart( *partListIter );
+ logMsg
+ << "\t\t\t\t Input Message Part: "
+ << "\n\t\t\t\t\t Name: " << part.getPartName()
+ << "\n\t\t\t\t\t Type: " << part.getPartType()
+ << "\n\t\t\t\t\t URI: " << part.getPartUri();
+ log( logMsg, DATA_WSDL );
+ }
+
+ partList = wsdlOper.getOutputMessagePartNames();
+ partListIter = partList.begin();
+ partListIterEnd = partList.end();
+ for( ; partListIter != partListIterEnd; ++partListIter )
+ {
+ tuscany::sca::model::WSDLMessagePart part =
+ wsdlOper.getOutputMessagePart( *partListIter );
+ logMsg
+ << "\t\t\t\t Output Message Part: "
+ << "\n\t\t\t\t\t Name: " << part.getPartName()
+ << "\n\t\t\t\t\t Type: " << part.getPartType()
+ << "\n\t\t\t\t\t URI: " << part.getPartUri();
+ log( logMsg, DATA_WSDL );
+ }
+ }
+ }
+ }
+ }
+
+ // private
+ void TuscanyServiceLoader::getComponentsFromComposite( tuscany::sca::model::Composite *composite )
+ {
+ std::stringstream logMsg;
+
+ std::list<std::string> topLevelComponentList = composite->getComponents();
+ if( topLevelComponentList.empty() )
+ {
+ logMsg << "Top level Composite has no Components to process: " << composite->getName();
+ log( logMsg, DATA_MODEL );
+
+ return;
+ }
+
+ std::list<std::string>::const_iterator tlclIter = topLevelComponentList.begin();
+ std::list<std::string>::const_iterator tlclIterEnd = topLevelComponentList.end();
+
+ // Iterate through the top level composite components
+ for( ; tlclIter != tlclIterEnd; ++tlclIter )
+ {
+ tuscany::sca::model::Component *topLevelComponent = composite->findComponent( *tlclIter );
+ if( 0 == topLevelComponent )
+ {
+ logMsg << "Skipping NULL Component: " << *tlclIter;
+ log( logMsg, DATA_MODEL );
+
+ continue;
+ }
+
+ logMsg << "\t Top Level Component: " << topLevelComponent->getName();
+ log( logMsg, DATA_MODEL );
+
+ // Top level composites will just include lower composites
+ // Get the actual implementation composite
+ tuscany::sca::model::Composite *impComposite =
+ (tuscany::sca::model::Composite*)topLevelComponent->getType();
+ if( 0 == impComposite )
+ {
+ logMsg << "Couldn't get implemetation composite for top level component: " << *tlclIter;
+ log( logMsg, DATA_MODEL );
+
+ continue;
+ }
+
+ logMsg << "\t\t Implemetation Composite: " << topLevelComponent->getName();
+ log( logMsg, DATA_MODEL );
+
+ std::list<std::string> componentList = impComposite->getComponents();
+ if( componentList.empty() )
+ {
+ log( "\t\t Implemetation Composite has no components", DATA_MODEL );
+
+ continue;
+ }
+
+ std::list<std::string>::const_iterator clIter = componentList.begin();
+ std::list<std::string>::const_iterator clIterEnd = componentList.end();
+
+ // Iterate through the components
+ for( ; clIter != clIterEnd; ++clIter )
+ {
+
+ tuscany::sca::model::Component *component = impComposite->findComponent( *clIter );
+ if( 0 == component )
+ {
+ logMsg << "Skipping NULL Component: " << *clIter;
+ log( logMsg, DATA_MODEL );
+
+ continue;
+ }
+
+ std::string bindingType;
+ std::string bindingURI;
+ std::string componentType = "\t\t\t Component: ";
+
+ tuscany::sca::model::CompositeService *compositeService =
+ dynamic_cast<tuscany::sca::model::CompositeService*>(component);
+ if (compositeService)
+ {
+ componentType = "\t\t\t Service: ";
+ tuscany::sca::model::Reference *reference = compositeService->getReference();
+ bindingType = reference->getBinding()->getType();
+ bindingURI = reference->getBinding()->getURI();
+ }
+ else
+ {
+ tuscany::sca::model::CompositeReference *compositeReference =
+ dynamic_cast<tuscany::sca::model::CompositeReference*>(component);
+ if (compositeReference)
+ {
+ componentType = "\t\t\t Reference: ";
+ tuscany::sca::model::Service *service = compositeReference->getService();
+ bindingType = service->getBinding()->getType();
+ bindingURI = service->getBinding()->getURI();
+
+ }
+ }
+
+ logMsg << componentType << component->getName();
+ log( logMsg, DATA_MODEL );
+ logMsg << "\t\t\t\t Component Type: " << component->getType()->getName();
+ log( logMsg, DATA_MODEL );
+
+ if (!bindingType.empty())
+ {
+ logMsg << "\t\t\t\t Binding Type: " << bindingType;
+ log( logMsg, DATA_MODEL );
+ }
+ if (!bindingURI.empty())
+ {
+ logMsg << "\t\t\t\t Binding URI: " << bindingURI;
+ log( logMsg, DATA_MODEL );
+ }
+
+ const tuscany::sca::model::Component::SERVICE_MAP &serviceMap = component->getServices();
+ if( serviceMap.empty() )
+ {
+
+ continue;
+ }
+
+ tuscany::sca::model::Component::SERVICE_MAP::const_iterator smIter = serviceMap.begin();
+ tuscany::sca::model::Component::SERVICE_MAP::const_iterator smIterEnd = serviceMap.end();
+
+ for( ; smIter != smIterEnd; ++smIter )
+ {
+ const tuscany::sca::model::Service *service = smIter->second;
+
+ if( 0 == service )
+ {
+ logMsg << "Skipping NULL Service: " << smIter->second;
+ log( logMsg, DATA_MODEL );
+
+ continue;
+ }
+
+ // A ServiceType defines the characteristics of the Service
+ tuscany::sca::model::ServiceType *serviceType = service->getType();
+ logMsg << "\t\t\t\t Service: " << serviceType->getName();
+ log( logMsg, DATA_MODEL );
+ }
+
+ const tuscany::sca::model::Component::REFERENCE_MAP &referenceMap = component->getReferences();
+ if( referenceMap.empty() )
+ {
+ continue;
+ }
+
+ tuscany::sca::model::Component::REFERENCE_MAP::const_iterator rmIter = referenceMap.begin();
+ tuscany::sca::model::Component::REFERENCE_MAP::const_iterator rmIterEnd = referenceMap.end();
+
+ for( ; rmIter != rmIterEnd; ++rmIter )
+ {
+ const tuscany::sca::model::Reference *reference = rmIter->second;
+
+ if( 0 == reference )
+ {
+ logMsg << "Skipping NULL Reference: " << rmIter->second;
+ log( logMsg, DATA_MODEL );
+
+ continue;
+ }
+
+ // A ReferenceType defines the characteristics of the Service
+ logMsg << "\t\t\t\t Reference: " << reference->getType()->getName();
+ log( logMsg, DATA_MODEL );
+
+ }
+ }
+ }
+ }
+
+ // private
+ void TuscanyServiceLoader::log( std::stringstream &msg, TuscanyServiceLoader::DataType type )
+ {
+ log( msg.str(), type );
+ msg.str( "" ); // clear it to be able to use the same one again
+ }
+
+ // private
+ void TuscanyServiceLoader::log( const std::string &msg, TuscanyServiceLoader::DataType type )
+ {
+ bool doLog = false;
+
+ if( type == DATA_BOTH )
+ {
+ doLog = true;
+ }
+ else if( type == DATA_BOTH && (showModel_ || showWsdl_) )
+ {
+ doLog = true;
+ }
+ else if( type == DATA_WSDL && showWsdl_ )
+ {
+ doLog = true;
+ }
+ else if( type == DATA_MODEL && showModel_ )
+ {
+ doLog = true;
+ }
+
+ if( doLog )
+ {
+ std::cout << msg << std::endl;
+ }
+
+ }
+
+ } // namespace toys
+ } // namespace sca
+} // namespace tuscany
diff --git a/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.h b/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.h
new file mode 100644
index 0000000000..de35c38119
--- /dev/null
+++ b/cpp/sca/tools/TuscanyDriver/TuscanyServiceLoader.h
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_toys_service_loader_h
+#define tuscany_sca_toys_service_loader_h
+
+#include <string>
+#include <sstream>
+
+#include <tuscany/sca/core/SCARuntime.h>
+#include <tuscany/sca/model/Composite.h>
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace toys
+ {
+ class TuscanyServiceLoader
+ {
+ public:
+ TuscanyServiceLoader( const std::string &installRoot,
+ const std::string &systemRoot,
+ const std::string &systemPath,
+ const std::string &baseURI,
+ const std::string &defaultComponentName,
+ bool showModel = false,
+ bool showWsdl = false );
+
+ ~TuscanyServiceLoader();
+
+ void load();
+
+ private:
+ enum DataType
+ {
+ DATA_WSDL = 0,
+ DATA_MODEL,
+ DATA_BOTH
+ };
+
+ TuscanyServiceLoader();
+
+ void log( std::stringstream &msg, TuscanyServiceLoader::DataType type );
+ void log( const std::string &msg, TuscanyServiceLoader::DataType type );
+ void getOperationsFromComposite( tuscany::sca::model::Composite *composite );
+ void getComponentsFromComposite( tuscany::sca::model::Composite *composite );
+
+ tuscany::sca::SCARuntime *tuscanyRuntime_;
+
+ bool showModel_;
+ bool showWsdl_;
+ std::string tuscanyInstallRoot_;
+ std::string tuscanySystemRoot_;
+ std::string tuscanySystemPath_;
+ std::string tuscanyBaseURI_;
+ std::string tuscanyDefaultComponent_;
+ };
+
+ } // namespace toys
+
+ } // namespace sca
+
+} // namespace tuscany
+
+#endif // tuscany_sca_toys_service_loader_h
+
diff --git a/cpp/sca/tools/TuscanyDriver/build.xml b/cpp/sca/tools/TuscanyDriver/build.xml
new file mode 100644
index 0000000000..9ccdb2b833
--- /dev/null
+++ b/cpp/sca/tools/TuscanyDriver/build.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project name="tuscanyDriver" default="all" basedir="../..">
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+ <property name="tuscanyServiceLoader.app" value="tuscanyServiceLoader"/>
+ <property name="tuscanyServiceLoader.files" value="TuscanyServiceLoader.cpp CommandLineProcessor.cpp main.cpp"/>
+ <property name="this.dir" location="${basedir}/tools/TuscanyDriver"/>
+ <property name="bin.dir" location="${this.dir}/bin"/>
+ <property name="install.dir" location="${tuscanySCA.install.dir}/bin"/>
+
+ <!--
+ Public targets
+ -->
+ <target name="all" description="Compile, Link, and Install the TuscanyServiceLoader">
+ <antcall target="build"/>
+ <antcall target="install"/>
+ </target>
+
+ <target name="clean" description="Remove the TuscanyServiceLoader installation">
+ <sequential>
+ <delete dir="${bin.dir}"/>
+ <delete file="${install.dir}/${tuscanyServiceLoader.app}${exe.ext}"/>
+ </sequential>
+ </target>
+
+ <!--
+ Internal targets
+ -->
+ <target name="build">
+ <sequential>
+ <cpp-build
+ srcdir="${this.dir}"
+ infiles="${tuscanyServiceLoader.files}"
+ outdir="${bin.dir}"
+ outfile="${tuscanyServiceLoader.app}"
+ outtype="executable">
+ <custom-build-elements>
+ <libset dir="${tuscanySCA.install.dir}/lib" libs="tuscany_sca"/>
+ <syslibset if="unix" libs="dl"/>
+ </custom-build-elements>
+ </cpp-build>
+ </sequential>
+ </target>
+
+ <target name="install">
+ <cpp-install-file
+ srcfile="${tuscanyServiceLoader.app}${exe.ext}"
+ srcdir="${bin.dir}"
+ destdir="${install.dir}"/>
+ </target>
+
+</project>
diff --git a/cpp/sca/tools/TuscanyDriver/main.cpp b/cpp/sca/tools/TuscanyDriver/main.cpp
new file mode 100644
index 0000000000..7fdde27177
--- /dev/null
+++ b/cpp/sca/tools/TuscanyDriver/main.cpp
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+#include <string>
+
+#include <tuscany/sca/core/Exceptions.h>
+#include <commonj/sdo/SDORuntimeException.h>
+
+#include "TuscanyServiceLoader.h"
+
+struct InputArgs
+{
+ std::string installRoot_;
+ std::string systemRoot_;
+ std::string systemPath_;
+ std::string baseURI_;
+ std::string defaultComponentName_;
+ bool showWsdl_;
+ bool showModel_;
+
+ InputArgs() :
+ showWsdl_(false),
+ showModel_(false)
+ {}
+};
+
+const std::string ARG_INSTALL_ROOT = "-ir";
+const std::string ARG_SYSTEM_ROOT = "-sr";
+const std::string ARG_SYSTEM_PATH = "-sp";
+const std::string ARG_BASE_URI = "-uri";
+const std::string ARG_DEFAULT_COMPONENT = "-dc";
+const std::string ARG_VERBOSE = "-v";
+const std::string ARG_SHOW_MODEL = "-model";
+const std::string ARG_SHOW_WSDL = "-wsdl";
+const std::string ARG_HELP_H = "-h";
+const std::string ARG_HELP_HELP = "-help";
+const std::string ARG_HELP_QMARK = "-?";
+
+
+void
+printUsage()
+{
+ std::cout
+ << "\nUsage\ntuscanyDriver\n\t"
+ << ARG_INSTALL_ROOT << " Mandatory: Installation root where extensions are located: ${TUSCANY_SCACPP}\n\t"
+ << ARG_SYSTEM_ROOT << " Mandatory: System root where projects are located: ${TUSCANY_SCACPP}/samples\n\t"
+ << ARG_SYSTEM_PATH << " Optional: System path\n\t"
+ << ARG_BASE_URI << " Optional: Base URI\n\t"
+ << ARG_DEFAULT_COMPONENT << " Optional: Default Component name\n\t"
+ << ARG_SHOW_MODEL << " Optional: Display SCA Model Hierarchy\n\t"
+ << ARG_SHOW_WSDL << " Optional: Display WSDL information\n\t"
+ << ARG_VERBOSE << " Optional: Same as specifying both: "
+ << ARG_SHOW_MODEL << " and " << ARG_SHOW_WSDL
+ << std::endl;
+}
+
+bool
+parseArgs( int argc, char *argv[], InputArgs &input )
+{
+ if( argc < 5 )
+ {
+ std::cerr << "\nInvalid number of input arguments: " << argc << std::endl;
+ printUsage();
+ return false;
+ }
+
+ for( int i = 1; i < argc; i++ )
+ {
+ if( argv[i] == ARG_INSTALL_ROOT )
+ {
+ input.installRoot_ = argv[++i];
+ }
+ else if( argv[i] == ARG_SYSTEM_ROOT )
+ {
+ input.systemRoot_ = argv[++i];
+ }
+ else if( argv[i] == ARG_SYSTEM_PATH )
+ {
+ input.systemPath_ = argv[++i];
+ }
+ else if( argv[i] == ARG_BASE_URI )
+ {
+ input.baseURI_ = argv[++i];
+ }
+ else if( argv[i] == ARG_DEFAULT_COMPONENT )
+ {
+ input.defaultComponentName_ = argv[++i];
+ }
+ else if( argv[i] == ARG_VERBOSE )
+ {
+ input.showWsdl_ = true;
+ input.showModel_ = true;
+ }
+ else if( argv[i] == ARG_SHOW_MODEL )
+ {
+ input.showModel_ = true;
+ }
+ else if( argv[i] == ARG_SHOW_WSDL )
+ {
+ input.showWsdl_ = true;
+ }
+ else if( argv[i] == ARG_HELP_H ||
+ argv[i] == ARG_HELP_QMARK ||
+ argv[i] == ARG_HELP_HELP )
+ {
+ printUsage();
+ return false;
+ }
+ else
+ {
+ std::cerr << "\nUnrecognized argument: " << argv[i];
+ printUsage();
+ return false;
+ }
+ }
+
+ if( input.installRoot_.empty() )
+ {
+ std::cerr << "\nMissing mandatory argument: Install root " << ARG_INSTALL_ROOT << std::endl;
+ return false;
+ }
+
+ if( input.systemRoot_.empty() )
+ {
+ std::cerr << "\nMissing mandatory argument: System root " << ARG_SYSTEM_ROOT << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int
+main(int argc, char* argv[])
+{
+ try
+ {
+ InputArgs input;
+ if( ! parseArgs( argc, argv, input ) )
+ {
+ return 1;
+ }
+
+ tuscany::sca::toys::TuscanyServiceLoader
+ tuscany( input.installRoot_,
+ input.systemRoot_,
+ input.systemPath_,
+ input.baseURI_,
+ input.defaultComponentName_,
+ input.showModel_,
+ input.showWsdl_ );
+
+ tuscany.load( );
+ }
+ catch (...)
+ {
+ std::cerr << "Caught unknown exception." << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
+
diff --git a/cpp/sca/tools/ant_cpptasks/build.xml b/cpp/sca/tools/ant_cpptasks/build.xml
new file mode 100644
index 0000000000..69d85ecca2
--- /dev/null
+++ b/cpp/sca/tools/ant_cpptasks/build.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+
+<project name="org.apache.tuscany.sca.cpp.antCompilers" default="all" basedir="../..">
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+ <target name="init">
+ <tstamp/>
+ <property name="this.dir" location="${basedir}/tools/ant_cpptasks"/>
+ <property name="build.dir" location="${this.dir}/build" />
+ <property name="java.src.dir" location="${this.dir}/tuscanyAntCompilers" />
+ <property name="install.dir" location="${basedir}/antscripts" />
+ <property name="class.name" value="TuscanyMSVC8DevStudioCCompiler" />
+ </target>
+
+ <target name="all" depends="init,build,install"/>
+
+ <target name="build" depends="init" description="Build tuscany ant msvc 8.0 compiler task">
+ <mkdir dir="${build.dir}" />
+
+ <!-- compile the source code -->
+ <javac srcdir="${java.src.dir}"
+ destdir="${build.dir}"
+ failonerror="true"
+ includeAntRuntime="no">
+ <classpath>
+ <pathelement path="${env.ANT_HOME}/lib/cpptasks.jar"/>
+ <pathelement path="${env.ANT_HOME}/lib/ant.jar"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="make.jar" depends="init,build">
+ <jar jarfile="${build.dir}/${class.name}.jar"
+ basedir="${build.dir}"
+ includes="tuscany/antCompilers/${class.name}.class">
+ <manifest>
+ <attribute name="Main-Class" value="tuscany.antCompilers.${class.name}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="install" depends="init,make.jar">
+ <mkdir dir="${install.dir}"/>
+ <copy todir="${install.dir}" overwrite='true'>
+ <fileset dir="${build.dir}" includes="${class.name}.jar"/>
+ </copy>
+ </target>
+
+ <target name="clean" depends="init" description="Clean of all the files created.">
+ <delete dir="${build.dir}" quiet="true"/>
+ <delete file="${install.dir}/${class.name}.jar" quiet="true"/>
+ </target>
+
+</project>
diff --git a/cpp/sca/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java b/cpp/sca/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java
new file mode 100644
index 0000000000..981592a2a2
--- /dev/null
+++ b/cpp/sca/tools/ant_cpptasks/tuscanyAntCompilers/TuscanyMSVC8DevStudioCCompiler.java
@@ -0,0 +1,224 @@
+/*
+ * 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.
+ */
+
+package tuscany.antCompilers;
+
+import java.io.File;
+import java.util.Vector;
+
+import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.OptimizationEnum;
+
+import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;
+import net.sf.antcontrib.cpptasks.compiler.Linker;
+import net.sf.antcontrib.cpptasks.compiler.LinkType;
+import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;
+import net.sf.antcontrib.cpptasks.compiler.Processor;
+
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioProcessor;
+import net.sf.antcontrib.cpptasks.devstudio.DevStudioLinker;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Environment;
+
+
+/**
+ * An abstract base class for compilers that are basically command line
+ * compatible with Microsoft(r) C/C++ Optimizing Compiler
+ *
+ * This class was taken from cpptasks. Its a combination of the following 2 classes:
+ * net.sf.antcontrib.cpptasks.devstudio.DevStudioCompatibleCCompiler
+ * net.sf.antcontrib.cpptasks.devstudio.DevStudioCCompiler
+ *
+ * To compile MSVC8.0 in debug mode, the cpptasks msvc compiler doesnt distinguish
+ * between msvc 7.1 and 8.0 and seems to actually be 7.1 centric. This implementation
+ * For the Apache Tuscany project tries to address those issues.
+ */
+
+public final class TuscanyMSVC8DevStudioCCompiler
+ extends PrecompilingCommandLineCCompiler
+{
+ private static String[] mflags_ =
+ new String[] {"/ML", "/MLd", null, null, "/MT", "/MTd", "/MD", "/MDd"};
+ // first four are single-threaded
+ // (runtime=static,debug=false), (..,debug=true),
+ // (runtime=dynamic,debug=true), (..,debug=false), (not supported)
+ // next four are multi-threaded, same sequence
+
+ // Indeces into the mflags_ array
+ private static int MINDEX_DEBUG = 1;
+ private static int MINDEX_STATIC_RUNTIME = 2;
+ private static int MINDEX_MULTI_THREADED = 4;
+
+ private static final TuscanyMSVC8DevStudioCCompiler instance_ =
+ new TuscanyMSVC8DevStudioCCompiler( "cl", false, null);
+
+ public static TuscanyMSVC8DevStudioCCompiler getInstance()
+ {
+ return instance_;
+ }
+
+ private TuscanyMSVC8DevStudioCCompiler(
+ String command,
+ boolean newEnvironment,
+ Environment env)
+ {
+ super(command,
+ "/bogus",
+ new String[]{".c", ".cc", ".cpp", ".cxx", ".c++"},
+ new String[]{".h", ".hpp", ".inl"},
+ ".obj",
+ false,
+ null,
+ newEnvironment,
+ env);
+ }
+
+ public Processor changeEnvironment(boolean newEnvironment, Environment env)
+ {
+ if (newEnvironment || env != null) {
+ return new TuscanyMSVC8DevStudioCCompiler(getCommand(), newEnvironment, env);
+ }
+ return this;
+ }
+
+ public Linker getLinker(LinkType type)
+ {
+ return DevStudioLinker.getInstance().getLinker(type);
+ }
+
+ public int getMaximumCommandLength()
+ {
+ return 32767;
+ }
+
+ protected void addImpliedArgs(
+ final Vector args,
+ final boolean debug,
+ final boolean multithreaded,
+ final boolean exceptions,
+ final LinkType linkType,
+ final Boolean rtti,
+ final OptimizationEnum optimization)
+ {
+ args.addElement("/c");
+ args.addElement("/nologo");
+ if (exceptions) {
+ // changed to eliminate warning on VC 2005, should support VC 6 and later
+ // use /GX to support VC5 - 2005 (with warning)
+ args.addElement("/EHsc");
+ }
+ int mindex = 0;
+ if (multithreaded) {
+ mindex += MINDEX_MULTI_THREADED;
+ }
+ boolean staticRuntime = linkType.isStaticRuntime();
+ if (!staticRuntime) {
+ mindex += MINDEX_STATIC_RUNTIME;
+ }
+
+ if (debug) {
+ mindex += MINDEX_DEBUG;
+ args.addElement("/Zi"); // Generates complete debugging information
+ args.addElement("/Od"); // Disables optimization
+ args.addElement("/RTC1"); // Enables run-time error checking as opposed to depracated /GZ
+ args.addElement("/Gd"); // Uses the __cdecl calling convention (x86 only)
+ args.addElement("/D_DEBUG"); // Debug mode
+ } else {
+ args.addElement("/DNDEBUG");
+ if (optimization != null) {
+ if (optimization.isSize()) {
+ args.addElement("/O1");
+ }
+
+ if (optimization.isSpeed()) {
+ args.addElement("/O2");
+ }
+ }
+ }
+
+ String mflag = mflags_[mindex];
+ if (mflag == null) {
+ throw new BuildException(
+ "multithread='false' and runtime='dynamic' not supported");
+ }
+ args.addElement(mflag);
+ if (rtti != null && rtti.booleanValue()) {
+ args.addElement("/GR");
+ }
+ }
+
+ protected void addWarningSwitch(Vector args, int level)
+ {
+ DevStudioProcessor.addWarningSwitch(args, level);
+ }
+
+ protected CompilerConfiguration createPrecompileGeneratingConfig(
+ CommandLineCompilerConfiguration baseConfig,
+ File prototype,
+ String lastInclude)
+ {
+ String[] additionalArgs = new String[]{
+ "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yc"};
+ return new
+ CommandLineCompilerConfiguration(
+ baseConfig,
+ additionalArgs,
+ null,
+ true);
+ }
+
+ protected CompilerConfiguration createPrecompileUsingConfig(
+ CommandLineCompilerConfiguration baseConfig,
+ File prototype,
+ String lastInclude,
+ String[] exceptFiles)
+ {
+ String[] additionalArgs = new String[]{
+ "/Fp" + CUtil.getBasename(prototype) + ".pch",
+ "/Yu" + lastInclude};
+ return new
+ CommandLineCompilerConfiguration(
+ baseConfig,
+ additionalArgs,
+ exceptFiles,
+ false);
+ }
+
+ protected void getDefineSwitch(StringBuffer buffer, String define, String value)
+ {
+ DevStudioProcessor.getDefineSwitch(buffer, define, value);
+ }
+
+ protected File[] getEnvironmentIncludePath()
+ {
+ return CUtil.getPathFromEnvironment("INCLUDE", ";");
+ }
+
+ protected String getIncludeDirSwitch(String includeDir)
+ {
+ return DevStudioProcessor.getIncludeDirSwitch(includeDir);
+ }
+
+ protected void getUndefineSwitch(StringBuffer buffer, String define)
+ {
+ DevStudioProcessor.getUndefineSwitch(buffer, define);
+ }
+}
diff --git a/cpp/sca/tools/build.xml b/cpp/sca/tools/build.xml
new file mode 100644
index 0000000000..1e5b496c94
--- /dev/null
+++ b/cpp/sca/tools/build.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project name="TuscanyScaNative_tools" default="all" basedir="..">
+
+ <!--
+ This is the root level ant build.xml file for TuscanySCA Native tools
+ Nothing is actually performed here, it just delegates to subdirectory
+ build.xml files.
+ -->
+
+ <import file="${basedir}/antscripts/system.xml"/>
+ <import file="${basedir}/antscripts/compile-targets.xml"/>
+
+ <!--
+ Notice that the basedir for this project is set to the TuscanySCA root dir
+ This makes path setting in system.xml much simpler, but we'll just have to
+ set a property here to this directory.
+ -->
+
+ <property name="this.dir" location="${basedir}/tools"/>
+ <property name="TuscanyDriver.dir" location="${this.dir}/TuscanyDriver"/>
+ <property name="ant_cpptasks.dir" location="${this.dir}/ant_cpptasks"/>
+
+ <!--
+ Public targets
+ -->
+
+ <target name="all" description="Build and install all TuscanyScaNative tools">
+ <antcall target="build"/>
+ <antcall target="install"/>
+ </target>
+
+ <!--
+ Notice the ant_cpptasks tool is not included in the "all" target.
+ This is because its not something that should be built that often.
+ The resulting jar is included in TUSCANY_SCA_SRC_ROOT/antscripts svn
+ -->
+
+ <target name="build" description="Build all TuscanyScaNative tools">
+ <antcall target="build.TuscanyDriver"/>
+ </target>
+
+ <target name="install" description="Install TuscanyScaNative tools">
+ <antcall target="install.TuscanyDriver"/>
+ </target>
+
+ <target name="clean" description="Clean all TuscanyScaNative tools">
+ <antcall target="clean.TuscanyDriver"/>
+ </target>
+
+ <!--
+ Internal targets
+ They can still be called, they're just not described, so wont show up in "ant -p"
+ Using antfile and inheritAll="false" to maintain the subdir build.xml basedir settings
+ -->
+
+ <!-- build -->
+
+ <target name="build.ant_cpptasks">
+ <ant target="build" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <target name="build.TuscanyDriver">
+ <ant target="build" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <!-- install -->
+
+ <target name="install.ant_cpptasks">
+ <ant target="install" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <target name="install.TuscanyDriver">
+ <ant target="install" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <!-- clean -->
+
+ <target name="clean.ant_cpptasks">
+ <ant target="clean" antfile="${ant_cpptasks.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+ <target name="clean.TuscanyDriver">
+ <ant target="clean" antfile="${TuscanyDriver.dir}/build.xml" inheritAll="false"/>
+ </target>
+
+</project>