use of org.apache.aries.samples.goat.api.ModelInfoService 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.ModelInfoService in project aries by apache.
the class ServiceInterceptor method registerServiceEnhancer.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void registerServiceEnhancer(ServiceReference reference) {
Object actualService = ctx.getService(reference);
if (actualService instanceof ModelInfoService) {
ModelInfoService infoService = (ModelInfoService) actualService;
Object serviceId = reference.getProperty(SERVICE_ID);
Object enhancer = new ModelInfoEnhancerService(infoService);
Dictionary properties = new Hashtable();
Object originalDisplayName = reference.getProperty(DISPLAY_NAME);
properties.put(DISPLAY_NAME, originalDisplayName + " [enhanced]");
ServiceRegistration registration = ctx.registerService(ModelInfoService.class.getName(), enhancer, properties);
registrations.put(serviceId + "", registration);
} else {
System.out.println("Oh dear - unexpected service " + actualService.getClass());
}
}
Aggregations