Example usage for org.springframework.context.support ClassPathXmlApplicationContext getBean

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext getBean.

Prototype

@Override
    public Object getBean(String name) throws BeansException 

Source Link

Usage

From source file:org.kuali.student.git.cleaner.RepositoryCleanerMain.java

/**
 * @param args/*from w  w  w . ja  v a  2s .co m*/
 */
public static void main(String[] args) {

    if (args.length < 1) {
        log.error("USAGE: <module name> [module specific arguments]");
        System.exit(-1);
    }
    try {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                "RepositoryCleanerMain-applicationContext.xml");

        applicationContext.registerShutdownHook();

        String beanName = args[0];

        RepositoryCleaner repoCleaner = (RepositoryCleaner) applicationContext.getBean(beanName);

        /*
         * Exclude the module name from the args sent to the module.
         */

        repoCleaner.validateArgs(Arrays.asList(args).subList(1, args.length));

        repoCleaner.execute();

    } catch (Exception e) {
        log.error("unexpected exception", e);
    }

}

From source file:com.roncoo.pay.app.settlement.SettTask.java

public static void main(String[] args) {

    try {//www . j av a2 s. c om

        @SuppressWarnings("resource")
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] { "spring-context.xml" });
        context.start();
        LOG.debug("");
        SettScheduled settScheduled = (SettScheduled) context.getBean("settScheduled");

        LOG.debug("(??)");
        settScheduled.launchDailySettCollect();
        LOG.debug("(??)?");

        Thread.sleep(MILLIS);

        LOG.debug("()");
        settScheduled.launchAutoSett();
        LOG.debug("()?");

        context.stop();
    } catch (Exception e) {
        LOG.error("SettTask execute error:", e);
    } finally {
        System.exit(0);
        LOG.debug("SettTask Complete");
    }
}

From source file:commonline.query.gui.Frame.java

public static void main(String args[]) throws Exception {
    Plastic3DLookAndFeel.setTabStyle(Plastic3DLookAndFeel.TAB_STYLE_METAL_VALUE);
    UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");

    System.setProperty("com.apple.macos.useScreenMenuBar", "true");

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("MainContext.xml");

    List dataSources = new ArrayList();
    dataSources.addAll(context.getBeansOfType(RecordParserDataSource.class).values());
    CommonlineRecordRepository repository = (CommonlineRecordRepository) context.getBean("clRepository");

    Frame frame = new Frame(System.getProperty("os.name").toLowerCase().indexOf("mac") != -1, dataSources,
            repository);//from   w  ww  . j a  va2s .co  m
    frame.setVisible(true);
}

From source file:org.openpplsoft.Main.java

/**
 * Main entry point for the OPS runtime.
 * @param args command line args to main
 *///from   w  w w.ja  va 2  s .co m
public static void main(final String[] args) {

    // The name of the environment to access is expected at args[0]
    System.setProperty("contextFile", args[0] + ".xml");
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(System.getProperty("contextFile"));

    // The name of the component to load is expected at args[1]
    ComponentRuntimeProfile profileToRun = (ComponentRuntimeProfile) ctx.getBean(args[1]);

    try {
        Runtime.getRuntime().addShutdownHook(new ENTShutdownHook());
        TraceFileVerifier.init(profileToRun);
        Environment.init((String) ctx.getBean("psEnvironmentName"), profileToRun.getOprid());

        Environment.setSystemVar("%Component", new PTString(profileToRun.getComponentName()));
        Environment.setSystemVar("%Menu", new PTString("SA_LEARNER_SERVICES"));
        Environment.setSystemVar("%Mode", new PTString(profileToRun.getMode()));

        Environment.setSystemVar("%Action_UpdateDisplay", new PTString("U"));
        Environment.setSystemVar("%Action_Add", new PTString("A"));

        /*
         * The following system vars can theoretically vary among environments.
         * However, at the moment, I am running this on identically configured
         * vanilla PS instances. Therefore, I am not going to externalize these
         * values for the time being.
         */
        Environment.setSystemVar("%Portal", new PTString("EMPLOYEE"));
        Environment.setSystemVar("%Node", new PTString("HRMS"));

        // Since we are verifying against a tracefile, we have to override
        // the default current date and time with the date and time
        // on/at which the tracefile was generated.
        Environment.setSystemVar("%Date", profileToRun.getTraceFileDate());
        Environment.setSystemVar("%Time", profileToRun.getTraceFileDateTime());

        final Component c = DefnCache.getComponent((String) Environment.getSystemVar("%Component").read(),
                "GBL");

        // Set %Page to the name of the first page in the component.
        Environment.setSystemVar("%Page", new PTString(c.getPages().get(0).getPNLNAME()));

        DefnCache.getMenu((String) Environment.getSystemVar("%Menu").read());

        ComponentBuffer.init(c);
        ComponentBuffer.getSearchRecord().fireEvent(PCEvent.SEARCH_INIT, new FireEventSummary());
        ComponentBuffer.fillSearchRecord();

        ComponentBuffer.assembleBuffers();
        ComponentBuffer.expandRecordBuffersWhereNecessary();
        ComponentBuffer.addEffDtKeyWhereNecessary();
        ComponentBuffer.logPageHierarchyVisual();
        ComponentBuffer.printStructure();
        ComponentStructureVerifier.verify(profileToRun);
        ComponentBuffer.materialize();

        ComponentBuffer.emitPRM();

        ComponentBuffer.firstPassFill();
        ComponentBuffer.fireEvent(PCEvent.PRE_BUILD, new FireEventSummary());
        ComponentBuffer.runRelatedDisplayProcessing();
        ComponentBuffer.runDefaultProcessing();

        ComponentBuffer.fireEvent(PCEvent.ROW_INIT, new FireEventSummary());
        ComponentBuffer.fireEvent(PCEvent.POST_BUILD, new FireEventSummary());

        TraceFileVerifier.logVerificationSummary(false);

    } catch (final OPSVMachRuntimeException opsvmre) {
        log.fatal(opsvmre.getMessage(), opsvmre);
        TraceFileVerifier.logVerificationSummary(true);
        System.exit(1);
    }
}

From source file:raymond.mockftpserver.S3CachedFtpServer.java

public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

    String identityPath = (String) ctx.getBean("identityPath");
    String charset = (String) ctx.getBean("charset");
    String keyBase = (String) ctx.getBean("keyBase");
    // String host = (String) ctx.getBean("s3Host");
    String bucket = (String) ctx.getBean("s3Bucket");
    String chave = (String) ctx.getBean("chave");
    Region region = (Region) ctx.getBean("s3Region");

    ctx.close();//www.  j a  va2 s  .  com

    // check if user wants to create credentials
    File _accessFile = new File(identityPath);

    S3CachedFtpServer s3FtpServer = new S3CachedFtpServer();
    s3FtpServer.init(_accessFile, chave, charset, keyBase, bucket, region);

    if (!_accessFile.exists() && args.length != 2) {
        throw new RuntimeException("sem credenciais");
    } else if (!_accessFile.exists()) {
        s3FtpServer.writeKeyFile(args[0], args[1].toCharArray());
    }

    s3FtpServer.go();
}

From source file:com.jmstoolkit.pipeline.Main.java

/**
 *
 * @param args/*from   w  ww . ja v  a2 s  . com*/
 */
public static void main(final String[] args) {
    try {
        Settings.loadSystemSettings("jndi.properties");
        Settings.loadSystemSettings("app.properties");
    } catch (JTKException ex) {
        System.out.println("Failed to load application settings");
        System.out.println(JTKException.formatException(ex));
        System.exit(1);
    }

    final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {
            "/infrastructure-context.xml", "/mdb-context.xml", "/jmx-context.xml", "/logging-context.xml" });
    applicationContext.start();

    final DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) applicationContext
            .getBean("listenerContainer");
    if (dmlc != null) {
        dmlc.start();
        final Pipeline pipeline = (Pipeline) applicationContext.getBean("pipelineService");
        // enable access to the original application context
        pipeline.setApplicationContext(applicationContext);

        // Insure that the Pipeline loads configuration files AFTER
        // the listenerContainer is running.
        while (!dmlc.isRunning()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
        }
        pipeline.loadPlugins();
        pipeline.sendProperties();
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
        }
    }
}

From source file:com.trailmagic.image.util.FixDimensions.java

public static final void main(String[] args) {
    ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {
            "applicationContext-global.xml", "applicationContext-user.xml", "applicationContext-imagestore.xml",
            "applicationContext-imagestore-authorization.xml", "applicationContext-standalone.xml" });

    FixDimensions fd = (FixDimensions) appContext.getBean(FIX_DIMENSIONS_BEAN);

    fd.fixDimensions(args[0], args[1]);/*  w w  w.j  a  v a 2  s  .c o  m*/
}

From source file:org.kuali.student.git.importer.GitImporterMain.java

/**
 * @param args//from  w ww.  ja  v  a  2  s  .co m
 */
public static void main(final String[] args) {

    if (args.length != 8 && args.length != 9) {
        log.error(
                "USAGE: <svn dump file> <git repository> <veto.log> <skipped-copy-from.log> <blob.log> <gc enabled> <svn repo base url> <repo uuid> [<git command path>]");
        log.error("\t<veto.log> : which paths were veto's as not being a valid branch");
        log.error("\t<skipped-copy-from.log> : which copy-from-paths were skipped");
        log.error("\t<blob.log> : issues related to blobs (typically directory copy related)");
        log.error("\t<gc enabled> : set to 1 (true ever 500 revs) or 0 (false) to disable");
        log.error("\t<svn repo base url> : the svn repo base url to use in the git-svn-id");
        log.error(
                "\t<repo uuid> : The svn repository uuid to use in the git-svn-id.\n\tIt you are importing from a clone use this to set the field to the real repositories uuid.");
        log.error("\t<git command path> : the path to a native git to use for gc's which occur every 500 revs");
        System.exit(-1);
    }

    try {

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                "GitImporterMain-applicationContext.xml");

        applicationContext.registerShutdownHook();

        SvnDumpFilter filter = applicationContext.getBean(SvnDumpFilter.class);

        BranchDetector branchDetector = applicationContext.getBean("branchDetector", BranchDetector.class);

        // final MergeDetectorData detectorData = applicationContext
        // .getBean(MergeDetectorData.class);

        File dumpFile = new File(args[0]);

        if (!dumpFile.exists()) {
            throw new FileNotFoundException(args[0] + " path not found");
        }

        File gitRepository = new File(args[1]).getAbsoluteFile();

        if (!gitRepository.getParentFile().exists())
            throw new FileNotFoundException(args[1] + "path not found");

        final PrintWriter vetoLog = new PrintWriter(args[2]);

        final PrintWriter copyFromSkippedLog = new PrintWriter(args[3]);

        final PrintWriter blobLog = new PrintWriter(args[4]);

        boolean gcEnabled = true;

        final boolean printGitSvnIds = true; // not optional anymore

        String repositoryBaseUrl = null;

        String repositoryUUID = null;

        if (args[5].trim().equals("0"))
            gcEnabled = false;

        repositoryBaseUrl = args[6].trim();

        repositoryUUID = args[7].trim();

        String nativeGitCommandPath = null;

        if (args.length == 9)
            nativeGitCommandPath = args[8].trim();

        final Repository repo = GitRepositoryUtils.buildFileRepository(gitRepository, false);

        // extract any known branches from the repository

        BZip2CompressorInputStream compressedInputStream = new BZip2CompressorInputStream(
                new FileInputStream(dumpFile));

        filter.parseDumpFile(compressedInputStream,
                new GitImporterParseOptions(repo, vetoLog, copyFromSkippedLog, blobLog, printGitSvnIds,
                        repositoryBaseUrl, repositoryUUID, branchDetector, gcEnabled, nativeGitCommandPath));

        vetoLog.close();
        copyFromSkippedLog.close();
        blobLog.close();

        compressedInputStream.close();

    } catch (Exception e) {
        log.error("Processing failed", e);
    }

}

From source file:com.bt.aloha.batchtest.Chart.java

public static void main(String args[]) throws Exception {
    try {//  w w w  .ja  v a2  s.  c  om
        BasicConfigurator.configure();
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                "batchTestApplicationContext.xml");
        PerformanceMeasurmentDao dao = (PerformanceMeasurmentDao) applicationContext
                .getBean("performanceMeasurementDaoBean");
        List<Metrics> list1 = dao.findMetricsByRunId(1);
        List<Metrics> list2 = dao.findMetricsByRunId(2);
        List<Metrics> list3 = dao.findMetricsByRunId(3);
        List<Metrics> list4 = dao.findMetricsByRunId(4);
        List<Metrics> list5 = dao.findMetricsByRunId(5);
        List<Metrics> list6 = dao.findMetricsByRunId(6);
        List<Metrics> list7 = dao.findMetricsByRunId(7);
        List<Metrics> list8 = dao.findMetricsByRunId(8);
        List<Metrics> list9 = dao.findMetricsByRunId(9);
        List<Metrics> list10 = dao.findMetricsByRunId(10);
        HashMap<Long, List<Metrics>> map = new HashMap<Long, List<Metrics>>();
        map.put(1L, list1);
        Chart c = new Chart(map);
        c.saveChart(new File("unitPerSecond.jpg"), "Run with standard deviation", "threads",
                "units per second");
        map.put(2L, list2);
        map.put(3L, list3);
        map.put(4L, list4);
        map.put(5L, list5);
        map.put(6L, list6);
        map.put(7L, list7);
        map.put(8L, list8);
        map.put(9L, list9);
        map.put(10L, list10);
        c = new Chart(map);
        c.saveCombinedChart(new File("unitPerSecond-historical.jpg"), "Runs Per Second", "threads",
                "runs per second", "Standard Deviation", "threads", "std. deviation");
    } catch (RuntimeException e) {
        log.error(e);
    } finally {
        System.exit(0);
    }
}

From source file:com.trailmagic.image.util.MakeAlbum.java

public static void main(String[] args) {
    if (args.length != 4) {
        printUsage();//from   w w w  .ja  va2 s  .  c  om
        System.exit(1);
    }

    ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {
            "applicationContext-global.xml", "applicationContext-user.xml", "applicationContext-imagestore.xml",
            "applicationContext-imagestore-authorization.xml", "applicationContext-standalone.xml" });
    MakeAlbum worker = (MakeAlbum) appContext.getBean(MAKE_ALBUM_BEAN);

    worker.doStuff(args[0], args[1], args[2], args[3]);
}