brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [05/27] brooklyn-server git commit: remove deprecated CAMP ServiceTypeResolver
Date Fri, 30 Jun 2017 14:02:53 GMT
remove deprecated CAMP ServiceTypeResolver

changed a while ago to EntitySpecResolver; removes references to catalog items and hokey lookup


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c9d03c93
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c9d03c93
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c9d03c93

Branch: refs/heads/master
Commit: c9d03c93e35eb5417ca6168207f4b0ddc3de9e7c
Parents: eb08f8e
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Jun 16 13:46:20 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Jun 16 17:06:05 2017 +0100

----------------------------------------------------------------------
 .../BrooklynComponentTemplateResolver.java      |  9 +--
 .../service/BrooklynServiceTypeResolver.java    | 78 --------------------
 .../creation/service/ServiceTypeResolver.java   | 77 -------------------
 .../service/ServiceTypeResolverAdaptor.java     | 70 ------------------
 .../service/ServiceTypeResolverTest.java        | 39 ----------
 .../service/TestServiceTypeResolver.java        | 54 --------------
 6 files changed, 1 insertion(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index 7e9b562..ae92c92 100644
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -30,7 +30,6 @@ import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.framework.FrameworkLookup;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
@@ -39,8 +38,6 @@ import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
 import org.apache.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
 import org.apache.brooklyn.camp.brooklyn.spi.creation.service.CampServiceSpecResolver;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.service.ServiceTypeResolver;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.service.ServiceTypeResolverAdaptor;
 import org.apache.brooklyn.camp.spi.AbstractResource;
 import org.apache.brooklyn.camp.spi.ApplicationComponentTemplate;
 import org.apache.brooklyn.camp.spi.AssemblyTemplate;
@@ -82,7 +79,6 @@ import com.google.common.collect.Maps;
  * This generates instances of a template resolver that use a {@link ServiceTypeResolver}
  * to parse the {@code serviceType} line in the template.
  */
-@SuppressWarnings("deprecation")  // Because of ServiceTypeResolver
 public class BrooklynComponentTemplateResolver {
 
     private static final Logger log = LoggerFactory.getLogger(BrooklynComponentTemplateResolver.class);
@@ -197,10 +193,7 @@ public class BrooklynComponentTemplateResolver {
 
     private List<EntitySpecResolver> getServiceTypeResolverOverrides() {
         List<EntitySpecResolver> overrides = new ArrayList<>();
-        Iterable<ServiceTypeResolver> loader = FrameworkLookup.lookupAll(ServiceTypeResolver.class,
mgmt.getCatalogClassLoader());
-        for (ServiceTypeResolver resolver : loader) {
-            overrides.add(new ServiceTypeResolverAdaptor(this, resolver));
-        }
+        // none for now -- previously supported ServiceTypeResolver service
         return overrides;
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/BrooklynServiceTypeResolver.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/BrooklynServiceTypeResolver.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/BrooklynServiceTypeResolver.java
deleted file mode 100644
index f9c07e4..0000000
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/BrooklynServiceTypeResolver.java
+++ /dev/null
@@ -1,78 +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.brooklyn.camp.brooklyn.spi.creation.service;
-
-import javax.annotation.Nullable;
-
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver;
-import org.apache.brooklyn.camp.spi.PlatformComponentTemplate;
-import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
-import org.apache.brooklyn.core.mgmt.persist.DeserializingClassRenamesProvider;
-import org.apache.brooklyn.core.resolve.entity.AbstractEntitySpecResolver;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This converts {@link PlatformComponentTemplate} instances whose type is prefixed {@code
brooklyn:}
- * to Brooklyn {@link EntitySpec} instances.
- * 
- * @deprecated since 0.9.0, use {@link AbstractEntitySpecResolver} instead
- */
-@Deprecated
-public class BrooklynServiceTypeResolver implements ServiceTypeResolver {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(ServiceTypeResolver.class);
-    
-    public BrooklynServiceTypeResolver() {
-    }
-    
-    @Override
-    public String getTypePrefix() { return DEFAULT_TYPE_PREFIX; }
-
-    @Override
-    public String getBrooklynType(String serviceType) {
-        return Strings.removeFromStart(serviceType, getTypePrefix() + ":").trim();
-    }
-
-    @Nullable
-    @Override
-    public CatalogItem<Entity,EntitySpec<?>> getCatalogItem(BrooklynComponentTemplateResolver
resolver, String serviceType) {
-        String type = getBrooklynType(serviceType);
-        if (type != null) {
-            return getCatalogItemImpl(resolver.getManagementContext(),  type);
-        } else {
-            return null;
-        }
-    }
-
-    @Override
-    public <T extends Entity> void decorateSpec(BrooklynComponentTemplateResolver resolver,
EntitySpec<T> spec) {
-    }
-
-    protected CatalogItem<Entity,EntitySpec<?>> getCatalogItemImpl(ManagementContext
mgmt, String brooklynType) {
-        brooklynType = DeserializingClassRenamesProvider.INSTANCE.findMappedName(brooklynType);
-        return CatalogUtils.getCatalogItemOptionalVersion(mgmt, Entity.class,  brooklynType);
-    }
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolver.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolver.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolver.java
deleted file mode 100644
index 14f855a..0000000
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolver.java
+++ /dev/null
@@ -1,77 +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.brooklyn.camp.brooklyn.spi.creation.service;
-
-import java.util.ServiceLoader;
-
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver;
-import org.apache.brooklyn.core.resolve.entity.EntitySpecResolver;
-
-/**
- * Resolves and decorates {@link EntitySpec entity specifications} based on the {@code serviceType}
in a template.
- * <p>
- * The {@link #getTypePrefix()} method returns a string that should match the beginning of
the
- * service type. The resolver implementation will use the rest of the service type information
- * to create and decorate an approprate {@link EntitySpec entity}.
- * <p>
- * The resolvers are loaded using the {@link ServiceLoader} mechanism, allowing external
libraries
- * to add extra service type implementations that will be picked up at runtime.
- *
- * @see BrooklynServiceTypeResolver
- * @see ChefServiceTypeResolver
- * 
- * @deprecated since 0.9.0, {@link EntitySpecResolver} instead.
- */
-@Deprecated
-public interface ServiceTypeResolver {
-
-    String DEFAULT_TYPE_PREFIX = "brooklyn";
-
-    /**
-     * The service type prefix the resolver is responsible for.
-     */
-    String getTypePrefix();
-
-    /**
-     * The name of the Java type that Brooklyn will instantiate to create the
-     * service. This can be generated from parts of the service type information
-     * or may be a fixed value.
-     */
-    String getBrooklynType(String serviceType);
-
-    /**
-     * Returns the {@link CatalogItem} if there is one for the given type.
-     * <p>
-     * If no type, callers should fall back to default classloading.
-     */
-    CatalogItem<Entity, EntitySpec<?>> getCatalogItem(BrooklynComponentTemplateResolver
resolver, String serviceType);
-
-    /**
-     * Takes the provided {@link EntitySpec} and decorates it appropriately for the service
type.
-     * <p>
-     * This includes setting configuration and adding policies, enrichers and initializers.
-     *
-     * @see BrooklynServiceTypeResolver#decorateSpec(BrooklynComponentTemplateResolver, EntitySpec)
-     */
-    <T extends Entity> void decorateSpec(BrooklynComponentTemplateResolver resolver,
EntitySpec<T> spec);
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverAdaptor.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverAdaptor.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverAdaptor.java
deleted file mode 100644
index d4cf6e9..0000000
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverAdaptor.java
+++ /dev/null
@@ -1,70 +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.brooklyn.camp.brooklyn.spi.creation.service;
-
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver;
-import org.apache.brooklyn.core.resolve.entity.AbstractEntitySpecResolver;
-import org.apache.brooklyn.core.resolve.entity.EntitySpecResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Splitter;
-
-@SuppressWarnings("deprecation")
-public class ServiceTypeResolverAdaptor extends AbstractEntitySpecResolver {
-    private static final Logger log = LoggerFactory.getLogger(ServiceTypeResolverAdaptor.class);
-    private ServiceTypeResolver serviceTypeResolver;
-    private BrooklynComponentTemplateResolver resolver;
-
-    public ServiceTypeResolverAdaptor(BrooklynComponentTemplateResolver resolver, ServiceTypeResolver
serviceTypeResolver) {
-        super(serviceTypeResolver.getTypePrefix());
-        this.serviceTypeResolver = serviceTypeResolver;
-        this.resolver = resolver;
-    }
-
-    @Override
-    public boolean accepts(String type, BrooklynClassLoadingContext loader) {
-        if (type.indexOf(':') != -1) {
-            String prefix = Splitter.on(":").splitToList(type).get(0);
-            return prefix.equals(serviceTypeResolver.getTypePrefix());
-        } else {
-            return false;
-        }
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    @Override
-    public EntitySpec<?> resolve(String type, BrooklynClassLoadingContext loader, Set<String>
encounteredTypes) {
-        // Assume this is interface! Only known implementation is DockerServiceTypeResolver.
-        String brooklynType = serviceTypeResolver.getBrooklynType(type);
-        Class<? extends Entity> javaType = loader.loadClass(brooklynType, Entity.class);
-        if (!javaType.isInterface()) {
-            log.warn("Using " + ServiceTypeResolver.class.getSimpleName() + " with a non-interface
type - this usage is not supported. Use " + EntitySpecResolver.class.getSimpleName() + " instead.");
-        }
-        EntitySpec<?> spec = EntitySpec.create((Class)javaType);
-        serviceTypeResolver.decorateSpec(resolver, spec);
-        return spec;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverTest.java
deleted file mode 100644
index cbaccf0..0000000
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/ServiceTypeResolverTest.java
+++ /dev/null
@@ -1,39 +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.brooklyn.camp.brooklyn.spi.creation.service;
-
-import static org.testng.Assert.assertEquals;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
-import org.apache.brooklyn.entity.stock.BasicEntity;
-import org.testng.annotations.Test;
-
-
-public class ServiceTypeResolverTest extends AbstractYamlTest {
-    
-    @Test
-    public void testAddCatalogItemVerySimple() throws Exception {
-        EntitySpec<?> spec = createAppEntitySpec(
-                "services:",
-                "- type: \"test-resolver:" + BasicEntity.class.getName() + "\"");
-        assertEquals(spec.getChildren().get(0).getFlags().get("resolver"), TestServiceTypeResolver.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c9d03c93/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/TestServiceTypeResolver.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/TestServiceTypeResolver.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/TestServiceTypeResolver.java
deleted file mode 100644
index 1c13211..0000000
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/spi/creation/service/TestServiceTypeResolver.java
+++ /dev/null
@@ -1,54 +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.brooklyn.camp.brooklyn.spi.creation.service;
-
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynComponentTemplateResolver;
-import org.apache.brooklyn.util.text.Strings;
-
-@SuppressWarnings("deprecation")
-public class TestServiceTypeResolver implements ServiceTypeResolver {
-
-    private static final String PREFIX = "test-resolver";
-
-    @Override
-    public String getTypePrefix() {
-        return PREFIX;
-    }
-
-    @Override
-    public String getBrooklynType(String serviceType) {
-        return Strings.removeFromStart(serviceType, PREFIX + ":");
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public CatalogItem<Entity, EntitySpec<?>> getCatalogItem(BrooklynComponentTemplateResolver
resolver, String serviceType) {
-        return (CatalogItem<Entity, EntitySpec<?>>) 
-            resolver.getManagementContext().getCatalog().getCatalogItem(getBrooklynType(serviceType),
null);
-    }
-
-    @Override
-    public <T extends Entity> void decorateSpec(BrooklynComponentTemplateResolver resolver,
EntitySpec<T> spec) {
-        spec.configure("resolver", TestServiceTypeResolver.class);
-    }
-
-}


Mime
View raw message