JBoss-OSGI SVN: r87181 - in projects/jboss-osgi/trunk: service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-13 07:08:55 -0400 (Mon, 13 Apr 2009)
New Revision: 87181
Added:
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/
projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/RemoteLogEntry.java
Modified:
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
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
Log:
WIP: Remote Logging
Modified: 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/RemoteLogActivator.java 2009-04-13 10:24:04 UTC (rev 87180)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogActivator.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -25,8 +25,6 @@
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;
Modified: 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 2009-04-13 10:24:04 UTC (rev 87180)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogReceiverService.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -23,11 +23,14 @@
//$Id$
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
import javax.management.MBeanServer;
+import org.jboss.osgi.service.remlog.internal.RemoteLogEntry;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.ServerInvocationHandler;
@@ -50,10 +53,9 @@
private String host;
private Integer port;
private Connector connector;
+
+ private List<LogListener> listeners = new ArrayList<LogListener>();
- // 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);
@@ -62,10 +64,12 @@
public void addLogListener(LogListener listener)
{
+ listeners.add(listener);
}
public void removeLogListener(LogListener listener)
{
+ listeners.remove(listener);
}
public Enumeration<LogEntry> getLog()
@@ -75,26 +79,16 @@
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.
+ String locatorURI = "socket://" + host + ":" + port;
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();
+ LogEntryInvocationHandler invocationHandler = new LogEntryInvocationHandler();
+ connector.addInvocationHandler("remote-log", invocationHandler);
+ connector.start(true);
}
catch (Throwable ex)
{
@@ -116,64 +110,46 @@
}
/**
- * Simple invocation handler implementation. This is the code that will be called with the invocation payload from the client.
+ * 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
+ class LogEntryInvocationHandler 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;
+ RemoteLogEntry remoteEntry = (RemoteLogEntry)invocation.getParameter();
+ for (LogListener listener : listeners)
+ {
+ try
+ {
+ listener.logged(remoteEntry);
+ }
+ catch (RuntimeException rte)
+ {
+ System.out.println(rte.toString());
+ }
+ }
+ return null;
}
- /**
- * 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
+ // NOOP as do not handling callback listeners
}
- /**
- * 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
+ // NOOP as do not handling callback listeners
}
- /**
- * 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
+ // NOOP 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
+ // NOOP as do not need reference back to the server invoker
}
}
}
\ No newline at end of file
Modified: 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 2009-04-13 10:24:04 UTC (rev 87180)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/RemoteLogSenderService.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -25,6 +25,7 @@
import java.util.Properties;
+import org.jboss.osgi.service.remlog.internal.RemoteLogEntry;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.osgi.framework.BundleContext;
@@ -79,30 +80,19 @@
public void logged(LogEntry entry)
{
- String locatorURI = "socket://" + host + ":" + port;
+ RemoteLogEntry remoteEntry = new RemoteLogEntry(entry);
try
{
- makeInvocation(locatorURI);
+ String locatorURI = "socket://" + host + ":" + port;
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+ Client remotingClient = new Client(locator);
+ remotingClient.connect();
+ remotingClient.invoke(remoteEntry);
+ remotingClient.disconnect();
}
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
Added: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/RemoteLogEntry.java
===================================================================
--- projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/RemoteLogEntry.java (rev 0)
+++ projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/RemoteLogEntry.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -0,0 +1,318 @@
+/*
+ * 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.internal;
+
+// $Id$
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.jboss.osgi.service.remlog.NotImplementedException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogService;
+
+/**
+ * A unified implementation of a LogEntry.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Apr-2009
+ */
+public class RemoteLogEntry implements LogEntry
+{
+ private long time;
+ private Bundle bundle;
+ private ServiceReference sref;
+ private int level;
+ private String message;
+ private Throwable exception;
+
+ public RemoteLogEntry(LogEntry entry)
+ {
+ this.time = entry.getTime();
+ this.level = entry.getLevel();
+ this.message = entry.getMessage();
+ this.exception = entry.getException();
+
+ if (entry.getBundle() != null)
+ bundle = new DummyBundle(entry.getBundle());
+
+ if (entry.getServiceReference() != null)
+ sref = new DummyServiceReference(entry.getServiceReference());
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ public ServiceReference getServiceReference()
+ {
+ return sref;
+ }
+
+ public int getLevel()
+ {
+ return level;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public Throwable getException()
+ {
+ return exception;
+ }
+
+ @Override
+ public String toString()
+ {
+ String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
+ String l = " " + logLevel(level);
+ String s = sref != null ? ",sref=" + sref.getBundle().getSymbolicName() : "";
+ String b = ",bnd=" + bundle.getSymbolicName();
+ String m = ",msg=" + message;
+ String e = exception != null ? ",ex=" + exception : "";
+ return "[" + t + l + b + s + m + e + "]";
+ }
+
+ private String logLevel(int level)
+ {
+ String logLevel;
+ switch (level)
+ {
+ case LogService.LOG_DEBUG:
+ logLevel = "DEBUG";
+ break;
+ case LogService.LOG_INFO:
+ logLevel = "INFO";
+ break;
+ case LogService.LOG_WARNING:
+ logLevel = "WARN";
+ break;
+ case LogService.LOG_ERROR:
+ logLevel = "ERROR";
+ break;
+ default:
+ logLevel = "Level=" + level;
+ }
+ return logLevel;
+ }
+
+ /**
+ * A dummy Bundle for remote logging
+ */
+ class DummyBundle implements Bundle
+ {
+ private String symbolicName;
+
+ public DummyBundle(Bundle bundle)
+ {
+ this.symbolicName = bundle.getSymbolicName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ {
+ throw new NotImplementedException();
+ }
+
+ public BundleContext getBundleContext()
+ {
+ throw new NotImplementedException();
+ }
+
+ public long getBundleId()
+ {
+ throw new NotImplementedException();
+ }
+
+ public URL getEntry(String path)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getEntryPaths(String path)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Dictionary getHeaders()
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Dictionary getHeaders(String locale)
+ {
+ throw new NotImplementedException();
+ }
+
+ public long getLastModified()
+ {
+ throw new NotImplementedException();
+ }
+
+ public String getLocation()
+ {
+ throw new NotImplementedException();
+ }
+
+ public ServiceReference[] getRegisteredServices()
+ {
+ throw new NotImplementedException();
+ }
+
+ public URL getResource(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration getResources(String name) throws IOException
+ {
+ throw new NotImplementedException();
+ }
+
+ public ServiceReference[] getServicesInUse()
+ {
+ throw new NotImplementedException();
+ }
+
+ public int getState()
+ {
+ throw new NotImplementedException();
+ }
+
+ public String getSymbolicName()
+ {
+ return symbolicName;
+ }
+
+ public boolean hasPermission(Object permission)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void start() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void start(int options) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void stop() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void stop(int options) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void uninstall() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void update() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void update(InputStream in) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ /**
+ * A dummy ServiceReference for remote logging
+ */
+ class DummyServiceReference implements ServiceReference
+ {
+ private Bundle bundle;
+
+ public DummyServiceReference(ServiceReference sref)
+ {
+ if (sref.getBundle() != null)
+ this.bundle = new DummyBundle(sref.getBundle());
+ }
+
+ public int compareTo(Object reference)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle getBundle()
+ {
+ return bundle;
+ }
+
+ public Object getProperty(String key)
+ {
+ throw new NotImplementedException();
+ }
+
+ public String[] getPropertyKeys()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle[] getUsingBundles()
+ {
+ throw new NotImplementedException();
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String className)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/service/remlog/src/main/java/org/jboss/osgi/service/remlog/internal/RemoteLogEntry.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/LogServiceRemoteTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java 2009-04-13 10:24:04 UTC (rev 87180)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceRemoteTestCase.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -52,5 +52,7 @@
logServiceBundle.start();
installBundle(sysContext, "thirdparty/jboss-osgi-service-remlog.jar", true);
+
+ installBundle(sysContext, "example/example-log-bundleA.jar", true);
}
}
\ No newline at end of file
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-13 10:24:04 UTC (rev 87180)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-13 11:08:55 UTC (rev 87181)
@@ -47,7 +47,7 @@
*/
public class LogServiceTestCase extends OSGiTest
{
- public void testServiceA() throws Exception
+ public void testLogEntryFilter() throws Exception
{
// Bootstrap the Framework and get the system bundle
OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
@@ -71,7 +71,8 @@
};
tracker.open();
- // Install and start the 3rd party LogService.
+ // Install and start the 3rd party LogService.
+ // This will register the LogReaderService that we track above.
URL testURL = getTestArchiveURL("thirdparty/org.apache.felix.log.jar");
Bundle logServiceBundle = sysContext.installBundle(testURL.toExternalForm());
logServiceBundle.start();
17 years, 3 months
JBoss-OSGI SVN: r87178 - in projects/jboss-osgi/trunk: runtime/spi/src/main/java/org/jboss/osgi/service/log and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)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(a)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(a)jboss.com
+ * @since 18-Jun-2008
+ */
+@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(a)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(a)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(a)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(a)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
17 years, 3 months
JBoss-OSGI SVN: r87171 - projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 17:13:26 -0400 (Sat, 11 Apr 2009)
New Revision: 87171
Modified:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
Log:
Uninstall the 3rd party LogService
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-11 21:03:48 UTC (rev 87170)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-11 21:13:26 UTC (rev 87171)
@@ -85,6 +85,9 @@
bundleA.stop();
bundleA.uninstall();
+ // Uninstall the 3rd party LogService
+ logServiceBundle.uninstall();
+
// Verify the received log entries
List<LogEntry> entries = logEntryCache.getLog();
assertEquals("Number of entries", 6, entries.size());
17 years, 3 months
JBoss-OSGI SVN: r87170 - projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 17:03:48 -0400 (Sat, 11 Apr 2009)
New Revision: 87170
Modified:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
Log:
Make costants public
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-04-11 20:58:27 UTC (rev 87169)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-04-11 21:03:48 UTC (rev 87170)
@@ -21,11 +21,11 @@
*/
package org.jboss.osgi.spi;
+//$Id$
+
import org.osgi.framework.Bundle;
import org.osgi.service.log.LogService;
-// $Id$
-
/**
* JBossOSGi Constants
*
@@ -35,7 +35,7 @@
public abstract class Constants
{
/** The JBossOSGi domain 'jboss.osgi' */
- final String DOMAIN_NAME = "jboss.osgi";
+ public final static String DOMAIN_NAME = "jboss.osgi";
/**
* If set to 'true' bundles can be deployed in any order. Deployed bundle will get started when their dependencies can be resolved.
@@ -43,7 +43,7 @@
*
* The default is 'true'
*/
- final String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
+ public final static String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
/**
* Return the string representation of a bundle state
17 years, 3 months
JBoss-OSGI SVN: r87168 - in projects/jboss-osgi/trunk: testsuite/src/test/java/org/jboss/test/osgi/example/log and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 16:57:05 -0400 (Sat, 11 Apr 2009)
New Revision: 87168
Modified:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java
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:
Add stop/uninstall coverage
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java 2009-04-11 19:55:38 UTC (rev 87167)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java 2009-04-11 20:57:05 UTC (rev 87168)
@@ -47,7 +47,7 @@
{
this.bndRegex = bndRegex;
this.msgRegex = msgRegex;
- this.level = level;
+ this.level = level < 1 ? Integer.MAX_VALUE : level;
}
/**
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-11 19:55:38 UTC (rev 87167)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-11 20:57:05 UTC (rev 87168)
@@ -54,8 +54,9 @@
BundleContext sysContext = framework.getSystemBundleContext();
// Setup the LogEntryStore
- LogEntryFilter filter = new LogEntryFilter("example-log(.*)", LogService.LOG_DEBUG, "BundleEvent(.*)");
- final LogEntryCache logEntryCache = new LogEntryCache(filter);
+ final LogEntryCache logEntryCache = new LogEntryCache();
+ logEntryCache.addFilter(new LogEntryFilter("example-log(.*)", LogService.LOG_INFO, "BundleEvent(.*)"));
+ logEntryCache.addFilter(new LogEntryFilter(null, -1, "addingService(.*)"));
// Track the LogReaderService to add the LogEntryCache as LogListener
ServiceTracker tracker = new ServiceTracker(sysContext, LogReaderService.class.getName(), null)
@@ -80,11 +81,18 @@
Bundle bundleA = sysContext.installBundle(testURL.toExternalForm());
bundleA.start();
+ // Stop and uninstall the test bundle
+ bundleA.stop();
+ bundleA.uninstall();
+
// Verify the received log entries
List<LogEntry> entries = logEntryCache.getLog();
- assertEquals("Number of entries", 3, entries.size());
+ assertEquals("Number of entries", 6, entries.size());
assertEquals("BundleEvent INSTALLED", entries.get(0).getMessage());
assertEquals("BundleEvent RESOLVED", entries.get(1).getMessage());
- assertEquals("BundleEvent STARTED", entries.get(2).getMessage());
+ assertEquals("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());
}
}
\ No newline at end of file
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-11 19:55:38 UTC (rev 87167)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java 2009-04-11 20:57:05 UTC (rev 87168)
@@ -49,7 +49,7 @@
public Object addingService(ServiceReference sref)
{
log = (LogService)super.addingService(sref);
- log.log(sref, LOG_INFO, "LogService added - " + log.getClass().getName());
+ log.log(sref, LOG_INFO, "addingService: " + log.getClass().getName());
return log;
}
};
17 years, 3 months
JBoss-OSGI SVN: r87167 - projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 15:55:38 -0400 (Sat, 11 Apr 2009)
New Revision: 87167
Modified:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
Log:
Use low-level OSGi API
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-11 19:44:28 UTC (rev 87166)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-11 19:55:38 UTC (rev 87167)
@@ -23,6 +23,7 @@
//$Id$
+import java.net.URL;
import java.util.List;
import org.jboss.osgi.service.log.LogEntryCache;
@@ -30,6 +31,7 @@
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.framework.ServiceReference;
import org.osgi.service.log.LogEntry;
@@ -69,10 +71,14 @@
tracker.open();
// Install and start the 3rd party LogService.
- installBundle(sysContext, "thirdparty/org.apache.felix.log.jar", true);
+ URL testURL = getTestArchiveURL("thirdparty/org.apache.felix.log.jar");
+ Bundle logServiceBundle = sysContext.installBundle(testURL.toExternalForm());
+ logServiceBundle.start();
// Install and start the test bundle
- installBundle(sysContext, "example/example-log-bundleA.jar", true);
+ testURL = getTestArchiveURL("example/example-log-bundleA.jar");
+ Bundle bundleA = sysContext.installBundle(testURL.toExternalForm());
+ bundleA.start();
// Verify the received log entries
List<LogEntry> entries = logEntryCache.getLog();
17 years, 3 months
JBoss-OSGI SVN: r87166 - projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 15:44:28 -0400 (Sat, 11 Apr 2009)
New Revision: 87166
Modified:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
Log:
Fix typos
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-11 19:41:30 UTC (rev 87165)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-11 19:44:28 UTC (rev 87166)
@@ -53,16 +53,16 @@
// Setup the LogEntryStore
LogEntryFilter filter = new LogEntryFilter("example-log(.*)", LogService.LOG_DEBUG, "BundleEvent(.*)");
- final LogEntryCache logEntryStore = new LogEntryCache(filter);
+ final LogEntryCache logEntryCache = new LogEntryCache(filter);
- // Track the LogReaderService to add the LogEntryStore as LogListener
+ // Track the LogReaderService to add the LogEntryCache as LogListener
ServiceTracker tracker = new ServiceTracker(sysContext, LogReaderService.class.getName(), null)
{
@Override
public Object addingService(ServiceReference sref)
{
LogReaderService service = (LogReaderService)super.addingService(sref);
- service.addLogListener(logEntryStore);
+ service.addLogListener(logEntryCache);
return service;
}
};
@@ -75,7 +75,7 @@
installBundle(sysContext, "example/example-log-bundleA.jar", true);
// Verify the received log entries
- List<LogEntry> entries = logEntryStore.getLog();
+ List<LogEntry> entries = logEntryCache.getLog();
assertEquals("Number of entries", 3, entries.size());
assertEquals("BundleEvent INSTALLED", entries.get(0).getMessage());
assertEquals("BundleEvent RESOLVED", entries.get(1).getMessage());
17 years, 3 months
JBoss-OSGI SVN: r87165 - in projects/jboss-osgi/trunk: runtime/felix/src/main/resources and 18 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-11 15:41:30 -0400 (Sat, 11 Apr 2009)
New Revision: 87165
Added:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/
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/LogEntryFilter.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/service/mc/
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/mc/MicrocontainerService.java
projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/
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/
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/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/resources/example/
projects/jboss-osgi/trunk/testsuite/src/test/resources/example/log/
projects/jboss-osgi/trunk/testsuite/src/test/resources/example/log/example-log-bundleA.bnd
Removed:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/MicrocontainerService.java
Modified:
projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml
projects/jboss-osgi/trunk/runtime/spi/pom.xml
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
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/junit/OSGiTest.java
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/trunk/testsuite/pom.xml
projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java
Log:
[JBOSGI-60] Initial LogService example
Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleRealDeployer.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -30,7 +30,7 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.spi.framework.OSGiStateFormat;
+import org.jboss.osgi.spi.Constants;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -96,7 +96,7 @@
Bundle bundle = systemContext.installBundle(bundleUri.toString());
unit.addAttachment(Bundle.class, bundle);
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info("Installed: " + bundle + state);
}
}
@@ -116,7 +116,7 @@
try
{
bundle.uninstall();
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info("Uninstalled: " + bundle + state);
}
catch (BundleException ex)
Modified: projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/deployer/src/main/java/org/jboss/osgi/deployer/BundleStartStopDeployer.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -31,7 +31,6 @@
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.spi.Constants;
-import org.jboss.osgi.spi.framework.OSGiStateFormat;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -85,7 +84,7 @@
unresolvedBundles.remove(bundle);
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info("Stoped: " + bundle + state);
}
catch (BundleException e)
@@ -99,7 +98,7 @@
try
{
bundle.start();
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info("Started: " + bundle + state);
}
catch (BundleException e)
@@ -139,7 +138,7 @@
try
{
auxBundle.start();
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info("Started: " + bundle + state);
}
catch (BundleException e)
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-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/jboss-osgi-beans.xml 2009-04-11 19:41:30 UTC (rev 87165)
@@ -11,7 +11,9 @@
<entry>
<key>org.osgi.framework.system.packages</key>
<value>
+ org.jboss.osgi.service.log,
org.osgi.framework; version=1.4,
+ org.osgi.service.log; version=1.3,
org.osgi.util.tracker
</value>
</entry>
Modified: projects/jboss-osgi/trunk/runtime/spi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/pom.xml 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/pom.xml 2009-04-11 19:41:30 UTC (rev 87165)
@@ -24,6 +24,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-client-spi</artifactId>
</dependency>
Deleted: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/MicrocontainerService.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/MicrocontainerService.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/MicrocontainerService.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -1,85 +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.service;
-
-//$Id$
-
-import javax.management.MBeanServer;
-
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.kernel.Kernel;
-import org.osgi.framework.BundleContext;
-
-/**
- * An OSGi Service the gives access to the Kernel and MBeanServer.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public class MicrocontainerService
-{
- private BundleContext systemContext;
- private MBeanServer mbeanServer;
- private Kernel kernel;
-
- /**
- * Register this bean as an OSGi service
- */
- public void create()
- {
- systemContext.registerService(MicrocontainerService.class.getName(), this, null);
- }
-
- public void setSystemContext(BundleContext bundleContext)
- {
- this.systemContext = bundleContext;
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- public Kernel getKernel()
- {
- return kernel;
- }
-
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
-
- public void setMbeanServer(MBeanServer server)
- {
- this.mbeanServer = server;
- }
-
- public Object getRegisteredBean(String beanName)
- {
- if (kernel == null)
- throw new IllegalArgumentException("Kernel cannot be null");
-
- ControllerContext context = kernel.getController().getInstalledContext(beanName);
- return context.getTarget();
- }
-}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,199 @@
+/*
+ * 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;
+
+//$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.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogListener;
+
+/**
+ * A LogListener that caches LogEntry objects for later retrieval.
+ *
+ * The entries can be filtered with a list of {@link LogEntryFilter} instances.
+ * A log entry is cached if it matches at least one of the registered filters.
+ * If there is no filter registered entries are cached unconditionally.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Apr-2009
+ */
+public class LogEntryCache implements LogListener
+{
+ private List<LogEntry> entries = new ArrayList<LogEntry>();
+ private List<LogEntryFilter> filters = new ArrayList<LogEntryFilter>();
+
+ /**
+ * Create a LogEntryCache with a single associated filter
+ */
+ public LogEntryCache(LogEntryFilter filter)
+ {
+ filters.add(filter);
+ }
+
+ /**
+ * Create a LogEntryCache with no associated filters
+ */
+ public LogEntryCache()
+ {
+ }
+
+ /**
+ * Add a LogEntryFilter
+ */
+ public void addFilter(LogEntryFilter filter)
+ {
+ filters.add(filter);
+ }
+
+ /**
+ * Clear the list of cached entries.
+ */
+ public void clear()
+ {
+ // entries.clear() would need synchronization
+ entries = new ArrayList<LogEntry>();
+ }
+
+ /**
+ * Clear the list of registered filters.
+ */
+ public void clearFilters()
+ {
+ // filters.clear() would need synchronization
+ filters = new ArrayList<LogEntryFilter>();
+ }
+
+ /**
+ * Get the list of cached entries
+ */
+ public List<LogEntry> getLog()
+ {
+ return new ArrayList<LogEntry>(entries);
+ }
+
+ /**
+ * Listener method called for each LogEntry object created.
+ */
+ public void logged(LogEntry entry)
+ {
+ // Replace entry with a unified wrapper
+ entry = new LogEntryWrapper(entry);
+
+ if (filters.size() == 0)
+ {
+ entries.add(entry);
+ return;
+ }
+
+ // Add the entry if if matches at least one filter
+ for (LogEntryFilter filter : filters)
+ {
+ if (match(filter, entry))
+ {
+ entries.add(entry);
+ break;
+ }
+ }
+ }
+
+ private boolean match(LogEntryFilter filter, LogEntry entry)
+ {
+ boolean match = entry.getLevel() <= filter.getLevel();
+
+ if (match && filter.getBundleRegex() != null)
+ {
+ String entryBnd = entry.getBundle().getSymbolicName();
+ String filterRegex = filter.getBundleRegex();
+ match = entryBnd.matches(filterRegex);
+ }
+
+ if (match && filter.getMessageRegex() != null)
+ {
+ String entryMsg = entry.getMessage();
+ String filterRegex = filter.getMessageRegex();
+ match = entryMsg.matches(filterRegex);
+ }
+
+ 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
Property changes on: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryCache.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,97 @@
+/*
+ * 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;
+
+//$Id$
+
+
+/**
+ * A LogEntry filter that can be used with the LogEntryCache
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Apr-2009
+ */
+public class LogEntryFilter
+{
+ private int level;
+ private String bndRegex;
+ private String msgRegex;
+
+ /**
+ * Create a LogEntryFilter with the associated criteria.
+ *
+ * @param bndRegex A regex that matches a Bundle's SymbolicName
+ * @param level The maximum log level accepted by this filter
+ * @param msgRegex A regex that matches the log message
+ */
+ public LogEntryFilter(String bndRegex, int level, String msgRegex)
+ {
+ this.bndRegex = bndRegex;
+ this.msgRegex = msgRegex;
+ this.level = level;
+ }
+
+ /**
+ * Create a LogEntryFilter with the associated criteria.
+ *
+ * @param bndRegex A regex that matches a Bundle's SymbolicName
+ * @param level The maximum log level accepted by this filter
+ */
+ public LogEntryFilter(String bndRegex, int level)
+ {
+ this(bndRegex, level, null);
+ }
+
+ /**
+ * Create a LogEntryFilter with the associated criteria.
+ *
+ * @param bndRegex A regex that matches a Bundle's SymbolicName
+ */
+ public LogEntryFilter(String bndRegex)
+ {
+ this(bndRegex, Integer.MAX_VALUE, null);
+ }
+
+ /**
+ * Get the Bundle Symbolic-Name regex.
+ */
+ public String getBundleRegex()
+ {
+ return bndRegex;
+ }
+
+ /**
+ * Get the log message regex.
+ */
+ public String getMessageRegex()
+ {
+ return msgRegex;
+ }
+
+ /**
+ * Get the log entry maximum log level.
+ */
+ public int getLevel()
+ {
+ return level;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/LogEntryFilter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+//$Id$
+
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * A basic LogService that writes to System.out
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 11-Apr-2009
+ */
+public class SystemLogService implements LogService
+{
+ public void log(int level, String message)
+ {
+ logInternal(null, level, message, null);
+ }
+
+ public void log(int level, String message, Throwable exception)
+ {
+ logInternal(null, level, message, exception);
+ }
+
+ public void log(ServiceReference sr, int level, String message)
+ {
+ logInternal(sr, level, message, null);
+ }
+
+ public void log(ServiceReference sr, int level, String message, Throwable exception)
+ {
+ logInternal(sr, level, message, exception);
+ }
+
+ 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 + ": ");
+ }
+
+ buf.append("[" + Constants.logLevel(level) +"] ");
+
+ buf.append(message);
+ System.out.println(buf);
+
+ if (exception != null)
+ exception.printStackTrace(System.out);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/log/SystemLogService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/mc/MicrocontainerService.java (from rev 87161, projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/MicrocontainerService.java)
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/mc/MicrocontainerService.java (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/service/mc/MicrocontainerService.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,85 @@
+/*
+ * 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.mc;
+
+//$Id$
+
+import javax.management.MBeanServer;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.Kernel;
+import org.osgi.framework.BundleContext;
+
+/**
+ * An OSGi Service the gives access to the Kernel and MBeanServer.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public class MicrocontainerService
+{
+ private BundleContext systemContext;
+ private MBeanServer mbeanServer;
+ private Kernel kernel;
+
+ /**
+ * Register this bean as an OSGi service
+ */
+ public void create()
+ {
+ systemContext.registerService(MicrocontainerService.class.getName(), this, null);
+ }
+
+ public void setSystemContext(BundleContext bundleContext)
+ {
+ this.systemContext = bundleContext;
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+
+ public void setMbeanServer(MBeanServer server)
+ {
+ this.mbeanServer = server;
+ }
+
+ public Object getRegisteredBean(String beanName)
+ {
+ if (kernel == null)
+ throw new IllegalArgumentException("Kernel cannot be null");
+
+ ControllerContext context = kernel.getController().getInstalledContext(beanName);
+ return context.getTarget();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/Constants.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -21,6 +21,9 @@
*/
package org.jboss.osgi.spi;
+import org.osgi.framework.Bundle;
+import org.osgi.service.log.LogService;
+
// $Id$
/**
@@ -29,7 +32,7 @@
* @author thomas.diesler(a)jboss.com
* @since 04-Mar-2009
*/
-public interface Constants
+public abstract class Constants
{
/** The JBossOSGi domain 'jboss.osgi' */
final String DOMAIN_NAME = "jboss.osgi";
@@ -41,4 +44,53 @@
* The default is 'true'
*/
final String PROPERTY_DEFERRED_START = "org.jboss.osgi.deferred.start";
+
+ /**
+ * Return the string representation of a bundle state
+ */
+ public static String bundleState(int bundleState)
+ {
+ String retState = "[" + bundleState + "]";
+
+ if (Bundle.UNINSTALLED == bundleState)
+ retState = "[UNINSTALLED]";
+ else if (Bundle.INSTALLED == bundleState)
+ retState = "[INSTALLED]";
+ else if (Bundle.RESOLVED == bundleState)
+ retState = "[RESOLVED]";
+ else if (Bundle.STARTING == bundleState)
+ retState = "[STARTING]";
+ else if (Bundle.STOPPING == bundleState)
+ retState = "[STOPPING]";
+ else if (Bundle.ACTIVE == bundleState)
+ retState = "[ACTIVE]";
+
+ return retState;
+ }
+
+ /**
+ * Return the string representation of a log level
+ */
+ public static String logLevel(int level)
+ {
+ String logLevel;
+ switch (level)
+ {
+ case LogService.LOG_DEBUG:
+ logLevel = "DEBUG";
+ break;
+ case LogService.LOG_INFO:
+ logLevel = "INFO";
+ break;
+ case LogService.LOG_WARNING:
+ logLevel = "WARN";
+ break;
+ case LogService.LOG_ERROR:
+ logLevel = "ERROR";
+ break;
+ default:
+ logLevel = "Level=" + level;
+ }
+ return logLevel;
+ }
}
Modified: 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-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiStateFormat.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -23,7 +23,6 @@
//$Id$
-import org.osgi.framework.Bundle;
/**
* A string format helper for OSGi states
@@ -37,27 +36,4 @@
private OSGiStateFormat()
{
}
-
- /**
- * Return the string representation of a bundle state
- */
- public static String formatBundleState(int bundleState)
- {
- String retState = "[" + bundleState + "]";
-
- if (Bundle.UNINSTALLED == bundleState)
- retState = "[UNINSTALLED]";
- else if (Bundle.INSTALLED == bundleState)
- retState = "[INSTALLED]";
- else if (Bundle.RESOLVED == bundleState)
- retState = "[RESOLVED]";
- else if (Bundle.STARTING == bundleState)
- retState = "[STARTING]";
- else if (Bundle.STOPPING == bundleState)
- retState = "[STOPPING]";
- else if (Bundle.ACTIVE == bundleState)
- retState = "[ACTIVE]";
-
- return retState;
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -29,6 +29,9 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.virtual.VFS;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
import junit.framework.TestCase;
@@ -116,4 +119,9 @@
{
return delegate.getTestArchiveFile(archive).toURI().toURL();
}
+
+ protected Bundle installBundle(BundleContext sysContext, String bundlePath, boolean start) throws BundleException
+ {
+ return delegate.installBundle(sysContext, bundlePath, start);
+ }
}
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -25,6 +25,10 @@
import java.net.MalformedURLException;
import java.net.URL;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
/**
* An OSGi Test Helper
*
@@ -33,76 +37,93 @@
*/
public class OSGiTestHelper
{
- private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
- private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+ private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
+ private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
- private static String testResourcesDir;
- private static String testArchiveDir;
+ private static String testResourcesDir;
+ private static String testArchiveDir;
- /** Try to discover the URL for the test resource */
- public URL getResourceURL(String resource)
- {
- URL resURL = null;
- try
- {
- File resourceFile = getResourceFile(resource);
- resURL = resourceFile.toURI().toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- return resURL;
- }
+ /** Try to discover the URL for the test resource */
+ public URL getResourceURL(String resource)
+ {
+ URL resURL = null;
+ try
+ {
+ File resourceFile = getResourceFile(resource);
+ resURL = resourceFile.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ return resURL;
+ }
- /** Try to discover the File for the test resource */
- public File getResourceFile(String resource)
- {
- File file = new File(resource);
- if (file.exists())
- return file;
+ /** Try to discover the File for the test resource */
+ public File getResourceFile(String resource)
+ {
+ File file = new File(resource);
+ if (file.exists())
+ return file;
- file = new File(getTestResourcesDir() + "/" + resource);
- if (file.exists())
- return file;
+ file = new File(getTestResourcesDir() + "/" + resource);
+ if (file.exists())
+ return file;
- throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
- }
+ throw new IllegalArgumentException("Cannot obtain '" + getTestResourcesDir() + "/" + resource + "'");
+ }
- public String getTestResourcesDir()
- {
- if (testResourcesDir == null)
- testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
+ public String getTestResourcesDir()
+ {
+ if (testResourcesDir == null)
+ testResourcesDir = System.getProperty(SYSPROP_TEST_RESOURCES_DIRECTORY, "target/test-classes");
- return testResourcesDir;
- }
+ return testResourcesDir;
+ }
- /** Try to discover the URL for the deployment archive */
- public URL getTestArchiveURL(String archive) throws MalformedURLException
- {
- return getTestArchiveFile(archive).toURI().toURL();
- }
+ /** Try to discover the URL for the deployment archive */
+ public URL getTestArchiveURL(String archive)
+ {
+ try
+ {
+ return getTestArchiveFile(archive).toURI().toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
- /** Try to discover the File for the deployment archive */
- public File getTestArchiveFile(String archive)
- {
- File file = new File(archive);
- if (file.exists())
- return file;
-
- file = new File(getTestArchiveDir() + "/" + archive);
- if (file.exists())
- return file;
-
- String notSet = (getTestArchiveDir() == null ? " System property '" + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "");
- throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir() + "/" + archive + "'." + notSet);
- }
+ /** Try to discover the File for the deployment archive */
+ public File getTestArchiveFile(String archive)
+ {
+ File file = new File(archive);
+ if (file.exists())
+ return file;
- public String getTestArchiveDir()
- {
- if (testArchiveDir == null)
- testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
-
- return testArchiveDir;
- }
+ file = new File(getTestArchiveDir() + "/" + archive);
+ if (file.exists())
+ return file;
+
+ String notSet = (getTestArchiveDir() == null ? " System property '" + SYSPROP_TEST_ARCHIVE_DIRECTORY + "' not set." : "");
+ throw new IllegalArgumentException("Cannot obtain '" + getTestArchiveDir() + "/" + archive + "'." + notSet);
+ }
+
+ public String getTestArchiveDir()
+ {
+ if (testArchiveDir == null)
+ testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
+
+ return testArchiveDir;
+ }
+
+ public Bundle installBundle(BundleContext sysContext, String bundlePath, boolean start) throws BundleException
+ {
+ Bundle bundle = sysContext.installBundle(getTestArchiveURL(bundlePath).toExternalForm());
+
+ if (start == true)
+ bundle.start();
+
+ return bundle;
+ }
}
Modified: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -27,7 +27,6 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.Constants;
-import org.jboss.osgi.spi.framework.OSGiStateFormat;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -80,7 +79,7 @@
{
bundle.start();
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info(bundle.getSymbolicName() + ",state=" + state);
}
@@ -88,7 +87,7 @@
{
bundle.stop();
- String state = OSGiStateFormat.formatBundleState(bundle.getState());
+ String state = Constants.bundleState(bundle.getState());
log.info(bundle.getSymbolicName() + ",state=" + state);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-11 19:41:30 UTC (rev 87165)
@@ -41,6 +41,18 @@
<artifactId>jboss-aop-mc-int</artifactId>
</dependency>
+ <!-- Provided Dependencies -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
@@ -59,6 +71,26 @@
</testResources>
<plugins>
<plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>thirdparty-bundles</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-thirdparty-bundles.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
@@ -83,9 +115,9 @@
<profiles>
<!--
- Name: framework-any
- Descr: Create the testsuite.zip and skip tests
- -->
+ Name: framework-any
+ Descr: Create the testsuite.zip and skip tests
+ -->
<profile>
<id>framework-any</id>
<activation>
@@ -138,8 +170,7 @@
<configuration>
<artifacts>
<artifact>
- <file>target/${project.artifactId}-${project.version}.zip
- </file>
+ <file>target/${project.artifactId}-${project.version}.zip</file>
<type>zip</type>
</artifact>
</artifacts>
@@ -158,7 +189,7 @@
</profile>
<!--
- Name: framework-default
+ Name: framework-default
Descr: Setup for default framework integration testing
-->
<profile>
@@ -184,9 +215,9 @@
</profile>
<!--
- Name: embedded-tesing
+ Name: embedded-tesing
Descr: Setup for embedded integration testing
- -->
+ -->
<profile>
<id>embedded-tesing</id>
<activation>
@@ -211,7 +242,7 @@
</profile>
<!--
- Name: remote-tesing
+ Name: remote-tesing
Descr: Setup for remote integration testing
-->
<profile>
Modified: projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-04-11 19:41:30 UTC (rev 87165)
@@ -22,7 +22,7 @@
<property name="maven.runtime.classpath" value="/usr/java/bnd.jar" />
<property name="tests.output.dir" value="${basedir}/../target" />
- <mkdir dir="${tests.output.dir}/test-libs" />
+ <mkdir dir="${tests.output.dir}/test-libs/example" />
<property name="tests.classes.dir" value="${tests.output.dir}/test-classes" />
<property name="tests.resources.dir" value="${tests.output.dir}/test-classes" />
@@ -42,6 +42,9 @@
<!-- Please add alphabetically -->
+ <!-- example/log -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example/example-log-bundleA.jar" files="${tests.resources.dir}/example/log/example-log-bundleA.bnd" />
+
<!-- jbosgi36 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi36-bundle.jar" files="${tests.resources.dir}/deployer/jbosgi36/jbosgi36.bnd" />
<jar jarfile="${tests.output.dir}/test-libs/jbosgi36-mbean.jar">
Added: projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,27 @@
+<assembly 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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+
+ <id>deploy-artifacts</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <!-- Dependency Sets -->
+ <dependencySets>
+
+ <!-- bundle -->
+ <dependencySet>
+ <outputDirectory>thirdparty</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>*:org.apache.felix.log:jar</include>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>true</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+
+ </dependencySets>
+</assembly>
Property changes on: projects/jboss-osgi/trunk/testsuite/scripts/assembly-thirdparty-bundles.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,84 @@
+/*
+ * 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.util.List;
+
+import org.jboss.osgi.service.log.LogEntryCache;
+import org.jboss.osgi.service.log.LogEntryFilter;
+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.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogEntry;
+import org.osgi.service.log.LogReaderService;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * This example demonstrates the usage of the {@link LogService}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Apr-2009
+ */
+public class LogServiceTestCase extends OSGiTest
+{
+ public void testServiceA() throws Exception
+ {
+ // Bootstrap the Framework and get the system bundle
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ // Setup the LogEntryStore
+ LogEntryFilter filter = new LogEntryFilter("example-log(.*)", LogService.LOG_DEBUG, "BundleEvent(.*)");
+ final LogEntryCache logEntryStore = new LogEntryCache(filter);
+
+ // Track the LogReaderService to add the LogEntryStore as LogListener
+ ServiceTracker tracker = new ServiceTracker(sysContext, LogReaderService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference sref)
+ {
+ LogReaderService service = (LogReaderService)super.addingService(sref);
+ service.addLogListener(logEntryStore);
+ return service;
+ }
+ };
+ tracker.open();
+
+ // Install and start the 3rd party LogService.
+ installBundle(sysContext, "thirdparty/org.apache.felix.log.jar", true);
+
+ // Install and start the test bundle
+ installBundle(sysContext, "example/example-log-bundleA.jar", true);
+
+ // Verify the received log entries
+ List<LogEntry> entries = logEntryStore.getLog();
+ assertEquals("Number of entries", 3, entries.size());
+ assertEquals("BundleEvent INSTALLED", entries.get(0).getMessage());
+ assertEquals("BundleEvent RESOLVED", entries.get(1).getMessage());
+ assertEquals("BundleEvent STARTED", entries.get(2).getMessage());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,58 @@
+/*
+ * 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.bundleA;
+
+//$Id$
+
+import static org.osgi.service.log.LogService.LOG_INFO;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A service that logs some messages to the LogService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 11-Apr-2009
+ */
+public class ServiceA
+{
+ private LogService log;
+
+ public ServiceA(BundleContext context)
+ {
+ // Track changes in LogService registration
+ ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference sref)
+ {
+ log = (LogService)super.addingService(sref);
+ log.log(sref, LOG_INFO, "LogService added - " + log.getClass().getName());
+ return log;
+ }
+ };
+ tracker.open();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceA.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceActivator.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,48 @@
+/*
+ * 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.bundleA;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class ServiceActivator implements BundleActivator
+{
+ private ServiceRegistration registration;
+
+ public void start(BundleContext context)
+ {
+ ServiceA service = new ServiceA(context);
+ registration = context.registerService(ServiceA.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/example/log/bundleA/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java 2009-04-11 14:37:30 UTC (rev 87164)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java 2009-04-11 19:41:30 UTC (rev 87165)
@@ -26,7 +26,7 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.jboss.osgi.service.MicrocontainerService;
+import org.jboss.osgi.service.mc.MicrocontainerService;
import org.jboss.osgi.spi.management.ObjectNameFactory;
import org.jboss.test.osgi.service.microcontainer.bundle.Foo;
import org.osgi.framework.BundleContext;
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/example/log/example-log-bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/example/log/example-log-bundleA.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/example/log/example-log-bundleA.bnd 2009-04-11 19:41:30 UTC (rev 87165)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-log-bundleA.jar src/test/resources/example/log/example-log-bundleA.bnd
+
+Bundle-SymbolicName: example-log-bundleA
+
+Bundle-Activator: org.jboss.test.osgi.example.log.bundleA.ServiceActivator
+Export-Package: org.jboss.test.osgi.example.log.bundleA
17 years, 3 months
JBoss-OSGI SVN: r87158 - projects/jboss-osgi/trunk/build/hudson/jboss/bin.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-10 17:32:11 -0400 (Fri, 10 Apr 2009)
New Revision: 87158
Modified:
projects/jboss-osgi/trunk/build/hudson/jboss/bin/runjboss.sh
Log:
Add -Djava.net.preferIPv4Stack=true -Dxb.builder.useUnorderedSequence=true
Modified: projects/jboss-osgi/trunk/build/hudson/jboss/bin/runjboss.sh
===================================================================
--- projects/jboss-osgi/trunk/build/hudson/jboss/bin/runjboss.sh 2009-04-10 20:37:10 UTC (rev 87157)
+++ projects/jboss-osgi/trunk/build/hudson/jboss/bin/runjboss.sh 2009-04-10 21:32:11 UTC (rev 87158)
@@ -91,28 +91,15 @@
fi
fi
-# Setup JBosst Native library path
-JBOSS_NATIVE_DIR="$JBOSS_HOME/bin/native"
-if [ -d "$JBOSS_NATIVE_DIR" ]; then
- if [ "x$LD_LIBRARY_PATH" = "x" ]; then
- LD_LIBRARY_PATH="$JBOSS_NATIVE_DIR"
- else
- LD_LIBRARY_PATH="$JBOSS_NATIVE_DIR:$LD_LIBRARY_PATH"
- fi
- export LD_LIBRARY_PATH
- if [ "x$JAVA_OPTS" = "x" ]; then
- JAVA_OPTS="-Djava.library.path=$JBOSS_NATIVE_DIR"
- else
- JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$JBOSS_NATIVE_DIR"
- fi
-fi
-
-#JPDA options. Uncomment and modify as appropriate to enable remote debugging .
-#JAVA_OPTS="-classic -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n $JAVA_OPTS"
-
# Setup JBoss sepecific properties
JAVA_OPTS="-Dprogram.name=$PROGNAME $JAVA_OPTS"
+# Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
+JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
+
+# This should be removed when JBoss configuration XML files can be validated JBAS-6744
+JAVA_OPTS="$JAVA_OPTS -Dxb.builder.useUnorderedSequence=true"
+
# Setup the java endorsed dirs
JBOSS_ENDORSED_DIRS="$JBOSS_HOME/lib/endorsed"
17 years, 3 months
JBoss-OSGI SVN: r87104 - projects/jboss-osgi/trunk/testsuite.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-04-09 18:27:46 -0400 (Thu, 09 Apr 2009)
New Revision: 87104
Modified:
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Fix dependencies for -Dframework
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-09 22:18:31 UTC (rev 87103)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-09 22:27:46 UTC (rev 87104)
@@ -27,6 +27,10 @@
<artifactId>bnd</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-runtime-deployer</artifactId>
<version>${version}</version>
@@ -89,6 +93,18 @@
<name>framework</name>
</property>
</activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
17 years, 3 months