[jboss-osgi-commits] JBoss-OSGI SVN: r87178 - in projects/jboss-osgi/trunk: runtime/spi/src/main/java/org/jboss/osgi/service/log and 12 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Sun Apr 12 18:17:11 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-04-12 18:17:09 -0400 (Sun, 12 Apr 2009)
New Revision: 87178
Added:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/LogEntryImpl.java
projects/jboss-osgi/trunk/service/remlog/
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/NotImplementedException.java
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java
Removed:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiStateFormat.java
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/logging/
Modified:
projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/FrameworkException.java
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/trunk/service/pom.xml
projects/jboss-osgi/trunk/service/remlog/.project
projects/jboss-osgi/trunk/service/remlog/pom.xml
projects/jboss-osgi/trunk/service/webconsole/pom.xml
projects/jboss-osgi/trunk/testsuite/pom.xml
projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java
Log:
Initial cut of remote logging service
Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -14,7 +14,19 @@
org.jboss.osgi.service.log,
org.osgi.framework; version=1.4,
org.osgi.service.log; version=1.3,
- org.osgi.util.tracker
+ org.osgi.util.tracker; version=1.3,
+
+ <!-- needed by jboss-remoting -->
+ javax.management,
+ javax.naming,
+ javax.net,
+ javax.net.ssl,
+ org.apache.log4j,
+ org.jboss.logging,
+ org.jboss.util,
+ org.jboss.util.id,
+ org.jboss.util.threadpool,
+ org.jboss.util.propertyeditor,
</value>
</entry>
</map>
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -23,14 +23,10 @@
//$Id$
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
+import org.jboss.osgi.service.log.internal.LogEntryImpl;
import org.osgi.service.log.LogEntry;
import org.osgi.service.log.LogListener;
@@ -91,7 +87,11 @@
}
/**
- * Get the list of cached entries
+ * Get the list of cached entries.
+ *
+ * Note, that the LogService delivers LogEntries asynchronously.
+ * Client should not rely on a certain LogEntry already beein delivered
+ * when calling this method.
*/
public List<LogEntry> getLog()
{
@@ -104,7 +104,7 @@
public void logged(LogEntry entry)
{
// Replace entry with a unified wrapper
- entry = new LogEntryWrapper(entry);
+ entry = new LogEntryImpl(entry);
if (filters.size() == 0)
{
@@ -143,57 +143,4 @@
return match;
}
-
- class LogEntryWrapper implements LogEntry
- {
- private LogEntry delegate;
-
-
- public LogEntryWrapper(LogEntry entry)
- {
- this.delegate = entry;
- }
-
- public Bundle getBundle()
- {
- return delegate.getBundle();
- }
-
- public Throwable getException()
- {
- return delegate.getException();
- }
-
- public int getLevel()
- {
- return delegate.getLevel();
- }
-
- public String getMessage()
- {
- return delegate.getMessage();
- }
-
- public ServiceReference getServiceReference()
- {
- return delegate.getServiceReference();
- }
-
- public long getTime()
- {
- return delegate.getTime();
- }
-
- @Override
- public String toString()
- {
- String time = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(getTime()));
- String level = " " + Constants.logLevel(getLevel());
- String sref = getServiceReference() != null ? ",sref=" + getServiceReference().getBundle().getSymbolicName() : "";
- String bundle = ",bnd=" + getBundle().getSymbolicName();
- String msg = ",msg=" + getMessage();
- String ex = getException() != null ? ",ex=" + getException().toString() : "";
- return "[" + time + level + bundle + sref + msg + ex + "]";
- }
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -23,7 +23,9 @@
//$Id$
-import org.jboss.osgi.spi.Constants;
+import org.jboss.osgi.service.log.internal.LogEntryImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -35,6 +37,13 @@
*/
public class SystemLogService implements LogService
{
+ private BundleContext context;
+
+ public SystemLogService(BundleContext context)
+ {
+ this.context = context;
+ }
+
public void log(int level, String message)
{
logInternal(null, level, message, null);
@@ -57,18 +66,11 @@
private void logInternal(ServiceReference sr, int level, String message, Throwable exception)
{
- StringBuffer buf = new StringBuffer();
- if (sr != null)
- {
- String symbolicName = sr.getBundle().getSymbolicName();
- buf.append(symbolicName + ": ");
- }
+ long time = System.currentTimeMillis();
+ Bundle bundle = context.getBundle();
- buf.append("[" + Constants.logLevel(level) +"] ");
-
- buf.append(message);
- System.out.println(buf);
-
+ System.out.println(new LogEntryImpl(time, bundle, sr, level, message, exception));
+
if (exception != null)
exception.printStackTrace(System.out);
}
Added: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/LogEntryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/LogEntryImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/LogEntryImpl.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -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.log.internal;
+
+// $Id$
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+
+/**
+ * A unified implementation of a LogEntry.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Apr-2009
+ */
+public class LogEntryImpl implements LogEntry
+{
+ private long time;
+ private int level;
+ private Bundle bundle;
+ private ServiceReference sref;
+ private String message;
+ private Throwable exception;
+
+ private String bndStr;
+ private String srefStr;
+
+ public LogEntryImpl(LogEntry le)
+ {
+ this(le.getTime(), le.getBundle(), le.getServiceReference(), le.getLevel(), le.getMessage(), le.getException());
+ }
+
+ public LogEntryImpl(long time, Bundle bundle, ServiceReference sref, int level, String message, Throwable exception)
+ {
+ this.time = time;
+ this.bundle = bundle;
+ this.sref = sref;
+ this.level = level;
+ this.message = message;
+ this.exception = exception;
+
+ if (bundle != null)
+ bndStr = bundle.getSymbolicName();
+
+ if (sref != null && sref.getBundle() != null)
+ srefStr = sref.getBundle().getSymbolicName();
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+ public int getLevel()
+ {
+ return level;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public ServiceReference getServiceReference()
+ {
+ return sref;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+
+ @Override
+ public String toString()
+ {
+ String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
+ String l = " " + Constants.logLevel(level);
+ String s = srefStr != null ? ",sref=" + srefStr : "";
+ String b = ",bnd=" + bndStr;
+ String m = ",msg=" + message;
+ String e = exception != null ? ",ex=" + exception : "";
+ return "[" + t + l + b + s + m + e + "]";
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/internal/LogEntryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/FrameworkException.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/FrameworkException.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/FrameworkException.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -37,9 +37,13 @@
super(message);
}
- public FrameworkException(String message, Exception cause)
+ public FrameworkException(String message, Throwable cause)
{
super(message, cause);
}
+ public FrameworkException(Throwable cause)
+ {
+ super(cause);
+ }
}
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -81,7 +81,7 @@
if (providerName == null)
throw new IllegalStateException("Cannot obtain bootstrap provider");
- // Load the config provider
+ // Load the bootstrap provider
try
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
Deleted: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiStateFormat.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiStateFormat.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiStateFormat.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -1,39 +0,0 @@
-/*
- * 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.spi.framework;
-
-//$Id$
-
-
-/**
- * A string format helper for OSGi states
- *
- * @author thomas.diesler at jboss.com
- * @since 02-Mar-2009
- */
-public abstract class OSGiStateFormat
-{
- // Hide ctor
- private OSGiStateFormat()
- {
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/service/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/service/pom.xml 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/service/pom.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -13,6 +13,7 @@
<modules>
<module>logging</module>
+ <module>remlog</module>
<module>webconsole</module>
</modules>
Copied: projects/jboss-osgi/trunk/service/remlog (from rev 87175, projects/jboss-osgi/trunk/service/logging)
Property changes on: projects/jboss-osgi/trunk/service/remlog
___________________________________________________________________
Name: svn:ignore
+ target
Name: svn:mergeinfo
+
Modified: projects/jboss-osgi/trunk/service/remlog/.project
===================================================================
--- projects/jboss-osgi/trunk/service/logging/.project 2009-04-12 09:08:42 UTC (rev 87175)
+++ projects/jboss-osgi/trunk/service/remlog/.project 2009-04-12 22:17:09 UTC (rev 87178)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jboss-osgi-service-logging</name>
+ <name>jboss-osgi-service-remlog</name>
<comment></comment>
<projects>
</projects>
Modified: projects/jboss-osgi/trunk/service/remlog/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/service/logging/pom.xml 2009-04-12 09:08:42 UTC (rev 87175)
+++ projects/jboss-osgi/trunk/service/remlog/pom.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -2,10 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - Service Logging</name>
+ <name>JBossOSGi - Service Remote Logging</name>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-service-logging</artifactId>
+ <artifactId>jboss-osgi-service-remlog</artifactId>
<packaging>bundle</packaging>
<!-- Parent -->
@@ -17,6 +17,9 @@
<!-- Properties -->
<properties>
+ <version.concurrent>1.3.4</version.concurrent>
+ <version.jboss.remoting>2.5.0.SP2</version.jboss.remoting>
+ <version.jboss.serialization>1.0.3.GA</version.jboss.serialization>
</properties>
<!-- Dependencies -->
@@ -31,11 +34,34 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
+
+ <!-- Remoting Dependencies -->
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <scope>provided</scope>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting-core</artifactId>
+ <version>${version.jboss.remoting}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting-socket</artifactId>
+ <version>${version.jboss.remoting}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting-socket-client</artifactId>
+ <version>${version.jboss.remoting}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-serialization</artifactId>
+ <version>${version.jboss.serialization}</version>
+ </dependency>
+ <dependency>
+ <groupId>concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>${version.concurrent}</version>
+ </dependency>
+
</dependencies>
<build>
@@ -46,15 +72,46 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Bundle-SymbolicName>org.jboss.osgi.service.logging</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.service.logging.LoggingServiceActivator</Bundle-Activator>
- <Private-Package>org.jboss.osgi.service.logging</Private-Package>
+ <Bundle-SymbolicName>org.jboss.osgi.service.remlog</Bundle-SymbolicName>
+ <Bundle-Activator>org.jboss.osgi.service.remlog.RemoteLogActivator</Bundle-Activator>
+ <Export-Package>org.jboss.osgi.service.remlog;version=${version}</Export-Package>
<Import-Package>
- org.jboss.logging,
org.osgi.framework,
org.osgi.service.log,
- org.osgi.util.tracker
+ org.osgi.util.tracker,
+
+ javax.crypto;resolution:=optional,
+ javax.crypto.spec;resolution:=optional,
+ javax.management,
+ javax.naming,
+ javax.net,
+ javax.net.ssl,
+ javax.servlet;resolution:=optional,
+ javax.servlet.http;resolution:=optional,
+ org.apache.log4j,
+ org.jboss.logging,
+ org.jboss.mx.util;resolution:=optional,
+ org.jboss.remoting;resolution:=optional,
+ org.jboss.remoting.*;resolution:=optional,
+ org.jboss.util.*,
+ org.w3c.dom;resolution:=optional,
+
+ <!-- jboss-serialization -->
+ gnu.trove;resolution:=optional,
+ sun.misc;resolution:=optional,
+ sun.reflect;resolution:=optional,
+
+ <!-- concurrent -->
+ javax.swing;resolution:=optional,
+ javax.swing.border;resolution:=optional
</Import-Package>
+ <Embed-Dependency>
+ concurrent,
+ jboss-remoting-core,
+ jboss-remoting-socket,
+ jboss-remoting-socket-client,
+ jboss-serialization
+ </Embed-Dependency>
</instructions>
</configuration>
</plugin>
Added: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/NotImplementedException.java
===================================================================
--- projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/NotImplementedException.java (rev 0)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/NotImplementedException.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -0,0 +1,43 @@
+/*
+ * 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$
+
+/**
+ * A RuntimeException that should be thrown for unimplemented features
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Jun-2008
+ */
+ at SuppressWarnings("serial")
+public class NotImplementedException extends RuntimeException
+{
+ public NotImplementedException()
+ {
+ }
+
+ public NotImplementedException(String message)
+ {
+ super(message);
+ }
+}
Property changes on: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/NotImplementedException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java (from rev 87175, projects/jboss-osgi/trunk/service/logging/src/main/java/org/jboss/osgi/service/logging/LoggingServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -0,0 +1,90 @@
+/*
+ * 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.remoting.transport.ServerFactory;
+import org.jboss.remoting.transport.local.TransportServerFactory;
+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_HOST = "org.jboss.osgi.service.remlog.host";
+ public static final String REMOTE_LOG_PORT = "org.jboss.osgi.service.remlog.port";
+
+ private RemoteLogReceiverService receiverService;
+ private ServiceRegistration receiverRegistration;
+
+ private RemoteLogSenderService senderService;
+ private ServiceRegistration senderRegistration;
+
+ public void start(BundleContext context)
+ {
+ Properties props = new Properties();
+ props.put(REMOTE_LOG_HOST, "localhost");
+ props.put(REMOTE_LOG_PORT, "5400");
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+ receiverService = new RemoteLogReceiverService(context, props);
+ receiverRegistration = context.registerService(RemoteLogReceiverService.class.getName(), receiverService, props);
+ receiverService.start();
+
+ senderService = new RemoteLogSenderService(context, props);
+ senderRegistration = context.registerService(RemoteLogSenderService.class.getName(), senderService, props);
+ senderService.start();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ receiverRegistration.unregister();
+ receiverRegistration = null;
+
+ receiverService.stop();
+ receiverService = null;
+
+ senderRegistration.unregister();
+ senderRegistration = null;
+
+ senderService.stop();
+ senderService = null;
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java
===================================================================
--- projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java (rev 0)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -0,0 +1,179 @@
+/*
+ * 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.Enumeration;
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogListener;
+import org.osgi.service.log.LogReaderService;
+
+/**
+ * [TODO]
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 12-Apr-2009
+ */
+public class RemoteLogReceiverService implements LogReaderService
+{
+ private String host;
+ private Integer port;
+ private Connector connector;
+
+ // String to be returned from invocation handler upon client invocation calls.
+ private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
+
+ public RemoteLogReceiverService(BundleContext context, Properties props)
+ {
+ this.host = props.getProperty(RemoteLogActivator.REMOTE_LOG_HOST);
+ this.port = new Integer(props.getProperty(RemoteLogActivator.REMOTE_LOG_PORT));
+ }
+
+ public void addLogListener(LogListener listener)
+ {
+ }
+
+ public void removeLogListener(LogListener listener)
+ {
+ }
+
+ public Enumeration<LogEntry> getLog()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void start()
+ {
+ String locatorURI = "socket://" + host + ":" + port;
+ try
+ {
+ // create the InvokerLocator based on url string format
+ // to indicate the transport, host, and port to use for the
+ // server invoker.
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ System.out.println("Starting remoting server with locator uri of: " + locatorURI);
+ connector = new Connector(locator);
+ // creates all the connector's needed resources, such as the server invoker
+ connector.create();
+
+ // create the handler to receive the invocation request from the client for processing
+ SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
+ // first parameter is sub-system name. can be any String value.
+ connector.addInvocationHandler("sample", invocationHandler);
+
+ // start with a new non daemon thread so
+ // server will wait for request and not exit
+ connector.start();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void stop()
+ {
+ try
+ {
+ if (connector != null)
+ connector.stop();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Simple invocation handler implementation. This is the code that will be called with the invocation payload from the client.
+ */
+ public static class SampleInvocationHandler implements ServerInvocationHandler
+ {
+ /**
+ * called to handle a specific invocation
+ *
+ * @param invocation
+ * @return
+ * @throws Throwable
+ */
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ // Print out the invocation request
+ System.out.println("Invocation request is: " + invocation.getParameter());
+ System.out.println("Returning response of: " + RESPONSE_VALUE);
+ // Just going to return static string as this is just simple example code.
+ return RESPONSE_VALUE;
+ }
+
+ /**
+ * Adds a callback handler that will listen for callbacks from the server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * Removes the callback handler that was listening for callbacks from the server invoker handler.
+ *
+ * @param callbackHandler
+ */
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ // NO OP as do not handling callback listeners in this example
+ }
+
+ /**
+ * set the mbean server that the handler can reference
+ *
+ * @param server
+ */
+ public void setMBeanServer(MBeanServer server)
+ {
+ // NO OP as do not need reference to MBeanServer for this handler
+ }
+
+ /**
+ * set the invoker that owns this handler
+ *
+ * @param invoker
+ */
+ public void setInvoker(ServerInvoker invoker)
+ {
+ // NO OP as do not need reference back to the server invoker
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java
===================================================================
--- projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java (rev 0)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -0,0 +1,108 @@
+/*
+ * 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.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogListener;
+import org.osgi.service.log.LogReaderService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * [TODO]
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 12-Apr-2009
+ */
+public class RemoteLogSenderService implements LogListener
+{
+ private BundleContext context;
+ private ServiceTracker tracker;
+ private String host;
+ private Integer port;
+
+ public RemoteLogSenderService(BundleContext context, Properties props)
+ {
+ this.context = context;
+ this.host = props.getProperty(RemoteLogActivator.REMOTE_LOG_HOST);
+ this.port = new Integer(props.getProperty(RemoteLogActivator.REMOTE_LOG_PORT));
+ }
+
+ public void start()
+ {
+ final LogListener logListener = this;
+ tracker = new ServiceTracker(context, LogReaderService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LogReaderService logReader = (LogReaderService)super.addingService(reference);
+ logReader.addLogListener(logListener);
+ return logReader;
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop()
+ {
+ LogReaderService logReader = (LogReaderService)tracker.getService();
+ if (logReader != null)
+ logReader.removeLogListener(this);
+ }
+
+ public void logged(LogEntry entry)
+ {
+ String locatorURI = "socket://" + host + ":" + port;
+ try
+ {
+ makeInvocation(locatorURI);
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void makeInvocation(String locatorURI) throws Throwable
+ {
+ // create InvokerLocator with the url type string
+ // indicating the target remoting server to call upon.
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ System.out.println("Calling remoting server with locator uri of: " + locatorURI);
+
+ Client remotingClient = new Client(locator);
+ remotingClient.connect();
+ String request = "Do something";
+ System.out.println("Invoking server with request of '" + request + "'");
+ Object response = remotingClient.invoke(request);
+ remotingClient.disconnect();
+ System.out.println("Invocation response: " + response);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/service/webconsole/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/service/webconsole/pom.xml 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/service/webconsole/pom.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -1,8 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <name>JBossOSGi - Service Web Console</name>
- <description>JBossOSGi - Web Console Service</description>
+ <name>JBossOSGi - Service WebConsole</name>
+ <description>JBossOSGi - WebConsole Service</description>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-service-webconsole</artifactId>
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -52,6 +52,12 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-service-remlog</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
<!-- Test Dependencies -->
<dependency>
Modified: projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml 2009-04-12 22:17:09 UTC (rev 87178)
@@ -17,6 +17,7 @@
<includes>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.osgi.compendium:jar</include>
+ <include>*:jboss-osgi-service-remlog:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
<scope>provided</scope>
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -0,0 +1,56 @@
+/*
+ * 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.test.osgi.example.log;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.junit.OSGiTest;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * This example demonstrates the usage of the {@link LogService}
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 09-Apr-2009
+ */
+public class LogServiceRemoteTestCase extends OSGiTest
+{
+ public void testServiceA() throws Exception
+ {
+ // Bootstrap the Framework and get the system bundle
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ // Install and start the 3rd party LogService.
+ URL testURL = getTestArchiveURL("thirdparty/org.apache.felix.log.jar");
+ Bundle logServiceBundle = sysContext.installBundle(testURL.toExternalForm());
+ logServiceBundle.start();
+
+ installBundle(sysContext, "thirdparty/jboss-osgi-service-remlog.jar", true);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -53,10 +53,10 @@
OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
BundleContext sysContext = framework.getSystemBundleContext();
- // Setup the LogEntryStore
+ // Setup the LogEntryCache
final LogEntryCache logEntryCache = new LogEntryCache();
logEntryCache.addFilter(new LogEntryFilter("example-log(.*)", LogService.LOG_INFO, "BundleEvent(.*)"));
- logEntryCache.addFilter(new LogEntryFilter(null, -1, "addingService(.*)"));
+ logEntryCache.addFilter(new LogEntryFilter(null, -1, "\\[ServiceA\\](.*)"));
// Track the LogReaderService to add the LogEntryCache as LogListener
ServiceTracker tracker = new ServiceTracker(sysContext, LogReaderService.class.getName(), null)
@@ -80,7 +80,7 @@
testURL = getTestArchiveURL("example/example-log-bundleA.jar");
Bundle bundleA = sysContext.installBundle(testURL.toExternalForm());
bundleA.start();
-
+
// Stop and uninstall the test bundle
bundleA.stop();
bundleA.uninstall();
@@ -93,7 +93,7 @@
assertEquals("Number of entries", 6, entries.size());
assertEquals("BundleEvent INSTALLED", entries.get(0).getMessage());
assertEquals("BundleEvent RESOLVED", entries.get(1).getMessage());
- assertEquals("addingService: org.apache.felix.log.LogServiceImpl", entries.get(2).getMessage());
+ assertEquals("[ServiceA] addingService: org.apache.felix.log.LogServiceImpl", entries.get(2).getMessage());
assertEquals("BundleEvent STARTED", entries.get(3).getMessage());
assertEquals("BundleEvent STOPPED", entries.get(4).getMessage());
assertEquals("BundleEvent UNINSTALLED", entries.get(5).getMessage());
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java 2009-04-12 12:41:46 UTC (rev 87177)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java 2009-04-12 22:17:09 UTC (rev 87178)
@@ -25,6 +25,7 @@
import static org.osgi.service.log.LogService.LOG_INFO;
+import org.jboss.osgi.service.log.SystemLogService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -49,10 +50,23 @@
public Object addingService(ServiceReference sref)
{
log = (LogService)super.addingService(sref);
- log.log(sref, LOG_INFO, "addingService: " + log.getClass().getName());
+ log.log(sref, LOG_INFO, "[ServiceA] addingService: " + log.getClass().getName());
return log;
}
+
+ @Override
+ public void removedService(ServiceReference sref, Object service)
+ {
+ super.removedService(sref, service);
+ log.log(sref, LOG_INFO, "[ServiceA] removedService: " + service.getClass().getName());
+ log = new SystemLogService(context);
+ }
};
tracker.open();
}
+
+ public String echo(String msg)
+ {
+ return msg;
+ }
}
\ No newline at end of file
More information about the jboss-osgi-commits
mailing list