KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > OutboundResourceAdapter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment;
25
26 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
27 import java.util.Iterator JavaDoc;
28 import java.util.Set JavaDoc;
29
30 /**
31  * Deployment Information for connector outbound-resourceadapter
32  *
33  * @author Qingqing Ouyang
34  * @author Sheetal Vartak
35  */

36 public class OutboundResourceAdapter extends Descriptor
37 {
38     private boolean isDirty = false;
39     
40     private int transactionSupport = PoolManagerConstants.LOCAL_TRANSACTION;
41     private Set JavaDoc authMechanisms;
42     private boolean reauthenticationSupport = false;
43     private Set JavaDoc connectionDefs;
44
45     public OutboundResourceAdapter ()
46     {
47         this.authMechanisms = new OrderedSet();
48     this.connectionDefs = new OrderedSet();
49     }
50
51     /**
52      * Gets the value of supportsReauthentication
53      */

54     public boolean
55     supportsReauthentication()
56     {
57         return reauthenticationSupport;
58     }
59
60     public String JavaDoc getReauthenticationSupport() {
61         return String.valueOf(reauthenticationSupport);
62     }
63  
64     /**
65      * Sets the value of supportsReauthentication
66      */

67     public void
68     setReauthenticationSupport(boolean reauthenticationSupport)
69     {
70         this.reauthenticationSupport = reauthenticationSupport;
71     this.setDirty();
72         this.changed();
73     }
74
75     /** sets the value of supportsReauthentication
76      * DOL rearchitecture
77     */

78     public void setReauthenticationSupport(String JavaDoc reauthSupport) {
79         this.reauthenticationSupport =
80         (Boolean.valueOf(reauthSupport)).booleanValue();
81     this.setDirty();
82     this.changed();
83     }
84
85
86     /**
87      * Returns NO_TRANSACTION, LOCAL_TRANSACTION, XA_TRANSACTION
88      * as defined in PoolManagerConstants interface
89      */

90     public String JavaDoc
91     getTransSupport()
92     {
93         if (transactionSupport == PoolManagerConstants.NO_TRANSACTION)
94         return ConnectorTagNames.DD_NO_TRANSACTION;
95     else if (transactionSupport == PoolManagerConstants.LOCAL_TRANSACTION)
96             return ConnectorTagNames.DD_LOCAL_TRANSACTION;
97     else
98             return ConnectorTagNames.DD_XA_TRANSACTION;
99     }
100
101     public int
102     getTransactionSupport()
103     {
104         return transactionSupport;
105     }
106  
107     /**
108      * Set value of transactionSupport to NO_TRANSACTION,
109      * LOCAL_TRANSACTION, XA_TRANSACTION as defined in
110      * PoolManagerConstants interface
111      */

112     public void
113     setTransactionSupport(int transactionSupport)
114     {
115         this.transactionSupport = transactionSupport;
116     this.setDirty();
117         this.changed();
118     }
119
120     /**
121      * Set value of transactionSupport to NO_TRANSACTION,
122      * LOCAL_TRANSACTION, XA_TRANSACTION as defined in
123      * PoolManagerConstants interface
124      */

125     public void
126     setTransactionSupport(String JavaDoc support)
127     {
128         if (ConnectorTagNames.DD_NO_TRANSACTION.equals(support))
129             this.transactionSupport = PoolManagerConstants.NO_TRANSACTION;
130         else if (ConnectorTagNames.DD_LOCAL_TRANSACTION.equals(support))
131             this.transactionSupport = PoolManagerConstants.LOCAL_TRANSACTION;
132         else
133             this.transactionSupport = PoolManagerConstants.XA_TRANSACTION;
134
135     this.setDirty();
136         this.changed();
137     }
138       
139    /**
140     * Set of AuthMechanism objects
141     */

142     public Set JavaDoc
143     getAuthMechanisms()
144     {
145         if (authMechanisms == null) {
146             authMechanisms = new OrderedSet();
147         }
148         return authMechanisms;
149     }
150     
151     /**
152      * Add a AuthMechanism object to the set return value :
153      * false = found
154      * true = not found
155      */

156     public boolean
157     addAuthMechanism(AuthMechanism mech)
158     {
159         boolean flag=false;
160         for (Iterator JavaDoc itr = authMechanisms.iterator(); itr.hasNext();){
161         AuthMechanism next = (AuthMechanism) itr.next();
162         if (next.getAuthMechVal()==mech.getAuthMechVal()) {
163             return(flag);
164         }
165     }
166     flag=this.authMechanisms.add(mech);
167     this.setDirty();
168     this.changed();
169     return(flag);
170     }
171     
172     /**
173      * Remove a AuthMechanism object to the set
174      * return value : false = found
175      * true = not found
176      */

177     public boolean
178     removeAuthMechanism(AuthMechanism mech)
179     {
180         boolean flag=false;
181         for (Iterator JavaDoc itr = authMechanisms.iterator(); itr.hasNext();){
182         AuthMechanism next = (AuthMechanism) itr.next();
183         if (next.equals(mech)) {
184             flag=this.authMechanisms.remove(mech);
185         this.setDirty();
186             this.changed();
187         return(flag);
188         }
189     }
190     return(flag);
191     }
192
193
194    /**
195     * Add a AuthMechanism object with given auth mech value to the set
196     * return value : false = found
197     * true = not found
198     */

199     public boolean
200     addAuthMechanism(int mech)
201     {
202         boolean flag = false;
203         for (Iterator JavaDoc itr = authMechanisms.iterator(); itr.hasNext();){
204         AuthMechanism next = (AuthMechanism) itr.next();
205         if (next.getAuthMechVal() == mech)
206            return(flag);
207     }
208         String JavaDoc credInf = null;
209         if (mech == PoolManagerConstants.BASIC_PASSWORD) {
210             credInf = PoolManagerConstants.PASSWORD_CREDENTIAL;
211         } else {
212             credInf = PoolManagerConstants.GENERIC_CREDENTIAL;
213         }
214     AuthMechanism auth = new AuthMechanism("",mech, credInf);
215         flag = this.authMechanisms.add(auth);
216     this.setDirty();
217         this.changed();
218     return(flag);
219     }
220     
221
222     /**
223      * Remove a AuthMechanism object with given auth mech value from the set
224      * return value : false = found
225      * true = not found
226      */

227     public boolean
228     removeAuthMechanism(int mech)
229     {
230         boolean flag = false;
231         for (Iterator JavaDoc itr = authMechanisms.iterator(); itr.hasNext();){
232         AuthMechanism next = (AuthMechanism) itr.next();
233         if (next.getAuthMechVal()==mech)
234         {
235             flag = this.authMechanisms.remove(next);
236         this.setDirty();
237             this.changed();
238                 return(flag);
239         }
240     }
241     return(flag);
242     }
243
244     /**
245      * adds an entry to the set of connection definitions
246      */

247     public void addConnectionDefDescriptor(ConnectionDefDescriptor conDefDesc) {
248     this.connectionDefs.add(conDefDesc);
249     this.setDirty();
250     this.changed();
251     }
252
253     /**
254      * removes an entry from the set of connection definitions
255      */

256     public void removeConnectionDefDescriptor(ConnectionDefDescriptor conDefDesc) {
257     this.connectionDefs.remove(conDefDesc);
258     this.setDirty();
259     this.changed();
260     }
261
262     /**
263      * returns the set of connection definitions
264      */

265     public Set JavaDoc getConnectionDefs() {
266     return connectionDefs;
267     }
268     
269     ///////////////////////////////////////////////////////////////////////
270
/**
271      * For 1.0 DTD, the OutboundRA descriptor needs to take care of adding
272      * connection factories and connection interfaces/impls
273      * The following methods create a ConnectionFactoryDescriptor/ConnectionDescriptor instance
274      * using the info available in the 1.0 DTD.
275      * BACKWARD COMPATIBILITY REQUIREMENT
276      */

277
278     /* public void createNewConnectionDescriptor() {
279      ConnectionDescriptor conDesc = new ConnectionDescriptor();
280      this.addConnection(conDesc);
281     }
282
283     public void createNewConnectionFactoryDescriptor() {
284     ConnectionFactoryDescriptor conDesc = new ConnectionFactoryDescriptor();
285      this.addConnectionFactory(conDesc);
286     }
287
288     public String getConnectionInterface()
289     {
290     Iterator cons = getConnections().iterator();
291     if (cons.hasNext()) {
292         return ((ConnectionDescriptor)cons.next()).getConnectionInterface();
293     }
294         else return null;
295     }
296     
297     public String getConnectionClass()
298     {
299     Iterator cons = getConnections().iterator();
300     if (cons.hasNext()) {
301         return ((ConnectionDescriptor)cons.next()).getConnectionClass();
302     }
303         else return null;
304     }
305
306     public void setConnectionInterface(String intf)
307     {
308     Iterator cons = getConnections().iterator();
309     if (cons.hasNext()) {
310         ((ConnectionDescriptor)cons.next()).setConnectionInterface(intf);
311     }
312     else throw new RuntimeException("There is no connection-interface specified for this 1.0 DTD");
313     }
314
315     public void setConnectionClass(String cl)
316     {
317     Iterator cons = getConnections().iterator();
318     if (cons.hasNext()) {
319         ((ConnectionDescriptor)cons.next()).setConnectionClass(cl);
320     }
321     else throw new RuntimeException("There is no connection-class specified for this 1.0 DTD");
322     }
323
324     public String getConnectionFactoryInterface()
325     {
326     Iterator cons = getConnectionFactories().iterator();
327     if (cons.hasNext()) {
328         return ((ConnectionFactoryDescriptor)cons.next()).getConnectionFactoryInterface();
329     }
330         else return null;
331     }
332     
333     public String getConnectionFactoryClass()
334     {
335     Iterator cons = getConnectionFactories().iterator();
336     if (cons.hasNext()) {
337         return ((ConnectionFactoryDescriptor)cons.next()).getConnectionFactoryClass();
338     }
339         else return null;
340     }
341
342     public void setConnectionFactoryInterface(String intf)
343     {
344     Iterator cons = getConnectionFactories().iterator();
345     if (cons.hasNext()) {
346         ((ConnectionFactoryDescriptor)cons.next()).setConnectionFactoryInterface(intf);
347     }
348     else throw new RuntimeException("There is no connectionfactory-interface specified for this 1.0 DTD");
349     }
350
351     public void setConnectionFactoryClass(String cl)
352     {
353     Iterator cons = getConnectionFactories().iterator();
354     if (cons.hasNext()) {
355         ((ConnectionFactoryDescriptor)cons.next()).setConnectionFactoryClass(cl);
356     }
357     else throw new RuntimeException("There is no connectionfactory-class specified for this 1.0 DTD");
358     }*/

359     
360     ///////////////////////////
361

362     /**
363      * For being able to read 1.0 and write 1.5
364      */

365
366     public void setConnectionDef(ConnectionDefDescriptor conDef) {
367         this.connectionDefs.add(conDef);
368         this.setDirty();
369         this.changed();
370     }
371     
372     public ConnectionDefDescriptor getConnectionDef() {
373     Iterator JavaDoc iter = connectionDefs.iterator();
374     ConnectionDefDescriptor conDef = (ConnectionDefDescriptor)iter.next();
375     return conDef;
376     }
377     
378     /**
379      * Gets the value of ManagedconnectionFactoryImpl
380      */

381     public String JavaDoc getManagedConnectionFactoryImpl()
382     {
383         return getConnectionDef().getManagedConnectionFactoryImpl();
384     }
385     
386     /**
387      * Sets the value of ManagedconnectionFactoryImpl
388      */

389     public void
390     setManagedConnectionFactoryImpl(String JavaDoc managedConnectionFactoryImpl)
391     {
392         getConnectionDef().setManagedConnectionFactoryImpl(managedConnectionFactoryImpl);
393     }
394
395     /**
396      * Set of EnvironmentProperty
397      */

398     public Set JavaDoc getConfigProperties()
399     {
400         return getConnectionDef().getConfigProperties();
401     }
402       
403     /**
404      * Add a configProperty to the set
405      */

406     public void addConfigProperty(EnvironmentProperty configProperty)
407     {
408     getConnectionDef().getConfigProperties().add(configProperty);
409     }
410
411     /**
412      * Add a configProperty to the set
413      */

414     public void removeConfigProperty(EnvironmentProperty configProperty)
415     {
416     getConnectionDef().getConfigProperties().remove(configProperty);
417     }
418     
419     /**
420      * Get connection factory impl
421      */

422     public String JavaDoc getConnectionFactoryImpl()
423     {
424         return getConnectionDef().getConnectionFactoryImpl();
425     }
426
427     /**
428      * set connection factory impl
429      */

430     public void setConnectionFactoryImpl(String JavaDoc cf)
431     {
432     getConnectionDef().setConnectionFactoryImpl(cf);
433     }
434
435     /**
436      * Get connection factory intf
437      */

438     public String JavaDoc getConnectionFactoryIntf()
439     {
440         return getConnectionDef().getConnectionFactoryIntf();
441     }
442
443     /**
444      * set connection factory intf
445      */

446     public void setConnectionFactoryIntf(String JavaDoc cf)
447     {
448     getConnectionDef().setConnectionFactoryIntf(cf);
449     }
450
451     /**
452      * Get connection intf
453      */

454     public String JavaDoc getConnectionIntf()
455     {
456         return getConnectionDef().getConnectionIntf();
457     }
458
459     /**
460      * set connection intf
461      */

462     public void setConnectionIntf(String JavaDoc con)
463     {
464     getConnectionDef().setConnectionIntf(con);
465     }
466
467     /**
468      * Get connection impl
469      */

470     public String JavaDoc getConnectionImpl()
471     {
472         return getConnectionDef().getConnectionImpl();
473     }
474
475     /**
476      * set connection intf
477      */

478     public void setConnectionImpl(String JavaDoc con)
479     {
480     getConnectionDef().setConnectionImpl(con);
481     }
482
483     public boolean
484     isDirty()
485     {
486     return this.isDirty;
487     }
488     
489     public void
490     changed()
491     {
492     super.changed();
493     }
494
495     private void setDirty() {
496         this.isDirty = true;
497     }
498 }
499
Popular Tags