summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java
blob: 0922bf3e64092fd5d8696e4139bf66999174d6ed (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * Copyright(C) OASIS(R) 2005,2010. All Rights Reserved.
 * OASIS trademark, IPR and other policies apply.
 */
package org.oasisopen.sca.client;

import java.net.URI;
import java.util.Properties;

import org.oasisopen.sca.NoSuchDomainException;
import org.oasisopen.sca.NoSuchServiceException;
import org.oasisopen.sca.client.SCAClientFactoryFinder;
import org.oasisopen.sca.client.impl.SCAClientFactoryFinderImpl;

/**
 * The SCAClientFactory can be used by non-SCA managed code to 
 * lookup services that exist in a SCA Domain.
 * 
 * @see SCAClientFactoryFinderImpl
 * 
 * @author OASIS Open
 */

public abstract class SCAClientFactory {

    /**
     * The SCAClientFactoryFinder. 
     * Provides a means by which a provider of an SCAClientFactory
     * implementation can inject a factory finder implementation into
     * the abstract SCAClientFactory class - once this is done, future
     * invocations of the SCAClientFactory use the injected factory
     * finder to locate and return an instance of a subclass of
     * SCAClientFactory.
     */
    protected static SCAClientFactoryFinder factoryFinder;
    /**
     * The Domain URI of the SCA Domain which is accessed by this 
     * SCAClientFactory
     */
    private URI domainURI;

    /**
     * Prevent concrete subclasses from using the no-arg constructor
     */
    private SCAClientFactory() {
    }

    /**
     * Constructor used by concrete subclasses
     * @param domainURI - The Domain URI of the Domain accessed via this
     * SCAClientFactory
     */
    protected SCAClientFactory(URI domainURI)
    	throws NoSuchDomainException {
        this.domainURI = domainURI;
    }

    /**
     * Gets the Domain URI of the Domain accessed via this SCAClientFactory
     * @return - the URI for the Domain
     */
    protected URI getDomainURI() {
        return domainURI;
    }
   
      
    /**
     * Creates a new instance of the SCAClientFactory that can be 
     * used to lookup SCA Services.
     * 
     * @param domainURI 	URI of the target domain for the SCAClientFactory
     * @return A new SCAClientFactory 
     */
    public static SCAClientFactory newInstance( URI domainURI ) 
    	throws NoSuchDomainException {
        return newInstance(null, null, domainURI);
    }
    
    /**
     * Creates a new instance of the SCAClientFactory that can be 
     * used to lookup SCA Services.
     *
     * @param properties   Properties that may be used when 
     * creating a new instance of the SCAClientFactory
     * @param domainURI 	URI of the target domain for the SCAClientFactory
     * @return A new SCAClientFactory instance
     */
    public static SCAClientFactory newInstance(Properties properties,
    									URI domainURI) 
    	throws NoSuchDomainException {
        return newInstance(properties, null, domainURI);
    }

    /**
     * Creates a new instance of the SCAClientFactory that can be 
     * used to lookup SCA Services.
     *
     * @param classLoader   ClassLoader that may be used when 
     * creating a new instance of the SCAClientFactory
     * @param domainURI 	URI of the target domain for the SCAClientFactory
     * @return A new SCAClientFactory instance
     */
    public static SCAClientFactory newInstance(ClassLoader classLoader, 
    									URI domainURI) 
    	throws NoSuchDomainException {
        return newInstance(null, classLoader, domainURI);
    }

    /**
     * Creates a new instance of the SCAClientFactory that can be 
     * used to lookup SCA Services.
     *
     * @param properties    Properties that may be used when 
     * creating a new instance of the SCAClientFactory
     * @param classLoader   ClassLoader that may be used when 
     * creating a new instance of the SCAClientFactory
     * @param domainURI 	URI of the target domain for the SCAClientFactory
     * @return A new SCAClientFactory instance
     */
    public static SCAClientFactory newInstance(Properties properties, 
    		                            ClassLoader classLoader,
    		                            URI domainURI) 
    	throws NoSuchDomainException {
        final SCAClientFactoryFinder finder =
            factoryFinder != null ? factoryFinder :
            	new SCAClientFactoryFinderImpl();
        final SCAClientFactory factory
            = finder.find(properties, classLoader, domainURI);
        return factory;
    }
  
    /**
     * Returns a reference proxy that implements the business interface <T>
     * of a service in the SCA Domain handled by this SCAClientFactory
     *
     * @param serviceURI the relative URI of the target service. Takes the
     * form componentName/serviceName.
     * Can also take the extended form componentName/serviceName/bindingName
     * to use a specific binding of the target service
     * 
     * @param interfaze The business interface class of the service in the 
     * domain
     * @param <T> The business interface class of the service in the domain
     *
     * @return a proxy to the target service, in the specified SCA Domain 
     * that implements the business interface <B>.
     * @throws NoSuchServiceException Service requested was not found
     */
    public abstract <T> T getService(Class<T> interfaze, String serviceURI) 
        throws NoSuchServiceException;    
}