# ignite-63
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/85840a5b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/85840a5b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/85840a5b Branch: refs/heads/ignite-63 Commit: 85840a5bfc4153f74f825c8b611ff2991a488cd1 Parents: 39bc425 Author: sboikov <sboi...@gridgain.com> Authored: Fri Jan 23 10:39:01 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Jan 23 10:39:01 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/logger/jcl/GridJclLogger.java | 170 +++++++++++++++++++ .../org/apache/ignite/logger/jcl/package.html | 23 +++ .../gridgain/grid/logger/jcl/GridJclLogger.java | 170 ------------------- .../org/gridgain/grid/logger/jcl/package.html | 23 --- .../ignite/logger/jcl/GridJclLoggerTest.java | 48 ++++++ .../org/apache/ignite/logger/jcl/package.html | 23 +++ .../testsuites/bamboo/GridJclTestSuite.java | 2 +- .../grid/logger/jcl/GridJclLoggerTest.java | 48 ------ .../org/gridgain/grid/logger/jcl/package.html | 23 --- 9 files changed, 265 insertions(+), 265 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/GridJclLogger.java ---------------------------------------------------------------------- diff --git a/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/GridJclLogger.java b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/GridJclLogger.java new file mode 100644 index 0000000..c8a1c34 --- /dev/null +++ b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/GridJclLogger.java @@ -0,0 +1,170 @@ +/* + * 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.logger.jcl; + +import org.apache.commons.logging.*; +import org.apache.ignite.*; +import org.jetbrains.annotations.*; + +/** + * This logger wraps any JCL (<a target=_blank href="http://jakarta.apache.org/commons/logging/">Jakarta Commons Logging</a>) + * loggers. Implementation simply delegates to underlying JCL logger. This logger + * should be used by loaders that have JCL-based internal logging (e.g., Websphere). + * <p> + * Here is an example of configuring JCL logger in GridGain configuration Spring + * file to work over log4j implementation. Note that we use the same configuration file + * as we provide by default: + * <pre name="code" class="xml"> + * ... + * <property name="gridLogger"> + * <bean class="org.apache.ignite.logger.jcl.GridJclLogger"> + * <constructor-arg type="org.apache.commons.logging.Log"> + * <bean class="org.apache.commons.logging.impl.Log4JLogger"> + * <constructor-arg type="java.lang.String" value="config/gridgain-log4j.xml"/> + * </bean> + * </constructor-arg> + * </bean> + * </property> + * ... + * </pre> + * If you are using system properties to configure JCL logger use following configuration: + * <pre name="code" class="xml"> + * ... + * <property name="gridLogger"> + * <bean class="org.apache.ignite.logger.jcl.GridJclLogger"/> + * </property> + * ... + * </pre> + * And the same configuration if you'd like to configure GridGain in your code: + * <pre name="code" class="java"> + * GridConfiguration cfg = new GridConfiguration(); + * ... + * GridLogger log = new GridJclLogger(new Log4JLogger("config/gridgain-log4j.xml")); + * ... + * cfg.setGridLogger(log); + * </pre> + * or following for the configuration by means of system properties: + * <pre name="code" class="java"> + * GridConfiguration cfg = new GridConfiguration(); + * ... + * GridLogger log = new GridJclLogger(); + * ... + * cfg.setGridLogger(log); + * </pre> + * + * <p> + * It's recommended to use GridGain logger injection instead of using/instantiating + * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource} annotation about logger + * injection. + */ +public class GridJclLogger implements IgniteLogger { + /** */ + private static final long serialVersionUID = 0L; + + /** JCL implementation proxy. */ + private Log impl; + + /** + * Creates new logger. + */ + public GridJclLogger() { + this(LogFactory.getLog(GridJclLogger.class.getName())); + } + + /** + * Creates new logger with given implementation. + * + * @param impl JCL implementation to use. + */ + public GridJclLogger(Log impl) { + assert impl != null; + + this.impl = impl; + } + + /** {@inheritDoc} */ + @Override public IgniteLogger getLogger(Object ctgr) { + return new GridJclLogger(LogFactory.getLog( + ctgr instanceof Class ? ((Class)ctgr).getName() : String.valueOf(ctgr))); + } + + /** {@inheritDoc} */ + @Override public void trace(String msg) { + impl.trace(msg); + } + + /** {@inheritDoc} */ + @Override public void debug(String msg) { + impl.debug(msg); + } + + /** {@inheritDoc} */ + @Override public void info(String msg) { + impl.info(msg); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg) { + impl.warn(msg); + } + + /** {@inheritDoc} */ + @Override public void warning(String msg, @Nullable Throwable e) { + impl.warn(msg, e); + } + + /** {@inheritDoc} */ + @Override public void error(String msg) { + impl.error(msg); + } + + /** {@inheritDoc} */ + @Override public boolean isQuiet() { + return !isInfoEnabled() && !isDebugEnabled(); + } + + /** {@inheritDoc} */ + @Override public void error(String msg, @Nullable Throwable e) { + impl.error(msg, e); + } + + /** {@inheritDoc} */ + @Override public boolean isTraceEnabled() { + return impl.isTraceEnabled(); + } + + /** {@inheritDoc} */ + @Override public boolean isDebugEnabled() { + return impl.isDebugEnabled(); + } + + /** {@inheritDoc} */ + @Override public boolean isInfoEnabled() { + return impl.isInfoEnabled(); + } + + /** {@inheritDoc} */ + @Nullable @Override public String fileName() { + return null; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "GridJclLogger [impl=" + impl + ']'; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/package.html ---------------------------------------------------------------------- diff --git a/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/package.html b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/package.html new file mode 100644 index 0000000..d39af55 --- /dev/null +++ b/modules/jcl/src/main/java/org/apache/ignite/logger/jcl/package.html @@ -0,0 +1,23 @@ +<!-- + 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. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains Jakarta commons logging implementation for logging. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java ---------------------------------------------------------------------- diff --git a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java deleted file mode 100644 index 8f54592..0000000 --- a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/GridJclLogger.java +++ /dev/null @@ -1,170 +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.gridgain.grid.logger.jcl; - -import org.apache.commons.logging.*; -import org.apache.ignite.*; -import org.jetbrains.annotations.*; - -/** - * This logger wraps any JCL (<a target=_blank href="http://jakarta.apache.org/commons/logging/">Jakarta Commons Logging</a>) - * loggers. Implementation simply delegates to underlying JCL logger. This logger - * should be used by loaders that have JCL-based internal logging (e.g., Websphere). - * <p> - * Here is an example of configuring JCL logger in GridGain configuration Spring - * file to work over log4j implementation. Note that we use the same configuration file - * as we provide by default: - * <pre name="code" class="xml"> - * ... - * <property name="gridLogger"> - * <bean class="org.gridgain.grid.logger.jcl.GridJclLogger"> - * <constructor-arg type="org.apache.commons.logging.Log"> - * <bean class="org.apache.commons.logging.impl.Log4JLogger"> - * <constructor-arg type="java.lang.String" value="config/gridgain-log4j.xml"/> - * </bean> - * </constructor-arg> - * </bean> - * </property> - * ... - * </pre> - * If you are using system properties to configure JCL logger use following configuration: - * <pre name="code" class="xml"> - * ... - * <property name="gridLogger"> - * <bean class="org.gridgain.grid.logger.jcl.GridJclLogger"/> - * </property> - * ... - * </pre> - * And the same configuration if you'd like to configure GridGain in your code: - * <pre name="code" class="java"> - * GridConfiguration cfg = new GridConfiguration(); - * ... - * GridLogger log = new GridJclLogger(new Log4JLogger("config/gridgain-log4j.xml")); - * ... - * cfg.setGridLogger(log); - * </pre> - * or following for the configuration by means of system properties: - * <pre name="code" class="java"> - * GridConfiguration cfg = new GridConfiguration(); - * ... - * GridLogger log = new GridJclLogger(); - * ... - * cfg.setGridLogger(log); - * </pre> - * - * <p> - * It's recommended to use GridGain logger injection instead of using/instantiating - * logger in your task/job code. See {@link org.apache.ignite.resources.IgniteLoggerResource} annotation about logger - * injection. - */ -public class GridJclLogger implements IgniteLogger { - /** */ - private static final long serialVersionUID = 0L; - - /** JCL implementation proxy. */ - private Log impl; - - /** - * Creates new logger. - */ - public GridJclLogger() { - this(LogFactory.getLog(GridJclLogger.class.getName())); - } - - /** - * Creates new logger with given implementation. - * - * @param impl JCL implementation to use. - */ - public GridJclLogger(Log impl) { - assert impl != null; - - this.impl = impl; - } - - /** {@inheritDoc} */ - @Override public IgniteLogger getLogger(Object ctgr) { - return new GridJclLogger(LogFactory.getLog( - ctgr instanceof Class ? ((Class)ctgr).getName() : String.valueOf(ctgr))); - } - - /** {@inheritDoc} */ - @Override public void trace(String msg) { - impl.trace(msg); - } - - /** {@inheritDoc} */ - @Override public void debug(String msg) { - impl.debug(msg); - } - - /** {@inheritDoc} */ - @Override public void info(String msg) { - impl.info(msg); - } - - /** {@inheritDoc} */ - @Override public void warning(String msg) { - impl.warn(msg); - } - - /** {@inheritDoc} */ - @Override public void warning(String msg, @Nullable Throwable e) { - impl.warn(msg, e); - } - - /** {@inheritDoc} */ - @Override public void error(String msg) { - impl.error(msg); - } - - /** {@inheritDoc} */ - @Override public boolean isQuiet() { - return !isInfoEnabled() && !isDebugEnabled(); - } - - /** {@inheritDoc} */ - @Override public void error(String msg, @Nullable Throwable e) { - impl.error(msg, e); - } - - /** {@inheritDoc} */ - @Override public boolean isTraceEnabled() { - return impl.isTraceEnabled(); - } - - /** {@inheritDoc} */ - @Override public boolean isDebugEnabled() { - return impl.isDebugEnabled(); - } - - /** {@inheritDoc} */ - @Override public boolean isInfoEnabled() { - return impl.isInfoEnabled(); - } - - /** {@inheritDoc} */ - @Nullable @Override public String fileName() { - return null; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "GridJclLogger [impl=" + impl + ']'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/package.html ---------------------------------------------------------------------- diff --git a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/package.html b/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/package.html deleted file mode 100644 index d39af55..0000000 --- a/modules/jcl/src/main/java/org/gridgain/grid/logger/jcl/package.html +++ /dev/null @@ -1,23 +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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains Jakarta commons logging implementation for logging. -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/GridJclLoggerTest.java ---------------------------------------------------------------------- diff --git a/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/GridJclLoggerTest.java b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/GridJclLoggerTest.java new file mode 100644 index 0000000..d639b1e --- /dev/null +++ b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/GridJclLoggerTest.java @@ -0,0 +1,48 @@ +/* + * 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.logger.jcl; + +import junit.framework.*; +import org.apache.commons.logging.*; +import org.apache.ignite.*; +import org.apache.ignite.testframework.junits.common.*; + +/** + * Jcl logger test. + */ +@GridCommonTest(group = "Logger") +public class GridJclLoggerTest extends TestCase { + /** */ + @SuppressWarnings({"FieldCanBeLocal"}) + private IgniteLogger log; + + /** */ + public void testLogInitialize() { + log = new GridJclLogger(LogFactory.getLog(GridJclLoggerTest.class.getName())); + + assert log.isInfoEnabled() == true; + + log.info("This is 'info' message."); + log.warning("This is 'warning' message."); + log.warning("This is 'warning' message.", new Exception("It's a test warning exception")); + log.error("This is 'error' message."); + log.error("This is 'error' message.", new Exception("It's a test error exception")); + + assert log.getLogger(GridJclLoggerTest.class.getName()) instanceof GridJclLogger; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/package.html ---------------------------------------------------------------------- diff --git a/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/package.html b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/package.html new file mode 100644 index 0000000..1f85ff2 --- /dev/null +++ b/modules/jcl/src/test/java/org/apache/ignite/logger/jcl/package.html @@ -0,0 +1,23 @@ +<!-- + 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. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains internal tests or test related classes and interfaces. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/test/java/org/apache/ignite/testsuites/bamboo/GridJclTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/jcl/src/test/java/org/apache/ignite/testsuites/bamboo/GridJclTestSuite.java b/modules/jcl/src/test/java/org/apache/ignite/testsuites/bamboo/GridJclTestSuite.java index e06c82b..6554142 100644 --- a/modules/jcl/src/test/java/org/apache/ignite/testsuites/bamboo/GridJclTestSuite.java +++ b/modules/jcl/src/test/java/org/apache/ignite/testsuites/bamboo/GridJclTestSuite.java @@ -18,7 +18,7 @@ package org.apache.ignite.testsuites.bamboo; import junit.framework.*; -import org.gridgain.grid.logger.jcl.*; +import org.apache.ignite.logger.jcl.*; /** * Commons logging test. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/GridJclLoggerTest.java ---------------------------------------------------------------------- diff --git a/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/GridJclLoggerTest.java b/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/GridJclLoggerTest.java deleted file mode 100644 index 7d4b09a..0000000 --- a/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/GridJclLoggerTest.java +++ /dev/null @@ -1,48 +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.gridgain.grid.logger.jcl; - -import junit.framework.*; -import org.apache.commons.logging.*; -import org.apache.ignite.*; -import org.apache.ignite.testframework.junits.common.*; - -/** - * Jcl logger test. - */ -@GridCommonTest(group = "Logger") -public class GridJclLoggerTest extends TestCase { - /** */ - @SuppressWarnings({"FieldCanBeLocal"}) - private IgniteLogger log; - - /** */ - public void testLogInitialize() { - log = new GridJclLogger(LogFactory.getLog(GridJclLoggerTest.class.getName())); - - assert log.isInfoEnabled() == true; - - log.info("This is 'info' message."); - log.warning("This is 'warning' message."); - log.warning("This is 'warning' message.", new Exception("It's a test warning exception")); - log.error("This is 'error' message."); - log.error("This is 'error' message.", new Exception("It's a test error exception")); - - assert log.getLogger(GridJclLoggerTest.class.getName()) instanceof GridJclLogger; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/85840a5b/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/package.html ---------------------------------------------------------------------- diff --git a/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/package.html b/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/package.html deleted file mode 100644 index 1f85ff2..0000000 --- a/modules/jcl/src/test/java/org/gridgain/grid/logger/jcl/package.html +++ /dev/null @@ -1,23 +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. - --> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<body> - <!-- Package description. --> - Contains internal tests or test related classes and interfaces. -</body> -</html>