Author: davsclaus
Date: Tue Dec 14 11:08:43 2010
New Revision: 1049042
URL: http://svn.apache.org/viewvc?rev=1049042&view=rev
Log:
CAMEL-3425: CamelContext logger should not be static, so extended class have
its classname logged. Eg so its easier to spot OsgiCamelContext and
BlueprintCamelContext.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel/trunk/components/camel-blueprint/ (props changed)
camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
camel/trunk/components/camel-guice/ (props changed)
camel/trunk/tests/camel-itest-osgi/ (props changed)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1049042&r1=1049041&r2=1049042&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Tue Dec 14 11:08:43 2010
@@ -129,7 +129,7 @@ import org.apache.commons.logging.LogFac
* @version $Revision$
*/
public class DefaultCamelContext extends ServiceSupport implements
CamelContext, SuspendableService {
- private static final transient Log LOG =
LogFactory.getLog(DefaultCamelContext.class);
+ private final transient Log log = LogFactory.getLog(getClass());
private JAXBContext jaxbContext;
private CamelContextNameStrategy nameStrategy = new
DefaultCamelContextNameStrategy();
private String managementName;
@@ -200,7 +200,7 @@ public class DefaultCamelContext extends
// use WebSphere specific resolver if running on WebSphere
if
(WebSpherePackageScanClassResolver.isWebSphereClassLoader(this.getClass().getClassLoader()))
{
- LOG.info("Using WebSphere specific PackageScanClassResolver");
+ log.info("Using WebSphere specific PackageScanClassResolver");
packageScanClassResolver = new
WebSpherePackageScanClassResolver("META-INF/services/org/apache/camel/TypeConverter");
} else {
packageScanClassResolver = new DefaultPackageScanClassResolver();
@@ -395,8 +395,8 @@ public class DefaultCamelContext extends
public Endpoint getEndpoint(String uri) {
ObjectHelper.notEmpty(uri, "uri");
- if (LOG.isTraceEnabled()) {
- LOG.trace("Getting endpoint with uri: " + uri);
+ if (log.isTraceEnabled()) {
+ log.trace("Getting endpoint with uri: " + uri);
}
// in case path has property placeholders then try to let property
component resolve those
@@ -413,8 +413,8 @@ public class DefaultCamelContext extends
throw new ResolveEndpointFailedException(uri, e);
}
- if (LOG.isTraceEnabled()) {
- LOG.trace("Getting endpoint with normalized uri: " + uri);
+ if (log.isTraceEnabled()) {
+ log.trace("Getting endpoint with normalized uri: " + uri);
}
Endpoint answer;
@@ -434,8 +434,8 @@ public class DefaultCamelContext extends
// Have the component create the endpoint if it
can.
answer = component.createEndpoint(uri);
- if (answer != null && LOG.isDebugEnabled()) {
- LOG.debug(uri + " converted to endpoint: " +
answer + " by component: " + component);
+ if (answer != null && log.isDebugEnabled()) {
+ log.debug(uri + " converted to endpoint: " +
answer + " by component: " + component);
}
}
}
@@ -561,8 +561,8 @@ public class DefaultCamelContext extends
}
public void addRoutes(RoutesBuilder builder) throws Exception {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Adding routes from builder: " + builder);
+ if (log.isDebugEnabled()) {
+ log.debug("Adding routes from builder: " + builder);
}
// lets now add the routes from the builder
builder.addRoutesToCamelContext(this);
@@ -882,8 +882,8 @@ public class DefaultCamelContext extends
PropertiesComponent pc = getComponent("properties",
PropertiesComponent.class);
// the parser will throw exception if property key was not found
String answer = pc.parseUri(text);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Resolved text: " + text + " -> " + answer);
+ if (log.isDebugEnabled()) {
+ log.debug("Resolved text: " + text + " -> " + answer);
}
return answer;
}
@@ -1143,7 +1143,7 @@ public class DefaultCamelContext extends
protected void doSuspend() throws Exception {
EventHelper.notifyCamelContextSuspending(this);
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is suspending");
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is suspending");
StopWatch watch = new StopWatch();
// update list of started routes to be suspended
@@ -1180,8 +1180,8 @@ public class DefaultCamelContext extends
}
watch.stop();
- if (LOG.isInfoEnabled()) {
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is suspended in " + TimeUtils.printDuration(watch.taken()));
+ if (log.isInfoEnabled()) {
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is suspended in " + TimeUtils.printDuration(watch.taken()));
}
EventHelper.notifyCamelContextSuspended(this);
@@ -1192,7 +1192,7 @@ public class DefaultCamelContext extends
try {
EventHelper.notifyCamelContextResuming(this);
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is resuming");
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is resuming");
StopWatch watch = new StopWatch();
// start the suspended routes (do not check for route clashes, and
indicate)
@@ -1208,9 +1208,9 @@ public class DefaultCamelContext extends
}
watch.stop();
- if (LOG.isInfoEnabled()) {
- LOG.info("Resumed " + suspendedRouteServices.size() + "
routes");
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") resumed in " + TimeUtils.printDuration(watch.taken()));
+ if (log.isInfoEnabled()) {
+ log.info("Resumed " + suspendedRouteServices.size() + "
routes");
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") resumed in " + TimeUtils.printDuration(watch.taken()));
}
// and clear the list as they have been resumed
@@ -1226,7 +1226,7 @@ public class DefaultCamelContext extends
public void start() throws Exception {
startDate = new Date();
stopWatch.restart();
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is starting");
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is starting");
doNotStartRoutesOnFirstStart = !firstStartDone && !isAutoStartup();
firstStartDone = true;
@@ -1235,7 +1235,7 @@ public class DefaultCamelContext extends
super.start();
stopWatch.stop();
- if (LOG.isInfoEnabled()) {
+ if (log.isInfoEnabled()) {
// count how many routes are actually started
int started = 0;
for (Route route : getRoutes()) {
@@ -1243,8 +1243,8 @@ public class DefaultCamelContext extends
started++;
}
}
- LOG.info("Total " + getRoutes().size() + " routes, of which " +
started + " is started.");
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") started in " + TimeUtils.printDuration(stopWatch.taken()));
+ log.info("Total " + getRoutes().size() + " routes, of which " +
started + " is started.");
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") started in " + TimeUtils.printDuration(stopWatch.taken()));
}
EventHelper.notifyCamelContextStarted(this);
}
@@ -1267,20 +1267,20 @@ public class DefaultCamelContext extends
if (isStreamCaching()) {
// only add a new stream cache if not already configured
if (StreamCaching.getStreamCaching(this) == null) {
- LOG.info("StreamCaching is enabled on CamelContext: " +
getName());
+ log.info("StreamCaching is enabled on CamelContext: " +
getName());
addInterceptStrategy(new StreamCaching());
}
}
if (isTracing()) {
// tracing is added in the DefaultChannel so we can enable it on
the fly
- LOG.info("Tracing is enabled on CamelContext: " + getName());
+ log.info("Tracing is enabled on CamelContext: " + getName());
}
if (isHandleFault()) {
// only add a new handle fault if not already configured
if (HandleFault.getHandleFault(this) == null) {
- LOG.info("HandleFault is enabled on CamelContext: " +
getName());
+ log.info("HandleFault is enabled on CamelContext: " +
getName());
addInterceptStrategy(new HandleFault());
}
}
@@ -1289,14 +1289,14 @@ public class DefaultCamelContext extends
// only add a new delayer if not already configured
if (Delayer.getDelayer(this) == null) {
long millis = getDelayer();
- LOG.info("Delayer is enabled with: " + millis + " ms. on
CamelContext: " + getName());
+ log.info("Delayer is enabled with: " + millis + " ms. on
CamelContext: " + getName());
addInterceptStrategy(new Delayer(millis));
}
}
// register debugger
if (getDebugger() != null) {
- LOG.info("Debugger: " + getDebugger() + " is enabled on
CamelContext: " + getName());
+ log.info("Debugger: " + getDebugger() + " is enabled on
CamelContext: " + getName());
// register this camel context on the debugger
getDebugger().setCamelContext(this);
startServices(getDebugger());
@@ -1314,10 +1314,10 @@ public class DefaultCamelContext extends
strategy.onContextStart(this);
} catch (VetoCamelContextStartException e) {
// okay we should not start Camel since it was vetoed
- LOG.warn("Lifecycle strategy vetoed starting CamelContext (" +
getName() + ")", e);
+ log.warn("Lifecycle strategy vetoed starting CamelContext (" +
getName() + ")", e);
throw e;
} catch (Exception e) {
- LOG.warn("Lifecycle strategy " + strategy + " failed starting
CamelContext (" + getName() + ")", e);
+ log.warn("Lifecycle strategy " + strategy + " failed starting
CamelContext (" + getName() + ")", e);
throw e;
}
}
@@ -1349,7 +1349,7 @@ public class DefaultCamelContext extends
// start routes
if (doNotStartRoutesOnFirstStart) {
- LOG.info("Cannot start routes as CamelContext has been configured
with autoStartup=false");
+ log.info("Cannot start routes as CamelContext has been configured
with autoStartup=false");
}
// invoke this logic to warmup the routes and if possible also start
the routes
@@ -1360,14 +1360,14 @@ public class DefaultCamelContext extends
protected synchronized void doStop() throws Exception {
stopWatch.restart();
- LOG.info("Apache Camel " + getVersion() + " (CamelContext:" +
getName() + ") is shutting down");
+ log.info("Apache Camel " + getVersion() + " (CamelContext:" +
getName() + ") is shutting down");
EventHelper.notifyCamelContextStopping(this);
// stop route inputs in the same order as they was started so we stop
the very first inputs first
try {
shutdownStrategy.shutdown(this, getRouteStartupOrder());
} catch (Throwable e) {
- LOG.warn("Error occurred while shutting down routes. This
exception will be ignored.", e);
+ log.warn("Error occurred while shutting down routes. This
exception will be ignored.", e);
}
getRouteStartupOrder().clear();
@@ -1393,7 +1393,7 @@ public class DefaultCamelContext extends
strategy.onContextStop(this);
}
} catch (Throwable e) {
- LOG.warn("Error occurred while stopping lifecycle strategies. This
exception will be ignored.", e);
+ log.warn("Error occurred while stopping lifecycle strategies. This
exception will be ignored.", e);
}
// shutdown services as late as possible
@@ -1415,9 +1415,9 @@ public class DefaultCamelContext extends
forceStopLazyInitialization();
stopWatch.stop();
- if (LOG.isInfoEnabled()) {
- LOG.info("Uptime: " + getUptime());
- LOG.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is shutdown in " + TimeUtils.printDuration(stopWatch.taken()));
+ if (log.isInfoEnabled()) {
+ log.info("Uptime: " + getUptime());
+ log.info("Apache Camel " + getVersion() + " (CamelContext: " +
getName() + ") is shutdown in " + TimeUtils.printDuration(stopWatch.taken()));
}
// and clear start date
@@ -1486,7 +1486,7 @@ public class DefaultCamelContext extends
try {
ServiceHelper.stopAndShutdownService(service);
} catch (Throwable e) {
- LOG.warn("Error occurred while shutting down service: " + service
+ ". This exception will be ignored.", e);
+ log.warn("Error occurred while shutting down service: " + service
+ ". This exception will be ignored.", e);
// fire event
EventHelper.notifyServiceStopFailure(this, service, e);
}
@@ -1605,8 +1605,8 @@ public class DefaultCamelContext extends
protected synchronized void stopRouteService(RouteService routeService)
throws Exception {
routeService.stop();
for (Route route : routeService.getRoutes()) {
- if (LOG.isInfoEnabled()) {
- LOG.info("Route: " + route.getId() + " stopped, was consuming
from: " + route.getConsumer().getEndpoint());
+ if (log.isInfoEnabled()) {
+ log.info("Route: " + route.getId() + " stopped, was consuming
from: " + route.getConsumer().getEndpoint());
}
}
}
@@ -1614,8 +1614,8 @@ public class DefaultCamelContext extends
protected synchronized void shutdownRouteService(RouteService
routeService) throws Exception {
routeService.shutdown();
for (Route route : routeService.getRoutes()) {
- if (LOG.isInfoEnabled()) {
- LOG.info("Route: " + route.getId() + " shutdown and removed,
was consuming from: " + route.getConsumer().getEndpoint());
+ if (log.isInfoEnabled()) {
+ log.info("Route: " + route.getId() + " shutdown and removed,
was consuming from: " + route.getConsumer().getEndpoint());
}
}
}
@@ -1623,8 +1623,8 @@ public class DefaultCamelContext extends
protected synchronized void suspendRouteService(RouteService routeService)
throws Exception {
routeService.suspend();
for (Route route : routeService.getRoutes()) {
- if (LOG.isInfoEnabled()) {
- LOG.info("Route: " + route.getId() + " suspended, was
consuming from: " + route.getConsumer().getEndpoint());
+ if (log.isInfoEnabled()) {
+ log.info("Route: " + route.getId() + " suspended, was
consuming from: " + route.getConsumer().getEndpoint());
}
}
}
@@ -1733,8 +1733,8 @@ public class DefaultCamelContext extends
// what this does is to ensure Camel is more robust on starting
routes as all routes
// will then be prepared in time before we start inputs which will
consume messages to be routed
RouteService routeService = entry.getValue().getRouteService();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Warming up route id: " + routeService.getId() + "
having autoStartup=" + autoStartup);
+ if (log.isDebugEnabled()) {
+ log.debug("Warming up route id: " + routeService.getId() + "
having autoStartup=" + autoStartup);
}
routeService.warmUp();
}
@@ -1759,7 +1759,7 @@ public class DefaultCamelContext extends
// if we are starting camel, then skip routes which are configured
to not be auto started
boolean autoStartup =
routeService.getRouteDefinition().isAutoStartup(this);
if (addingRoute && !autoStartup) {
- LOG.info("Cannot start route " + routeService.getId() + " as
its configured with autoStartup=false");
+ log.info("Cannot start route " + routeService.getId() + " as
its configured with autoStartup=false");
continue;
}
@@ -1774,26 +1774,26 @@ public class DefaultCamelContext extends
}
// start the consumer on the route
- if (LOG.isDebugEnabled()) {
- LOG.debug("Route: " + route.getId() + " >>> " + route);
+ if (log.isDebugEnabled()) {
+ log.debug("Route: " + route.getId() + " >>> " + route);
if (resumeOnly) {
- LOG.debug("Resuming consumer (order: " + order + ") on
route: " + route.getId());
+ log.debug("Resuming consumer (order: " + order + ") on
route: " + route.getId());
} else {
- LOG.debug("Starting consumer (order: " + order + ") on
route: " + route.getId());
+ log.debug("Starting consumer (order: " + order + ") on
route: " + route.getId());
}
}
if (resumeOnly && route.supportsSuspension()) {
// if we are resuming and the route can be resumed
resumeServices(consumer);
- LOG.info("Route: " + route.getId() + " resumed and
consuming from: " + endpoint);
+ log.info("Route: " + route.getId() + " resumed and
consuming from: " + endpoint);
} else {
// when starting we should invoke the lifecycle strategies
for (LifecycleStrategy strategy : lifecycleStrategies) {
strategy.onServiceAdd(this, consumer, route);
}
startServices(consumer);
- LOG.info("Route: " + route.getId() + " started and
consuming from: " + endpoint);
+ log.info("Route: " + route.getId() + " started and
consuming from: " + endpoint);
}
routeInputs.add(endpoint);
@@ -2033,7 +2033,7 @@ public class DefaultCamelContext extends
public void setManagementStrategy(ManagementStrategy managementStrategy) {
synchronized (managementStrategyInitialized) {
if (managementStrategyInitialized.get()) {
- LOG.warn("Resetting ManagementStrategy for context " +
getName());
+ log.warn("Resetting ManagementStrategy for context " +
getName());
}
this.managementStrategy = managementStrategy;
@@ -2177,11 +2177,11 @@ public class DefaultCamelContext extends
ManagementStrategy answer;
if (disableJMX || Boolean.getBoolean(JmxSystemPropertyKeys.DISABLED)) {
- LOG.info("JMX is disabled. Using DefaultManagementStrategy.");
+ log.info("JMX is disabled. Using DefaultManagementStrategy.");
answer = new DefaultManagementStrategy();
} else {
try {
- LOG.info("JMX enabled. Using ManagedManagementStrategy.");
+ log.info("JMX enabled. Using ManagedManagementStrategy.");
answer = new ManagedManagementStrategy(new
DefaultManagementAgent(this));
// must start it to ensure JMX works and can load needed
Spring JARs
startServices(answer);
@@ -2192,18 +2192,18 @@ public class DefaultCamelContext extends
// if we can't instantiate the JMX enabled strategy then
fallback to default
// could be because of missing .jars on the classpath
- LOG.warn("Cannot find needed classes for JMX lifecycle
strategy."
+ log.warn("Cannot find needed classes for JMX lifecycle
strategy."
+ " Needed class is in spring-context.jar using Spring
2.5 or newer"
+ " (spring-jmx.jar using Spring 2.0.x)."
+ " NoClassDefFoundError: " + e.getMessage());
} catch (Exception e) {
answer = null;
- LOG.warn("Cannot create JMX lifecycle strategy. Fallback to
using DefaultManagementStrategy (non JMX).", e);
+ log.warn("Cannot create JMX lifecycle strategy. Fallback to
using DefaultManagementStrategy (non JMX).", e);
}
}
if (answer == null) {
- LOG.warn("Cannot use JMX. Fallback to using
DefaultManagementStrategy (non JMX).");
+ log.warn("Cannot use JMX. Fallback to using
DefaultManagementStrategy (non JMX).");
answer = new DefaultManagementStrategy();
}
Propchange: camel/trunk/components/camel-blueprint/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Dec 14 11:08:43 2010
@@ -5,3 +5,5 @@
target
.settings
eclipse-classes
+*.i??
+classes
Modified:
camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java?rev=1049042&r1=1049041&r2=1049042&view=diff
==============================================================================
---
camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
(original)
+++
camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
Tue Dec 14 11:08:43 2010
@@ -74,8 +74,6 @@ public class BlueprintCamelContext exten
private void maybeStart() throws Exception {
if (!isStarted() && !isStarting()) {
- // Make sure we will not get into the endless loop of calling star
- LOG.info("Starting Apache Camel as property ShouldStartContext is
true");
start();
} else {
// ignore as Camel is already started
Propchange: camel/trunk/components/camel-guice/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Dec 14 11:08:43 2010
@@ -1,7 +1,9 @@
.project
-.pmd
.checkstyle
+.pmd
.classpath
target
.settings
eclipse-classes
+*.i??
+classes
Propchange: camel/trunk/tests/camel-itest-osgi/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Dec 14 11:08:43 2010
@@ -5,3 +5,5 @@
target
.settings
eclipse-classes
+*.i??
+classes