}
public static ServiceBinding getServiceBinding(BindingTemplate bs, LifeCycleManager lcm)
throws JAXRException
{
ServiceBinding serviceBinding = new ServiceBindingImpl(lcm);
String keystr = bs.getServiceKey();
if (keystr != null)
{
Service svc = new ServiceImpl(lcm);
svc.setKey(lcm.createKey(keystr));
((ServiceBindingImpl)serviceBinding).setService(svc);
}
String bindingKey = bs.getBindingKey();
if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey));
//Access URI
AccessPoint access = bs.getAccessPoint();
if (access != null) serviceBinding.setAccessURI(access.getStringValue());
//Description
Description[] da = bs.getDescriptionArray();
if (da != null && da.length > 0)
{
Description des = da[0];
serviceBinding.setDescription(new InternationalStringImpl(des.getStringValue()));
}
/**Section D.10 of JAXR 1.0 Specification */
TModelInstanceDetails details = bs.getTModelInstanceDetails();
TModelInstanceInfo[] tmodelInstanceInfoArray = details.getTModelInstanceInfoArray();
for (int i = 0; tmodelInstanceInfoArray != null && i < tmodelInstanceInfoArray.length; i++)
{
TModelInstanceInfo info = (TModelInstanceInfo)tmodelInstanceInfoArray[i];
if (info!=null && info.getInstanceDetails()!=null) {
InstanceDetails idetails = info.getInstanceDetails();
Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lcm);
SpecificationLink slink = new SpecificationLinkImpl(lcm);
slink.addExternalLinks(elinks);
serviceBinding.addSpecificationLink(slink);
ConceptImpl c = new ConceptImpl(lcm);
c.setExternalLinks(elinks);
c.setKey(lcm.createKey(info.getTModelKey()));
c.setName(lcm.createInternationalString(idetails.getInstanceParms()));
c.setValue(idetails.getInstanceParms());
slink.setSpecificationObject(c);
}
}
HostingRedirector hr = bs.getHostingRedirector();
if(hr != null)
{
ServiceBinding sb = lcm.createServiceBinding();
sb.setKey(new KeyImpl(hr.getBindingKey()));
serviceBinding.setTargetBinding(sb);
}
return serviceBinding;
}