use of java.util.Dictionary in project aries by apache.
the class HelloWorldManagedServiceImpl method start.
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
Properties props = new Properties();
props.put(Constants.SERVICE_PID, "helloworld-mn");
this.context = context;
this.msRegistration = context.registerService(ManagedService.class.getName(), this, (Dictionary) props);
this.hwRegistration = null;
//manually call our update to make sure the HW service is exposed out
updated(null);
}
use of java.util.Dictionary in project aries by apache.
the class JavaUtils method getBundleVersion.
public static Version getBundleVersion(Bundle bundle) {
Dictionary headers = bundle.getHeaders();
String version = (String) headers.get(Constants.BUNDLE_VERSION);
return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
}
use of java.util.Dictionary in project aries by apache.
the class MapRecipe method internalCreate.
protected Object internalCreate() throws ComponentDefinitionException {
Class<?> mapType = getMap(typeClass);
if (!ReflectionUtils.hasDefaultConstructor(mapType)) {
throw new ComponentDefinitionException("Type does not have a default constructor " + mapType.getName());
}
Object o;
try {
o = mapType.newInstance();
} catch (Exception e) {
throw new ComponentDefinitionException("Error while creating set instance: " + mapType.getName());
}
Map instance;
if (o instanceof Map) {
instance = (Map) o;
} else if (o instanceof Dictionary) {
instance = new DummyDictionaryAsMap((Dictionary) o);
} else {
throw new ComponentDefinitionException("Specified map type does not implement the Map interface: " + mapType.getName());
}
ReifiedType defaultConvertKeyType = getType(keyType);
ReifiedType defaultConvertValueType = getType(valueType);
// add map entries
try {
for (Recipe[] entry : entries) {
ReifiedType convertKeyType = workOutConversionType(entry[0], defaultConvertKeyType);
Object key = convert(entry[0].create(), convertKeyType);
// Each entry may have its own types
ReifiedType convertValueType = workOutConversionType(entry[1], defaultConvertValueType);
Object value = entry[1] != null ? convert(entry[1].create(), convertValueType) : null;
instance.put(key, value);
}
} catch (Exception e) {
throw new ComponentDefinitionException(e);
}
return instance;
}
use of java.util.Dictionary in project aries by apache.
the class Activator method start.
public void start(BundleContext bc) throws Exception {
Dictionary props = new Hashtable();
props.put("service.exported.interfaces", "*");
props.put("service.exported.configs", "org.apache.cxf.ws");
props.put("org.apache.cxf.ws.address", "http://localhost:9090/greeter");
registration = bc.registerService(GreeterService.class.getName(), new GreeterServiceImpl(), props);
}
use of java.util.Dictionary 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