Author: cziegeler
Date: Fri May 16 04:36:42 2008
New Revision: 657021
URL: http://svn.apache.org/viewvc?rev=657021&view=rev
Log:
SLING-414: Separate activator from service implementation.
Added:
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
(with props)
Modified:
incubator/sling/trunk/engine/pom.xml
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/SlingSettingsServiceImpl.java
Modified: incubator/sling/trunk/engine/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/engine/pom.xml?rev=657021&r1=657020&r2=657021&view=diff
==============================================================================
--- incubator/sling/trunk/engine/pom.xml (original)
+++ incubator/sling/trunk/engine/pom.xml Fri May 16 04:36:42 2008
@@ -74,7 +74,7 @@
*
</Import-Package>
<Bundle-Activator>
-
org.apache.sling.engine.impl.SlingSettingsServiceImpl
+ org.apache.sling.engine.impl.EngineBundleActivator
</Bundle-Activator>
<Embed-Dependency>
commons-fileupload
Added:
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java?rev=657021&view=auto
==============================================================================
---
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
(added)
+++
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
Fri May 16 04:36:42 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.engine.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.sling.engine.SlingSettingsService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * This is the bundle activator for the Sling engine.
+ * It registers the SlingSettingsService.
+ *
+ */
+public class EngineBundleActivator implements BundleActivator {
+
+ /** The service registration */
+ private ServiceRegistration serviceRegistration;
+
+ /**
+ * @see
org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ final Object service = new SlingSettingsServiceImpl(context);
+ final Dictionary<String, String> props = new Hashtable<String,
String>();
+ props.put(Constants.SERVICE_PID, service.getClass().getName());
+ props.put(Constants.SERVICE_DESCRIPTION,
+ "Apache Sling Settings Service");
+ props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+ serviceRegistration =
context.registerService(SlingSettingsService.class.getName(),
+ service,
+ props);
+ }
+
+ /**
+ * @see
org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ if ( serviceRegistration != null ) {
+ serviceRegistration.unregister();
+ serviceRegistration = null;
+ }
+ }
+}
Propchange:
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/EngineBundleActivator.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Modified:
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/SlingSettingsServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/SlingSettingsServiceImpl.java?rev=657021&r1=657020&r2=657021&view=diff
==============================================================================
---
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/SlingSettingsServiceImpl.java
(original)
+++
incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/SlingSettingsServiceImpl.java
Fri May 16 04:36:42 2008
@@ -25,15 +25,13 @@
import java.util.UUID;
import org.apache.sling.engine.SlingSettingsService;
-import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
import org.slf4j.LoggerFactory;
/**
* This is the basic implementation of the sling settings service.
*/
-public class SlingSettingsServiceImpl implements SlingSettingsService,
BundleActivator {
+public class SlingSettingsServiceImpl implements SlingSettingsService {
/** The logger */
private org.slf4j.Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -41,21 +39,7 @@
/** The sling instance id. */
private String slingId;
- /** The service registration */
- private ServiceRegistration serviceRegistration;
-
- /**
- * @see org.apache.sling.engine.SlingSettingsService#getSlingId()
- */
- public String getSlingId() {
- return this.slingId;
- }
-
- /**
- * Read/Create the sling instance id.
- * @see
org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
+ public SlingSettingsServiceImpl(final BundleContext context) {
// try to read the id from the id file first
File idFile = context.getDataFile("sling.id.file");
if ( idFile == null ) {
@@ -108,16 +92,12 @@
}
}
}
- serviceRegistration =
context.registerService(SlingSettingsService.class.getName(), this, null);
}
/**
- * @see
org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ * @see org.apache.sling.engine.SlingSettingsService#getSlingId()
*/
- public void stop(BundleContext context) throws Exception {
- if ( serviceRegistration != null ) {
- serviceRegistration.unregister();
- serviceRegistration = null;
- }
+ public String getSlingId() {
+ return this.slingId;
}
}