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-validation-test-services.git

commit 6bec3a9f12ba14d4c70c0ddf4cd9e3ba002a0335
Author: Oliver Lietz <o...@apache.org>
AuthorDate: Sat Mar 18 15:42:01 2017 +0000

    remove resource presence and presenter
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787571 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../validation/testservices/ResourcePresence.java  |  26 ----
 .../testservices/internal/ResourcePresenter.java   | 131 ---------------------
 2 files changed, 157 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/validation/testservices/ResourcePresence.java 
b/src/main/java/org/apache/sling/validation/testservices/ResourcePresence.java
deleted file mode 100644
index 6a414a1..0000000
--- 
a/src/main/java/org/apache/sling/validation/testservices/ResourcePresence.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.validation.testservices;
-
-import org.osgi.annotation.versioning.ProviderType;
-
-@ProviderType
-public interface ResourcePresence {
-
-}
diff --git 
a/src/main/java/org/apache/sling/validation/testservices/internal/ResourcePresenter.java
 
b/src/main/java/org/apache/sling/validation/testservices/internal/ResourcePresenter.java
deleted file mode 100644
index 7043488..0000000
--- 
a/src/main/java/org/apache/sling/validation/testservices/internal/ResourcePresenter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.validation.testservices.internal;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-
-import org.apache.sling.api.resource.LoginException;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.api.resource.observation.ResourceChange;
-import org.apache.sling.api.resource.observation.ResourceChangeListener;
-import org.apache.sling.validation.testservices.ResourcePresence;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Component(
-    service = ResourceChangeListener.class,
-    immediate = true,
-    property = {
-        "resource.paths=/apps/sling/validation"
-    }
-)
-public class ResourcePresenter implements ResourceChangeListener {
-
-    @Reference
-    private ResourceResolverFactory resourceResolverFactory;
-
-    private ServiceRegistration<ResourcePresence> model;
-
-    private DefaultResourcePresence resourcePresence = new 
DefaultResourcePresence("/apps/sling/validation/models/model1");
-
-    private BundleContext bundleContext;
-
-    private final Logger logger = 
LoggerFactory.getLogger(ResourcePresenter.class);
-
-    @Activate
-    public void activate(final BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-        try (final ResourceResolver resourceResolver = 
getServiceResourceResolver()) {
-            final Resource validation = 
resourceResolver.getResource("/apps/sling/validation/models/model1");
-            if (validation != null) {
-                registerResourcePresence();
-            }
-        } catch (LoginException e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-
-    @Deactivate
-    public void deactivate(final BundleContext bundleContext) {
-        unregisterResourcePresence();
-    }
-
-    @Override
-    public void onChange(@Nonnull List<ResourceChange> list) {
-        for (ResourceChange resourceChange : list) {
-            logger.info("resource change at {}: {}", resourceChange.getPath(), 
resourceChange.getType());
-            if (resourcePresence.getPath().equals(resourceChange.getPath())) {
-                switch (resourceChange.getType()) {
-                    case ADDED:
-                        registerResourcePresence();
-                        break;
-                    case REMOVED:
-                        unregisterResourcePresence();
-                        break;
-                    default:
-                        break;
-                }
-            }
-        }
-    }
-
-    private ResourceResolver getServiceResourceResolver() throws 
LoginException {
-        return resourceResolverFactory.getServiceResourceResolver(null);
-    }
-
-    private void registerResourcePresence() {
-        final Dictionary<String, Object> properties = new Hashtable<>();
-        properties.put("path", resourcePresence.getPath());
-        this.model = bundleContext.registerService(ResourcePresence.class, 
resourcePresence, properties);
-        logger.info("resource presence for {} registered", 
resourcePresence.getPath());
-    }
-
-    private void unregisterResourcePresence() {
-        if (model != null) {
-            model.unregister();
-            logger.info("resource presence for {} unregistered", 
resourcePresence.getPath());
-        }
-    }
-
-    private class DefaultResourcePresence implements ResourcePresence {
-
-        private final String path;
-
-        DefaultResourcePresence(final String path) {
-            this.path = path;
-        }
-
-        public String getPath() {
-            return path;
-        }
-    }
-
-}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Reply via email to