Package org.datanucleus.util

Examples of org.datanucleus.util.CommandLine


     */
    public static void main(String[] args) throws Exception
    {
        SchemaTool tool = new SchemaTool();

        CommandLine cmd = new CommandLine();
        cmd.addOption("create", "create", null, LOCALISER.msg(false, "014026"));
        cmd.addOption("delete", "delete", null, LOCALISER.msg(false, "014027"));
        cmd.addOption("validate", "validate", null, LOCALISER.msg(false, "014028"));
        cmd.addOption("dbinfo", "dbinfo", null, LOCALISER.msg(false, "014029"));
        cmd.addOption("schemainfo", "schemainfo", null, LOCALISER.msg(false, "014030"));
        cmd.addOption("help", "help", null, LOCALISER.msg(false, "014033"));

        cmd.addOption("ddlFile", "ddlFile", "ddlFile", LOCALISER.msg(false, "014031"));
        cmd.addOption("completeDdl", "completeDdl", null, LOCALISER.msg(false, "014032"));

        cmd.addOption("includeAutoStart", "includeAutoStart", null, "Include Auto-Start Mechanisms");

        cmd.addOption("api", "api", "api", "API Adapter (JDO, JPA, etc)");
        cmd.addOption("v", "verbose", null, "verbose output");

        cmd.addOption("pu", "persistenceUnit", "<persistence-unit>",
            "name of the persistence unit to handle the schema for");
        cmd.addOption("props", "properties", "props", "path to a properties file");
        cmd.parse(args);

        // Remaining command line args are filenames (class files, metadata files)
        String[] filenames = cmd.getDefaultArgs();

        if (cmd.hasOption("api"))
        {
            tool.setApi(cmd.getOptionArg("api"));
        }

        // Determine the mode of operation required
        String msg = null;
        int mode = SCHEMATOOL_CREATE_MODE;
        if (cmd.hasOption("create"))
        {
            mode = SCHEMATOOL_CREATE_MODE;
            msg = LOCALISER.msg(false, "014000");
        }
        else if (cmd.hasOption("delete"))
        {
            mode = SCHEMATOOL_DELETE_MODE;
            msg = LOCALISER.msg(false, "014001");
        }
        else if (cmd.hasOption("validate"))
        {
            mode = SCHEMATOOL_VALIDATE_MODE;
            msg = LOCALISER.msg(false, "014002");
        }
        else if (cmd.hasOption("dbinfo"))
        {
            mode = SCHEMATOOL_DATABASE_INFO_MODE;
            msg = LOCALISER.msg(false, "014003");
        }
        else if (cmd.hasOption("schemainfo"))
        {
            mode = SCHEMATOOL_SCHEMA_INFO_MODE;
            msg = LOCALISER.msg(false, "014004");
        }
        else if (cmd.hasOption("help"))
        {
            System.out.println(LOCALISER.msg(false, "014023"));
            System.out.println(LOCALISER.msg(false, "014024"));
            System.out.println(LOCALISER.msg(false, "014025"));
            System.out.println(cmd.toString());
            System.out.println(LOCALISER.msg(false, "014034"));
            System.out.println(LOCALISER.msg(false, "014035"));
            System.exit(0);
        }
        LOGGER.info(msg);
        System.out.println(msg);

        // Extract the selected options
        String propsFileName = null;
        String persistenceUnitName = null;
        if (cmd.hasOption("ddlFile"))
        {
            tool.setDdlFile(cmd.getOptionArg("ddlFile"));
        }
        if (cmd.hasOption("completeDdl"))
        {
            tool.setCompleteDdl(true);
        }
        if (cmd.hasOption("includeAutoStart"))
        {
            tool.setIncludeAutoStart(true);
        }
        if (cmd.hasOption("v"))
        {
            tool.setVerbose(true);
        }

        if (cmd.hasOption("pu"))
        {
            persistenceUnitName = cmd.getOptionArg("pu");
        }
        if (cmd.hasOption("props"))
        {
            propsFileName = cmd.getOptionArg("props");
        }

        // Classpath
        msg = LOCALISER.msg(false, "014005");
        LOGGER.info(msg);
View Full Code Here


     */
    public static void main(String args[])
    throws Exception
    {
        // Create the enhancer, and set the various options
        CommandLine cmd = new CommandLine();
        cmd.addOption("pu", "persistenceUnit", "<name-of-persistence-unit>", "name of the persistence unit to enhance");
        cmd.addOption("d", "dest", "<directory>", "output directory");
        cmd.addOption("checkonly", "checkonly", null, "only check if the class is enhanced");
        cmd.addOption("q", "quiet", null, "no output");
        cmd.addOption("v", "verbose", null, "verbose output");
        cmd.addOption("api", "api", "<api-name>", "API Name (JDO, JPA, etc)");
        cmd.addOption("enhancerName", "enhancerName", "<enhancer-name>", "Class Enhancer name (ASM, etc)");
        cmd.addOption("generatePK", "generatePK", "<generate-pk>", "Generate PK class where needed?");
        cmd.addOption("generateConstructor", "generateConstructor", "<generate-constructor>",
            "Generate default constructor where needed?");
        cmd.addOption("detachListener", "detachListener", "<detach-listener>", "Use Detach Listener?");
        cmd.parse(args);

        // Create the DataNucleusEnhancer to the required API/enhancer
        String apiName = cmd.hasOption("api") ? cmd.getOptionArg("api") : "JDO";
        String enhancerName = cmd.hasOption("enhancerName") ? cmd.getOptionArg("enhancerName") : "ASM";

        // TODO Add a way of defining input properties for startup
        Properties props = new Properties();
        props.setProperty("datanucleus.plugin.allowUserBundles", "true");
        DataNucleusEnhancer enhancer = new DataNucleusEnhancer(apiName, enhancerName, props);

        boolean quiet = false;
        if (cmd.hasOption("q"))
        {
            quiet = true;
            if (cmd.hasOption("v")) // Verbose only recognised when not quiet
            {
                enhancer.setVerbose(true);
            }
        }
        if (!quiet)
        {
            enhancer.setSystemOut(true);
        }

        if (cmd.hasOption("d"))
        {
            String destination = cmd.getOptionArg("d");
            File tmp = new File(destination);
            if (tmp.exists())
            {
                if (!tmp.isDirectory())
                {
                    System.out.println(destination + " is not directory. please set directory.");
                    System.exit(1);
                }
            }
            else
            {
                tmp.mkdirs();
            }
            enhancer.setOutputDirectory(destination);
        }
        if (cmd.hasOption("generateConstructor"))
        {
            String val = cmd.getOptionArg("generateConstructor");
            if (val.equalsIgnoreCase("false"))
            {
                enhancer.setGenerateConstructor(false);
            }
        }
        if (cmd.hasOption("generatePK"))
        {
            String val = cmd.getOptionArg("generatePK");
            if (val.equalsIgnoreCase("false"))
            {
                enhancer.setGeneratePK(false);
            }
        }
        if (cmd.hasOption("detachListener"))
        {
            String val = cmd.getOptionArg("detachListener");
            if (val.equalsIgnoreCase("true"))
            {
                enhancer.setDetachListener(true);
            }
        }

        boolean validating = cmd.hasOption("checkonly") ? true : false;
        String persistenceUnitName = cmd.hasOption("pu") ? cmd.getOptionArg("pu") : null;
        String[] filenames = cmd.getDefaultArgs();

        // Debug Info : title
        String msg = null;
        String version = enhancer.nucleusContext.getPluginManager().getVersionForBundle("org.datanucleus.enhancer");
        if (validating)
View Full Code Here

     */
    public static void main(String args[])
    throws Exception
    {
        // Create the enhancer, and set the various options
        CommandLine cmd = new CommandLine();
        cmd.addOption("d", "dest", "<directory>", "output directory");
        cmd.addOption("api", "api", "<adapter-name>", "API Adapter (JDO, JPA, etc)");
        cmd.addOption("persistenceUnit", "persistenceUnit", "<name-of-persistence-unit>", "name of the persistence unit to enhance");
        cmd.addOption("v", "verbose", null, "verbose output");
        cmd.addOption("enhancerName", "enhancerName", "<enhancer-name>", "Class Enhancer name (ASM, etc)");
        cmd.addOption("checkonly", "checkonly", null, "only check if the class is enhanced");

        cmd.parse(args);

        // Create the DataNucleusEnhancer to the required API/enhancer
        String api = "JDO";
        if (cmd.hasOption("api"))
        {
            api = cmd.getOptionArg("api");
        }
        String enhancerName = "ASM";
        if (cmd.hasOption("enhancerName"))
        {
            enhancerName = cmd.getOptionArg("enhancerName");
        }
        DataNucleusEnhancer enhancer = new DataNucleusEnhancer(api, enhancerName);
        enhancer.setSystemOut(true); // Using command line so make use of System.out

        if (cmd.hasOption("d"))
        {
            String destination = cmd.getOptionArg("d");
            File tmp = new File(destination);
            if (tmp.exists())
            {
                if (!tmp.isDirectory())
                {
                    System.out.println(destination + " is not directory. please set directory.");
                    System.exit(1);
                }
            }
            else
            {
                tmp.mkdirs();
            }
            enhancer.setOutputDirectory(destination);
        }
        if (cmd.hasOption("v"))
        {
            enhancer.setVerbose(true);
        }
        boolean validating = false;
        if (cmd.hasOption("checkonly"))
        {
            validating = true;
        }
        String persistenceUnitName = null;
        if (cmd.hasOption("persistenceUnit"))
        {
            persistenceUnitName = cmd.getOptionArg("persistenceUnit");
        }
        String[] filenames = cmd.getDefaultArgs();

        // Debug Info : title
        String msg = null;
        if (validating)
        {
View Full Code Here

TOP

Related Classes of org.datanucleus.util.CommandLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.