@Test public void testJavaInterfaceAsService() throws Exception { JavaService js = JavaService.fromClass(JavaInterface.class); Assert.assertEquals(2, js.getOperations().size()); ServiceOperation method1 = js.getOperation("method1"); Assert.assertNotNull(method1); Assert.assertEquals(method1.getInputType(), METHOD1_INPUT); Assert.assertEquals(method1.getExchangePattern(), ExchangePattern.IN_ONLY); ServiceOperation method2 = js.getOperation("method2"); Assert.assertNotNull(method2); Assert.assertEquals(method2.getInputType(), METHOD2_INPUT); Assert.assertEquals(method2.getOutputType(), METHOD2_OUTPUT); Assert.assertEquals(method2.getExchangePattern(), ExchangePattern.IN_OUT); }
public static JavaService fromClass(Class<?> serviceInterface) { HashSet<ServiceOperation> ops = new HashSet<ServiceOperation>(); Method[] methods = serviceInterface.isInterface() ? serviceInterface.getMethods() : serviceInterface.getDeclaredMethods(); for (Method m : methods) { if (Modifier.isPublic(m.getModifiers())) { Class<?>[] params = m.getParameterTypes(); if (params.length > 1) { throw APIMessages.MESSAGES.serviceOpNeedOneParamater(); } OperationTypeQNames operationTypeNames = new OperationTypeQNames(m); if (m.getReturnType().equals(Void.TYPE)) { ops.add(new InOnlyOperation(m.getName(), operationTypeNames.in())); } else { ops.add(new InOutOperation(m.getName(), operationTypeNames.in(), operationTypeNames.out(), operationTypeNames.fault())); } } } return new JavaService(ops, serviceInterface); }
JavaService extends BaseService { public static JavaService fromClass(Class<?> serviceInterface) { HashSet<ServiceOperation> ops = new HashSet<ServiceOperation>(); Method[] methods = serviceInterface.isInterface() ? serviceInterface.getMethods() : serviceInterface.getDeclaredMethods(); for (Method m : methods) { if (Modifier.isPublic(m.getModifiers())) { Class<?>[] params = m.getParameterTypes(); if (params.length > 1) { throw APIMessages.MESSAGES.serviceOpNeedOneParamater(); } OperationTypeQNames operationTypeNames = new OperationTypeQNames(m); if (m.getReturnType().equals(Void.TYPE)) { ops.add(new InOnlyOperation(m.getName(), operationTypeNames.in())); } else { ops.add(new InOutOperation(m.getName(), operationTypeNames.in(), operationTypeNames.out(), operationTypeNames.fault())); } } } return new JavaService(ops, serviceInterface); } }
JavaService extends BaseService { public static JavaService fromClass(Class<?> serviceInterface) { HashSet<ServiceOperation> ops = new HashSet<ServiceOperation>(); Method[] methods = serviceInterface.isInterface() ? serviceInterface.getMethods() : serviceInterface.getDeclaredMethods(); for (Method m : methods) { if (Modifier.isPublic(m.getModifiers())) { Class<?>[] params = m.getParameterTypes(); if (params.length > 1) { throw APIMessages.MESSAGES.serviceOpNeedOneParamater(); } OperationTypeQNames operationTypeNames = new OperationTypeQNames(m); if (m.getReturnType().equals(Void.TYPE)) { ops.add(new InOnlyOperation(m.getName(), operationTypeNames.in())); } else { ops.add(new InOutOperation(m.getName(), operationTypeNames.in(), operationTypeNames.out(), operationTypeNames.fault())); } } } return new JavaService(ops, serviceInterface); } private  JavaService(Set<ServiceOperation> operations, Class<?> serviceInterface); }
JavaService extends BaseService { public static JavaService fromClass(Class<?> serviceInterface) { HashSet<ServiceOperation> ops = new HashSet<ServiceOperation>(); Method[] methods = serviceInterface.isInterface() ? serviceInterface.getMethods() : serviceInterface.getDeclaredMethods(); for (Method m : methods) { if (Modifier.isPublic(m.getModifiers())) { Class<?>[] params = m.getParameterTypes(); if (params.length > 1) { throw APIMessages.MESSAGES.serviceOpNeedOneParamater(); } OperationTypeQNames operationTypeNames = new OperationTypeQNames(m); if (m.getReturnType().equals(Void.TYPE)) { ops.add(new InOnlyOperation(m.getName(), operationTypeNames.in())); } else { ops.add(new InOutOperation(m.getName(), operationTypeNames.in(), operationTypeNames.out(), operationTypeNames.fault())); } } } return new JavaService(ops, serviceInterface); } private  JavaService(Set<ServiceOperation> operations, Class<?> serviceInterface); static JavaService fromClass(Class<?> serviceInterface); Class<?> getJavaInterface(); static Class<?> parseType(final QName type); }
JavaService extends BaseService { public static JavaService fromClass(Class<?> serviceInterface) { HashSet<ServiceOperation> ops = new HashSet<ServiceOperation>(); Method[] methods = serviceInterface.isInterface() ? serviceInterface.getMethods() : serviceInterface.getDeclaredMethods(); for (Method m : methods) { if (Modifier.isPublic(m.getModifiers())) { Class<?>[] params = m.getParameterTypes(); if (params.length > 1) { throw APIMessages.MESSAGES.serviceOpNeedOneParamater(); } OperationTypeQNames operationTypeNames = new OperationTypeQNames(m); if (m.getReturnType().equals(Void.TYPE)) { ops.add(new InOnlyOperation(m.getName(), operationTypeNames.in())); } else { ops.add(new InOutOperation(m.getName(), operationTypeNames.in(), operationTypeNames.out(), operationTypeNames.fault())); } } } return new JavaService(ops, serviceInterface); } private  JavaService(Set<ServiceOperation> operations, Class<?> serviceInterface); static JavaService fromClass(Class<?> serviceInterface); Class<?> getJavaInterface(); static Class<?> parseType(final QName type); static final String TYPE; }