[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-04-05 Thread geomacy
Github user geomacy commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r58542079
  
--- Diff: karaf/init/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---
@@ -20,63 +20,63 @@ limitations under the License.

xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0;
xsi:schemaLocation="
  http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
- 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
+ http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.2.0.xsd
  ">
 
 
 
--- End diff --

Me too! not sure how I managed that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-04-05 Thread geomacy
Github user geomacy commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r58541474
  
--- Diff: core/src/main/resources/catalog.bom ---
@@ -0,0 +1,21 @@
+# 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.
+
+brooklyn.catalog:
--- End diff --

They would be handled better by the build, but I think this would require a 
moderately significant amount of work, to scan the code for the appropriate 
annotations, which I think would be best treated as a separate bit of 
development.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-30 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-server/pull/80


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-25 Thread neykov
Github user neykov commented on the pull request:

https://github.com/apache/brooklyn-server/pull/80#issuecomment-201273208
  
Finished review, comments in commit 
https://github.com/apache/brooklyn-server/pull/80/commits/f76f9eefe5c85c100e1d9d78873dbdf2e968150b.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-25 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r57442486
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScanner.java
 ---
@@ -0,0 +1,185 @@
+/*
+ * 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.core.catalog.internal;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.yaml.Yamls;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.BundleTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+public class CatalogBomScanner {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(CatalogBomScanner.class);
+private static final String CATALOG_BOM_URL = "catalog.bom";
+private static final String BROOKLYN_CATALOG = "brooklyn.catalog";
+private static final String BROOKLYN_LIBRARIES = "brooklyn.libraries";
+
+private CatalogPopulator catalogTracker;
+
+public void bind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Binding management context");
+catalogTracker = new CatalogPopulator(managementContext);
+}
+
+public void unbind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Unbinding management context");
+if (null != catalogTracker) {
+CatalogPopulator temp = catalogTracker;
+catalogTracker = null;
+temp.close();
+}
+}
+
+private String[] bundleIds(Bundle bundle) {
+return new String[] {
+String.valueOf(bundle.getBundleId()), 
String.valueOf(bundle.getState()), bundle.getSymbolicName()
+};
+}
+
+
+public class CatalogPopulator extends BundleTracker {
+
+private ServiceReference mgmtContextReference;
+private ManagementContext managementContext;
+
+public CatalogPopulator(ServiceReference 
serviceReference) {
+super(serviceReference.getBundle().getBundleContext(), 
Bundle.ACTIVE, null);
+this.mgmtContextReference = serviceReference;
+open();
+}
+
+@Override
+public void open() {
+managementContext = 
mgmtContextReference.getBundle().getBundleContext().getService(mgmtContextReference);
+super.open();
+}
+
+@Override
+public void close() {
+super.close();
+managementContext = null;
+
mgmtContextReference.getBundle().getBundleContext().ungetService(mgmtContextReference);
+}
+
+public ManagementContext getManagementContext() {
+return managementContext;
+}
+
+@Override
+public Long addingBundle(Bundle bundle, BundleEvent bundleEvent) {
+
+final BundleContext bundleContext = 
FrameworkUtil.getBundle(CatalogBomScanner.class).getBundleContext();
+if (bundleContext == null) {
+LOG.info("Bundle context not yet established for bundle {} 
{} {}", bundleIds(bundle));
+return null;
+

[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-25 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r57437435
  
--- Diff: core/src/main/resources/catalog.bom ---
@@ -0,0 +1,21 @@
+# 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.
+
+brooklyn.catalog:
--- End diff --

Aren't these (including in related PRs) better handled by the maven build? 
Probably can be set up to generate them automatically if doesn't exist already.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-25 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r57437307
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScanner.java
 ---
@@ -0,0 +1,185 @@
+/*
+ * 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.core.catalog.internal;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.yaml.Yamls;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.BundleTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+public class CatalogBomScanner {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(CatalogBomScanner.class);
+private static final String CATALOG_BOM_URL = "catalog.bom";
+private static final String BROOKLYN_CATALOG = "brooklyn.catalog";
+private static final String BROOKLYN_LIBRARIES = "brooklyn.libraries";
+
+private CatalogPopulator catalogTracker;
+
+public void bind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Binding management context");
+catalogTracker = new CatalogPopulator(managementContext);
+}
+
+public void unbind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Unbinding management context");
+if (null != catalogTracker) {
+CatalogPopulator temp = catalogTracker;
+catalogTracker = null;
+temp.close();
+}
+}
+
+private String[] bundleIds(Bundle bundle) {
+return new String[] {
+String.valueOf(bundle.getBundleId()), 
String.valueOf(bundle.getState()), bundle.getSymbolicName()
+};
+}
+
+
+public class CatalogPopulator extends BundleTracker {
+
+private ServiceReference mgmtContextReference;
+private ManagementContext managementContext;
+
+public CatalogPopulator(ServiceReference 
serviceReference) {
+super(serviceReference.getBundle().getBundleContext(), 
Bundle.ACTIVE, null);
+this.mgmtContextReference = serviceReference;
+open();
+}
+
+@Override
+public void open() {
+managementContext = 
mgmtContextReference.getBundle().getBundleContext().getService(mgmtContextReference);
+super.open();
+}
+
+@Override
+public void close() {
+super.close();
+managementContext = null;
+
mgmtContextReference.getBundle().getBundleContext().ungetService(mgmtContextReference);
+}
+
+public ManagementContext getManagementContext() {
+return managementContext;
+}
+
+@Override
+public Long addingBundle(Bundle bundle, BundleEvent bundleEvent) {
+
+final BundleContext bundleContext = 
FrameworkUtil.getBundle(CatalogBomScanner.class).getBundleContext();
+if (bundleContext == null) {
+LOG.info("Bundle context not yet established for bundle {} 
{} {}", bundleIds(bundle));
+return null;
+

[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-25 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/80#discussion_r57437262
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBomScanner.java
 ---
@@ -0,0 +1,185 @@
+/*
+ * 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.core.catalog.internal;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.yaml.Yamls;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.BundleTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+public class CatalogBomScanner {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(CatalogBomScanner.class);
+private static final String CATALOG_BOM_URL = "catalog.bom";
+private static final String BROOKLYN_CATALOG = "brooklyn.catalog";
+private static final String BROOKLYN_LIBRARIES = "brooklyn.libraries";
+
+private CatalogPopulator catalogTracker;
+
+public void bind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Binding management context");
+catalogTracker = new CatalogPopulator(managementContext);
+}
+
+public void unbind(ServiceReference 
managementContext) throws Exception {
+LOG.debug("Unbinding management context");
+if (null != catalogTracker) {
+CatalogPopulator temp = catalogTracker;
+catalogTracker = null;
+temp.close();
+}
+}
+
+private String[] bundleIds(Bundle bundle) {
+return new String[] {
+String.valueOf(bundle.getBundleId()), 
String.valueOf(bundle.getState()), bundle.getSymbolicName()
+};
+}
+
+
+public class CatalogPopulator extends BundleTracker {
+
+private ServiceReference mgmtContextReference;
+private ManagementContext managementContext;
+
+public CatalogPopulator(ServiceReference 
serviceReference) {
+super(serviceReference.getBundle().getBundleContext(), 
Bundle.ACTIVE, null);
+this.mgmtContextReference = serviceReference;
+open();
+}
+
+@Override
+public void open() {
+managementContext = 
mgmtContextReference.getBundle().getBundleContext().getService(mgmtContextReference);
+super.open();
+}
+
+@Override
+public void close() {
+super.close();
+managementContext = null;
+
mgmtContextReference.getBundle().getBundleContext().ungetService(mgmtContextReference);
+}
+
+public ManagementContext getManagementContext() {
+return managementContext;
+}
+
+@Override
+public Long addingBundle(Bundle bundle, BundleEvent bundleEvent) {
+
+final BundleContext bundleContext = 
FrameworkUtil.getBundle(CatalogBomScanner.class).getBundleContext();
+if (bundleContext == null) {
+LOG.info("Bundle context not yet established for bundle {} 
{} {}", bundleIds(bundle));
--- End diff --

A short mention of 

[GitHub] brooklyn-server pull request: Populate catalog from bundle bom

2016-03-24 Thread geomacy
GitHub user geomacy opened a pull request:

https://github.com/apache/brooklyn-server/pull/80

Populate catalog from bundle bom

This PR adds the ability for bundles to contain a 'catalog.bom' file 
specifying items that the bundle contains which should be added to the catalog.

The bundle is scanned for a catalog.bom upon bundle start.  The catalog.bom 
file is automatically enhanced with a 'brooklyn.libraries' entry that refers to 
the newly started bundle, and any items in it are added to the catalog.

The PR also includes updates to the existing jars to add a catalog.bom file 
that includes the details of the various entities in each. 

This PR is based upon the following and should be merged after them:

https://github.com/apache/brooklyn-server/pull/65
https://github.com/apache/brooklyn-server/pull/66


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/geomacy/brooklyn-server 
populate-catalog-from-bundle-bom

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-server/pull/80.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #80


commit a51fdc71c9a1620e35cd88b1b6643ca4439b719d
Author: Geoff Macartney 
Date:   2016-03-04T10:52:46Z

Use OSGI lookup for ApiObjectsFactory and fall back to ServiceLoader.

Abstract out the lookup into a utility.

commit 00d1338b5c500a5585aaa91c38b3205668254821
Author: Geoff Macartney 
Date:   2016-03-07T16:19:39Z

Add framework lookup for (deprecated) PlanToSpecFactory.

commit f7a03f03897a7b0acc50163aeed32bf65283c1c4
Author: Geoff Macartney 
Date:   2016-03-07T17:08:18Z

Apply FrameworkLookup to TypePlanTransformers.

commit 8f88e41afc94bcdf7dfc7896dbaa44ceaffc464f
Author: Geoff Macartney 
Date:   2016-03-08T09:51:55Z

Use prototype scope on beans rather than explicit factory classes.

commit ebaeae7beac048f488b5a46c5430395ddc0ca35b
Author: Geoff Macartney 
Date:   2016-03-08T10:30:13Z

Replace ServiceLoader with FrameworkLookup for EntitySpecResolver.

commit 98d1b6003e9b71c3a0d85d25152e31c5414ccf92
Author: Geoff Macartney 
Date:   2016-03-08T14:26:05Z

Replace ServiceLoader with FrameworkLookup for ServiceTypeResolver.

commit b60db4c6f4dd5f57e06a962d52e734f361dd7c88
Author: Geoff Macartney 
Date:   2016-03-08T14:56:22Z

Replace ServiceLoader with FrameworkLookup for LocationResolver.

commit e6a412bfc0b0347364f50aee92977d6488d3d3e9
Author: Geoff Macartney 
Date:   2016-03-08T16:56:17Z

Fix list handling.

commit 6c3c508c8da03447742d19567d225bcf045da7c0
Author: Geoff Macartney 
Date:   2016-03-10T15:37:31Z

ServiceLookups should be in core, and use correct interface for 
campToSpecTransformerService.

commit afcb689f0a31995a27c953abab73f4902d8f2754
Author: Geoff Macartney 
Date:   2016-03-16T12:43:38Z

Update call to ServiceLoader.load to match previous call pattern.

(Previous in the sense of prior to the FrameworkLookup change.)

commit a93c170b6753110b034dcb8244e33ea859bac544
Author: Geoff Macartney 
Date:   2016-03-16T15:02:18Z

Add Javadoc note on use of FrameworkLooup and OSGI service reference count.

commit 630eb6485f89f5d68f5d10107bbc56af3c570cc0
Author: Geoff Macartney 
Date:   2016-03-18T16:36:40Z

Merge branch 'master' into service-loader-updates

commit 71d5a1083f250ac419cdb34b139ba62abef1bd4d
Author: Geoff Macartney 
Date:   2016-03-18T16:41:26Z

Use FrameworkLookup class to get the bundle context.

Necessary to avoid NPE at line 135 and 160 if the class being looked up is 
in a bundle that hasn't started yet.
We don't really need to get the bundle context from that class, any 
suitable one will do, and we know that
the bundle we live in has started!

commit b2df8dd2943b63eba805eb1b5209c99b3ade1d3f
Author: Geoff Macartney 
Date:   2016-03-23T09:48:28Z

Merge branch 'master' into service-loader-updates

commit 50ece3dee91d0f07f4ac8bd78b462063799580cc
Author: Svetoslav Neykov 
Date:   2016-03-16T16:41:52Z

Make EmbeddedFelixFramework pluggable

Needs different implementations depending on whether running in Karaf or 
classical. Can't have EmbeddedFelixFramework loaded in Karaf because felix 
bundle doesn't export org.apache.framework packages, just generic OSGi ones.

commit