git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2179 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Hugues Malphettes 2010-07-27 02:24:22 +00:00
parent 53d195407a
commit e7f7c3eea5
12 changed files with 112 additions and 383 deletions

View File

@ -20,6 +20,7 @@ Import-Package: com.sun.el;resolution:=optional,
javax.servlet.jsp.resources;version="2.1",
javax.servlet.jsp.tagext;version="2.1",
javax.servlet.resources;version="2.5.0",
com.sun.org.apache.commons.logging;version="[2.1,3)";split="glassfish";resolution:=optional,
org.apache.jasper;version="6.0.0";resolution:=optional,
org.apache.jasper.compiler;version="6.0.0";resolution:=optional,
org.apache.jasper.compiler.tagplugin;version="6.0.0";resolution:=optional,

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jetty-osgi</artifactId>
<version>7.0.1-SNAPSHOT</version>
<groupId>org.eclipse.jetty.osgi</groupId>
</parent>
<artifactId>org.eclipse.jetty.osgi.boot.jsp</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View File

@ -1,19 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jetty-OSGi-Logback integration
Fragment-Host: org.eclipse.jetty.osgi.boot
Bundle-SymbolicName: org.eclipse.jetty.osgi.boot.logback;singleton:=true
Bundle-Version: 7.1.0.qualifier
Bundle-Vendor: Mort Bay Consulting
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: ch.qos.logback.classic,
ch.qos.logback.classic.joran,
ch.qos.logback.core,
ch.qos.logback.core.joran,
ch.qos.logback.core.joran.spi,
ch.qos.logback.core.spi,
ch.qos.logback.core.util,
org.apache.commons.logging;resolution:=optional,
org.apache.log4j;resolution:=optional,
org.osgi.framework,
org.slf4j

View File

@ -1,12 +0,0 @@
This bundle is made to inject the logback dependencies along with the slf4j dependencies to support log4j and commons-logging.
It will read the configuration in the jettyhome/resources/logback-test.xml or jettyhome/resources/logback.xml folder.
It was tested with these bundles:
#this provides lg4j and commons-logging via slf4j
SLF4J = group("com.springsource.slf4j.api", "com.springsource.slf4j.org.apache.log4j", "com.springsource.slf4j.org.apache.commons.logging",
:under=>"org.slf4j", :version=>"1.5.6")
#logback is not exporting enough packages for us to be able to configure logback classic programatically.. on the springsource version they are fine...
LOGBACK = group("com.springsource.ch.qos.logback.core", "com.springsource.ch.qos.logback.classic",
:under=>"ch.qos.logback", :version=>"0.9.15")

View File

@ -1,5 +0,0 @@
source.. = src/main/java/
output.. = target/classes/
bin.includes = META-INF/,\
.
src.includes = META-INF/

View File

@ -1,109 +0,0 @@
<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">
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
<version>7.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-boot-logback</artifactId>
<name>Jetty :: OSGi :: Boot Logback</name>
<description>Jetty OSGi Boot Logback bundle</description>
<properties>
<bundle-symbolic-name>${project.groupId}.boot.logback</bundle-symbolic-name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-boot</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>services</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<replace file="target/classes/META-INF/MANIFEST.MF" token="Bundle-Version: 7.1.0.qualifier" value="Bundle-Version: ${parsedVersion.osgiVersion}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>artifact-jar</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifestFile>target/classes/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<onlyAnalyze>org.eclipse.jetty.osgi.boot.logback.*</onlyAnalyze>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jetty-osgi</artifactId>
<version>7.0.1-SNAPSHOT</version>
<groupId>org.eclipse.jetty.osgi</groupId>
</parent>
<artifactId>org.eclipse.jetty.osgi.boot.logback</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View File

@ -1,86 +0,0 @@
// ========================================================================
// Copyright (c) 2009 Intalio, Inc.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
package org.eclipse.jetty.osgi.boot.logback;
import java.io.File;
import java.util.Map;
import org.eclipse.jetty.osgi.boot.internal.webapp.LibExtClassLoaderHelper;
import org.eclipse.jetty.osgi.boot.internal.webapp.OSGiWebappClassLoader;
import org.eclipse.jetty.osgi.boot.internal.webapp.LibExtClassLoaderHelper.IFilesInJettyHomeResourcesProcessor;
import org.eclipse.jetty.osgi.boot.logback.internal.LogbackInitializer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* Pseudo fragment activator.
* Called by the main org.eclipse.jetty.osgi.boot bundle.
* Please note: this is not a real BundleActivator. Simply something called back by
* the host bundle.
* The fragment is in charge of placing a hook to configure logback
* when the files inside jettyhome/resources are parsed.
*/
public class FragmentActivator implements BundleActivator, IFilesInJettyHomeResourcesProcessor
{
/**
*
*/
public void start(BundleContext context) throws Exception
{
LibExtClassLoaderHelper.registeredFilesInJettyHomeResourcesProcessors.add(this);
//now let's make sure no log4j, no slf4j and no commons.logging
//get inserted as a library that is not an osgi library
OSGiWebappClassLoader.addClassThatIdentifiesAJarThatMustBeRejected("org.apache.commons.logging.Log");
OSGiWebappClassLoader.addClassThatIdentifiesAJarThatMustBeRejected("org.apache.log4j.Logger");
OSGiWebappClassLoader.addClassThatIdentifiesAJarThatMustBeRejected("org.slf4j.Logger");
//OSGiWebappClassLoader.addClassThatIdentifiesAJarThatMustBeRejected(java.util.logging.Logger.class);
}
/**
* Called when this bundle is stopped so the Framework can perform the
* bundle-specific activities necessary to stop the bundle. In general, this
* method should undo the work that the <code>BundleActivator.start</code>
* method started. There should be no active threads that were started by
* this bundle when this bundle returns. A stopped bundle must not call any
* Framework objects.
*
* <p>
* This method must complete and return to its caller in a timely manner.
*
* @param context The execution context of the bundle being stopped.
* @throws Exception If this method throws an exception, the
* bundle is still marked as stopped, and the Framework will remove
* the bundle's listeners, unregister all services registered by the
* bundle, and release all services used by the bundle.
*/
public void stop(BundleContext context) throws Exception
{
LibExtClassLoaderHelper.registeredFilesInJettyHomeResourcesProcessors.remove(this);
}
public void processFilesInResourcesFolder(File jettyHome, Map<String,File> files)
{
try
{
LogbackInitializer.processFilesInResourcesFolder(jettyHome, files);
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}

View File

@ -1,98 +0,0 @@
// ========================================================================
// Copyright (c) 2009 Intalio, Inc.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
// You may elect to redistribute this code under either of these licenses.
// Contributors:
// Hugues Malphettes - initial API and implementation
// ========================================================================
package org.eclipse.jetty.osgi.boot.logback.internal;
import java.io.File;
import java.util.Map;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.JoranConfiguratorBase;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;
/**
* Setup logback eventually located in the config file inside jettyhome/resources
* All logback related code is done in this separate class for better debug
* and isolation when it does not load.
*/
public class LogbackInitializer {
/**
* @return true when we are currently being run by the pde in development mode.
*/
private static boolean isPDEDevelopment()
{
String eclipseCommands = System.getProperty("eclipse.commands");
// detect if we are being run from the pde: ie during development.
return eclipseCommands != null && eclipseCommands.indexOf("-dev") != -1
&& (eclipseCommands.indexOf("-dev\n") != -1
|| eclipseCommands.indexOf("-dev\r") != -1
|| eclipseCommands.indexOf("-dev ") != -1);
}
/**
* Follow the configuration for logback.
* unless the system propery was set in which case it
* was assume it was already setup.
*/
public static void processFilesInResourcesFolder(File jettyHome, Map<String,File> files)
{
String logbackConf = System.getProperty("logback.configurationFile");
if (logbackConf != null)
{
File confFile = new File(logbackConf);
if (confFile.exists())
{
//assume logback was configured by this one?
return;
}
}
File logConf = isPDEDevelopment() ? files.get("logback-dev.xml") : null;
if (logConf == null)
{
logConf = files.get("logback-test.xml");
}
if (logConf == null)
{
logConf = files.get("logback.xml");
}
if (logConf == null)
{
return;
}
// assume SLF4J is bound to logback in the current environment
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
try
{
JoranConfiguratorBase configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(logConf.getAbsoluteFile().getAbsolutePath());
}
catch (JoranException je)
{
je.printStackTrace();
}
StatusPrinter.printIfErrorsOccured(lc);
}
}

View File

@ -32,7 +32,7 @@
</dependency>
</dependencies>
<build>
<!--build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
@ -86,6 +86,113 @@
</configuration>
</plugin>
</plugins>
</build>
</build-->
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<delete file="target/classes/META-INF/MANIFEST.MF"/>
<copy todir="target/classes/jettyhome">
<fileset dir="jettyhome">
<exclude name="**/*.log"/>
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>artifact-jar</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifestFile>target/classes/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.eclipse.jetty.osgi.boot;singleton:=true</Bundle-SymbolicName>
<Export-Package>org.eclipse.jetty.osgi.boot,org.eclipse.jetty.osgi.boot.utils</Export-Package>
<Bundle-Activator>org.eclipse.jetty.osgi.boot.JettyBootstrapActivator</Bundle-Activator>
<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
<!-- disable the uses directive: jetty will accomodate pretty much any versions
of the packages it uses; no need to reflect some tight dependency determined at
compilation time. -->
<_nouses>true</_nouses>
<Import-Package>javax.mail;version="1.4.0";resolution:=optional,
javax.mail.event;version="1.4.0";resolution:=optional,
javax.mail.internet;version="1.4.0";resolution:=optional,
javax.mail.search;version="1.4.0";resolution:=optional,
javax.mail.util;version="1.4.0";resolution:=optional,
javax.servlet;version="2.5.0",
javax.servlet.http;version="2.5.0",
javax.transaction;version="1.1.0";resolution:=optional,
javax.transaction.xa;version="1.1.0";resolution:=optional,
org.osgi.framework,
org.osgi.service.cm;version="1.2.0",
org.osgi.service.packageadmin,
org.osgi.service.startlevel;version="1.0",
org.osgi.service.url;version="1.0.0",
org.osgi.util.tracker;version="1.3.0",
org.slf4j;resolution:=optional,
org.slf4j.spi;resolution:=optional,
org.slf4j.helpers;resolution:=optional,
org.xml.sax,
org.xml.sax.helpers,
*
</Import-Package>
<DynamicImport-Package>org.eclipse.jetty.*;version=[7.2,8)</DynamicImport-Package>
<!--Require-Bundle/-->
<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<onlyAnalyze>org.eclipse.jetty.osgi.boot.*</onlyAnalyze>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jetty-osgi</artifactId>
<groupId>org.eclipse.jetty.osgi</groupId>
<version>7.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jetty.osgi.boot</artifactId>
<packaging>eclipse-plugin</packaging>
<!--build>
<resources>
<resource>
<excludes>
<exclude>jettyhome/lib/ext/*.jar</exclude>
<exclude>jettyhome/logs/*.log</exclude>
</excludes>
</resource>
</resources>
</build-->
</project>

View File

@ -21,10 +21,9 @@
<modules>
<module>jetty-osgi-boot</module>
<module>jetty-osgi-boot-jsp</module>
<!-- logback is currently under CQs -->
<module>jetty-osgi-boot-logback</module>
<module>jetty-osgi-boot-warurl</module>
<module>jetty-osgi-httpservice</module>
<module>test-jetty-osgi</module>
<!-- module>example-jetty-osgi</module -->
</modules>
<build>