|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| PropertySet.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2003 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.integration.ant.util;
|
|
| 21 |
|
|
| 22 |
import java.io.File;
|
|
| 23 |
import java.io.FileInputStream;
|
|
| 24 |
import java.io.IOException;
|
|
| 25 |
import java.util.PropertyResourceBundle;
|
|
| 26 |
import java.util.ResourceBundle;
|
|
| 27 |
|
|
| 28 |
import org.apache.tools.ant.BuildException;
|
|
| 29 |
|
|
| 30 |
/**
|
|
| 31 |
* Ant element used to tell the Cactus task to load a properties file
|
|
| 32 |
* and passed its properties to the client side or server side JVMs.
|
|
| 33 |
*
|
|
| 34 |
* @version $Id: PropertySet.java 238812 2004-02-29 10:21:34Z vmassol $
|
|
| 35 |
*/
|
|
| 36 |
public class PropertySet |
|
| 37 |
{
|
|
| 38 |
/**
|
|
| 39 |
* Properties file to load.
|
|
| 40 |
*/
|
|
| 41 |
private File propertiesFile;
|
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* Are the properties for the Cactus server side JVM?
|
|
| 45 |
*/
|
|
| 46 |
private boolean isServer; |
|
| 47 |
|
|
| 48 |
/**
|
|
| 49 |
* @param thePropertiesFile the properties file to load
|
|
| 50 |
*/
|
|
| 51 | 0 |
public void setPropertiesFile(File thePropertiesFile) |
| 52 |
{
|
|
| 53 | 0 |
this.propertiesFile = thePropertiesFile;
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/**
|
|
| 57 |
* @param isServer if true the properties will be passed to the
|
|
| 58 |
* Cactus server side JVM
|
|
| 59 |
*/
|
|
| 60 | 0 |
public void setServer(boolean isServer) |
| 61 |
{
|
|
| 62 | 0 |
this.isServer = isServer;
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
/**
|
|
| 66 |
* @return true if the properties are to be passed to the Cactus
|
|
| 67 |
* server side JVM, false otherwise
|
|
| 68 |
*/
|
|
| 69 | 0 |
public boolean isServer() |
| 70 |
{
|
|
| 71 | 0 |
return this.isServer; |
| 72 |
} |
|
| 73 |
|
|
| 74 |
/**
|
|
| 75 |
* @return the properties loaded from the proeprties file
|
|
| 76 |
*/
|
|
| 77 | 0 |
public ResourceBundle readProperties()
|
| 78 |
{
|
|
| 79 | 0 |
if (this.propertiesFile == null) |
| 80 |
{
|
|
| 81 | 0 |
throw new BuildException("Missing 'propertiesFiles' attribute"); |
| 82 |
} |
|
| 83 |
|
|
| 84 | 0 |
ResourceBundle bundle; |
| 85 | 0 |
try
|
| 86 |
{
|
|
| 87 | 0 |
bundle = new PropertyResourceBundle(
|
| 88 |
new FileInputStream(this.propertiesFile)); |
|
| 89 |
} |
|
| 90 |
catch (IOException e)
|
|
| 91 |
{
|
|
| 92 | 0 |
throw new BuildException("Failed to load properties " |
| 93 |
+ "file [" + this.propertiesFile + "]"); |
|
| 94 |
} |
|
| 95 | 0 |
return bundle;
|
| 96 |
} |
|
| 97 |
} |
|
| 98 |
|
|
||||||||||