) {
Service service;
try {
service = createService(interfaze, null);
} catch (InvalidInterfaceException e) {
throw new IntrospectionException(e);
}
type.getServices().add(service);
}
}
return;
}
if (annotation.value().length == 0) {
throw new IntrospectionException("[JCA90059] The array of interfaces or classes specified by the value attribute of the @Service annotation MUST contain at least one element");
}
Class<?>[] interfaces = annotation.value();
if (annotation.names().length > 0) {
if (annotation.names().length != interfaces.length) {
throw new IntrospectionException("[JCA90050] The number of Strings in the names attribute array of the @Service annotation MUST match the number of elements in the value attribute array");
}
Set<String> names = new HashSet<String>();
names.addAll(Arrays.asList(annotation.names()));
if (names.size() != annotation.names().length) {
throw new IntrospectionException("[JCA90060] The value of each element in the @Service names array MUST be unique amongst all the other element values in the array");
}
}
//validate no scope on servce interface
for (Class<?> iface : interfaces) {
if (iface.getAnnotation(org.oasisopen.sca.annotation.Scope.class) != null) {
throw new IntrospectionException("[JCA90041] @Scope annotation not allowed on service interface " + iface
.getName());
}
}
//validate service methods implemented
Method[] ms = clazz.getMethods();
for (Class<?> iface : interfaces) {
for (Method m : iface.getMethods()) {
if (!hasMethod(m, ms)) {
throw new IntrospectionException("[JCA90042,JCI20002] Implementation missing service method " + m.getName() + " service interface " + iface.getName());
}
}
}
for (int i=0; i < interfaces.length; i++) {
try {
String name = (annotation.names().length > 0) ? annotation.names()[i] : null;
Service service = createService(interfaces[i], name);
type.getServices().add(service);
} catch (InvalidInterfaceException e) {
throw new IntrospectionException(e);
}
}
}