[jboss-cvs] JBossAS SVN: r95470 - in projects/jboss-osgi: trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 23 03:41:20 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-23 03:41:20 -0400 (Fri, 23 Oct 2009)
New Revision: 95470
Added:
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/InterceptorWrapper.java
Modified:
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java
projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java
projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java
projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
Log:
More interceptor logging
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java 2009-10-23 07:31:34 UTC (rev 95469)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebAppPublisherInterceptor.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -34,6 +34,8 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The WebApp lifecycle interceptor.
@@ -43,6 +45,9 @@
*/
public class WebAppPublisherInterceptor extends AbstractLifecycleInterceptor implements LifecycleInterceptor
{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(WebAppPublisherInterceptor.class);
+
private BundleContext context;
private ServiceTracker serviceTracker;
private WebAppPublisherExt publisher;
@@ -92,11 +97,15 @@
{
if (state == Bundle.STARTING)
{
+ log.debug("Publish WebApp metadata");
+
WebApp webApp = dep.getAttachment(WebApp.class);
publisher.publish(webApp);
}
else if (state == Bundle.STOPPING)
{
+ log.debug("Unpublish WebApp metadata");
+
WebApp webApp = dep.getAttachment(WebApp.class);
publisher.unpublish(webApp);
}
Modified: projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java 2009-10-23 07:31:34 UTC (rev 95469)
+++ projects/jboss-osgi/projects/bundles/webapp/trunk/src/main/java/org/jboss/osgi/webapp/internal/WebXMLParserInterceptor.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -37,6 +37,8 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The WebApp lifecycle interceptor.
@@ -46,6 +48,9 @@
*/
public class WebXMLParserInterceptor extends AbstractLifecycleInterceptor implements LifecycleInterceptor
{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(WebXMLParserInterceptor.class);
+
private BundleContext context;
private ServiceTracker serviceTracker;
@@ -98,7 +103,7 @@
VirtualFile webXML = dep.getRoot().getChild("/WEB-INF/web.xml");
if (webXML != null)
{
- // Create and attach the the WebApp metadata
+ log.debug("Create and attach WebApp metadata");
WebApp webApp = createWebAppMetadata(dep, webXML);
dep.addAttachment(WebApp.class, webApp);
}
Modified: projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java 2009-10-23 07:31:34 UTC (rev 95469)
+++ projects/jboss-osgi/trunk/reactor/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintInterceptor.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -33,15 +33,20 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * The Blueprint extender
+ * The Blueprint interceptor
*
* @author thomas.diesler at jboss.com
- * @since 13-May-2009
+ * @since 20-Oct-2009
*/
public class BlueprintInterceptor extends AbstractLifecycleInterceptor implements LifecycleInterceptor
{
+ // Provide logging
+ private Logger log = LoggerFactory.getLogger(BlueprintInterceptor.class);
+
private BlueprintProcessor processor;
private ServiceTracker serviceTracker;
@@ -50,9 +55,6 @@
this.processor = processor;
}
- /**
- * Start the BlueprintExtender
- */
public void start()
{
BlueprintContext bpContext = processor.getBlueprintContext();
@@ -79,9 +81,6 @@
serviceTracker.open();
}
- /**
- * Stop the BlueprintExtender
- */
public void stop()
{
processor.stopAllContainers();
@@ -97,10 +96,12 @@
Bundle bundle = dep.getAttachment(Bundle.class);
if (state == Bundle.STARTING)
{
+ log.debug("Create blueprint container");
processor.createContainer(bundle);
}
else if (state == Bundle.STOPPING)
{
+ log.debug("Stop blueprint container");
processor.stopContainer(bundle);
}
}
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java 2009-10-23 07:31:34 UTC (rev 95469)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -38,12 +38,12 @@
private Set<Class<?>> output;
/**
- * No relative order
- * @return 0
+ * Get default relative order
+ * @return 1000
*/
public int getRelativeOrder()
{
- return 0;
+ return 1000;
}
/**
Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java 2009-10-23 07:31:34 UTC (rev 95469)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptorService.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -31,6 +31,7 @@
import java.util.Set;
import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.internal.InterceptorWrapper;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
@@ -61,6 +62,11 @@
*/
public void addInterceptor(LifecycleInterceptor interceptor)
{
+ if (interceptor == null)
+ throw new IllegalArgumentException("Null interceptor");
+
+ log.debug("Add interceptor: " + new InterceptorWrapper(interceptor));
+
synchronized (interceptorChain)
{
Set<LifecycleInterceptor> unsortedSet = new HashSet<LifecycleInterceptor>();
@@ -112,6 +118,13 @@
addWithRelativeOrder(sortedList, aux);
}
+ // Log the interceptor order
+ for (LifecycleInterceptor aux : sortedList)
+ {
+ InterceptorWrapper wrapper = new InterceptorWrapper(aux);
+ log.debug("\n " + wrapper.toLongString());
+ }
+
// Use the sorted result as the new interceptor chain
interceptorChain.clear();
interceptorChain.addAll(sortedList);
@@ -154,6 +167,11 @@
*/
public void removeInterceptor(LifecycleInterceptor interceptor)
{
+ if (interceptor == null)
+ throw new IllegalArgumentException("Null interceptor");
+
+ log.debug("Remove interceptor: " + new InterceptorWrapper(interceptor));
+
synchronized (interceptorChain)
{
interceptorChain.remove(interceptor);
@@ -213,9 +231,9 @@
}
if (doInvocation)
{
- String className = aux.getClass().getName();
+ InterceptorWrapper wrapper = new InterceptorWrapper(aux);
String stateName = ConstantsHelper.bundleState(state);
- log.debug("Invoke: " + className + " with state " + stateName + " on " + dep.getLocation());
+ log.trace("Invoke: " + wrapper + " with state " + stateName + " on " + dep.getLocation());
aux.invoke(state, dep);
}
}
Added: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/InterceptorWrapper.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/InterceptorWrapper.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/InterceptorWrapper.java 2009-10-23 07:41:20 UTC (rev 95470)
@@ -0,0 +1,106 @@
+/*
+ * 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.deployment.internal;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
+
+/**
+ * A wrapper around lifecycle interceptors.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Oct-2009
+ */
+public class InterceptorWrapper implements LifecycleInterceptor
+{
+ private LifecycleInterceptor delegate;
+
+ public InterceptorWrapper(LifecycleInterceptor delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null interceptor");
+
+ this.delegate = delegate;
+ }
+
+ public Set<Class<?>> getInput()
+ {
+ return delegate.getInput();
+ }
+
+ public Set<Class<?>> getOutput()
+ {
+ return delegate.getOutput();
+ }
+
+ public int getRelativeOrder()
+ {
+ return delegate.getRelativeOrder();
+ }
+
+ public void invoke(int state, Deployment dep) throws LifecycleInterceptorException
+ {
+ delegate.invoke(state, dep);
+ }
+
+ public String toLongString()
+ {
+ String classToken = getLastNameToken(delegate.getClass());
+
+ Set<String> input = null;
+ if (getInput() != null)
+ {
+ input = new HashSet<String>();
+ for(Class<?> aux : getInput())
+ input.add(getLastNameToken(aux.getClass()));
+ }
+
+ Set<String> output = null;
+ if (getOutput() != null)
+ {
+ output = new HashSet<String>();
+ for(Class<?> aux : getOutput())
+ output.add(getLastNameToken(aux.getClass()));
+ }
+
+ return "[" + classToken + ",order=" + getRelativeOrder() + ",input=" + input + ",output=" + output + "]";
+ }
+
+ @Override
+ public String toString()
+ {
+ String className = delegate.getClass().getName();
+ return "[" + className + ",order=" + getRelativeOrder() + "]";
+ }
+
+ private String getLastNameToken(Class<?> clazz)
+ {
+ String token = clazz.getName();
+ return token.substring(token.lastIndexOf(".") + 1);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/internal/InterceptorWrapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the jboss-cvs-commits
mailing list