From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/monitor/Monitor.java | 35 +++++++++++ .../apache/tuscany/sca/monitor/MonitorFactory.java | 35 +++++++++++ .../org/apache/tuscany/sca/monitor/Problem.java | 49 +++++++++++++++ .../monitor/impl/DefaultMonitorFactoryImpl.java | 41 +++++++++++++ .../sca/monitor/impl/DefaultMonitorImpl.java | 70 ++++++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java create mode 100644 sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java create mode 100644 sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java create mode 100644 sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorFactoryImpl.java create mode 100644 sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorImpl.java (limited to 'sandbox/axis2-1.4/modules/monitor/src/main/java') diff --git a/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java new file mode 100644 index 0000000000..863df16b41 --- /dev/null +++ b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java @@ -0,0 +1,35 @@ +/* + * 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.tuscany.sca.monitor; + +/** + * A monitor for the watching for validation problems + * + * @version $Rev$ $Date$ + */ +public interface Monitor { + /** + * Reports a build problem. + * + * @param problem + */ + void problem(Problem problem); + +} diff --git a/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java new file mode 100644 index 0000000000..38c3bbd991 --- /dev/null +++ b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java @@ -0,0 +1,35 @@ +/* + * 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.tuscany.sca.monitor; + +/** + * A factory for validation monitors + * + * @version $Rev$ $Date$ + */ +public interface MonitorFactory { + + /** + * Create a new monitor + * + * @return a new monitor + */ + Monitor createMonitor(); + +} diff --git a/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java new file mode 100644 index 0000000000..83a2d63eae --- /dev/null +++ b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java @@ -0,0 +1,49 @@ +/* + * 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.tuscany.sca.monitor; + + +/** + * Records an validation problem. + * + * @version $Rev$ $Date$ + */ +public interface Problem { + + public enum Severity { + INFO, + WARNING, + ERROR + } + + String getSourceClassName(); + + String getBundleName(); + + Severity getSeverity(); + + Object getProblemObject(); + + String getMessageId(); + + Exception getCause(); + + Object[] getMessageParams(); +} diff --git a/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorFactoryImpl.java b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorFactoryImpl.java new file mode 100644 index 0000000000..274b4faefd --- /dev/null +++ b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorFactoryImpl.java @@ -0,0 +1,41 @@ +/* + * 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.tuscany.sca.monitor.impl; + +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; + + +/** + * A factory for creating validation monitors + * + * @version $Rev$ $Date$ + */ +public class DefaultMonitorFactoryImpl implements MonitorFactory { + + private Monitor monitor = null; + + public Monitor createMonitor() { + if (monitor == null){ + monitor = new DefaultMonitorImpl(); + } + return monitor ; + } +} diff --git a/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorImpl.java b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorImpl.java new file mode 100644 index 0000000000..afe9d52e6f --- /dev/null +++ b/sandbox/axis2-1.4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/DefaultMonitorImpl.java @@ -0,0 +1,70 @@ +/* + * 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.tuscany.sca.monitor.impl; + +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; + +/** + * A monitor for the watching for validation problems + * + * @version $Rev$ $Date$ + */ +public class DefaultMonitorImpl implements Monitor { + private static final Logger logger = Logger.getLogger(DefaultMonitorImpl.class.getName()); + + // remembers the last logged problem for testing purposes + private Problem lastProblem = null; + + /** + * Reports a build problem. + * + * @param problem + */ + public void problem(Problem problem) { + + lastProblem = problem; + + Logger problemLogger = Logger.getLogger(problem.getSourceClassName(), problem.getBundleName()); + + if (problemLogger == null){ + logger.severe("Can't get logger " + problem.getSourceClassName()+ " with bundle " + problem.getBundleName()); + } + + if (problem.getSeverity() == Severity.INFO) { + problemLogger.log(Level.INFO, problem.getMessageId(), problem.getMessageParams()); + } else if (problem.getSeverity() == Severity.WARNING) { + problemLogger.log(Level.WARNING, problem.getMessageId(), problem.getMessageParams()); + } else if (problem.getSeverity() == Severity.ERROR) { + if (problem.getCause() != null) { + problemLogger.log(Level.SEVERE, problem.getMessageId(), problem.getCause()); + } else { + problemLogger.log(Level.SEVERE, problem.getMessageId(), problem.getMessageParams()); + } + } + } + + public Problem getLastLoggedProblem(){ + return lastProblem; + } +} -- cgit v1.2.3