Java Reference
In-Depth Information
config.update(props);
}
public void rename(String oldName, String newName)
throws IOException, InvalidSyntaxException {
String filter = "(&(service.factoryPid=hello)(name=" + oldName + "))";
Configuration[] configs = ca.listConfigurations(filter);
if (configs != null) {
Hashtable props = new Hashtable();
props.put("name", newName);
configs[0].update(props);
}
}
Finds
Configuration object C
public void dispose(String name)
throws IOException, InvalidSyntaxException {
String filter = "(&(service.factoryPid=hello)(name=" + name + "))";
Configuration[] configs = ca.listConfigurations(filter);
if (configs != null) {
configs[0].delete();
}
}
}
This version of the Creator component requires the Configuration Admin Service.
You use it in create() to create a Configuration object for the factory associated with
your component B ; i POJO automatically registers a Configuration Admin Managed-
ServiceFactory for component factories and uses the factory name as its PID (see
chapter 9 for a refresher on Configuration Admin). You then set the configuration
property with the passed-in name and update the configuration. This results in Con-
figuration Admin creating an instance from the ManagedServiceFactory , which is
backed by the i POJO Factory service.
To update the component, in rename() you find the Configuration object associ-
ated with the passed-in name C . If it's found, you update its name property with the
specified value. Finally, in dispose() you again find the Configuration object associ-
ated with the passed-in name and delete it D , which disposes of the instance.
Although this approach is somewhat less direct than using i POJO factory services, the
component now only depends on standard OSG i API s.
We haven't touched on all of i POJO 's features (such as composite service descrip-
tion, which goes beyond what we can cover in this section), but we've discussed most of
what you'll need to get started. To see the i POJO version of the paint program in action,
go to the chapter12/paint-example-ip/ directory of the topic's companion code. Type
ant to build the example and java -jar launcher.jar bundles/ to run it.
Disposes of
Configuration object
D
12.3
Mix and match
In this and the preceding chapter, we've shown you three OSG i-based component
frameworks. You may be wondering which to choose. Unfortunately, there's no one-
size-fits-all answer. You have to pick based on your requirements, but table 12.4 pro-
vides a summary of some of the features of each to make this task a little easier.
 
Search WWH ::




Custom Search