/** {@inheritDoc} */ @Override public void afterPropertiesSet() throws Exception { if (cfg == null) cfg = new GridConfiguration(); g = GridGainSpring.start(cfg, appCtx); }
/** * Starts grid with default configuration. By default this method will * use grid configuration defined in {@code GRIDGAIN_HOME/config/default-config.xml} * configuration file. If such file is not found, then all system defaults will be used. * * @param springCtx Optional Spring application context, possibly {@code null}. * Spring bean definitions for bean injection are taken from this context. * If provided, this context can be injected into grid tasks and grid jobs using * {@link GridSpringApplicationContextResource @GridSpringApplicationContextResource} annotation. * @return Started grid. * @throws GridException If default grid could not be started. This exception will be thrown * also if default grid has already been started. */ public static Grid start(@Nullable GridSpringResourceContext springCtx) throws GridException { URL url = U.resolveGridGainUrl(DFLT_CFG); if (url != null) return start(DFLT_CFG, null, springCtx); U.warn(null, "Default Spring XML file not found (is GRIDGAIN_HOME set?): " + DFLT_CFG); return start0(new GridStartContext(new GridConfiguration(), null, springCtx)).grid(); }
/** * Starts all grids specified within given Spring XML configuration file. If grid with given name * is already started, then exception is thrown. In this case all instances that may * have been started so far will be stopped too. * <p> * Usually Spring XML configuration file will contain only one Grid definition. Note that * Grid configuration bean(s) is retrieved form configuration file by type, so the name of * the Grid configuration bean is ignored. * * @param springCfgPath Spring XML configuration file path or URL. * @param gridName Grid name that will override default. * @return Started grid. If Spring configuration contains multiple grid instances, * then the 1st found instance is returned. * @throws GridException If grid could not be started or configuration * read. This exception will be thrown also if grid with given name has already * been started or Spring XML configuration file is invalid. */ public static Grid start(@Nullable String springCfgPath, @Nullable String gridName) throws GridException { if (springCfgPath == null) { GridConfiguration cfg = new GridConfiguration(); if (cfg.getGridName() == null && !F.isEmpty(gridName)) cfg.setGridName(gridName); return start(cfg); } else return start(springCfgPath, gridName, null); }
GridConfiguration cfg0 = new GridConfiguration(cfg);
return null; GridConfiguration cp = new GridConfiguration();
cfg = new GridConfiguration(); GridConfiguration myCfg = new GridConfiguration();