Source Code Cross Referenced for SAPConfiguration.java in  » Portal » Open-Portal » com » sun » portal » sapportlet » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.sapportlet.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: SAPConfiguration.java,v 1.2 2005/08/12 07:38:22 nk137934 Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.sapportlet.config;
014:
015:        import java.util.ResourceBundle;
016:        import java.util.Enumeration;
017:        import java.util.MissingResourceException;
018:        import java.util.logging.Logger;
019:        import com.sun.portal.sapportlet.*;
020:
021:        /**
022:         * This class is used to read SAP related configuration data.
023:         * The config parameters are initilaized from a file called
024:         * "sapconfig.properties". This file needs to be present
025:         * in the classpath of any web application using this library.
026:         * It would typically be present in WEB-INF/classes directory.
027:         *
028:         * @author nk137934
029:         */
030:        public class SAPConfiguration implements  SAPPortletConstants {
031:
032:            private static ResourceBundle sapConfig = null;
033:            private static boolean initFailed = false;
034:            private static Logger logger = Logger.getLogger(LOGGER_NAMESPACE);
035:
036:            // Static initializer that reads the configuration file.
037:            // If read succeeds, initFailed is set to true.
038:            static {
039:                try {
040:                    sapConfig = ResourceBundle.getBundle(SAP_CONFIG_FILE_NAME);
041:                } catch (MissingResourceException mrExcp) {
042:                    logger.severe("Could not read the sap config file.");
043:                    logger.severe("Check if config file:"
044:                            + SAP_CONFIG_FILE_NAME + ".properties"
045:                            + " is present in Classpath ");
046:                    initFailed = true;
047:                }
048:
049:                logger.config("Start --- SAP Configuration Info ---");
050:                Enumeration allKeys = sapConfig.getKeys();
051:                while (allKeys.hasMoreElements()) {
052:                    String element = (String) allKeys.nextElement();
053:                    logger.severe(element + "=" + sapConfig.getString(element));
054:                }
055:                logger.config("End --- SAP Configuration Info ---");
056:
057:            }
058:
059:            /** Private Constructor */
060:            private SAPConfiguration() {
061:            }
062:
063:            /**
064:             * Returns the endpoint host name
065:             * @throws com.sun.portal.sapportlet.config.SAPConfigurationException On configuration error
066:             * @return Host name
067:             */
068:            public static String getEndpointHost()
069:                    throws SAPConfigurationException {
070:                checkConfig();
071:                return sapConfig.getString(CONFIG_ENDPOINT_HOST);
072:            }
073:
074:            /**
075:             * Return the endpoint port number
076:             * @throws com.sun.portal.sapportlet.config.SAPConfigurationException On configuration error
077:             * @return Endpoint port
078:             */
079:            public static String getEndpointPort()
080:                    throws SAPConfigurationException {
081:                checkConfig();
082:                return sapConfig.getString(CONFIG_ENDPOINT_PORT);
083:            }
084:
085:            /**
086:             * Returns the SAP client id
087:             * @throws com.sun.portal.sapportlet.config.SAPConfigurationException On configuration error
088:             * @return SAP client ID
089:             */
090:            public static String getClientID() throws SAPConfigurationException {
091:                checkConfig();
092:                return sapConfig.getString(CONFIG_CLIENTID);
093:            }
094:
095:            /**
096:             * Returns the endpoint address. This is constructed using the
097:             * endpoint hostname and the endpoint port
098:             * @throws com.sun.portal.sapportlet.config.SAPConfigurationException On configuration error
099:             * @return Endpoint address
100:             */
101:            public static String getEndpointAddress()
102:                    throws SAPConfigurationException {
103:
104:                String endHost = getEndpointHost();
105:                String endPort = getEndpointPort();
106:                String clientID = getClientID();
107:
108:                if (endHost == null || endPort == null) {
109:                    throw new SAPConfigurationException(
110:                            "Both endpointHost and "
111:                                    + "endpointPort need to be specified");
112:                }
113:
114:                if (clientID == null) {
115:                    clientID = "000";
116:                    logger.warning("sap.clientID not specified");
117:                    logger.warning("Default clientID 000 will be used");
118:                }
119:                return "http://" + endHost + ":" + endPort
120:                        + "/sap/bc/soap/rfc?sap-client=" + clientID;
121:
122:            }
123:
124:            /**
125:             * This method checks if the init has suceeded or not. If init
126:             * has failed and SAPConfiguration excpetion is thrown.
127:             * @throws SAPConfigurationException if init has failed.
128:             */
129:            private static void checkConfig() throws SAPConfigurationException {
130:                if (initFailed)
131:                    throw new SAPConfigurationException(
132:                            "Could not read config file:"
133:                                    + SAP_CONFIG_FILE_NAME);
134:
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.