diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-13 20:02:36 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-13 20:02:36 +0000 |
commit | 4ed0ed906e82c9484b384419fa4ef4c980768731 (patch) | |
tree | e0250b6d10349e29522a2b1667d2e1db4d9dab84 /branches/sca-java-1.x/vtest/java-api/annotations/service/src | |
parent | ba73f8abcef884936f965c3085b80485bf2b5e1a (diff) |
Creating Java SCA 1.x branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@713805 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/vtest/java-api/annotations/service/src')
25 files changed, 1424 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java new file mode 100644 index 0000000000..a923faf5ae --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/AService.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface AService { + + public String getName(); + + public String setAObject(AObject a); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java new file mode 100644 index 0000000000..26bcf3b9db --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/BService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; + +/** + * Simple Local Service + */ +public interface BService { + + public String getName(); + + public String setAObject(AObject a); + + public String testServices(); +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java new file mode 100644 index 0000000000..4f4f1e80c7 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/CService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; + +/** + * Simple Local Service without defining "@Service" at the implementation class + */ +public interface CService { + + public String getName(); + + public String setAObject(AObject a); +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java new file mode 100644 index 0000000000..ffabb3619c --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService1.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService1 { + + public String getName1(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java new file mode 100644 index 0000000000..83d7980dbc --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService2.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService2 { + + public String getName2(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java new file mode 100644 index 0000000000..a416e33de7 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/DService3.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface DService3 { + + public String getName3(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java new file mode 100644 index 0000000000..ad44d2b93a --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/EService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service which implementation class defines + * + * @Service() with no attributes + */ +public interface EService { + + public String getName(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java new file mode 100644 index 0000000000..52886131a1 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/FService.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service which implementation class defines + * + * @Service with full package name + */ +public interface FService { + + public String getName(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java new file mode 100644 index 0000000000..bd1a3a5fe6 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService1.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface GService1 { + + public String getName(); + + public String getServiceName(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java new file mode 100644 index 0000000000..0f8c7dabcb --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/GService2.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +/** + * Simple Local Service + */ +public interface GService2 extends GService1 { + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java new file mode 100644 index 0000000000..e50e230bd4 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/HService.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface HService { + + public String getName(); + + public String setAObject1(AObject a); + + public String setAObject2(AObject a); + + public String getComponentName(); + + public String getAObject1String(); + + public String getAObject2String(); + + public String getAObject3String(); + + public AObject getAObject3(); + + public String getServiceName1(); + + public String getServiceName2(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java new file mode 100644 index 0000000000..e3a1462f88 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/IService.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.osoa.sca.annotations.Remotable; + +/** + * Simple Remotable Service + */ +@Remotable +public interface IService { + + public String getName(); + + public String setAObject1(AObject a); + + public String setAObject2(AObject a); + + public void setComponentName1(String componentName1); + + public String getComponentName1(); + + public String getComponentName2(); + + public String getAObject1String(); + + public String getAObject2String(); + + public String getAObject3String(); + + public AObject getAObject3(); + + public String getServiceName1(); + + public String getServiceName2(); + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java new file mode 100644 index 0000000000..0ab2e29194 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AObject.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +/** + * A simple object to hold a string + */ +public class AObject { + + public String aString; + + public AObject() { + this.aString = null; + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java new file mode 100644 index 0000000000..7ce2235719 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/AServiceImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.AService; +import org.osoa.sca.annotations.Service; + +@Service(AService.class) +public class AServiceImpl implements AService { + + public String getName() { + return "AService"; + } + + public String setAObject(AObject a) { + a.aString = "AService"; + return "AService"; + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java new file mode 100644 index 0000000000..9c3f15743c --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.AService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.BService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.CService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.HService; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.IService; +import org.osoa.sca.annotations.Service; +import org.osoa.sca.annotations.Reference; + +@Service(BService.class) +public class BServiceImpl implements BService { + + @Reference(required=false) + public AService aService = null; + + @Reference(required=false) + public CService cService = null; + + @Reference(required=false) + public HService hService = null; + + @Reference(required=false) + public IService iService = null; + + public String getName() { + return "BService"; + } + + public String setAObject(AObject a) { + a.aString = "BService"; + return "BService"; + } + + public String testServices() { + + AObject a = new AObject(); + aService.setAObject(a); + if (a.aString != null) + return "AServiceNotPassByValue"; + + AObject c = new AObject(); + cService.setAObject(c); + if (c.aString == null || !c.aString.equals("CService")) + return "CServiceNotPassByReference"; + + + AObject h1 = new AObject(); + hService.setAObject1(h1); + if (h1.aString == null || !h1.aString.equals("HService")) + return "HServiceSetAObject1NotPassByReference"; + h1.aString = "testServices"; + if (!hService.getAObject1String().equals("testServices")) + return "HServiceGetAObject1NotPassByReference"; + + AObject h2 = new AObject(); + hService.setAObject2(h2); + if (h2.aString != null) + return "HServiceSetAObject2NotPassByValue"; + h2.aString = "testServices"; + if (!hService.getAObject2String().equals("HService")) + return "HServiceGetAObject1NotPassByValue"; + + AObject h3 = hService.getAObject3(); + h3.aString = "testServices"; + if (!hService.getAObject3String().equals("HService")) + return "HServiceGetAObject3NotPassByValue"; + + AObject i1 = new AObject(); + iService.setAObject1(i1); + if (i1.aString == null || !i1.aString.equals("IService")) + return "IServiceSetAObject1NotPassByReference"; + i1.aString = "testServices"; + if (!iService.getAObject1String().equals("testServices")) + return "IServiceGetAObject1NotPassByReference"; + + AObject i2 = new AObject(); + iService.setAObject2(i2); + if (i2.aString == null || !i2.aString.equals("IService")) + return "IServiceSetAObject2NotPassByReference"; + i2.aString = "testServices"; + if (!iService.getAObject2String().equals("testServices")) + return "IServiceGetAObject2NotPassByReference"; + + AObject i3 = iService.getAObject3(); + i3.aString = "testServices"; + if (!iService.getAObject3String().equals("testServices")) + return "IServiceGetAObject3NotPassByReference"; + + return "None"; + } +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java new file mode 100644 index 0000000000..3fc23d2f68 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/CServiceImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.CService; + +public class CServiceImpl implements CService { + + public String getName() { + return "CService"; + } + + public String setAObject(AObject a) { + a.aString = "CService"; + return "CService"; + } +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java new file mode 100644 index 0000000000..4cc9430c74 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/DServiceImpl.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService1; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService2; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.DService3; +import org.osoa.sca.annotations.Service; + +@Service(interfaces = {DService1.class, DService2.class}) +public class DServiceImpl implements DService1, DService2, DService3 { + + public String getName1() { + return "DService1"; + } + + public String getName2() { + return "DService2"; + } + + public String getName3() { + return "DService3"; + } +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java new file mode 100644 index 0000000000..a64d434a46 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/EServiceImpl.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.EService; +import org.osoa.sca.annotations.Service; + +@Service() +public class EServiceImpl implements EService { + + public String getName() { + return "EService"; + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java new file mode 100644 index 0000000000..49f34738ef --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.FService; +import org.osoa.sca.RequestContext; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Service; + +@Service(org.apache.tuscany.sca.vtest.javaapi.annotations.service.FService.class) +public class FServiceImpl implements FService { + + @Context + public RequestContext requestContext; + + public String getName() { + return requestContext.getServiceName(); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java new file mode 100644 index 0000000000..46370b7e19 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/FServiceImpl2.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.osoa.sca.annotations.Service; + +@Service(FServiceImpl2.class) +public class FServiceImpl2 extends FServiceImpl { +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java new file mode 100644 index 0000000000..a86d6e1da0 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/GServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.GService1; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.GService2; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Service; +import org.osoa.sca.RequestContext; + +@Service(interfaces = {GService1.class, GService2.class}) +public class GServiceImpl implements GService1 { + + @Context + public RequestContext requestContext; + + public String getName() { + return "GService"; + } + + public String getServiceName() { + return requestContext.getServiceName(); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java new file mode 100644 index 0000000000..ac525ea669 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/HServiceImpl.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.HService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.annotations.ComponentName; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; +import org.osoa.sca.annotations.AllowsPassByReference; + +@Service(HService.class) +@Scope("REQUEST") +public class HServiceImpl implements HService { + + @ComponentName + protected String componentName; + + private AObject aObject1 = null; + + private AObject aObject2 = null; + + private AObject aObject3 = null; + + public RequestContext requestContext; + + public ComponentContext componentContext; + + public String getName() { + return "HService"; + } + + @AllowsPassByReference + public String setAObject1(AObject a) { + a.aString = "HService"; + aObject1 = a; + return "HService"; + } + + public String setAObject2(AObject a) { + a.aString = "HService"; + aObject2 = a; + return "HService"; + } + + @Context + public void setComponentContext(ComponentContext componentContext) { + this.componentContext = componentContext; + } + + @Context + public void setRequestContext(RequestContext requestContext) { + this.requestContext = requestContext; + } + + public String getComponentName() { + return componentName; + } + + public String getAObject1String() { + return aObject1.aString; + } + + public String getAObject2String() { + return aObject2.aString; + } + + public String getAObject3String() { + return aObject3.aString; + } + + public AObject getAObject3() { + aObject3 = new AObject(); + aObject3.aString = "HService"; + return aObject3; + } + + public String getServiceName1() { + return requestContext.getServiceName(); + } + + public String getServiceName2() { + return componentContext.getRequestContext().getServiceName(); + } + +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java new file mode 100644 index 0000000000..f2760b96ab --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/IServiceImpl.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.IService; +import org.osoa.sca.ComponentContext; +import org.osoa.sca.RequestContext; +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.ComponentName; +import org.osoa.sca.annotations.Context; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(IService.class) +@Scope("REQUEST") +@AllowsPassByReference +public class IServiceImpl implements IService { + + @ComponentName + public String componentName1; + + public String componentName2; + + private AObject aObject1 = null; + + private AObject aObject2 = null; + + private AObject aObject3 = null; + + @Context + public RequestContext requestContext; + + @Context + public ComponentContext componentContext; + + public String getName() { + return "IService"; + } + + public String setAObject1(AObject a) { + a.aString = "IService"; + aObject1 = a; + return "IService"; + } + + public String setAObject2(AObject a) { + a.aString = "IService"; + aObject2 = a; + return "IService"; + } + + @ComponentName + public void setComponentName1(String componentName1) { + this.componentName2 = componentName1; + } + + public String getAObject1String() { + return aObject1.aString; + } + + public String getAObject2String() { + return aObject2.aString; + } + + public String getAObject3String() { + return aObject3.aString; + } + + public AObject getAObject3() { + aObject3 = new AObject(); + aObject3.aString = "IService"; + return aObject3; + } + + public String getComponentName1() { + return componentName1; + } + + public String getComponentName2() { + return componentName2; + } + + public String getServiceName1() { + return requestContext.getServiceName(); + } + + public String getServiceName2() { + return componentContext.getRequestContext().getServiceName(); + } +} diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/resources/service.composite b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/resources/service.composite new file mode 100644 index 0000000000..0731986df2 --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/main/resources/service.composite @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://java-api-tests" name="Service-Composite"> + + <component name="AComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AServiceImpl" /> + </component> + + <component name="BComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.BServiceImpl" /> + </component> + + <component name="BComponent1"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.BServiceImpl" /> + <reference name="aService" target="AComponent"/> + <reference name="cService" target="CComponent"/> + <reference name="hService" target="HComponent"/> + <reference name="iService" target="IComponent"/> + </component> + + <component name="CComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.CServiceImpl" /> + </component> + + <component name="DComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.DServiceImpl" /> + </component> + + <component name="EComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.EServiceImpl" /> + </component> + + <component name="FComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.FServiceImpl" /> + </component> + + <component name="FComponent2"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.FServiceImpl2" /> + </component> + + <component name="GComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.GServiceImpl" /> + </component> + + <component name="HComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.HServiceImpl" /> + </component> + + <component name="IComponent"> + <implementation.java + class="org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.IServiceImpl" /> + </component> + +</composite> diff --git a/branches/sca-java-1.x/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java new file mode 100644 index 0000000000..52f7821ebb --- /dev/null +++ b/branches/sca-java-1.x/vtest/java-api/annotations/service/src/test/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/ServiceAnnotationTestCase.java @@ -0,0 +1,335 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.vtest.javaapi.annotations.service; + +import static org.junit.Assert.fail; +import junit.framework.Assert; + +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.AObject; +import org.apache.tuscany.sca.vtest.javaapi.annotations.service.impl.FServiceImpl2; +import org.apache.tuscany.sca.vtest.utilities.ServiceFinder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This test class tests the Service annotation described in section 1.2.1 + * including 1.3.1, 1.8.1, 1.8.3, 1.8.6, 1.8.15 and 1.8.17<br> + * but not..<br> + * <li>Lines 1531 to 1534</li> + */ +public class ServiceAnnotationTestCase { + + protected static String compositeName = "service.composite"; + protected static AService aService = null; + protected static BService bService = null; + protected static BService bService1 = null; + protected static HService hService = null; + protected static IService iService = null; + + @BeforeClass + public static void init() throws Exception { + try { + System.out.println("Setting up"); + ServiceFinder.init(compositeName); + aService = ServiceFinder.getService(AService.class, "AComponent"); + bService = ServiceFinder.getService(BService.class, "BComponent"); + bService1 = ServiceFinder.getService(BService.class, "BComponent1"); + hService = ServiceFinder.getService(HService.class, "HComponent"); + iService = ServiceFinder.getService(IService.class, "IComponent"); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @AfterClass + public static void destroy() throws Exception { + + System.out.println("Cleaning up"); + ServiceFinder.cleanup(); + + } + + /** + * Line 215:<br> + * <li>As a Java interface</li> + * <p> + * Line 1622 to 1623:<br> + * The + * + * @Service annotation type is used on a component implementation class to + * specify the SCA services offered by the implementation.<br> + */ + @Test + public void atService1() throws Exception { + Assert.assertEquals("AService", aService.getName()); + } + + /** + * Line 216:<br> + * <li>As a Java class</li> + * <p> + * Line 1631:<br> + * <li>value – A shortcut for the case when the class provides only a + * single service interface.</li> + */ + @Test + public void atService2() throws Exception { + Assert.assertEquals("BService", bService.getName()); + } + + /** + * Lines 222 to 224:<br> + * A remotable service is defined using the "@Remotable" annotation on the + * Java interface that defines the service. Remotable services are intended + * to be used for coarse grained services, and the parameters are passed + * by-value.<br> + * <p> + * Lines 321 to 323:<br> + * The "@Remotable" annotation on a Java interface indicates that the + * interface is designed to be used for remote communication. Remotable + * interfaces are intended to be used for coarse grained services. + * Operations parameters and return values are passed by-value.<br> + */ + @Test + public void atService3() throws Exception { + AObject o = new AObject(); + Assert.assertEquals("AService", aService.setAObject(o)); + Assert.assertNull(o.aString); + } + + /** + * Lines 227 to 242:<br> + * A local service can only be called by clients that are deployed within + * the same address space as the component implementing the local service.<br> + * ...<br> + * The data exchange semantic for calls to local services is by-reference.<br> + * ...<br> + * Lines 996 to 1028:<br> + * 1.8.1 "@AllowsPassByReference"<br> + * ...<br> + * Lines 1535 to 1540:<br> + * Independent of whether the remotable service is called from outside of + * the composite that contains it or from another component in the same + * composite, the data exchange semantics are by-value.<br> + * Implementations of remotable services may modify input data during or + * after an invocation and may modify return data after the invocation. If a + * remotable service is called locally or remotely, the SCA container is + * responsible for making sure that no modification of input data or + * post-invocation modifications to return data are seen by the caller.<br> + * <p> + * Test under Non-SCA <-> SCA + * <li>BService is local service to test by reference</li> + * <li>HService is remotable service to test "@AllowsPassByReference" at + * method level</li> + * <li>IService is remotable service to test "@AllowsPassByReference" at + * class level</li> + */ + @Test + public void atService4() throws Exception { + AObject b = new AObject(); + Assert.assertEquals("BService", bService.setAObject(b)); + Assert.assertEquals("BService", b.aString); + + AObject h1 = new AObject(); + Assert.assertEquals("HService", hService.setAObject1(h1)); + Assert.assertEquals("HService", h1.aString); + h1.aString = "atService4"; + Assert.assertEquals("atService4", hService.getAObject1String()); + + AObject h2 = new AObject(); + Assert.assertEquals("HService", hService.setAObject2(h2)); + Assert.assertNull(h2.aString); + h2.aString = "atService4"; + Assert.assertEquals("HService", hService.getAObject2String()); + + AObject h3 = hService.getAObject3(); + h3.aString = "atService4"; + Assert.assertEquals("HService", hService.getAObject3String()); + + AObject i1 = new AObject(); + Assert.assertEquals("IService", iService.setAObject1(i1)); + Assert.assertEquals("IService", i1.aString); + i1.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject1String()); + + AObject i2 = new AObject(); + Assert.assertEquals("IService", iService.setAObject2(i2)); + Assert.assertEquals("IService", i2.aString); + i2.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject2String()); + + AObject i3 = iService.getAObject3(); + i3.aString = "atService4"; + Assert.assertEquals("atService4", iService.getAObject3String()); + } + + /** + * Line 1624 to 1627:<br> + * A class used as the implementation of a service is not required to have + * an "@Service" annotation. If a class has no "@Service" annotation, then + * the rules determining which services are offered and what interfaces + * those services have are determined by the specific implementation type. + * <br> + */ + @Test + public void atService5() throws Exception { + CService cService = ServiceFinder.getService(CService.class, "CComponent"); + Assert.assertEquals("CService", cService.getName()); + } + + /** + * Line 1623 to 1624:<br> + * The class need not be declared as implementing all of the interfaces + * implied by the services, but all methods of the service interfaces must + * be present.<br> + * <p> + * Line 1629 to 1630:<br> + * <li>interfaces – The value is an array of interface or class objects + * that should be exposed as services by this component.</li> + */ + @Test + public void atService6() throws Exception { + DService1 dService1 = ServiceFinder.getService(DService1.class, "DComponent/DService1"); + Assert.assertEquals("DService1", dService1.getName1()); + DService2 dService2 = ServiceFinder.getService(DService2.class, "DComponent/DService2"); + Assert.assertEquals("DService2", dService2.getName2()); + try { + ServiceFinder.getService(DService3.class, "DComponent/DService3"); + fail("Should have failed to get this service"); + } catch (Exception e) { + // Expect an exception + } + } + + /** + * Line 1635 to 1636:<br> + * A "@Service" annotation with no attributes is meaningless, it is the same + * as not having the annotation there at all.<br> + */ + @Test + public void atService7() throws Exception { + EService eService = ServiceFinder.getService(EService.class, "EComponent"); + Assert.assertEquals("EService", eService.getName()); + } + + /** + * Line 1637 to 1638:<br> + * The service names of the defined services default to the names of the + * interfaces or class, without the package name.<br> + */ + @Test + public void atService8() throws Exception { + FService fService = ServiceFinder.getService(FService.class, "FComponent"); + Assert.assertEquals("FService", fService.getName()); + FServiceImpl2 fServiceImpl2 = ServiceFinder.getService(FServiceImpl2.class, "FComponent2"); + Assert.assertEquals("FServiceImpl2", fServiceImpl2.getName()); + fService = ServiceFinder.getService(FService.class, "FComponent2"); + Assert.assertEquals("FServiceImpl2", fService.getName()); + } + + /** + * Line 1639 to 1641:<br> + * If a Java implementation needs to realize two services with the same + * interface, then this is achieved through subclassing of the interface. + * The subinterface must not add any methods. Both interfaces are listed in + * the "@Service" annotation of the Java implementation class. <br> + */ + @Test + public void atService9() throws Exception { + GService1 gService1 = ServiceFinder.getService(GService1.class, "GComponent/GService1"); + GService2 gService2 = ServiceFinder.getService(GService2.class, "GComponent/GService2"); + Assert.assertEquals("GService", gService1.getName()); + Assert.assertEquals("GService1", gService1.getServiceName()); + Assert.assertEquals("GService", gService2.getName()); + Assert.assertEquals("GService2", gService2.getServiceName()); + } + + /** + * Lines 227 to 242:<br> + * A local service can only be called by clients that are deployed within + * the same address space as the component implementing the local service.<br> + * ...<br> + * The data exchange semantic for calls to local services is by-reference.<br> + * ...<br> + * Lines 996 to 1028:<br> + * 1.8.1 "@AllowsPassByReference"<br> + * ...<br> + * Lines 1535 to 1540:<br> + * Independent of whether the remotable service is called from outside of + * the composite that contains it or from another component in the same + * composite, the data exchange semantics are by-value.<br> + * Implementations of remotable services may modify input data during or + * after an invocation and may modify return data after the invocation. If a + * remotable service is called locally or remotely, the SCA container is + * responsible for making sure that no modification of input data or + * post-invocation modifications to return data are seen by the caller.<br> + * <p> + * Test under SCA <-> SCA<br> + * <li>AService is remotable service to test by value</li> + * <li>CService is local service to test by-reference</li> + * <li>HService is remotable service to test "@AllowsPassByReference" at + * method level</li> + * <li>IService is remotable service to test "@AllowsPassByReference" at + * class level</li> + */ + @Test + public void atService10() throws Exception { + Assert.assertEquals("None", bService1.testServices()); + } + + /** + * Lines 1095 to 1124:<br> + * 1.8.3. "@ComponentName"<br> + * ...<br> + * The "@ComponentName" annotation type is used to annotate a Java class + * field or setter method that is used to inject the component name.<br> + * ...<br> + */ + @Test + public void atService11() throws Exception { + Assert.assertEquals("HComponent", hService.getComponentName()); + Assert.assertNull(iService.getComponentName1()); + Assert.assertEquals("IComponent", iService.getComponentName2()); + } + + /** + * Lines 1164 to 1187:<br> + * 1.8.6. "@Context"<br> + * ...<br> + * The "@Context" annotation type is used to annotate a Java class field or + * a setter method that is used to inject a composite context for the + * component. The type of context to be injected is defined by the type of + * the Java class field or type of the setter method input argument, the + * type is either ComponentContext or RequestContext.<br> + * ...<br> + * <p> + * HService - "@Context" is used to annotate setter methods<br> + * IService - "@Context" is used to annotate class fields<br> + * <br> + */ + @Test + public void atService12() throws Exception { + Assert.assertEquals("HService", hService.getServiceName1()); + Assert.assertEquals("HService", hService.getServiceName2()); + Assert.assertEquals("IService", iService.getServiceName1()); + Assert.assertEquals("IService", iService.getServiceName2()); + } +} |