/* * Copyright 2005 The Apache Software Foundation * * Licensed 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.felix.mosgi.jmx.remotelogger; import org.osgi.framework.Bundle; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; import org.osgi.framework.BundleException; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceEvent; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.Constants; import org.osgi.service.log.LogListener; import org.osgi.service.log.LogReaderService; import org.osgi.service.log.LogService; import org.osgi.service.log.LogEntry; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.NotificationBroadcasterSupport; import javax.management.AttributeChangeNotification; import javax.management.MalformedObjectNameException; import java.io.Serializable; import java.util.Enumeration; import java.util.Vector; public class Logger extends NotificationBroadcasterSupport implements LogListener,BundleActivator,ServiceListener, LoggerMBean, Serializable{ private static final String REMOTE_LOGGER_ON_STRING="OSGI:name=Remote Logger"; private ServiceRegistration mbean_sr=null; private String version=null; private LogReaderService lrs=null; private BundleContext bc=null; private Object logMutex=new Object(); private static final String[] LOG_LVL=new String[] {"","ERROR ","WARNING ","INFO ","DEBUG "}; private Integer logLvl=new Integer(4); private ObjectName remoteLoggerON=null; ///////////////////////////////// // LogerMBean Interface // ///////////////////////////////// public void sendOldLog(){ System.out.println("[remoteLogger.Logger] send old log"); Enumeration oldLog = this.lrs.getLog(); Vector invert=new Vector(); while(oldLog.hasMoreElements()) { LogEntry le=(LogEntry) (oldLog.nextElement()); invert.insertElementAt(le,0); } for (int i=0 ; i