Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.jdo;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
import static javax.jdo.Constants.ENHANCER_EXCEPTION;
import static javax.jdo.Constants.ENHANCER_NO_JDO_ENHANCER_FOUND;
import static javax.jdo.Constants.ENHANCER_USAGE_ERROR;
import static javax.jdo.Constants.PROPERTY_ENHANCER_VENDOR_NAME;
import static javax.jdo.Constants.PROPERTY_ENHANCER_VERSION_NUMBER;
import javax.jdo.spi.I18NHelper;
/**
* Main class to invoke a JDO Enhancer.
* The enhancer is invoked with the following command line:
*
* <classpath> must contain the jdo specification jar, the implementation jar and any
* implementation dependencies, the statically-compiled classes, and the jdo
* metadata files loadable as resources.
*
* <options> include:
*
? : print usage to stderr and exit
*
-h : print usage to stderr and exit
*
-help : print usage to stderr and exit
*
-pu <persistence-unit-name> : the name of a persistence unit
*
-d <target directory> : write the enhanced classes to the specified directory
*
-checkonly : just check the classes for enhancement status
*
-v : verbose output
*
-r : recurse through directories to find all classes and metadata files to enhance
*
-cp <enhancer class loader path> : if not already included in the java class loader,
* this parameter must contain the statically-compiled classes, and the jdo metadata
* files loadable as resources
*
<directory, file, or resource names>
*
Directory names must not end in ".jdo", ".jar", or ".class"
*
Directories will be searched for files with suffixes ".jdo", ".jar", and ".class"
*
Directories will be searched recursively if the -r option is set
*
*
* @since 3.0
*/
public class Enhancer {
/** The Internationalization message helper. */
private final static I18NHelper msg =
I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N
/** New Line */
private char NL = '\n'; //NOI18N
/** Jar file suffix */
private String JAR_FILE_SUFFIX = ".jar"; //NOI18N
/** JDO Metadata file suffix */
private String JDO_FILE_SUFFIX = ".jdo"; //NOI18N
/** Class file suffix */
private String CLASS_FILE_SUFFIX = ".class"; //NOI18N
/** Error indicator */
private boolean error = false;
/** If set, process parameters, print usage, and exit. */
private boolean printAndExit = false;
/** Persistence Units */
private List persistenceUnitNames = new ArrayList();
/** Target Directory Parameter */
private String directoryName = null;
/** ClassLoader for JDOEnhancer */
private ClassLoader loader = null;
/** Classpath (-cp) parameter */
private String classPath = null;
/** Check Only flag */
private boolean checkOnly = false;
/** Verbose flag */
private boolean verbose = false;
/** Recurse flag */
private boolean recurse = false;
/** Error messages should be empty unless there is an error */
private StringBuilder errorBuffer = new StringBuilder();
/** Verbose messages are always collected but only output if verbose flag is set */
private StringBuilder verboseBuffer = new StringBuilder();
/** File Names */
private List fileNames = new ArrayList();
/** Class File Names */
private List classFileNames = new ArrayList();
/** JDO File Names */
private List jdoFileNames = new ArrayList();
/** Jar File Names */
private List jarFileNames = new ArrayList();
/** The number of classes validated by the JDOEnhancer */
private int numberOfValidatedClasses = 0;
/** The number of classes enhanced by the JDOEnhancer */
private int numberOfEnhancedClasses = 0;
/** The properties from the JDOEnhancer */
private Properties properties;
/** Run the enhancer from the command line.
*
* @param args command line arguments
*/
public static void main (String[] args) {
Enhancer enhancerMain = new Enhancer();
enhancerMain.run(args);
}
/** Execute the enhancer.
*
* @param args the command line arguments
*/
private void run(String[] args) {
// processArgs will exit if errors or help
processArgs(args);
JDOEnhancer enhancer = null;
try {
enhancer = JDOHelper.getEnhancer();
} catch (JDOException jdoex) {
jdoex.printStackTrace(); // outputs to stderr
exit(ENHANCER_NO_JDO_ENHANCER_FOUND);
}
try {
// provide verbose property settings of the JDOEnhancer we just loaded
properties = enhancer.getProperties();
addVerboseMessage("MSG_EnhancerClass", enhancer.getClass().getName()); //NOI18N
addVerboseMessage("MSG_EnhancerProperty", PROPERTY_ENHANCER_VENDOR_NAME, //NOI18N
properties.getProperty(PROPERTY_ENHANCER_VENDOR_NAME));
addVerboseMessage("MSG_EnhancerProperty", PROPERTY_ENHANCER_VERSION_NUMBER, //NOI18N
properties.getProperty(PROPERTY_ENHANCER_VERSION_NUMBER));
Set> props = properties.entrySet();
Iterator> entries = props.iterator();
while (entries.hasNext()) {
Entry