01: package org.syrup.services;
02:
03: import java.util.Hashtable;
04:
05: import javax.naming.Name;
06: import javax.naming.RefAddr;
07: import javax.naming.Reference;
08: import javax.naming.spi.ObjectFactory;
09:
10: /**
11: * Implements an ObjectFactory to build implementations of a BlobClient.
12: *
13: * @author Robbert van Dalen
14: */
15: public class BlobClientFactory implements ObjectFactory {
16: static final String COPYRIGHT = "Copyright 2005 Robbert van Dalen."
17: + "At your option, you may copy, distribute, or make derivative works under "
18: + "the terms of The Artistic License. This License may be found at "
19: + "http://www.opensource.org/licenses/artistic-license.php. "
20: + "THERE IS NO WARRANTY; USE THIS PRODUCT AT YOUR OWN RISK.";
21:
22: public Object getObjectInstance(Object obj, Name name,
23: javax.naming.Context ctx, Hashtable env) throws Exception {
24: if (obj instanceof Reference) {
25: Reference ref = (Reference) obj;
26:
27: RefAddr addr = ref.get("blobclient");
28:
29: if (addr != null) {
30: return new BlobClient((String) addr.getContent());
31: }
32:
33: }
34: return null;
35: }
36: }
|