IGNITE-45 - renaimings
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0106f48f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0106f48f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0106f48f Branch: refs/heads/ignite-45 Commit: 0106f48fad8a60faeecdfa8d766706269a68db30 Parents: 28b6b51 Author: Valentin Kulichenko <vkuliche...@gridgain.com> Authored: Mon Mar 23 17:46:10 2015 -0700 Committer: Valentin Kulichenko <vkuliche...@gridgain.com> Committed: Mon Mar 23 17:46:10 2015 -0700 ---------------------------------------------------------------------- .../ignite/internal/GridKernalContextImpl.java | 4 +- .../ignite/internal/IgniteComponentType.java | 4 +- .../org/apache/ignite/internal/IgnitionEx.java | 6 +- .../impl/GridRouterCommandLineStartup.java | 4 +- .../internal/cluster/IgniteClusterImpl.java | 4 +- .../spring/IgniteSpringProcessor.java | 95 ------ .../util/nodestart/IgniteSshHelper.java | 34 +++ .../util/nodestart/IgniteSshProcessor.java | 34 --- .../util/spring/IgniteSpringHelper.java | 95 ++++++ .../spring/IgniteSpringProcessorImpl.java | 301 ------------------- .../util/spring/IgniteSpringHelperImpl.java | 301 +++++++++++++++++++ .../util/nodestart/IgniteSshHelperImpl.java | 28 ++ .../util/nodestart/IgniteSshProcessorImpl.java | 28 -- .../scala/org/apache/ignite/visor/visor.scala | 4 +- 14 files changed, 471 insertions(+), 471 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index 0291325..0c3f41f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -55,9 +55,9 @@ import org.apache.ignite.internal.processors.security.*; import org.apache.ignite.internal.processors.segmentation.*; import org.apache.ignite.internal.processors.service.*; import org.apache.ignite.internal.processors.session.*; -import org.apache.ignite.internal.processors.spring.*; import org.apache.ignite.internal.processors.task.*; import org.apache.ignite.internal.processors.timeout.*; +import org.apache.ignite.internal.util.spring.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; @@ -235,7 +235,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** */ @GridToStringExclude - private IgniteSpringProcessor spring; + private IgniteSpringHelper spring; /** */ @GridToStringExclude http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java index 0e5c1cf..42cc507 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java @@ -50,7 +50,7 @@ public enum IgniteComponentType { /** Spring XML parsing. */ SPRING( null, - "org.apache.ignite.internal.processors.spring.IgniteSpringProcessorImpl", + "org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl", "ignite-spring" ), @@ -64,7 +64,7 @@ public enum IgniteComponentType { /** Nodes starting using SSH. */ SSH( null, - "org.apache.ignite.internal.util.nodestart.IgniteSshProcessorImpl", + "org.apache.ignite.internal.util.nodestart.IgniteSshHelperImpl", "ignite-ssh" ), http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index 39eae15..4c70d1e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -22,7 +22,7 @@ import org.apache.ignite.cache.affinity.rendezvous.*; import org.apache.ignite.compute.ComputeJob; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.resource.*; -import org.apache.ignite.internal.processors.spring.*; +import org.apache.ignite.internal.util.spring.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -562,7 +562,7 @@ public class IgnitionEx { */ public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( URL springCfgUrl) throws IgniteCheckedException { - IgniteSpringProcessor spring = SPRING.create(false); + IgniteSpringHelper spring = SPRING.create(false); return spring.loadConfigurations(springCfgUrl); } @@ -910,7 +910,7 @@ public class IgnitionEx { A.notNull(springXmlUrl, "springXmlUrl"); A.notNull(beanName, "beanName"); - IgniteSpringProcessor spring = SPRING.create(false); + IgniteSpringHelper spring = SPRING.create(false); return spring.loadBean(springXmlUrl, beanName); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridRouterCommandLineStartup.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridRouterCommandLineStartup.java b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridRouterCommandLineStartup.java index 5dad4d2..41d4d28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridRouterCommandLineStartup.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/router/impl/GridRouterCommandLineStartup.java @@ -19,7 +19,7 @@ package org.apache.ignite.internal.client.router.impl; import org.apache.ignite.*; import org.apache.ignite.internal.client.router.*; -import org.apache.ignite.internal.processors.spring.*; +import org.apache.ignite.internal.util.spring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; @@ -108,7 +108,7 @@ public class GridRouterCommandLineStartup { " " ); - IgniteSpringProcessor spring = SPRING.create(false); + IgniteSpringHelper spring = SPRING.create(false); if (args.length < 1) { X.error("Missing XML configuration path."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java index 92170ba..76a49dd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterImpl.java @@ -344,7 +344,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus guard(); try { - IgniteSshProcessor sshProcessor = IgniteComponentType.SSH.create(false); + IgniteSshHelper sshHelper = IgniteComponentType.SSH.create(false); Map<String, Collection<IgniteRemoteStartSpecification>> specsMap = specifications(hosts, dflts); @@ -401,7 +401,7 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus assert spec.host().equals(host); for (int i = startIdx; i <= spec.nodes(); i++) { - nodeRuns.add(sshProcessor.nodeStartCallable(spec, timeout)); + nodeRuns.add(sshHelper.nodeStartCallable(spec, timeout)); nodeCallCnt++; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java deleted file mode 100644 index e0c4df5..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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.internal.processors.spring; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.processors.resource.*; -import org.apache.ignite.lang.*; - -import java.net.*; -import java.util.*; - -/** - * Spring processor which can parse Spring configuration files, interface was introduced to avoid mandatory - * runtime dependency on Spring framework. - */ -public interface IgniteSpringProcessor { - /** - * Loads all grid configurations specified within given configuration file. - * <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 cfgUrl Configuration file path or URL. This cannot be {@code null}. - * @param excludedProps Properties to exclude. - * @return Tuple containing all loaded configurations and Spring context used to load them. - * @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 IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, String... excludedProps) throws IgniteCheckedException; - - /** - * Loads all configurations with given type specified within given configuration file. - * - * @param cfgUrl Configuration file path or URL. This cannot be {@code null}. - * @param cl Required type of configuration. - * @param excludedProps Properties to exclude. - * @return Tuple containing all loaded configurations and Spring context used to load them. - * @throws IgniteCheckedException If configuration could not be read. - */ - public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException; - - /** - * Loads bean instances that match the given types from given configuration file. - * - * @param cfgUrl Configuration file path or URL. This cannot be {@code null}. - * @param beanClasses Beans classes. - * @return Bean class -> loaded bean instance map, if configuration does not contain bean with required type the - * map value is {@code null}. - * @throws IgniteCheckedException If failed to load configuration. - */ - public Map<Class<?>, Object> loadBeans(URL cfgUrl, Class<?>... beanClasses) throws IgniteCheckedException; - - /** - * Loads bean instance by name. - * - * @param url Spring XML file URL. - * @param beanName Bean name. - * @return Bean instance. - * @throws IgniteCheckedException In case of error. - */ - public <T> T loadBean(URL url, String beanName) throws IgniteCheckedException; - - /** - * Gets user version for given class loader by checking - * {@code META-INF/ignite.xml} file for {@code userVersion} attribute. If - * {@code ignite.xml} file is not found, or user version is not specified there, - * then default version (empty string) is returned. - * - * @param ldr Class loader. - * @param log Logger. - * @return User version for given class loader or empty string if no version - * was explicitly specified. - */ - public String userVersion(ClassLoader ldr, IgniteLogger log); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelper.java new file mode 100644 index 0000000..2cb620f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelper.java @@ -0,0 +1,34 @@ +/* + * 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.internal.util.nodestart; + +import java.util.concurrent.*; + +/** + * SSH processor, interface was introduced to avoid mandatory runtime dependency on SSH library. + */ +public interface IgniteSshHelper { + /** + * Creates {@link Callable} starting node using SSH. + * + * @param spec Specification. + * @param timeout Connection timeout. + * @return {@link Callable} starting node using SSH. + */ + public IgniteNodeCallable nodeStartCallable(IgniteRemoteStartSpecification spec, int timeout); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java deleted file mode 100644 index 9f59fa2..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.internal.util.nodestart; - -import java.util.concurrent.*; - -/** - * SSH processor, interface was introduced to avoid mandatory runtime dependency on SSH library. - */ -public interface IgniteSshProcessor { - /** - * Creates {@link Callable} starting node using SSH. - * - * @param spec Specification. - * @param timeout Connection timeout. - * @return {@link Callable} starting node using SSH. - */ - public IgniteNodeCallable nodeStartCallable(IgniteRemoteStartSpecification spec, int timeout); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java new file mode 100644 index 0000000..6bdfbac --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java @@ -0,0 +1,95 @@ +/* + * 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.internal.util.spring; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.resource.*; +import org.apache.ignite.lang.*; + +import java.net.*; +import java.util.*; + +/** + * Spring helper which can parse Spring configuration files, interface was introduced to avoid mandatory + * runtime dependency on Spring framework. + */ +public interface IgniteSpringHelper { + /** + * Loads all grid configurations specified within given configuration file. + * <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 cfgUrl Configuration file path or URL. This cannot be {@code null}. + * @param excludedProps Properties to exclude. + * @return Tuple containing all loaded configurations and Spring context used to load them. + * @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 IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( + URL cfgUrl, String... excludedProps) throws IgniteCheckedException; + + /** + * Loads all configurations with given type specified within given configuration file. + * + * @param cfgUrl Configuration file path or URL. This cannot be {@code null}. + * @param cl Required type of configuration. + * @param excludedProps Properties to exclude. + * @return Tuple containing all loaded configurations and Spring context used to load them. + * @throws IgniteCheckedException If configuration could not be read. + */ + public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( + URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException; + + /** + * Loads bean instances that match the given types from given configuration file. + * + * @param cfgUrl Configuration file path or URL. This cannot be {@code null}. + * @param beanClasses Beans classes. + * @return Bean class -> loaded bean instance map, if configuration does not contain bean with required type the + * map value is {@code null}. + * @throws IgniteCheckedException If failed to load configuration. + */ + public Map<Class<?>, Object> loadBeans(URL cfgUrl, Class<?>... beanClasses) throws IgniteCheckedException; + + /** + * Loads bean instance by name. + * + * @param url Spring XML file URL. + * @param beanName Bean name. + * @return Bean instance. + * @throws IgniteCheckedException In case of error. + */ + public <T> T loadBean(URL url, String beanName) throws IgniteCheckedException; + + /** + * Gets user version for given class loader by checking + * {@code META-INF/ignite.xml} file for {@code userVersion} attribute. If + * {@code ignite.xml} file is not found, or user version is not specified there, + * then default version (empty string) is returned. + * + * @param ldr Class loader. + * @param log Logger. + * @return User version for given class loader or empty string if no version + * was explicitly specified. + */ + public String userVersion(ClassLoader ldr, IgniteLogger log); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java b/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java deleted file mode 100644 index 545b596..0000000 --- a/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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.internal.processors.spring; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.processors.resource.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; -import org.springframework.beans.*; -import org.springframework.beans.factory.*; -import org.springframework.beans.factory.config.*; -import org.springframework.beans.factory.support.*; -import org.springframework.beans.factory.xml.*; -import org.springframework.context.*; -import org.springframework.context.support.*; -import org.springframework.core.io.*; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.atomic.*; - -/** - * Spring configuration processor. - */ -public class IgniteSpringProcessorImpl implements IgniteSpringProcessor { - /** Path to {@code ignite.xml} file. */ - public static final String IGNITE_XML_PATH = "META-INF/ignite.xml"; - - /** System class loader user version. */ - private static final AtomicReference<String> SYS_LDR_VER = new AtomicReference<>(null); - - /** - * Try to execute LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", null) - * to turn off default logging for Spring Framework. - */ - static { - Class<?> logFactoryCls = null; - - try { - logFactoryCls = Class.forName("org.apache.commons.logging.LogFactory"); - } - catch (ClassNotFoundException ignored) { - // No-op. - } - - if (logFactoryCls != null) { - try { - Object factory = logFactoryCls.getMethod("getFactory").invoke(null); - - factory.getClass().getMethod("setAttribute", String.class, Object.class). - invoke(factory, "org.apache.commons.logging.Log", null); - } - catch (Exception ignored) { - // No-op. - } - } - } - - /** {@inheritDoc} */ - @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, String... excludedProps) throws IgniteCheckedException { - return loadConfigurations(cfgUrl, IgniteConfiguration.class, excludedProps); - } - - /** {@inheritDoc} */ - @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( - URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException { - ApplicationContext springCtx = applicationContext(cfgUrl, excludedProps); - Map<String, T> cfgMap; - - try { - cfgMap = springCtx.getBeansOfType(cl); - } - catch (BeansException e) { - throw new IgniteCheckedException("Failed to instantiate bean [type=" + cl + - ", err=" + e.getMessage() + ']', e); - } - - if (cfgMap == null || cfgMap.isEmpty()) - throw new IgniteCheckedException("Failed to find configuration in: " + cfgUrl); - - return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx)); - } - - /** {@inheritDoc} */ - @Override public Map<Class<?>, Object> loadBeans(URL cfgUrl, Class<?>... beanClasses) throws IgniteCheckedException { - assert beanClasses.length > 0; - - ApplicationContext springCtx = initContext(cfgUrl); - - Map<Class<?>, Object> beans = new HashMap<>(); - - for (Class<?> cls : beanClasses) - beans.put(cls, bean(springCtx, cls)); - - return beans; - } - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override public <T> T loadBean(URL url, String beanName) throws IgniteCheckedException { - ApplicationContext springCtx = initContext(url); - - try { - return (T)springCtx.getBean(beanName); - } - catch (NoSuchBeanDefinitionException e) { - throw new IgniteCheckedException("Spring bean with provided name doesn't exist [url=" + url + - ", beanName=" + beanName + ']'); - } - catch (BeansException e) { - throw new IgniteCheckedException("Failed to load Spring bean with provided name [url=" + url + - ", beanName=" + beanName + ']', e); - } - } - - /** - * @param url XML file URL. - * @return Context. - * @throws IgniteCheckedException In case of error. - */ - private ApplicationContext initContext(URL url) throws IgniteCheckedException { - GenericApplicationContext springCtx; - - try { - springCtx = new GenericApplicationContext(); - - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(url)); - - springCtx.refresh(); - } - catch (BeansException e) { - if (X.hasCause(e, ClassNotFoundException.class)) - throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + - "(make sure all classes used in Spring configuration are present at CLASSPATH) " + - "[springUrl=" + url + ']', e); - else - throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + - url + ", err=" + e.getMessage() + ']', e); - } - - return springCtx; - } - - /** {@inheritDoc} */ - @Override public String userVersion(ClassLoader ldr, IgniteLogger log) { - assert ldr != null; - assert log != null; - - // For system class loader return cached version. - if (ldr == U.gridClassLoader() && SYS_LDR_VER.get() != null) - return SYS_LDR_VER.get(); - - String usrVer = U.DFLT_USER_VERSION; - - InputStream in = ldr.getResourceAsStream(IGNITE_XML_PATH); - - if (in != null) { - // Note: use ByteArrayResource instead of InputStreamResource because - // InputStreamResource doesn't work. - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - try { - U.copy(in, out); - - DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); - - XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); - - reader.loadBeanDefinitions(new ByteArrayResource(out.toByteArray())); - - usrVer = (String)factory.getBean("userVersion"); - - usrVer = usrVer == null ? U.DFLT_USER_VERSION : usrVer.trim(); - } - catch (NoSuchBeanDefinitionException ignored) { - if (log.isInfoEnabled()) - log.info("User version is not explicitly defined (will use default version) [file=" + - IGNITE_XML_PATH + ", clsLdr=" + ldr + ']'); - - usrVer = U.DFLT_USER_VERSION; - } - catch (BeansException e) { - U.error(log, "Failed to parse Spring XML file (will use default user version) [file=" + - IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e); - - usrVer = U.DFLT_USER_VERSION; - } - catch (IOException e) { - U.error(log, "Failed to read Spring XML file (will use default user version) [file=" + - IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e); - - usrVer = U.DFLT_USER_VERSION; - } - finally { - U.close(out, log); - } - } - - // For system class loader return cached version. - if (ldr == U.gridClassLoader()) - SYS_LDR_VER.compareAndSet(null, usrVer); - - return usrVer; - } - - /** - * Gets bean configuration. - * - * @param ctx Spring context. - * @param beanCls Bean class. - * @return Spring bean. - */ - @Nullable private static <T> T bean(ListableBeanFactory ctx, Class<T> beanCls) { - Map.Entry<String, T> entry = F.firstEntry(ctx.getBeansOfType(beanCls)); - - return entry == null ? null : entry.getValue(); - } - - /** - * Creates Spring application context. Optionally excluded properties can be specified, - * it means that if such a property is found in {@link org.apache.ignite.configuration.IgniteConfiguration} - * then it is removed before the bean is instantiated. - * For example, {@code streamerConfiguration} can be excluded from the configs that Visor uses. - * - * @param cfgUrl Resource where config file is located. - * @param excludedProps Properties to be excluded. - * @return Spring application context. - * @throws IgniteCheckedException If configuration could not be read. - */ - public static ApplicationContext applicationContext(URL cfgUrl, final String... excludedProps) throws IgniteCheckedException { - try { - GenericApplicationContext springCtx = new GenericApplicationContext(); - - BeanFactoryPostProcessor postProc = new BeanFactoryPostProcessor() { - @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) - throws BeansException { - for (String beanName : beanFactory.getBeanDefinitionNames()) { - BeanDefinition def = beanFactory.getBeanDefinition(beanName); - - if (def.getBeanClassName() != null) { - try { - Class.forName(def.getBeanClassName()); - } - catch (ClassNotFoundException ignored) { - ((BeanDefinitionRegistry) beanFactory).removeBeanDefinition(beanName); - - continue; - } - } - - MutablePropertyValues vals = def.getPropertyValues(); - - for (PropertyValue val : new ArrayList<>(vals.getPropertyValueList())) { - for (String excludedProp : excludedProps) { - if (val.getName().equals(excludedProp)) - vals.removePropertyValue(val); - } - } - } - } - }; - - springCtx.addBeanFactoryPostProcessor(postProc); - - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); - - springCtx.refresh(); - - return springCtx; - } - catch (BeansException e) { - if (X.hasCause(e, ClassNotFoundException.class)) - throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + - "(make sure all classes used in Spring configuration are present at CLASSPATH) " + - "[springUrl=" + cfgUrl + ']', e); - else - throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + - cfgUrl + ", err=" + e.getMessage() + ']', e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java ---------------------------------------------------------------------- diff --git a/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java new file mode 100644 index 0000000..0c69b53 --- /dev/null +++ b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java @@ -0,0 +1,301 @@ +/* + * 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.internal.util.spring; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.resource.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; +import org.springframework.beans.*; +import org.springframework.beans.factory.*; +import org.springframework.beans.factory.config.*; +import org.springframework.beans.factory.support.*; +import org.springframework.beans.factory.xml.*; +import org.springframework.context.*; +import org.springframework.context.support.*; +import org.springframework.core.io.*; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.concurrent.atomic.*; + +/** + * Spring configuration helper. + */ +public class IgniteSpringHelperImpl implements IgniteSpringHelper { + /** Path to {@code ignite.xml} file. */ + public static final String IGNITE_XML_PATH = "META-INF/ignite.xml"; + + /** System class loader user version. */ + private static final AtomicReference<String> SYS_LDR_VER = new AtomicReference<>(null); + + /** + * Try to execute LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", null) + * to turn off default logging for Spring Framework. + */ + static { + Class<?> logFactoryCls = null; + + try { + logFactoryCls = Class.forName("org.apache.commons.logging.LogFactory"); + } + catch (ClassNotFoundException ignored) { + // No-op. + } + + if (logFactoryCls != null) { + try { + Object factory = logFactoryCls.getMethod("getFactory").invoke(null); + + factory.getClass().getMethod("setAttribute", String.class, Object.class). + invoke(factory, "org.apache.commons.logging.Log", null); + } + catch (Exception ignored) { + // No-op. + } + } + } + + /** {@inheritDoc} */ + @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> loadConfigurations( + URL cfgUrl, String... excludedProps) throws IgniteCheckedException { + return loadConfigurations(cfgUrl, IgniteConfiguration.class, excludedProps); + } + + /** {@inheritDoc} */ + @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext> loadConfigurations( + URL cfgUrl, Class<T> cl, String... excludedProps) throws IgniteCheckedException { + ApplicationContext springCtx = applicationContext(cfgUrl, excludedProps); + Map<String, T> cfgMap; + + try { + cfgMap = springCtx.getBeansOfType(cl); + } + catch (BeansException e) { + throw new IgniteCheckedException("Failed to instantiate bean [type=" + cl + + ", err=" + e.getMessage() + ']', e); + } + + if (cfgMap == null || cfgMap.isEmpty()) + throw new IgniteCheckedException("Failed to find configuration in: " + cfgUrl); + + return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx)); + } + + /** {@inheritDoc} */ + @Override public Map<Class<?>, Object> loadBeans(URL cfgUrl, Class<?>... beanClasses) throws IgniteCheckedException { + assert beanClasses.length > 0; + + ApplicationContext springCtx = initContext(cfgUrl); + + Map<Class<?>, Object> beans = new HashMap<>(); + + for (Class<?> cls : beanClasses) + beans.put(cls, bean(springCtx, cls)); + + return beans; + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public <T> T loadBean(URL url, String beanName) throws IgniteCheckedException { + ApplicationContext springCtx = initContext(url); + + try { + return (T)springCtx.getBean(beanName); + } + catch (NoSuchBeanDefinitionException e) { + throw new IgniteCheckedException("Spring bean with provided name doesn't exist [url=" + url + + ", beanName=" + beanName + ']'); + } + catch (BeansException e) { + throw new IgniteCheckedException("Failed to load Spring bean with provided name [url=" + url + + ", beanName=" + beanName + ']', e); + } + } + + /** + * @param url XML file URL. + * @return Context. + * @throws IgniteCheckedException In case of error. + */ + private ApplicationContext initContext(URL url) throws IgniteCheckedException { + GenericApplicationContext springCtx; + + try { + springCtx = new GenericApplicationContext(); + + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(url)); + + springCtx.refresh(); + } + catch (BeansException e) { + if (X.hasCause(e, ClassNotFoundException.class)) + throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + + "[springUrl=" + url + ']', e); + else + throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + + url + ", err=" + e.getMessage() + ']', e); + } + + return springCtx; + } + + /** {@inheritDoc} */ + @Override public String userVersion(ClassLoader ldr, IgniteLogger log) { + assert ldr != null; + assert log != null; + + // For system class loader return cached version. + if (ldr == U.gridClassLoader() && SYS_LDR_VER.get() != null) + return SYS_LDR_VER.get(); + + String usrVer = U.DFLT_USER_VERSION; + + InputStream in = ldr.getResourceAsStream(IGNITE_XML_PATH); + + if (in != null) { + // Note: use ByteArrayResource instead of InputStreamResource because + // InputStreamResource doesn't work. + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + try { + U.copy(in, out); + + DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); + + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); + + reader.loadBeanDefinitions(new ByteArrayResource(out.toByteArray())); + + usrVer = (String)factory.getBean("userVersion"); + + usrVer = usrVer == null ? U.DFLT_USER_VERSION : usrVer.trim(); + } + catch (NoSuchBeanDefinitionException ignored) { + if (log.isInfoEnabled()) + log.info("User version is not explicitly defined (will use default version) [file=" + + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']'); + + usrVer = U.DFLT_USER_VERSION; + } + catch (BeansException e) { + U.error(log, "Failed to parse Spring XML file (will use default user version) [file=" + + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e); + + usrVer = U.DFLT_USER_VERSION; + } + catch (IOException e) { + U.error(log, "Failed to read Spring XML file (will use default user version) [file=" + + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e); + + usrVer = U.DFLT_USER_VERSION; + } + finally { + U.close(out, log); + } + } + + // For system class loader return cached version. + if (ldr == U.gridClassLoader()) + SYS_LDR_VER.compareAndSet(null, usrVer); + + return usrVer; + } + + /** + * Gets bean configuration. + * + * @param ctx Spring context. + * @param beanCls Bean class. + * @return Spring bean. + */ + @Nullable private static <T> T bean(ListableBeanFactory ctx, Class<T> beanCls) { + Map.Entry<String, T> entry = F.firstEntry(ctx.getBeansOfType(beanCls)); + + return entry == null ? null : entry.getValue(); + } + + /** + * Creates Spring application context. Optionally excluded properties can be specified, + * it means that if such a property is found in {@link org.apache.ignite.configuration.IgniteConfiguration} + * then it is removed before the bean is instantiated. + * For example, {@code streamerConfiguration} can be excluded from the configs that Visor uses. + * + * @param cfgUrl Resource where config file is located. + * @param excludedProps Properties to be excluded. + * @return Spring application context. + * @throws IgniteCheckedException If configuration could not be read. + */ + public static ApplicationContext applicationContext(URL cfgUrl, final String... excludedProps) throws IgniteCheckedException { + try { + GenericApplicationContext springCtx = new GenericApplicationContext(); + + BeanFactoryPostProcessor postProc = new BeanFactoryPostProcessor() { + @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) + throws BeansException { + for (String beanName : beanFactory.getBeanDefinitionNames()) { + BeanDefinition def = beanFactory.getBeanDefinition(beanName); + + if (def.getBeanClassName() != null) { + try { + Class.forName(def.getBeanClassName()); + } + catch (ClassNotFoundException ignored) { + ((BeanDefinitionRegistry) beanFactory).removeBeanDefinition(beanName); + + continue; + } + } + + MutablePropertyValues vals = def.getPropertyValues(); + + for (PropertyValue val : new ArrayList<>(vals.getPropertyValueList())) { + for (String excludedProp : excludedProps) { + if (val.getName().equals(excludedProp)) + vals.removePropertyValue(val); + } + } + } + } + }; + + springCtx.addBeanFactoryPostProcessor(postProc); + + new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); + + springCtx.refresh(); + + return springCtx; + } + catch (BeansException e) { + if (X.hasCause(e, ClassNotFoundException.class)) + throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + + "[springUrl=" + cfgUrl + ']', e); + else + throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + + cfgUrl + ", err=" + e.getMessage() + ']', e); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelperImpl.java ---------------------------------------------------------------------- diff --git a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelperImpl.java b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelperImpl.java new file mode 100644 index 0000000..cccf678 --- /dev/null +++ b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshHelperImpl.java @@ -0,0 +1,28 @@ +/* + * 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.internal.util.nodestart; + +/** + * Implementation of {@link IgniteSshHelper}. + */ +public class IgniteSshHelperImpl implements IgniteSshHelper { + /** {@inheritDoc} */ + @Override public IgniteNodeCallable nodeStartCallable(IgniteRemoteStartSpecification spec, int timeout) { + return new IgniteNodeCallableImpl(spec, timeout); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessorImpl.java b/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessorImpl.java deleted file mode 100644 index 723ce35..0000000 --- a/modules/ssh/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessorImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.internal.util.nodestart; - -/** - * Implementation of {@link IgniteSshProcessor}. - */ -public class IgniteSshProcessorImpl implements IgniteSshProcessor { - /** {@inheritDoc} */ - @Override public IgniteNodeCallable nodeStartCallable(IgniteRemoteStartSpecification spec, int timeout) { - return new IgniteNodeCallableImpl(spec, timeout); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0106f48f/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala ---------------------------------------------------------------------- diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala index bb41faa..9005cfe 100644 --- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala +++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala @@ -28,7 +28,6 @@ import org.apache.ignite.internal.IgniteEx import org.apache.ignite.internal.IgniteNodeAttributes._ import org.apache.ignite.internal.IgniteVersionUtils._ import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException -import org.apache.ignite.internal.processors.spring.IgniteSpringProcessor import org.apache.ignite.internal.util.lang.{GridFunc => F} import org.apache.ignite.internal.util.typedef._ import org.apache.ignite.internal.util.{GridConfigurationFinder, IgniteUtils => U} @@ -53,6 +52,7 @@ import scala.collection.JavaConversions._ import scala.collection.immutable import scala.language.{implicitConversions, reflectiveCalls} import scala.util.control.Breaks._ +import org.apache.ignite.internal.util.spring.IgniteSpringHelper /** * Holder for command help information. @@ -1509,7 +1509,7 @@ object visor extends VisorTag { else null - val spring: IgniteSpringProcessor = SPRING.create(false) + val spring: IgniteSpringHelper = SPRING.create(false) val cfgs = try