Source Code Cross Referenced for JmsConfiguration.java in  » ESB » servicemix » org » apache » servicemix » jms » 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 » ESB » servicemix » org.apache.servicemix.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.servicemix.jms;
018:
019:        import java.io.File;
020:        import java.io.FileInputStream;
021:        import java.io.FileOutputStream;
022:        import java.io.IOException;
023:        import java.io.InputStream;
024:        import java.util.Properties;
025:
026:        import javax.jms.ConnectionFactory;
027:
028:        import org.apache.servicemix.jbi.security.auth.AuthenticationService;
029:        import org.apache.servicemix.jbi.security.keystore.KeystoreManager;
030:
031:        /**
032:         * @author gnodet
033:         * @org.apache.xbean.XBean element="configuration"
034:         */
035:        public class JmsConfiguration implements  JmsConfigurationMBean {
036:
037:            public static final String CONFIG_FILE = "component.properties";
038:
039:            private String rootDir;
040:            private String componentName = "servicemix-jms";
041:            private Properties properties = new Properties();
042:            private String userName;
043:            private String password;
044:            private String jndiInitialContextFactory;
045:            private String jndiProviderUrl;
046:            private String jndiConnectionFactoryName;
047:            private String processorName = "multiplexing";
048:            private transient ConnectionFactory connectionFactory;
049:            private transient KeystoreManager keystoreManager;
050:            private transient AuthenticationService authenticationService;
051:
052:            /**
053:             * The JNDI name of the AuthenticationService object
054:             */
055:            private String authenticationServiceName = "java:comp/env/smx/AuthenticationService";
056:
057:            /**
058:             * The JNDI name of the KeystoreManager object
059:             */
060:            private String keystoreManagerName = "java:comp/env/smx/KeystoreManager";
061:
062:            /**
063:             * @return Returns the rootDir.
064:             * @org.apache.xbean.Property hidden="true"
065:             */
066:            public String getRootDir() {
067:                return rootDir;
068:            }
069:
070:            /**
071:             * @param rootDir The rootDir to set.
072:             */
073:            public void setRootDir(String rootDir) {
074:                this .rootDir = rootDir;
075:            }
076:
077:            /**
078:             * @return Returns the componentName.
079:             * @org.apache.xbean.Property hidden="true"
080:             */
081:            public String getComponentName() {
082:                return componentName;
083:            }
084:
085:            /**
086:             * @param componentName The componentName to set.
087:             */
088:            public void setComponentName(String componentName) {
089:                this .componentName = componentName;
090:            }
091:
092:            /**
093:             * @return the authenticationService
094:             */
095:            public AuthenticationService getAuthenticationService() {
096:                return authenticationService;
097:            }
098:
099:            /**
100:             * @param authenticationService the authenticationService to set
101:             */
102:            public void setAuthenticationService(
103:                    AuthenticationService authenticationService) {
104:                this .authenticationService = authenticationService;
105:            }
106:
107:            /**
108:             * @return the authenticationServiceName
109:             */
110:            public String getAuthenticationServiceName() {
111:                return authenticationServiceName;
112:            }
113:
114:            /**
115:             * @param authenticationServiceName the authenticationServiceName to set
116:             */
117:            public void setAuthenticationServiceName(
118:                    String authenticationServiceName) {
119:                this .authenticationServiceName = authenticationServiceName;
120:            }
121:
122:            /**
123:             * @return the keystoreManager
124:             */
125:            public KeystoreManager getKeystoreManager() {
126:                return keystoreManager;
127:            }
128:
129:            /**
130:             * @param keystoreManager the keystoreManager to set
131:             */
132:            public void setKeystoreManager(KeystoreManager keystoreManager) {
133:                this .keystoreManager = keystoreManager;
134:            }
135:
136:            /**
137:             * @return the keystoreManagerName
138:             */
139:            public String getKeystoreManagerName() {
140:                return keystoreManagerName;
141:            }
142:
143:            /**
144:             * @param keystoreManagerName the keystoreManagerName to set
145:             */
146:            public void setKeystoreManagerName(String keystoreManagerName) {
147:                this .keystoreManagerName = keystoreManagerName;
148:                save();
149:            }
150:
151:            /**
152:             * @return Returns the password.
153:             */
154:            public String getPassword() {
155:                return password;
156:            }
157:
158:            /**
159:             * @param password The password to set.
160:             */
161:            public void setPassword(String password) {
162:                this .password = password;
163:                save();
164:            }
165:
166:            /**
167:             * @return Returns the userName.
168:             */
169:            public String getUserName() {
170:                return userName;
171:            }
172:
173:            /**
174:             * @param userName The userName to set.
175:             */
176:            public void setUserName(String userName) {
177:                this .userName = userName;
178:                save();
179:            }
180:
181:            /**
182:             * @return Returns the jndiName.
183:             */
184:            public String getJndiConnectionFactoryName() {
185:                return jndiConnectionFactoryName;
186:            }
187:
188:            /**
189:             * @param jndiName The jndiName to set.
190:             */
191:            public void setJndiConnectionFactoryName(String jndiName) {
192:                this .jndiConnectionFactoryName = jndiName;
193:                save();
194:            }
195:
196:            /**
197:             * @return Returns the jndiInitialContextFactory.
198:             */
199:            public String getJndiInitialContextFactory() {
200:                return jndiInitialContextFactory;
201:            }
202:
203:            /**
204:             * @param jndiInitialContextFactory The jndiInitialContextFactory to set.
205:             */
206:            public void setJndiInitialContextFactory(
207:                    String jndiInitialContextFactory) {
208:                this .jndiInitialContextFactory = jndiInitialContextFactory;
209:                save();
210:            }
211:
212:            /**
213:             * @return Returns the jndiProviderUrl.
214:             */
215:            public String getJndiProviderUrl() {
216:                return jndiProviderUrl;
217:            }
218:
219:            /**
220:             * @param jndiProviderUrl The jndiProviderUrl to set.
221:             */
222:            public void setJndiProviderUrl(String jndiProviderUrl) {
223:                this .jndiProviderUrl = jndiProviderUrl;
224:                save();
225:            }
226:
227:            /**
228:             * @return Returns the processorName.
229:             */
230:            public String getProcessorName() {
231:                return processorName;
232:            }
233:
234:            /**
235:             * @param processorName The processorName to set.
236:             */
237:            public void setProcessorName(String processorName) {
238:                this .processorName = processorName;
239:                save();
240:            }
241:
242:            /**
243:             * @return Returns the connectionFactory.
244:             */
245:            public ConnectionFactory getConnectionFactory() {
246:                return connectionFactory;
247:            }
248:
249:            /**
250:             * Default ConnectionFactory to use in a spring configuration.
251:             * @param connectionFactory the connectionFactory to set.
252:             */
253:            public void setConnectionFactory(ConnectionFactory connectionFactory) {
254:                this .connectionFactory = connectionFactory;
255:            }
256:
257:            public void save() {
258:                setProperty(componentName + ".userName", userName);
259:                setProperty(componentName + ".password", password);
260:                setProperty(componentName + ".jndiInitialContextFactory",
261:                        jndiInitialContextFactory);
262:                setProperty(componentName + ".jndiProviderUrl", jndiProviderUrl);
263:                setProperty(componentName + ".jndiName",
264:                        jndiConnectionFactoryName);
265:                setProperty(componentName + ".processorName", processorName);
266:                setProperty(componentName + ".keystoreManagerName",
267:                        keystoreManagerName);
268:                setProperty(componentName + ".authenticationServiceName",
269:                        authenticationServiceName);
270:                if (rootDir != null) {
271:                    File f = new File(rootDir, CONFIG_FILE);
272:                    try {
273:                        this .properties.store(new FileOutputStream(f), null);
274:                    } catch (Exception e) {
275:                        throw new RuntimeException(
276:                                "Could not store component configuration", e);
277:                    }
278:                }
279:            }
280:
281:            protected void setProperty(String name, String value) {
282:                if (value == null) {
283:                    properties.remove(name);
284:                } else {
285:                    properties.setProperty(name, value);
286:                }
287:            }
288:
289:            public boolean load() {
290:                File f = null;
291:                InputStream in = null;
292:                if (rootDir != null) {
293:                    // try to find the property file in the workspace folder
294:                    f = new File(rootDir, CONFIG_FILE);
295:                    if (!f.exists()) {
296:                        f = null;
297:                    }
298:                }
299:                if (f == null) {
300:                    // find property file in classpath if it is not available in workspace 
301:                    in = this .getClass().getClassLoader().getResourceAsStream(
302:                            CONFIG_FILE);
303:                    if (in == null) {
304:                        return false;
305:                    }
306:                }
307:
308:                try {
309:                    if (f != null) {
310:                        properties.load(new FileInputStream(f));
311:                    } else {
312:                        properties.load(in);
313:                    }
314:                } catch (IOException e) {
315:                    throw new RuntimeException(
316:                            "Could not load component configuration", e);
317:                }
318:                if (properties.getProperty(componentName + ".userName") != null) {
319:                    userName = properties.getProperty("userName");
320:                }
321:                if (properties.getProperty(componentName + ".password") != null) {
322:                    password = properties.getProperty("password");
323:                }
324:                if (properties.getProperty(componentName
325:                        + ".jndiInitialContextFactory") != null) {
326:                    jndiInitialContextFactory = properties
327:                            .getProperty("jndiInitialContextFactory");
328:                }
329:                if (properties.getProperty(componentName + ".jndiProviderUrl") != null) {
330:                    jndiProviderUrl = properties.getProperty("jndiProviderUrl");
331:                }
332:                if (properties.getProperty(componentName + ".jndiName") != null) {
333:                    jndiConnectionFactoryName = properties
334:                            .getProperty("jndiName");
335:                }
336:                if (properties.getProperty(componentName + ".processorName") != null) {
337:                    processorName = properties.getProperty("processorName");
338:                }
339:                if (properties.getProperty(componentName
340:                        + ".keystoreManagerName") != null) {
341:                    keystoreManagerName = properties
342:                            .getProperty("keystoreManagerName");
343:                }
344:                if (properties.getProperty(componentName
345:                        + ".authenticationServiceName") != null) {
346:                    authenticationServiceName = properties
347:                            .getProperty("authenticationServiceName");
348:                }
349:                return true;
350:            }
351:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.