All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.ignite.IgniteSpring Maven / Gradle / Ivy

Go to download

Java-based middleware for in-memory processing of big data in a distributed environment.

There is a newer version: 2.16.0
Show newest version
/*
 * 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 org.apache.ignite;

import java.net.URL;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContextImpl;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationContext;

/**
 * Factory methods to start Ignite with optional Spring application context, this context can be injected into
 * grid tasks and grid jobs using {@link org.apache.ignite.resources.SpringApplicationContextResource @SpringApplicationContextResource}
 * annotation.
 * 

* You can also instantiate grid directly from Spring without using {@code Ignite}. * For more information refer to {@link IgniteSpringBean} documentation. */ public class IgniteSpring { /** * Starts grid with default configuration. By default this method will * use grid configuration defined in {@code IGNITE_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 org.apache.ignite.resources.SpringApplicationContextResource @SpringApplicationContextResource} annotation. * @return Started grid. * @throws IgniteCheckedException If default grid could not be started. This exception will be thrown * also if default grid has already been started. */ public static Ignite start(@Nullable ApplicationContext springCtx) throws IgniteCheckedException { return IgnitionEx.start(new GridSpringResourceContextImpl(springCtx)); } /** * Starts grid with given configuration. * * @param cfg Grid configuration. This cannot be {@code null}. * @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 org.apache.ignite.resources.SpringApplicationContextResource @SpringApplicationContextResource} annotation. * @return Started grid. * @throws IgniteCheckedException If grid could not be started. This exception will be thrown * also if named grid has already been started. */ public static Ignite start(IgniteConfiguration cfg, @Nullable ApplicationContext springCtx) throws IgniteCheckedException { return IgnitionEx.start(cfg, new GridSpringResourceContextImpl(springCtx)); } /** * 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. *

* 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. This cannot be {@code null}. * @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 org.apache.ignite.resources.SpringApplicationContextResource @SpringApplicationContextResource} annotation. * @return Started grid. If Spring configuration contains multiple grid instances, * then the 1st found instance is returned. * @throws IgniteCheckedException 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 Ignite start(String springCfgPath, @Nullable ApplicationContext springCtx) throws IgniteCheckedException { return IgnitionEx.start(springCfgPath, null, new GridSpringResourceContextImpl(springCtx), null); } /** * Starts all grids specified within given Spring XML configuration file URL. 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. *

* 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 springCfgUrl Spring XML configuration file URL. This cannot be {@code null}. * @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 org.apache.ignite.resources.SpringApplicationContextResource @GridSpringApplicationContextResource} annotation. * @return Started grid. If Spring configuration contains multiple grid instances, * then the 1st found instance is returned. * @throws IgniteCheckedException 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 Ignite start(URL springCfgUrl, @Nullable ApplicationContext springCtx) throws IgniteCheckedException { return IgnitionEx.start(springCfgUrl, null, new GridSpringResourceContextImpl(springCtx), null); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy