001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.identity.ant;
042:
043: import java.io.File;
044: import java.io.FileInputStream;
045: import java.io.FileOutputStream;
046: import java.io.IOException;
047: import java.util.Properties;
048: import org.apache.tools.ant.BuildException;
049: import org.apache.tools.ant.Task;
050:
051: /**
052: *
053: */
054: public class AMClassPathSetup extends Task {
055: private static final String J2EE_PLATFORM_CLASSPATH_PROP = "j2ee.platform.classpath"; //NOI18N
056:
057: private static final String JAR_LOCATION = File.separator
058: + "addons" + File.separator + "accessmanager"
059: + File.separator; //NOI18N
060:
061: private static final String CONFIG_LOCATION = File.separator
062: + "domains" + File.separator + "domain1" + File.separator
063: + "config"; //NOI18N
064:
065: private static final String AM_WEB_SERVICES_PROVIDER_JAR = JAR_LOCATION
066: + "amWebservicesProvider.jar"; //NOI18N
067:
068: private static final String AM_CLIENT_SDK_JAR = JAR_LOCATION
069: + "amclientsdk.jar"; //NOI18N
070:
071: private static final String CLASSPATH_SEPARATOR = ":"; //NOI18N
072:
073: private static final String AM_SUFFIX = "_am"; //NOI18N
074:
075: private String propertiesFile;
076: private String asRoot;
077:
078: public void setPropertiesfile(String path) {
079: this .propertiesFile = path;
080: }
081:
082: public void setAsroot(String asRoot) {
083: this .asRoot = asRoot;
084: }
085:
086: public void execute() throws BuildException {
087: Properties properties = new Properties();
088: FileInputStream is = null;
089: FileOutputStream os = null;
090:
091: try {
092: is = new FileInputStream(propertiesFile);
093: properties.load(is);
094:
095: String classPath = properties
096: .getProperty(J2EE_PLATFORM_CLASSPATH_PROP);
097:
098: classPath = classPath + CLASSPATH_SEPARATOR + asRoot
099: + AM_WEB_SERVICES_PROVIDER_JAR
100: + CLASSPATH_SEPARATOR + asRoot + AM_CLIENT_SDK_JAR
101: + CLASSPATH_SEPARATOR + asRoot + CONFIG_LOCATION;
102:
103: //System.out.println("classPath = " + classPath);
104: properties.setProperty(J2EE_PLATFORM_CLASSPATH_PROP,
105: classPath);
106:
107: os = new FileOutputStream(propertiesFile + AM_SUFFIX);
108:
109: properties.store(os, ""); //NOI18N
110:
111: } catch (IOException ex) {
112: if (is != null) {
113: try {
114: is.close();
115: } catch (IOException ex2) {
116: // ignore
117: }
118: }
119:
120: if (os != null) {
121: try {
122: os.close();
123: } catch (IOException ex2) {
124: // ignore
125: }
126: }
127: }
128:
129: }
130: }
|