if (sa != null) {
Connection[] connections = sa.getConnections().getConnection();
if (connections != null) {
for (int i = 0; i < connections.length; i++) {
Connection connection = connections[i];
Consumer consumer = connection.getConsumer();
Provider provider = connection.getProvider();
QName suName = consumer.getInterfaceName();
if (suName != null) {
LocalComponentConnector lcc = (LocalComponentConnector) container.getRegistry()
.getComponentConnector(suName);
if (lcc != null) {
lcc.getActivationSpec().setDestinationEndpoint(provider.getEndpointName());
lcc.getActivationSpec().setDestinationService(provider.getServiceName());
}
else {
throw new DeploymentException("Unable to build connections, can't find consumer interface "
+ suName);
}
}
else {
// We didn't have the interface so we will go after
// the service name and endpoint
InternalEndpoint endPoint = (InternalEndpoint) container.getRegistry().getEndpoint(
consumer.getServiceName(), consumer.getEndpointName());
if (endPoint != null) {
LocalComponentConnector lcc = (LocalComponentConnector) container.getRegistry()
.getComponentConnector(endPoint.getComponentNameSpace());
if (lcc != null) {
lcc.getActivationSpec().setDestinationEndpoint(provider.getEndpointName());
lcc.getActivationSpec().setDestinationService(provider.getServiceName());
}
else {
throw new DeploymentException(
"Unable to build connections, can't find consumer based on component name space "
+ endPoint.getComponentNameSpace());
}
}
else {
throw new DeploymentException(
"Unable to build connections, can't find consumer with servicename "
+ consumer.getServiceName() + " and endpoint " + consumer.getEndpointName());
}
}
}
}
}