use of org.apache.aries.samples.goat.api.ComponentInfo 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.api.ComponentInfo in project aries by apache.
the class ServerSideClass method getInitialComponents.
/**
* this is invoked by a page onload.. so until it's invoked.. we dont care
* about components
*/
public void getInitialComponents(String dataProvider) {
System.err.println("GET INITIAL BUNDLES ASKED TO USE DATAPROVIDER " + dataProvider);
if (dataProvider == null)
throw new IllegalArgumentException("Unable to accept 'null' as a dataProvider");
// do we need to update?
if (!this.modelInfoServiceHint.equals(dataProvider)) {
this.modelInfoServiceHint = dataProvider;
if (!(this.ModelInfoService == null)) {
// we already had a provider.. we need to shut down the existing
// components & relationships in the browsers..
addFunctionCall("forgetAboutEverything");
}
ServletContext context = org.directwebremoting.ServerContextFactory.get().getServletContext();
Object o = context.getAttribute("osgi-bundlecontext");
if (o != null) {
if (o instanceof BundleContext) {
BundleContext b_ctx = (BundleContext) o;
System.err.println("Looking up bcip");
try {
ServiceReference[] sr = b_ctx.getServiceReferences(ModelInfoService.class.getName(), "(displayName=" + this.modelInfoServiceHint + ")");
if (sr != null) {
System.err.println("Getting bcip");
this.ModelInfoService = (ModelInfoService) b_ctx.getService(sr[0]);
System.err.println("Got bcip " + this.ModelInfoService);
} else {
System.err.println("UNABLE TO FIND BCIP!!");
System.err.println("UNABLE TO FIND BCIP!!");
System.err.println("UNABLE TO FIND BCIP!!");
}
} catch (InvalidSyntaxException ise) {
}
if (this.ModelInfoService != null) {
if (!rlisteners.containsKey(this.ModelInfoService)) {
RelationshipInfoProvider.RelationshipInfoListener rl = new RelationshipInfoListenerImpl(this.modelInfoServiceHint);
rlisteners.put(this.ModelInfoService, rl);
this.ModelInfoService.getRelationshipInfoProvider().registerRelationshipInfoListener(rl);
}
if (!clisteners.containsKey(this.ModelInfoService)) {
ComponentInfoProvider.ComponentInfoListener cl = new ComponentInfoListenerImpl(this.modelInfoServiceHint);
clisteners.put(this.ModelInfoService, cl);
this.ModelInfoService.getComponentInfoProvider().registerComponentInfoListener(cl);
}
}
}
}
}
Collection<ComponentInfo> bis = this.ModelInfoService.getComponentInfoProvider().getComponents();
System.err.println("Got " + (bis == null ? "null" : bis.size()) + " components back from the provider ");
if (bis != null) {
for (ComponentInfo b : bis) {
System.err.println("Adding Component .. " + b.getId());
addFunctionCall("addComponent", b);
}
}
Collection<RelationshipInfo> ris = this.ModelInfoService.getRelationshipInfoProvider().getRelationships();
System.err.println("Got " + (ris == null ? "null" : ris.size()) + " relationships back from the provider ");
if (ris != null) {
for (RelationshipInfo r : ris) {
System.err.println("Adding relationship type " + r.getType() + " called " + r.getName() + " from " + r.getProvidedBy().getId());
addFunctionCall("addRelationship", r);
}
}
}
use of org.apache.aries.samples.goat.api.ComponentInfo 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.api.ComponentInfo in project aries by apache.
the class ModelInfoEnhancerService method updateSyntheticServiceArtefactsAndNotifyListeners.
private void updateSyntheticServiceArtefactsAndNotifyListeners(RelationshipInfo r) {
// We need to update our two relationships and the synthetic
// component
// Hopefully the thing which changed won't prevent us
// from finding our relationship
String componentId = constructServiceComponentId(r);
// Do the relationships first
// The registration has type "service registration", and the
// original provider and name
String registrationRelationshipId = SERVICE_REGISTRATION + "/" + r.getName() + "/" + r.getProvidedBy().getId();
RelationshipInfoImpl registrationRelationship = (RelationshipInfoImpl) relationships.get(registrationRelationshipId);
registrationRelationship.setName(r.getName());
registrationRelationship.setRelationshipAspects(r.getRelationshipAspects());
// The consumers have type "service usage", and the
// original name, and the new provided by
String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + componentId;
RelationshipInfoImpl usageRelationship = (RelationshipInfoImpl) relationships.get(usageRelationshipId);
// The consumers may have changed, so we update the usage relationship
usageRelationship.setConsumedBy(r.getConsumedBy());
usageRelationship.setName(r.getName());
usageRelationship.setRelationshipAspects(r.getRelationshipAspects());
for (RelationshipInfoListener listener : rlisteners) {
if (usageRelationship != null) {
listener.updateRelationship(usageRelationship);
}
if (registrationRelationship != null) {
listener.updateRelationship(registrationRelationship);
}
}
ComponentInfo component = components.get(componentId);
if (component != null) {
// Tell our listeners their service component was updated
for (ComponentInfoListener listener : clisteners) {
listener.updateComponent(component);
}
}
}
use of org.apache.aries.samples.goat.api.ComponentInfo in project aries by apache.
the class ModelInfoEnhancerService method removeSyntheticServiceArtefactsAndNotifyListeners.
private void removeSyntheticServiceArtefactsAndNotifyListeners(RelationshipInfo r) {
// We need to remove our two relationships and the synthetic
// component
String componentId = constructServiceComponentId(r);
// Do the relationships first
// The registration has type "service registration", and the
// original provider and name
String registrationRelationshipId = SERVICE_REGISTRATION + "/" + r.getName() + "/" + r.getProvidedBy().getId();
RelationshipInfo registrationRelationship = relationships.get(registrationRelationshipId);
// The consumers have type "service usage", and the
// original name, and the new provided by
String usageRelationshipId = SERVICE_USAGE + "/" + r.getName() + "/" + componentId;
RelationshipInfo usageRelationship = relationships.get(usageRelationshipId);
relationships.remove(usageRelationshipId);
relationships.remove(registrationRelationshipId);
for (RelationshipInfoListener listener : rlisteners) {
if (usageRelationship != null) {
listener.removeRelationship(usageRelationship);
}
if (registrationRelationship != null) {
listener.removeRelationship(registrationRelationship);
}
}
ComponentInfo component = components.remove(componentId);
if (component != null) {
// Tell our listeners their service component went away
for (ComponentInfoListener listener : clisteners) {
listener.removeComponent(component);
}
}
}
Aggregations