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.cxfbc;
018
019 import java.io.File;
020 import java.io.FileInputStream;
021 import java.io.IOException;
022 import java.io.InputStream;
023 import java.util.Properties;
024
025 public class CxfBcConfiguration {
026
027 public static final String CONFIG_FILE = "component.properties";
028
029 private String rootDir;
030 private String componentName = "servicemix-cxf-bc";
031 private Properties properties = new Properties();
032 private String busCfg;
033
034 private transient Object authenticationService;
035
036 /**
037 * The JNDI name of the AuthenticationService object
038 */
039 private String authenticationServiceName = "java:comp/env/smx/AuthenticationService";
040
041
042 /**
043 * @return the authenticationService
044 */
045 public Object getAuthenticationService() {
046 return authenticationService;
047 }
048
049 /**
050 * @param authenticationService the authenticationService to set
051 */
052 public void setAuthenticationService(Object authenticationService) {
053 this.authenticationService = authenticationService;
054 }
055
056 /**
057 * @return the authenticationServiceName
058 */
059 public String getAuthenticationServiceName() {
060 return authenticationServiceName;
061 }
062
063 /**
064 * @param authenticationServiceName the authenticationServiceName to set
065 */
066 public void setAuthenticationServiceName(String authenticationServiceName) {
067 this.authenticationServiceName = authenticationServiceName;
068 }
069
070 public boolean load() {
071 File f = null;
072 InputStream in = null;
073 if (rootDir != null) {
074 // try to find the property file in the workspace folder
075 f = new File(rootDir, CONFIG_FILE);
076 if (!f.exists()) {
077 f = null;
078 }
079 }
080 if (f == null) {
081 // find property file in classpath if it is not available in workspace
082 in = this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE);
083 if (in == null) {
084 return false;
085 }
086 }
087
088 try {
089 if (f != null) {
090 properties.load(new FileInputStream(f));
091 } else {
092 properties.load(in);
093 }
094 } catch (IOException e) {
095 throw new RuntimeException("Could not load component configuration", e);
096 }
097 if (properties.getProperty(componentName + ".busCfg") != null) {
098 setBusCfg(properties.getProperty(componentName + ".busCfg"));
099 }
100
101 return true;
102 }
103
104 /**
105 * @return Returns the rootDir.
106 * @org.apache.xbean.Property hidden="true"
107 */
108 public String getRootDir() {
109 return rootDir;
110 }
111
112 /**
113 * @param rootDir The rootDir to set.
114 */
115 public void setRootDir(String rootDir) {
116 this.rootDir = rootDir;
117 }
118
119 /**
120 * @return Returns the componentName.
121 * @org.apache.xbean.Property hidden="true"
122 */
123 public String getComponentName() {
124 return componentName;
125 }
126
127 /**
128 * @param componentName The componentName to set.
129 */
130 public void setComponentName(String componentName) {
131 this.componentName = componentName;
132 }
133
134 public void setBusCfg(String busCfg) {
135 this.busCfg = busCfg;
136 }
137
138 public String getBusCfg() {
139 return busCfg;
140 }
141
142
143 }