This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-startupfilter-disabler.git
commit 4045a1c28cf9676d2dcfc2574f9f4406a2803a6c Author: Bertrand Delacretaz <[email protected]> AuthorDate: Wed Jan 4 16:45:04 2012 +0000 SLING-2347 - startup filter disabler bundle added git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1227218 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 80 ++++++++++++++++++++++ .../startupfilterdisabler/impl/Activator.java | 49 +++++++++++++ 2 files changed, 129 insertions(+) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7cb5b11 --- /dev/null +++ b/pom.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to you under the Apache License, Version + 2.0 (the "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 Unless required by + applicable law or agreed to in writing, software distributed under + the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and + limitations under the License. + --> +<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> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling</artifactId> + <version>11</version> + <relativePath>../../../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.apache.sling.startupfilter.disabler</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>bundle</packaging> + + <name>Apache Sling Startup Filter Disabler</name> + <description> + The Activator of this bundle disables the Sling Startup Filter. + Configure this bundle with a high enough run level to remove the + startup filter once the system is ready. + </description> + + <scm> + <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter-disabler</connection> + <developerConnection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter-disabler</developerConnection> + <url>http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/startup-filter-disabler</url> + </scm> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Private-Package>org.apache.sling.startupfilterdisabler.impl.*</Private-Package> + <Bundle-Activator>org.apache.sling.startupfilterdisabler.impl.Activator</Bundle-Activator> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.startupfilter</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/src/main/java/org/apache/sling/startupfilterdisabler/impl/Activator.java b/src/main/java/org/apache/sling/startupfilterdisabler/impl/Activator.java new file mode 100644 index 0000000..e2b45c2 --- /dev/null +++ b/src/main/java/org/apache/sling/startupfilterdisabler/impl/Activator.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.startupfilterdisabler.impl; + +import org.apache.sling.startupfilter.StartupFilter; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Activator implements BundleActivator { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + public void start(BundleContext context) throws Exception { + final ServiceReference ref = context.getServiceReference(StartupFilter.class.getName()); + if(ref == null) { + log.warn("No StartupFilter service found to disable"); + } else { + final StartupFilter filter = (StartupFilter)context.getService(ref); + if(filter.isEnabled()) { + filter.disable(); + log.info("StartupFilter disabled: {}", filter); + } else { + log.info("StartupFilter already disabled, nothing to do: {}", filter); + } + } + } + + public void stop(BundleContext context) throws Exception { + } +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
