summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/annotations/service/src/main/java/org/apache/tuscany/sca/vtest/javaapi/annotations/service/impl/BServiceImpl.java
blob: 9c3f15743cec31522c795cc6e0390eb546eb24b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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";
    }
}