use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.
the class DummyRelationshipProvider method getRelationships.
@Override
public List<RelationshipInfo> getRelationships() {
ArrayList<RelationshipInfo> ris = new ArrayList<RelationshipInfo>();
ComponentInfo ci1 = cip.getComponentForId("/root/1");
ComponentInfo ci2 = cip.getComponentForId("/root/2");
ComponentInfo ci3 = cip.getComponentForId("/root/3");
RelationshipInfoImpl ri1 = new RelationshipInfoImpl();
RelationshipInfoImpl ri2 = new RelationshipInfoImpl();
RelationshipInfoImpl ri3 = new RelationshipInfoImpl();
RelationshipInfoImpl ri4 = new RelationshipInfoImpl();
RelationshipInfoImpl ri5 = new RelationshipInfoImpl();
RelationshipInfoImpl ri6 = new RelationshipInfoImpl();
ris.add(ri1);
ris.add(ri2);
ris.add(ri3);
ris.add(ri4);
ris.add(ri5);
ris.add(ri6);
ri1.setName("i.am.exported.by.1.and.used.by.2.and.3");
ri1.setProvidedBy(ci1);
ArrayList<ComponentInfo> c = new ArrayList<ComponentInfo>();
c.add(ci2);
c.add(ci3);
ri1.setConsumedBy(c);
ri1.setType("Package");
ri2.setName("i.am.exported.by.1.and.used.by.3");
ri2.setProvidedBy(ci1);
c = new ArrayList<ComponentInfo>();
c.add(ci3);
ri2.setConsumedBy(c);
ri2.setType("Package");
ri3.setName("i.am.exported.by.2.and.used.by.3");
ri3.setProvidedBy(ci2);
c = new ArrayList<ComponentInfo>();
c.add(ci3);
ri3.setConsumedBy(c);
ri3.setType("Package");
ri4.setName("i.am.exported.by.3.and.used.by.2");
ri4.setProvidedBy(ci3);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri4.setConsumedBy(c);
ri4.setType("Package");
ri5.setName("i.am.a.funky.service.from.3.used.by.2");
ri5.setProvidedBy(ci3);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri5.setConsumedBy(c);
ri5.setType("Service");
ri6.setName("i.am.a.funky.service.from.1.used.by.2");
ri6.setProvidedBy(ci1);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri6.setConsumedBy(c);
ri6.setType("Service");
return ris;
}
use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.
the class BundleContextInfoProvider method getRelationships.
@Override
public List<RelationshipInfo> getRelationships() {
ArrayList<RelationshipInfo> r = new ArrayList<RelationshipInfo>();
Bundle[] bundles = ctx.getBundles();
PackageAdmin pa = (PackageAdmin) ctx.getService(ctx.getServiceReference(PackageAdmin.class.getName().toString()));
if (bundles != null && bundles.length != 0) {
for (Bundle b : bundles) {
String bkey = getKeyForBundle(b);
ComponentInfo ci = getComponentForId(bkey);
//add all the packages..
//we only add exports, as imports are implied in the reverse
ExportedPackage[] eps = pa.getExportedPackages(b);
if (eps != null && eps.length != 0) {
for (ExportedPackage ep : eps) {
RelationshipInfoImpl ri = new RelationshipInfoImpl();
ri.setProvidedBy(ci);
ri.setType("Package");
ri.setName(ep.getName());
ri.setRelationshipAspects(new ArrayList<RelationshipAspect>());
ri.setConsumedBy(new ArrayList<ComponentInfo>());
//TODO: add versioning aspect.
Bundle[] imps = ep.getImportingBundles();
if (imps != null && imps.length != 0) {
for (Bundle imp : imps) {
ri.getConsumedBy().add(getComponentForId(getKeyForBundle(imp)));
}
}
r.add(ri);
}
}
//add all the services..
//we only add registered services, as ones in use are handled in the reverse
ServiceReference[] srs = b.getRegisteredServices();
if (srs != null && srs.length != 0) {
for (ServiceReference sr : srs) {
RelationshipInfoImpl ri = getRIforSR(sr);
ri.setProvidedBy(ci);
r.add(ri);
}
}
}
}
return r;
}
use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.
the class BundleContextInfoProvider method getRIforSR.
private RelationshipInfoImpl getRIforSR(ServiceReference sr) {
RelationshipInfoImpl ri = new RelationshipInfoImpl();
ri.setType("Service");
String serviceNames = "";
String[] objectClasses = (String[]) sr.getProperty("objectClass");
if (objectClasses != null) {
for (String objectClass : objectClasses) {
serviceNames += "," + objectClass;
}
}
if (serviceNames.length() > 1) {
serviceNames = serviceNames.substring(1);
}
ri.setName(serviceNames);
ri.setRelationshipAspects(new ArrayList<RelationshipAspect>());
//TODO: add service parameters
ri.setConsumedBy(new ArrayList<ComponentInfo>());
Bundle[] using = sr.getUsingBundles();
if (using != null && using.length != 0) {
for (Bundle u : using) {
ri.getConsumedBy().add(getComponentForId(getKeyForBundle(u)));
}
}
return ri;
}
use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.
the class BundleContextInfoProvider method serviceChanged.
@Override
public void serviceChanged(ServiceEvent arg0) {
if (arg0.getType() == ServiceEvent.REGISTERED || arg0.getType() == ServiceEvent.MODIFIED || arg0.getType() == ServiceEvent.MODIFIED_ENDMATCH) {
ServiceReference sr = arg0.getServiceReference();
RelationshipInfoImpl ri = getRIforSR(sr);
ComponentInfo ci = getComponentForId(getKeyForBundle(sr.getBundle()));
ri.setProvidedBy(ci);
for (RelationshipInfoListener ril : rlisteners) {
ril.updateRelationship(ri);
}
} else if (arg0.getType() == ServiceEvent.UNREGISTERING) {
ServiceReference sr = arg0.getServiceReference();
RelationshipInfoImpl ri = getRIforSR(sr);
ComponentInfo ci = getComponentForId(getKeyForBundle(sr.getBundle()));
ri.setProvidedBy(ci);
for (RelationshipInfoListener ril : rlisteners) {
ril.removeRelationship(ri);
}
}
}
use of org.apache.aries.samples.goat.info.RelationshipInfoImpl in project aries by apache.
the class DummyRelationshipProvider method getRelationships.
@Override
public List<RelationshipInfo> getRelationships() {
ArrayList<RelationshipInfo> ris = new ArrayList<RelationshipInfo>();
ComponentInfo ci1 = cip.getComponentForId("/root/1");
ComponentInfo ci2 = cip.getComponentForId("/root/2");
ComponentInfo ci3 = cip.getComponentForId("/root/3");
RelationshipInfoImpl ri1 = new RelationshipInfoImpl();
RelationshipInfoImpl ri2 = new RelationshipInfoImpl();
RelationshipInfoImpl ri3 = new RelationshipInfoImpl();
RelationshipInfoImpl ri4 = new RelationshipInfoImpl();
RelationshipInfoImpl ri5 = new RelationshipInfoImpl();
RelationshipInfoImpl ri6 = new RelationshipInfoImpl();
ris.add(ri1);
ris.add(ri2);
ris.add(ri3);
ris.add(ri4);
ris.add(ri5);
ris.add(ri6);
ri1.setName("i.am.exported.by.1.and.used.by.2.and.3");
ri1.setProvidedBy(ci1);
ArrayList<ComponentInfo> c = new ArrayList<ComponentInfo>();
c.add(ci2);
c.add(ci3);
ri1.setConsumedBy(c);
ri1.setType("Package");
ri2.setName("i.am.exported.by.1.and.used.by.3");
ri2.setProvidedBy(ci1);
c = new ArrayList<ComponentInfo>();
c.add(ci3);
ri2.setConsumedBy(c);
ri2.setType("Package");
ri3.setName("i.am.exported.by.2.and.used.by.3");
ri3.setProvidedBy(ci2);
c = new ArrayList<ComponentInfo>();
c.add(ci3);
ri3.setConsumedBy(c);
ri3.setType("Package");
ri4.setName("i.am.exported.by.3.and.used.by.2");
ri4.setProvidedBy(ci3);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri4.setConsumedBy(c);
ri4.setType("Package");
ri5.setName("i.am.a.funky.service.from.3.used.by.2");
ri5.setProvidedBy(ci3);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri5.setConsumedBy(c);
ri5.setType("Service");
ri6.setName("i.am.a.funky.service.from.1.used.by.2");
ri6.setProvidedBy(ci1);
c = new ArrayList<ComponentInfo>();
c.add(ci2);
ri6.setConsumedBy(c);
ri6.setType("Service");
return ris;
}
Aggregations