001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.services.codegeneration.serviceproxygenerator.transactionmanagementproxy;
016:
017: import java.util.Properties;
018:
019: import javax.naming.Context;
020: import javax.naming.InitialContext;
021: import javax.naming.NamingException;
022:
023: import org.apache.commons.logging.Log;
024: import org.apache.commons.logging.LogFactory;
025:
026: import com.metaboss.enterprise.bs.BSException;
027: import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
028: import com.metaboss.sdlctools.services.codegeneration.BSGenericGenerator;
029: import com.metaboss.sdlctools.services.codegeneration.BSServiceProxyGenerator;
030: import com.metaboss.sdlctools.services.codegeneration.CodeGenerationStylesheetAccessor;
031: import com.metaboss.sdlctools.services.codegenerationstylesheet.STServiceStylesheet;
032: import com.metaboss.sdlctools.services.codegenerationstylesheet.STServicemoduleStylesheet;
033:
034: /** Generator of adapter offering access via simple strings */
035: public class BSServiceProxyGeneratorImpl implements
036: BSServiceProxyGenerator {
037: // Commons Logging instance.
038: private static final Log sLogger = LogFactory
039: .getLog(BSServiceProxyGeneratorImpl.class);
040:
041: public BSServiceProxyGeneratorImpl(java.util.Hashtable pEnvironment) {
042: }
043:
044: // Generates servicemodules distribution implementation sourcecode for the particular servicemodule within particular enterprise
045: public void generateSourceCodeForService(
046: String pGenerationDirectoryPath, String pServiceRef)
047: throws BSException {
048: try {
049: sLogger
050: .info("Generating generic transaction management proxy source for "
051: + pServiceRef + " service...");
052: // Get the generator and run the plan
053: Context ctx = new InitialContext();
054: BSGenericGenerator lGenerator = (BSGenericGenerator) ctx
055: .lookup(BSGenericGenerator.COMPONENT_URL);
056: lGenerator
057: .generateDirectoryAsPerPlanForMetaBossModelElement(
058: pGenerationDirectoryPath,
059: "implementation.enterprise.java.services.generatedproxy.transactionmanagement",
060: pServiceRef, new Properties());
061: // Done
062: sLogger
063: .info("Done generating generic transaction management proxy source for "
064: + pServiceRef + " service.");
065: } catch (NamingException e) {
066: throw new BSNamingAndDirectoryServiceInvocationException(e);
067: }
068: }
069:
070: // Generates service proxy implementation sourcecode for the particular whole servicemodule within particular enterprise
071: public void generateSourceCodeForServicemodule(
072: String pGenerationDirectoryPath, String pServicemoduleRef)
073: throws BSException {
074: try {
075: sLogger.info("Generating data validation proxy source for "
076: + pServicemoduleRef + " servicemodule...");
077: // Get the generator and run the plan
078: Context ctx = new InitialContext();
079: BSGenericGenerator lGenerator = (BSGenericGenerator) ctx
080: .lookup(BSGenericGenerator.COMPONENT_URL);
081: lGenerator
082: .generateDirectoryAsPerPlanForMetaBossModelElement(
083: pGenerationDirectoryPath,
084: "implementation.enterprise.java.services.generatedproxy.transactionmanagement",
085: pServicemoduleRef, new Properties());
086: // Done
087: sLogger
088: .info("Done generating data validation proxy source for "
089: + pServicemoduleRef + " servicemodule.");
090: } catch (NamingException e) {
091: throw new BSNamingAndDirectoryServiceInvocationException(e);
092: }
093: }
094:
095: /* Returns the name of the package where adapter code is generated to */
096: public String getPackageNameForService(String pServiceRef)
097: throws BSException {
098: // This is a standard proxy - so stylesheet dictates the package name
099: STServiceStylesheet lServiceStylesheet = CodeGenerationStylesheetAccessor
100: .getServiceStylesheet(pServiceRef);
101: return lServiceStylesheet.getGeneratedProxyBasePackageName()
102: + ".transactionmanagement";
103: }
104:
105: // Returns the name of the root package where proxy implementation code is generated to
106: public String getPackageNameForServicemodule(
107: String pServicemoduleRef) throws BSException {
108: // This is a standard proxy - so stylesheet dictates the package name
109: STServicemoduleStylesheet lServicemoduleStylesheet = CodeGenerationStylesheetAccessor
110: .getServicemoduleStylesheet(pServicemoduleRef);
111: return lServicemoduleStylesheet
112: .getGeneratedProxyRootPackageName()
113: + ".transactionmanagement";
114: }
115:
116: /* @return array of names of adapters, which are required by this adapter,
117: * may be zero length array if this adapter is not relying on any other one. */
118: public String[] getRequiredAdapters() throws BSException {
119: return new String[0]; // No other adapters are required by this one
120: }
121: }
|