ENTAXY-374 release 1.8.2
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
|
||||
<artifactId>management</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<version>1.8.2</version>
|
||||
</parent>
|
||||
|
||||
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
|
||||
|
@ -19,7 +19,9 @@
|
||||
*/
|
||||
package ru.entaxy.esb.platform.core.management.connection;
|
||||
|
||||
public interface ConnectionMBean {
|
||||
import ru.entaxy.esb.platform.base.management.core.api.RuntimeTypedMBean;
|
||||
|
||||
public interface ConnectionMBean extends RuntimeTypedMBean {
|
||||
|
||||
public static final String CONNECTION_KEY = "connection";
|
||||
|
||||
|
@ -25,8 +25,11 @@ import javax.management.StandardMBean;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import ru.entaxy.esb.platform.base.management.core.api.EntaxyRuntimeTyped;
|
||||
import ru.entaxy.esb.platform.core.management.connection.ConnectionMBean;
|
||||
|
||||
//@TODO move string to constant
|
||||
@EntaxyRuntimeTyped(name = "entaxy.runtime.connection")
|
||||
public class ConnectionMBeanImpl extends StandardMBean implements ConnectionMBean {
|
||||
|
||||
protected ManagedConnection connection;
|
||||
|
@ -91,7 +91,7 @@ public class ConnectionsMBeanImpl extends StandardMBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addded(ManagedConnections connections) {
|
||||
public void added(ManagedConnections connections) {
|
||||
Hashtable props = new Hashtable<>();
|
||||
// String jmxObjectName = "jmx.objectname";
|
||||
// String objectName = "ru.entaxy.esb:group=platform,category=connections,connection=";
|
||||
@ -108,6 +108,7 @@ public class ConnectionsMBeanImpl extends StandardMBean
|
||||
descriptor.registration = bundleContext.registerService(ConnectionMBean.class
|
||||
, service
|
||||
, props);
|
||||
managed.put(connection.getName(), descriptor);
|
||||
} catch (Exception e) {
|
||||
log.error("Error adding connection [" + connection.getName() + "]", e);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package ru.entaxy.esb.platform.core.management.connection.impl;
|
||||
|
||||
public interface ManagedConnectionsListener {
|
||||
|
||||
public void addded(ManagedConnections connections);
|
||||
public void added(ManagedConnections connections);
|
||||
public void removed(ManagedConnections connections);
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import org.osgi.framework.BundleEvent;
|
||||
import org.osgi.framework.wiring.BundleCapability;
|
||||
import org.osgi.framework.wiring.BundleRevision;
|
||||
import org.osgi.util.tracker.BundleTrackerCustomizer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.esb.platform.core.management.connection.ConnectionsMBean;
|
||||
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnection;
|
||||
@ -35,6 +37,8 @@ import ru.entaxy.platform.base.support.CommonUtils;
|
||||
|
||||
public class DeployedConnectionCustomizer implements BundleTrackerCustomizer<ManagedConnections> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DeployedConnectionCustomizer.class);
|
||||
|
||||
protected ManagedConnectionsListener listener;
|
||||
|
||||
public DeployedConnectionCustomizer(ManagedConnectionsListener listener) {
|
||||
@ -43,16 +47,20 @@ public class DeployedConnectionCustomizer implements BundleTrackerCustomizer<Man
|
||||
|
||||
@Override
|
||||
public ManagedConnections addingBundle(Bundle bundle, BundleEvent event) {
|
||||
log.debug("INSPECTING: " + bundle.getBundleId());
|
||||
BundleRevision revision = bundle.adapt(BundleRevision.class);
|
||||
if (revision == null)
|
||||
return null;
|
||||
log.debug("REVISION FOUND: " + bundle.getBundleId());
|
||||
List<BundleCapability> capabilities = revision.getDeclaredCapabilities(ConnectionsMBean.CAPABILITY_NAMESPACE);
|
||||
if ((capabilities==null) || (capabilities.size()==0))
|
||||
return null;
|
||||
log.debug("CAPABILITIES FOUND: " + bundle.getBundleId());
|
||||
ManagedConnections result = new ManagedConnections();
|
||||
for (BundleCapability capability: capabilities) {
|
||||
Object val = capability.getAttributes().get("name");
|
||||
String name = val==null?"":val.toString();
|
||||
log.debug("CAPABILITIES/NAME [" + name + "] : " + bundle.getBundleId());
|
||||
if (!CommonUtils.isValid(name))
|
||||
continue;
|
||||
val = capability.getAttributes().get("platform");
|
||||
@ -66,7 +74,7 @@ public class DeployedConnectionCustomizer implements BundleTrackerCustomizer<Man
|
||||
.bundleId(bundle.getBundleId());
|
||||
result.managedConnections.add(mc);
|
||||
}
|
||||
listener.addded(result);
|
||||
listener.added(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -78,6 +86,7 @@ public class DeployedConnectionCustomizer implements BundleTrackerCustomizer<Man
|
||||
|
||||
@Override
|
||||
public void removedBundle(Bundle bundle, BundleEvent event, ManagedConnections object) {
|
||||
log.debug("BUNDLE [{}] REMOVING", bundle.getBundleId());
|
||||
listener.removed(object);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user