[jboss-osgi-commits] JBoss-OSGI SVN: r87183 - projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon Apr 13 09:48:51 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-04-13 09:48:51 -0400 (Mon, 13 Apr 2009)
New Revision: 87183

Added:
   projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java
Log:
First pass of remote logging service

Added: projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java
===================================================================
--- projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java	2009-04-13 13:48:51 UTC (rev 87183)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.service.remlog;
+
+//$Id$
+
+import java.util.Properties;
+
+import org.jboss.osgi.service.log.RemoteLogReaderService;
+import org.jboss.osgi.service.remlog.internal.RemoteLogReaderServiceImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * [TODO]
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class RemoteLogActivator implements BundleActivator
+{
+   public static final String REMOTE_LOG_SENDER = "org.jboss.osgi.service.remote.log.sender";
+   public static final String REMOTE_LOG_READER = "org.jboss.osgi.service.remote.log.reader";
+   public static final String REMOTE_LOG_HOST = "org.jboss.osgi.service.remote.log.host";
+   public static final String REMOTE_LOG_PORT = "org.jboss.osgi.service.remote.log.port";
+   
+   private Boolean isReader = Boolean.FALSE;
+   private Boolean isSender = Boolean.FALSE;
+   private RemoteLogReaderServiceImpl readerService;
+   private ServiceRegistration readerRegistration;
+   private RemoteLogListener remoteSender;
+   
+   public void start(BundleContext context)
+   {
+      String readerProp = context.getProperty(REMOTE_LOG_READER);
+      String senderProp = context.getProperty(REMOTE_LOG_SENDER);
+      String hostProp = context.getProperty(REMOTE_LOG_HOST);
+      String portProp = context.getProperty(REMOTE_LOG_PORT);
+      
+      if (readerProp != null)
+         isReader = Boolean.valueOf(readerProp);
+      
+      if (senderProp != null)
+         isSender = Boolean.valueOf(senderProp);
+      
+      String host = hostProp != null ? hostProp : "localhost";
+      String port = portProp != null ? portProp : "5400";
+      
+      Properties props = new Properties();
+      props.put(REMOTE_LOG_HOST, host);
+      props.put(REMOTE_LOG_PORT, port);
+      
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+         
+         if (isReader == true)
+         {
+            readerService = new RemoteLogReaderServiceImpl(context, props);
+            readerRegistration = context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
+            readerService.start();
+         }
+         
+         if (isSender == true)
+         {
+            remoteSender = new RemoteLogListener(context, props);
+            remoteSender.start();
+         }
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(ctxLoader);
+      }
+   }
+
+   public void stop(BundleContext context) throws Exception
+   {
+      if (isReader == true)
+      {
+         readerRegistration.unregister();
+         readerRegistration = null;
+         
+         readerService.stop();
+         readerService = null;
+      }
+
+      if (isSender == true)
+      {
+         remoteSender.stop();
+         remoteSender = null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/service/remote-log/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jboss-osgi-commits mailing list