Source Code Cross Referenced for BaseDirContext.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » naming » resources » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » org.apache.naming.resources 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:
0018:        package org.apache.naming.resources;
0019:
0020:        import java.util.Hashtable;
0021:
0022:        import javax.naming.Context;
0023:        import javax.naming.Name;
0024:        import javax.naming.NameParser;
0025:        import javax.naming.NamingEnumeration;
0026:        import javax.naming.NamingException;
0027:        import javax.naming.directory.Attributes;
0028:        import javax.naming.directory.DirContext;
0029:        import javax.naming.directory.ModificationItem;
0030:        import javax.naming.directory.SearchControls;
0031:
0032:        import org.apache.naming.NameParserImpl;
0033:        import org.apache.naming.StringManager;
0034:
0035:        /**
0036:         * Directory Context implementation helper class.
0037:         *
0038:         * @author Remy Maucherat
0039:         * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
0040:         */
0041:
0042:        public abstract class BaseDirContext implements  DirContext {
0043:
0044:            // -------------------------------------------------------------- Constants
0045:
0046:            // ----------------------------------------------------------- Constructors
0047:
0048:            /**
0049:             * Builds a base directory context.
0050:             */
0051:            public BaseDirContext() {
0052:                this .env = new Hashtable();
0053:            }
0054:
0055:            /**
0056:             * Builds a base directory context using the given environment.
0057:             */
0058:            public BaseDirContext(Hashtable env) {
0059:                this .env = env;
0060:            }
0061:
0062:            // ----------------------------------------------------- Instance Variables
0063:
0064:            /**
0065:             * The document base path.
0066:             */
0067:            protected String docBase = null;
0068:
0069:            /**
0070:             * Environment.
0071:             */
0072:            protected Hashtable env;
0073:
0074:            /**
0075:             * The string manager for this package.
0076:             */
0077:            protected StringManager sm = StringManager
0078:                    .getManager(Constants.Package);
0079:
0080:            /**
0081:             * Name parser for this context.
0082:             */
0083:            protected final NameParser nameParser = new NameParserImpl();
0084:
0085:            /**
0086:             * Cached.
0087:             */
0088:            protected boolean cached = true;
0089:
0090:            /**
0091:             * Cache TTL.
0092:             */
0093:            protected int cacheTTL = 5000; // 5s
0094:
0095:            /**
0096:             * Max size of resources which will have their content cached.
0097:             */
0098:            protected int cacheMaxSize = 10240; // 10 MB
0099:
0100:            // ------------------------------------------------------------- Properties
0101:
0102:            /**
0103:             * Return the document root for this component.
0104:             */
0105:            public String getDocBase() {
0106:                return (this .docBase);
0107:            }
0108:
0109:            /**
0110:             * Set the document root for this component.
0111:             *
0112:             * @param docBase The new document root
0113:             *
0114:             * @exception IllegalArgumentException if the specified value is not
0115:             *  supported by this implementation
0116:             * @exception IllegalArgumentException if this would create a
0117:             *  malformed URL
0118:             */
0119:            public void setDocBase(String docBase) {
0120:
0121:                // Validate the format of the proposed document root
0122:                if (docBase == null)
0123:                    throw new IllegalArgumentException(sm
0124:                            .getString("resources.null"));
0125:
0126:                // Change the document root property
0127:                this .docBase = docBase;
0128:
0129:            }
0130:
0131:            /**
0132:             * Set cached.
0133:             */
0134:            public void setCached(boolean cached) {
0135:                this .cached = cached;
0136:            }
0137:
0138:            /**
0139:             * Is cached ?
0140:             */
0141:            public boolean isCached() {
0142:                return cached;
0143:            }
0144:
0145:            /**
0146:             * Set cache TTL.
0147:             */
0148:            public void setCacheTTL(int cacheTTL) {
0149:                this .cacheTTL = cacheTTL;
0150:            }
0151:
0152:            /**
0153:             * Get cache TTL.
0154:             */
0155:            public int getCacheTTL() {
0156:                return cacheTTL;
0157:            }
0158:
0159:            /**
0160:             * Return the maximum size of the cache in KB.
0161:             */
0162:            public int getCacheMaxSize() {
0163:                return cacheMaxSize;
0164:            }
0165:
0166:            /**
0167:             * Set the maximum size of the cache in KB.
0168:             */
0169:            public void setCacheMaxSize(int cacheMaxSize) {
0170:                this .cacheMaxSize = cacheMaxSize;
0171:            }
0172:
0173:            // --------------------------------------------------------- Public Methods
0174:
0175:            /**
0176:             * Allocate resources for this directory context.
0177:             */
0178:            public void allocate() {
0179:                ; // No action taken by the default implementation
0180:            }
0181:
0182:            /**
0183:             * Release any resources allocated for this directory context.
0184:             */
0185:            public void release() {
0186:                ; // No action taken by the default implementation
0187:            }
0188:
0189:            // -------------------------------------------------------- Context Methods
0190:
0191:            /**
0192:             * Retrieves the named object. If name is empty, returns a new instance 
0193:             * of this context (which represents the same naming context as this 
0194:             * context, but its environment may be modified independently and it may 
0195:             * be accessed concurrently).
0196:             * 
0197:             * @param name the name of the object to look up
0198:             * @return the object bound to name
0199:             * @exception NamingException if a naming exception is encountered
0200:             */
0201:            public Object lookup(Name name) throws NamingException {
0202:                return lookup(name.toString());
0203:            }
0204:
0205:            /**
0206:             * Retrieves the named object.
0207:             * 
0208:             * @param name the name of the object to look up
0209:             * @return the object bound to name
0210:             * @exception NamingException if a naming exception is encountered
0211:             */
0212:            public abstract Object lookup(String name) throws NamingException;
0213:
0214:            /**
0215:             * Binds a name to an object. All intermediate contexts and the target 
0216:             * context (that named by all but terminal atomic component of the name) 
0217:             * must already exist.
0218:             * 
0219:             * @param name the name to bind; may not be empty
0220:             * @param obj the object to bind; possibly null
0221:             * @exception NameAlreadyBoundException if name is already bound
0222:             * @exception InvalidAttributesException if object did not supply all 
0223:             * mandatory attributes
0224:             * @exception NamingException if a naming exception is encountered
0225:             */
0226:            public void bind(Name name, Object obj) throws NamingException {
0227:                bind(name.toString(), obj);
0228:            }
0229:
0230:            /**
0231:             * Binds a name to an object.
0232:             * 
0233:             * @param name the name to bind; may not be empty
0234:             * @param obj the object to bind; possibly null
0235:             * @exception NameAlreadyBoundException if name is already bound
0236:             * @exception InvalidAttributesException if object did not supply all 
0237:             * mandatory attributes
0238:             * @exception NamingException if a naming exception is encountered
0239:             */
0240:            public void bind(String name, Object obj) throws NamingException {
0241:                bind(name, obj, null);
0242:            }
0243:
0244:            /**
0245:             * Binds a name to an object, overwriting any existing binding. All 
0246:             * intermediate contexts and the target context (that named by all but 
0247:             * terminal atomic component of the name) must already exist.
0248:             * <p>
0249:             * If the object is a DirContext, any existing attributes associated with 
0250:             * the name are replaced with those of the object. Otherwise, any 
0251:             * existing attributes associated with the name remain unchanged.
0252:             * 
0253:             * @param name the name to bind; may not be empty
0254:             * @param obj the object to bind; possibly null
0255:             * @exception InvalidAttributesException if object did not supply all 
0256:             * mandatory attributes
0257:             * @exception NamingException if a naming exception is encountered
0258:             */
0259:            public void rebind(Name name, Object obj) throws NamingException {
0260:                rebind(name.toString(), obj);
0261:            }
0262:
0263:            /**
0264:             * Binds a name to an object, overwriting any existing binding.
0265:             * 
0266:             * @param name the name to bind; may not be empty
0267:             * @param obj the object to bind; possibly null
0268:             * @exception InvalidAttributesException if object did not supply all 
0269:             * mandatory attributes
0270:             * @exception NamingException if a naming exception is encountered
0271:             */
0272:            public void rebind(String name, Object obj) throws NamingException {
0273:                rebind(name, obj, null);
0274:            }
0275:
0276:            /**
0277:             * Unbinds the named object. Removes the terminal atomic name in name 
0278:             * from the target context--that named by all but the terminal atomic 
0279:             * part of name.
0280:             * <p>
0281:             * This method is idempotent. It succeeds even if the terminal atomic 
0282:             * name is not bound in the target context, but throws 
0283:             * NameNotFoundException if any of the intermediate contexts do not exist. 
0284:             * 
0285:             * @param name the name to bind; may not be empty
0286:             * @exception NameNotFoundException if an intermediate context does not 
0287:             * exist
0288:             * @exception NamingException if a naming exception is encountered
0289:             */
0290:            public void unbind(Name name) throws NamingException {
0291:                unbind(name.toString());
0292:            }
0293:
0294:            /**
0295:             * Unbinds the named object.
0296:             * 
0297:             * @param name the name to bind; may not be empty
0298:             * @exception NameNotFoundException if an intermediate context does not 
0299:             * exist
0300:             * @exception NamingException if a naming exception is encountered
0301:             */
0302:            public abstract void unbind(String name) throws NamingException;
0303:
0304:            /**
0305:             * Binds a new name to the object bound to an old name, and unbinds the 
0306:             * old name. Both names are relative to this context. Any attributes 
0307:             * associated with the old name become associated with the new name. 
0308:             * Intermediate contexts of the old name are not changed.
0309:             * 
0310:             * @param oldName the name of the existing binding; may not be empty
0311:             * @param newName the name of the new binding; may not be empty
0312:             * @exception NameAlreadyBoundException if newName is already bound
0313:             * @exception NamingException if a naming exception is encountered
0314:             */
0315:            public void rename(Name oldName, Name newName)
0316:                    throws NamingException {
0317:                rename(oldName.toString(), newName.toString());
0318:            }
0319:
0320:            /**
0321:             * Binds a new name to the object bound to an old name, and unbinds the 
0322:             * old name.
0323:             * 
0324:             * @param oldName the name of the existing binding; may not be empty
0325:             * @param newName the name of the new binding; may not be empty
0326:             * @exception NameAlreadyBoundException if newName is already bound
0327:             * @exception NamingException if a naming exception is encountered
0328:             */
0329:            public abstract void rename(String oldName, String newName)
0330:                    throws NamingException;
0331:
0332:            /**
0333:             * Enumerates the names bound in the named context, along with the class 
0334:             * names of objects bound to them. The contents of any subcontexts are 
0335:             * not included.
0336:             * <p>
0337:             * If a binding is added to or removed from this context, its effect on 
0338:             * an enumeration previously returned is undefined.
0339:             * 
0340:             * @param name the name of the context to list
0341:             * @return an enumeration of the names and class names of the bindings in 
0342:             * this context. Each element of the enumeration is of type NameClassPair.
0343:             * @exception NamingException if a naming exception is encountered
0344:             */
0345:            public NamingEnumeration list(Name name) throws NamingException {
0346:                return list(name.toString());
0347:            }
0348:
0349:            /**
0350:             * Enumerates the names bound in the named context, along with the class 
0351:             * names of objects bound to them.
0352:             * 
0353:             * @param name the name of the context to list
0354:             * @return an enumeration of the names and class names of the bindings in 
0355:             * this context. Each element of the enumeration is of type NameClassPair.
0356:             * @exception NamingException if a naming exception is encountered
0357:             */
0358:            public abstract NamingEnumeration list(String name)
0359:                    throws NamingException;
0360:
0361:            /**
0362:             * Enumerates the names bound in the named context, along with the 
0363:             * objects bound to them. The contents of any subcontexts are not 
0364:             * included.
0365:             * <p>
0366:             * If a binding is added to or removed from this context, its effect on 
0367:             * an enumeration previously returned is undefined.
0368:             * 
0369:             * @param name the name of the context to list
0370:             * @return an enumeration of the bindings in this context. 
0371:             * Each element of the enumeration is of type Binding.
0372:             * @exception NamingException if a naming exception is encountered
0373:             */
0374:            public NamingEnumeration listBindings(Name name)
0375:                    throws NamingException {
0376:                return listBindings(name.toString());
0377:            }
0378:
0379:            /**
0380:             * Enumerates the names bound in the named context, along with the 
0381:             * objects bound to them.
0382:             * 
0383:             * @param name the name of the context to list
0384:             * @return an enumeration of the bindings in this context. 
0385:             * Each element of the enumeration is of type Binding.
0386:             * @exception NamingException if a naming exception is encountered
0387:             */
0388:            public abstract NamingEnumeration listBindings(String name)
0389:                    throws NamingException;
0390:
0391:            /**
0392:             * Destroys the named context and removes it from the namespace. Any 
0393:             * attributes associated with the name are also removed. Intermediate 
0394:             * contexts are not destroyed.
0395:             * <p>
0396:             * This method is idempotent. It succeeds even if the terminal atomic 
0397:             * name is not bound in the target context, but throws 
0398:             * NameNotFoundException if any of the intermediate contexts do not exist. 
0399:             * 
0400:             * In a federated naming system, a context from one naming system may be 
0401:             * bound to a name in another. One can subsequently look up and perform 
0402:             * operations on the foreign context using a composite name. However, an 
0403:             * attempt destroy the context using this composite name will fail with 
0404:             * NotContextException, because the foreign context is not a "subcontext" 
0405:             * of the context in which it is bound. Instead, use unbind() to remove 
0406:             * the binding of the foreign context. Destroying the foreign context 
0407:             * requires that the destroySubcontext() be performed on a context from 
0408:             * the foreign context's "native" naming system.
0409:             * 
0410:             * @param name the name of the context to be destroyed; may not be empty
0411:             * @exception NameNotFoundException if an intermediate context does not 
0412:             * exist
0413:             * @exception NotContextException if the name is bound but does not name 
0414:             * a context, or does not name a context of the appropriate type
0415:             */
0416:            public void destroySubcontext(Name name) throws NamingException {
0417:                destroySubcontext(name.toString());
0418:            }
0419:
0420:            /**
0421:             * Destroys the named context and removes it from the namespace.
0422:             * 
0423:             * @param name the name of the context to be destroyed; may not be empty
0424:             * @exception NameNotFoundException if an intermediate context does not 
0425:             * exist
0426:             * @exception NotContextException if the name is bound but does not name 
0427:             * a context, or does not name a context of the appropriate type
0428:             */
0429:            public abstract void destroySubcontext(String name)
0430:                    throws NamingException;
0431:
0432:            /**
0433:             * Creates and binds a new context. Creates a new context with the given 
0434:             * name and binds it in the target context (that named by all but 
0435:             * terminal atomic component of the name). All intermediate contexts and 
0436:             * the target context must already exist.
0437:             * 
0438:             * @param name the name of the context to create; may not be empty
0439:             * @return the newly created context
0440:             * @exception NameAlreadyBoundException if name is already bound
0441:             * @exception InvalidAttributesException if creation of the subcontext 
0442:             * requires specification of mandatory attributes
0443:             * @exception NamingException if a naming exception is encountered
0444:             */
0445:            public Context createSubcontext(Name name) throws NamingException {
0446:                return createSubcontext(name.toString());
0447:            }
0448:
0449:            /**
0450:             * Creates and binds a new context.
0451:             * 
0452:             * @param name the name of the context to create; may not be empty
0453:             * @return the newly created context
0454:             * @exception NameAlreadyBoundException if name is already bound
0455:             * @exception InvalidAttributesException if creation of the subcontext 
0456:             * requires specification of mandatory attributes
0457:             * @exception NamingException if a naming exception is encountered
0458:             */
0459:            public Context createSubcontext(String name) throws NamingException {
0460:                return createSubcontext(name, null);
0461:            }
0462:
0463:            /**
0464:             * Retrieves the named object, following links except for the terminal 
0465:             * atomic component of the name. If the object bound to name is not a 
0466:             * link, returns the object itself.
0467:             * 
0468:             * @param name the name of the object to look up
0469:             * @return the object bound to name, not following the terminal link 
0470:             * (if any).
0471:             * @exception NamingException if a naming exception is encountered
0472:             */
0473:            public Object lookupLink(Name name) throws NamingException {
0474:                return lookupLink(name.toString());
0475:            }
0476:
0477:            /**
0478:             * Retrieves the named object, following links except for the terminal 
0479:             * atomic component of the name.
0480:             * 
0481:             * @param name the name of the object to look up
0482:             * @return the object bound to name, not following the terminal link 
0483:             * (if any).
0484:             * @exception NamingException if a naming exception is encountered
0485:             */
0486:            public abstract Object lookupLink(String name)
0487:                    throws NamingException;
0488:
0489:            /**
0490:             * Retrieves the parser associated with the named context. In a 
0491:             * federation of namespaces, different naming systems will parse names 
0492:             * differently. This method allows an application to get a parser for 
0493:             * parsing names into their atomic components using the naming convention 
0494:             * of a particular naming system. Within any single naming system, 
0495:             * NameParser objects returned by this method must be equal (using the 
0496:             * equals() test).
0497:             * 
0498:             * @param name the name of the context from which to get the parser
0499:             * @return a name parser that can parse compound names into their atomic 
0500:             * components
0501:             * @exception NamingException if a naming exception is encountered
0502:             */
0503:            public NameParser getNameParser(Name name) throws NamingException {
0504:                return new NameParserImpl();
0505:            }
0506:
0507:            /**
0508:             * Retrieves the parser associated with the named context.
0509:             * 
0510:             * @param name the name of the context from which to get the parser
0511:             * @return a name parser that can parse compound names into their atomic 
0512:             * components
0513:             * @exception NamingException if a naming exception is encountered
0514:             */
0515:            public NameParser getNameParser(String name) throws NamingException {
0516:                return new NameParserImpl();
0517:            }
0518:
0519:            /**
0520:             * Composes the name of this context with a name relative to this context.
0521:             * <p>
0522:             * Given a name (name) relative to this context, and the name (prefix) 
0523:             * of this context relative to one of its ancestors, this method returns 
0524:             * the composition of the two names using the syntax appropriate for the 
0525:             * naming system(s) involved. That is, if name names an object relative 
0526:             * to this context, the result is the name of the same object, but 
0527:             * relative to the ancestor context. None of the names may be null.
0528:             * 
0529:             * @param name a name relative to this context
0530:             * @param prefix the name of this context relative to one of its ancestors
0531:             * @return the composition of prefix and name
0532:             * @exception NamingException if a naming exception is encountered
0533:             */
0534:            public Name composeName(Name name, Name prefix)
0535:                    throws NamingException {
0536:                prefix = (Name) prefix.clone();
0537:                return prefix.addAll(name);
0538:            }
0539:
0540:            /**
0541:             * Composes the name of this context with a name relative to this context.
0542:             * 
0543:             * @param name a name relative to this context
0544:             * @param prefix the name of this context relative to one of its ancestors
0545:             * @return the composition of prefix and name
0546:             * @exception NamingException if a naming exception is encountered
0547:             */
0548:            public String composeName(String name, String prefix)
0549:                    throws NamingException {
0550:                return prefix + "/" + name;
0551:            }
0552:
0553:            /**
0554:             * Adds a new environment property to the environment of this context. If 
0555:             * the property already exists, its value is overwritten.
0556:             * 
0557:             * @param propName the name of the environment property to add; may not 
0558:             * be null
0559:             * @param propVal the value of the property to add; may not be null
0560:             * @exception NamingException if a naming exception is encountered
0561:             */
0562:            public Object addToEnvironment(String propName, Object propVal)
0563:                    throws NamingException {
0564:                return env.put(propName, propVal);
0565:            }
0566:
0567:            /**
0568:             * Removes an environment property from the environment of this context. 
0569:             * 
0570:             * @param propName the name of the environment property to remove; 
0571:             * may not be null
0572:             * @exception NamingException if a naming exception is encountered
0573:             */
0574:            public Object removeFromEnvironment(String propName)
0575:                    throws NamingException {
0576:                return env.remove(propName);
0577:            }
0578:
0579:            /**
0580:             * Retrieves the environment in effect for this context. See class 
0581:             * description for more details on environment properties. 
0582:             * The caller should not make any changes to the object returned: their 
0583:             * effect on the context is undefined. The environment of this context 
0584:             * may be changed using addToEnvironment() and removeFromEnvironment().
0585:             * 
0586:             * @return the environment of this context; never null
0587:             * @exception NamingException if a naming exception is encountered
0588:             */
0589:            public Hashtable getEnvironment() throws NamingException {
0590:                return env;
0591:            }
0592:
0593:            /**
0594:             * Closes this context. This method releases this context's resources 
0595:             * immediately, instead of waiting for them to be released automatically 
0596:             * by the garbage collector.
0597:             * This method is idempotent: invoking it on a context that has already 
0598:             * been closed has no effect. Invoking any other method on a closed 
0599:             * context is not allowed, and results in undefined behaviour.
0600:             * 
0601:             * @exception NamingException if a naming exception is encountered
0602:             */
0603:            public void close() throws NamingException {
0604:                env.clear();
0605:            }
0606:
0607:            /**
0608:             * Retrieves the full name of this context within its own namespace.
0609:             * <p>
0610:             * Many naming services have a notion of a "full name" for objects in 
0611:             * their respective namespaces. For example, an LDAP entry has a 
0612:             * distinguished name, and a DNS record has a fully qualified name. This 
0613:             * method allows the client application to retrieve this name. The string 
0614:             * returned by this method is not a JNDI composite name and should not be 
0615:             * passed directly to context methods. In naming systems for which the 
0616:             * notion of full name does not make sense, 
0617:             * OperationNotSupportedException is thrown.
0618:             * 
0619:             * @return this context's name in its own namespace; never null
0620:             * @exception OperationNotSupportedException if the naming system does 
0621:             * not have the notion of a full name
0622:             * @exception NamingException if a naming exception is encountered
0623:             */
0624:            public abstract String getNameInNamespace() throws NamingException;
0625:
0626:            // ----------------------------------------------------- DirContext Methods
0627:
0628:            /**
0629:             * Retrieves all of the attributes associated with a named object. 
0630:             * 
0631:             * @return the set of attributes associated with name. 
0632:             * Returns an empty attribute set if name has no attributes; never null.
0633:             * @param name the name of the object from which to retrieve attributes
0634:             * @exception NamingException if a naming exception is encountered
0635:             */
0636:            public Attributes getAttributes(Name name) throws NamingException {
0637:                return getAttributes(name.toString());
0638:            }
0639:
0640:            /**
0641:             * Retrieves all of the attributes associated with a named object.
0642:             * 
0643:             * @return the set of attributes associated with name
0644:             * @param name the name of the object from which to retrieve attributes
0645:             * @exception NamingException if a naming exception is encountered
0646:             */
0647:            public Attributes getAttributes(String name) throws NamingException {
0648:                return getAttributes(name, null);
0649:            }
0650:
0651:            /**
0652:             * Retrieves selected attributes associated with a named object. 
0653:             * See the class description regarding attribute models, attribute type 
0654:             * names, and operational attributes.
0655:             * 
0656:             * @return the requested attributes; never null
0657:             * @param name the name of the object from which to retrieve attributes
0658:             * @param attrIds the identifiers of the attributes to retrieve. null 
0659:             * indicates that all attributes should be retrieved; an empty array 
0660:             * indicates that none should be retrieved
0661:             * @exception NamingException if a naming exception is encountered
0662:             */
0663:            public Attributes getAttributes(Name name, String[] attrIds)
0664:                    throws NamingException {
0665:                return getAttributes(name.toString(), attrIds);
0666:            }
0667:
0668:            /**
0669:             * Retrieves selected attributes associated with a named object.
0670:             * 
0671:             * @return the requested attributes; never null
0672:             * @param name the name of the object from which to retrieve attributes
0673:             * @param attrIds the identifiers of the attributes to retrieve. null 
0674:             * indicates that all attributes should be retrieved; an empty array 
0675:             * indicates that none should be retrieved
0676:             * @exception NamingException if a naming exception is encountered
0677:             */
0678:            public abstract Attributes getAttributes(String name,
0679:                    String[] attrIds) throws NamingException;
0680:
0681:            /**
0682:             * Modifies the attributes associated with a named object. The order of 
0683:             * the modifications is not specified. Where possible, the modifications 
0684:             * are performed atomically.
0685:             * 
0686:             * @param name the name of the object whose attributes will be updated
0687:             * @param mod_op the modification operation, one of: ADD_ATTRIBUTE, 
0688:             * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
0689:             * @param attrs the attributes to be used for the modification; may not 
0690:             * be null
0691:             * @exception AttributeModificationException if the modification cannot be
0692:             * completed successfully
0693:             * @exception NamingException if a naming exception is encountered
0694:             */
0695:            public void modifyAttributes(Name name, int mod_op, Attributes attrs)
0696:                    throws NamingException {
0697:                modifyAttributes(name.toString(), mod_op, attrs);
0698:            }
0699:
0700:            /**
0701:             * Modifies the attributes associated with a named object.
0702:             * 
0703:             * @param name the name of the object whose attributes will be updated
0704:             * @param mod_op the modification operation, one of: ADD_ATTRIBUTE, 
0705:             * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
0706:             * @param attrs the attributes to be used for the modification; may not 
0707:             * be null
0708:             * @exception AttributeModificationException if the modification cannot be
0709:             * completed successfully
0710:             * @exception NamingException if a naming exception is encountered
0711:             */
0712:            public abstract void modifyAttributes(String name, int mod_op,
0713:                    Attributes attrs) throws NamingException;
0714:
0715:            /**
0716:             * Modifies the attributes associated with a named object using an an 
0717:             * ordered list of modifications. The modifications are performed in the 
0718:             * order specified. Each modification specifies a modification operation 
0719:             * code and an attribute on which to operate. Where possible, the 
0720:             * modifications are performed atomically.
0721:             * 
0722:             * @param name the name of the object whose attributes will be updated
0723:             * @param mods an ordered sequence of modifications to be performed; may 
0724:             * not be null
0725:             * @exception AttributeModificationException if the modification cannot be
0726:             * completed successfully
0727:             * @exception NamingException if a naming exception is encountered
0728:             */
0729:            public void modifyAttributes(Name name, ModificationItem[] mods)
0730:                    throws NamingException {
0731:                modifyAttributes(name.toString(), mods);
0732:            }
0733:
0734:            /**
0735:             * Modifies the attributes associated with a named object using an an 
0736:             * ordered list of modifications.
0737:             * 
0738:             * @param name the name of the object whose attributes will be updated
0739:             * @param mods an ordered sequence of modifications to be performed; may 
0740:             * not be null
0741:             * @exception AttributeModificationException if the modification cannot be
0742:             * completed successfully
0743:             * @exception NamingException if a naming exception is encountered
0744:             */
0745:            public abstract void modifyAttributes(String name,
0746:                    ModificationItem[] mods) throws NamingException;
0747:
0748:            /**
0749:             * Binds a name to an object, along with associated attributes. If attrs 
0750:             * is null, the resulting binding will have the attributes associated 
0751:             * with obj if obj is a DirContext, and no attributes otherwise. If attrs 
0752:             * is non-null, the resulting binding will have attrs as its attributes; 
0753:             * any attributes associated with obj are ignored.
0754:             * 
0755:             * @param name the name to bind; may not be empty
0756:             * @param obj the object to bind; possibly null
0757:             * @param attrs the attributes to associate with the binding
0758:             * @exception NameAlreadyBoundException if name is already bound
0759:             * @exception InvalidAttributesException if some "mandatory" attributes 
0760:             * of the binding are not supplied
0761:             * @exception NamingException if a naming exception is encountered
0762:             */
0763:            public void bind(Name name, Object obj, Attributes attrs)
0764:                    throws NamingException {
0765:                bind(name.toString(), obj, attrs);
0766:            }
0767:
0768:            /**
0769:             * Binds a name to an object, along with associated attributes.
0770:             * 
0771:             * @param name the name to bind; may not be empty
0772:             * @param obj the object to bind; possibly null
0773:             * @param attrs the attributes to associate with the binding
0774:             * @exception NameAlreadyBoundException if name is already bound
0775:             * @exception InvalidAttributesException if some "mandatory" attributes 
0776:             * of the binding are not supplied
0777:             * @exception NamingException if a naming exception is encountered
0778:             */
0779:            public abstract void bind(String name, Object obj, Attributes attrs)
0780:                    throws NamingException;
0781:
0782:            /**
0783:             * Binds a name to an object, along with associated attributes, 
0784:             * overwriting any existing binding. If attrs is null and obj is a 
0785:             * DirContext, the attributes from obj are used. If attrs is null and obj 
0786:             * is not a DirContext, any existing attributes associated with the object
0787:             * already bound in the directory remain unchanged. If attrs is non-null, 
0788:             * any existing attributes associated with the object already bound in 
0789:             * the directory are removed and attrs is associated with the named 
0790:             * object. If obj is a DirContext and attrs is non-null, the attributes 
0791:             * of obj are ignored.
0792:             * 
0793:             * @param name the name to bind; may not be empty
0794:             * @param obj the object to bind; possibly null
0795:             * @param attrs the attributes to associate with the binding
0796:             * @exception InvalidAttributesException if some "mandatory" attributes 
0797:             * of the binding are not supplied
0798:             * @exception NamingException if a naming exception is encountered
0799:             */
0800:            public void rebind(Name name, Object obj, Attributes attrs)
0801:                    throws NamingException {
0802:                rebind(name.toString(), obj, attrs);
0803:            }
0804:
0805:            /**
0806:             * Binds a name to an object, along with associated attributes, 
0807:             * overwriting any existing binding.
0808:             * 
0809:             * @param name the name to bind; may not be empty
0810:             * @param obj the object to bind; possibly null
0811:             * @param attrs the attributes to associate with the binding
0812:             * @exception InvalidAttributesException if some "mandatory" attributes 
0813:             * of the binding are not supplied
0814:             * @exception NamingException if a naming exception is encountered
0815:             */
0816:            public abstract void rebind(String name, Object obj,
0817:                    Attributes attrs) throws NamingException;
0818:
0819:            /**
0820:             * Creates and binds a new context, along with associated attributes. 
0821:             * This method creates a new subcontext with the given name, binds it in 
0822:             * the target context (that named by all but terminal atomic component of 
0823:             * the name), and associates the supplied attributes with the newly 
0824:             * created object. All intermediate and target contexts must already 
0825:             * exist. If attrs is null, this method is equivalent to 
0826:             * Context.createSubcontext().
0827:             * 
0828:             * @param name the name of the context to create; may not be empty
0829:             * @param attrs the attributes to associate with the newly created context
0830:             * @return the newly created context
0831:             * @exception NameAlreadyBoundException if the name is already bound
0832:             * @exception InvalidAttributesException if attrs does not contain all 
0833:             * the mandatory attributes required for creation
0834:             * @exception NamingException if a naming exception is encountered
0835:             */
0836:            public DirContext createSubcontext(Name name, Attributes attrs)
0837:                    throws NamingException {
0838:                return createSubcontext(name.toString(), attrs);
0839:            }
0840:
0841:            /**
0842:             * Creates and binds a new context, along with associated attributes.
0843:             * 
0844:             * @param name the name of the context to create; may not be empty
0845:             * @param attrs the attributes to associate with the newly created context
0846:             * @return the newly created context
0847:             * @exception NameAlreadyBoundException if the name is already bound
0848:             * @exception InvalidAttributesException if attrs does not contain all 
0849:             * the mandatory attributes required for creation
0850:             * @exception NamingException if a naming exception is encountered
0851:             */
0852:            public abstract DirContext createSubcontext(String name,
0853:                    Attributes attrs) throws NamingException;
0854:
0855:            /**
0856:             * Retrieves the schema associated with the named object. The schema 
0857:             * describes rules regarding the structure of the namespace and the 
0858:             * attributes stored within it. The schema specifies what types of 
0859:             * objects can be added to the directory and where they can be added; 
0860:             * what mandatory and optional attributes an object can have. The range 
0861:             * of support for schemas is directory-specific.
0862:             * 
0863:             * @param name the name of the object whose schema is to be retrieved
0864:             * @return the schema associated with the context; never null
0865:             * @exception OperationNotSupportedException if schema not supported
0866:             * @exception NamingException if a naming exception is encountered
0867:             */
0868:            public DirContext getSchema(Name name) throws NamingException {
0869:                return getSchema(name.toString());
0870:            }
0871:
0872:            /**
0873:             * Retrieves the schema associated with the named object.
0874:             * 
0875:             * @param name the name of the object whose schema is to be retrieved
0876:             * @return the schema associated with the context; never null
0877:             * @exception OperationNotSupportedException if schema not supported
0878:             * @exception NamingException if a naming exception is encountered
0879:             */
0880:            public abstract DirContext getSchema(String name)
0881:                    throws NamingException;
0882:
0883:            /**
0884:             * Retrieves a context containing the schema objects of the named 
0885:             * object's class definitions.
0886:             * 
0887:             * @param name the name of the object whose object class definition is to 
0888:             * be retrieved
0889:             * @return the DirContext containing the named object's class 
0890:             * definitions; never null
0891:             * @exception OperationNotSupportedException if schema not supported
0892:             * @exception NamingException if a naming exception is encountered
0893:             */
0894:            public DirContext getSchemaClassDefinition(Name name)
0895:                    throws NamingException {
0896:                return getSchemaClassDefinition(name.toString());
0897:            }
0898:
0899:            /**
0900:             * Retrieves a context containing the schema objects of the named 
0901:             * object's class definitions.
0902:             * 
0903:             * @param name the name of the object whose object class definition is to 
0904:             * be retrieved
0905:             * @return the DirContext containing the named object's class 
0906:             * definitions; never null
0907:             * @exception OperationNotSupportedException if schema not supported
0908:             * @exception NamingException if a naming exception is encountered
0909:             */
0910:            public abstract DirContext getSchemaClassDefinition(String name)
0911:                    throws NamingException;
0912:
0913:            /**
0914:             * Searches in a single context for objects that contain a specified set 
0915:             * of attributes, and retrieves selected attributes. The search is 
0916:             * performed using the default SearchControls settings.
0917:             * 
0918:             * @param name the name of the context to search
0919:             * @param matchingAttributes the attributes to search for. If empty or 
0920:             * null, all objects in the target context are returned.
0921:             * @param attributesToReturn the attributes to return. null indicates 
0922:             * that all attributes are to be returned; an empty array indicates that 
0923:             * none are to be returned.
0924:             * @return a non-null enumeration of SearchResult objects. Each 
0925:             * SearchResult contains the attributes identified by attributesToReturn 
0926:             * and the name of the corresponding object, named relative to the 
0927:             * context named by name.
0928:             * @exception NamingException if a naming exception is encountered
0929:             */
0930:            public NamingEnumeration search(Name name,
0931:                    Attributes matchingAttributes, String[] attributesToReturn)
0932:                    throws NamingException {
0933:                return search(name.toString(), matchingAttributes,
0934:                        attributesToReturn);
0935:            }
0936:
0937:            /**
0938:             * Searches in a single context for objects that contain a specified set 
0939:             * of attributes, and retrieves selected attributes.
0940:             * 
0941:             * @param name the name of the context to search
0942:             * @param matchingAttributes the attributes to search for. If empty or 
0943:             * null, all objects in the target context are returned.
0944:             * @param attributesToReturn the attributes to return. null indicates 
0945:             * that all attributes are to be returned; an empty array indicates that 
0946:             * none are to be returned.
0947:             * @return a non-null enumeration of SearchResult objects. Each 
0948:             * SearchResult contains the attributes identified by attributesToReturn 
0949:             * and the name of the corresponding object, named relative to the 
0950:             * context named by name.
0951:             * @exception NamingException if a naming exception is encountered
0952:             */
0953:            public abstract NamingEnumeration search(String name,
0954:                    Attributes matchingAttributes, String[] attributesToReturn)
0955:                    throws NamingException;
0956:
0957:            /**
0958:             * Searches in a single context for objects that contain a specified set 
0959:             * of attributes. This method returns all the attributes of such objects. 
0960:             * It is equivalent to supplying null as the atributesToReturn parameter 
0961:             * to the method search(Name, Attributes, String[]).
0962:             * 
0963:             * @param name the name of the context to search
0964:             * @param matchingAttributes the attributes to search for. If empty or 
0965:             * null, all objects in the target context are returned.
0966:             * @return a non-null enumeration of SearchResult objects. Each 
0967:             * SearchResult contains the attributes identified by attributesToReturn 
0968:             * and the name of the corresponding object, named relative to the 
0969:             * context named by name.
0970:             * @exception NamingException if a naming exception is encountered
0971:             */
0972:            public NamingEnumeration search(Name name,
0973:                    Attributes matchingAttributes) throws NamingException {
0974:                return search(name.toString(), matchingAttributes);
0975:            }
0976:
0977:            /**
0978:             * Searches in a single context for objects that contain a specified set 
0979:             * of attributes.
0980:             * 
0981:             * @param name the name of the context to search
0982:             * @param matchingAttributes the attributes to search for. If empty or 
0983:             * null, all objects in the target context are returned.
0984:             * @return a non-null enumeration of SearchResult objects. Each 
0985:             * SearchResult contains the attributes identified by attributesToReturn 
0986:             * and the name of the corresponding object, named relative to the 
0987:             * context named by name.
0988:             * @exception NamingException if a naming exception is encountered
0989:             */
0990:            public abstract NamingEnumeration search(String name,
0991:                    Attributes matchingAttributes) throws NamingException;
0992:
0993:            /**
0994:             * Searches in the named context or object for entries that satisfy the 
0995:             * given search filter. Performs the search as specified by the search 
0996:             * controls.
0997:             * 
0998:             * @param name the name of the context or object to search
0999:             * @param filter the filter expression to use for the search; may not be 
1000:             * null
1001:             * @param cons the search controls that control the search. If null, 
1002:             * the default search controls are used (equivalent to 
1003:             * (new SearchControls())).
1004:             * @return an enumeration of SearchResults of the objects that satisfy 
1005:             * the filter; never null
1006:             * @exception InvalidSearchFilterException if the search filter specified 
1007:             * is not supported or understood by the underlying directory
1008:             * @exception InvalidSearchControlsException if the search controls 
1009:             * contain invalid settings
1010:             * @exception NamingException if a naming exception is encountered
1011:             */
1012:            public NamingEnumeration search(Name name, String filter,
1013:                    SearchControls cons) throws NamingException {
1014:                return search(name.toString(), filter, cons);
1015:            }
1016:
1017:            /**
1018:             * Searches in the named context or object for entries that satisfy the 
1019:             * given search filter. Performs the search as specified by the search 
1020:             * controls.
1021:             * 
1022:             * @param name the name of the context or object to search
1023:             * @param filter the filter expression to use for the search; may not be 
1024:             * null
1025:             * @param cons the search controls that control the search. If null, 
1026:             * the default search controls are used (equivalent to 
1027:             * (new SearchControls())).
1028:             * @return an enumeration of SearchResults of the objects that satisfy 
1029:             * the filter; never null
1030:             * @exception InvalidSearchFilterException if the search filter 
1031:             * specified is not supported or understood by the underlying directory
1032:             * @exception InvalidSearchControlsException if the search controls 
1033:             * contain invalid settings
1034:             * @exception NamingException if a naming exception is encountered
1035:             */
1036:            public abstract NamingEnumeration search(String name,
1037:                    String filter, SearchControls cons) throws NamingException;
1038:
1039:            /**
1040:             * Searches in the named context or object for entries that satisfy the 
1041:             * given search filter. Performs the search as specified by the search 
1042:             * controls.
1043:             * 
1044:             * @param name the name of the context or object to search
1045:             * @param filterExpr the filter expression to use for the search. 
1046:             * The expression may contain variables of the form "{i}" where i is a 
1047:             * nonnegative integer. May not be null.
1048:             * @param filterArgs the array of arguments to substitute for the 
1049:             * variables in filterExpr. The value of filterArgs[i] will replace each 
1050:             * occurrence of "{i}". If null, equivalent to an empty array.
1051:             * @param cons the search controls that control the search. If null, the 
1052:             * default search controls are used (equivalent to (new SearchControls())).
1053:             * @return an enumeration of SearchResults of the objects that satisy the 
1054:             * filter; never null
1055:             * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i} 
1056:             * expressions where i is outside the bounds of the array filterArgs
1057:             * @exception InvalidSearchControlsException if cons contains invalid 
1058:             * settings
1059:             * @exception InvalidSearchFilterException if filterExpr with filterArgs 
1060:             * represents an invalid search filter
1061:             * @exception NamingException if a naming exception is encountered
1062:             */
1063:            public NamingEnumeration search(Name name, String filterExpr,
1064:                    Object[] filterArgs, SearchControls cons)
1065:                    throws NamingException {
1066:                return search(name.toString(), filterExpr, filterArgs, cons);
1067:            }
1068:
1069:            /**
1070:             * Searches in the named context or object for entries that satisfy the 
1071:             * given search filter. Performs the search as specified by the search 
1072:             * controls.
1073:             * 
1074:             * @param name the name of the context or object to search
1075:             * @param filterExpr the filter expression to use for the search. 
1076:             * The expression may contain variables of the form "{i}" where i is a 
1077:             * nonnegative integer. May not be null.
1078:             * @param filterArgs the array of arguments to substitute for the 
1079:             * variables in filterExpr. The value of filterArgs[i] will replace each 
1080:             * occurrence of "{i}". If null, equivalent to an empty array.
1081:             * @param cons the search controls that control the search. If null, the 
1082:             * default search controls are used (equivalent to (new SearchControls())).
1083:             * @return an enumeration of SearchResults of the objects that satisy the 
1084:             * filter; never null
1085:             * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i} 
1086:             * expressions where i is outside the bounds of the array filterArgs
1087:             * @exception InvalidSearchControlsException if cons contains invalid 
1088:             * settings
1089:             * @exception InvalidSearchFilterException if filterExpr with filterArgs 
1090:             * represents an invalid search filter
1091:             * @exception NamingException if a naming exception is encountered
1092:             */
1093:            public abstract NamingEnumeration search(String name,
1094:                    String filterExpr, Object[] filterArgs, SearchControls cons)
1095:                    throws NamingException;
1096:
1097:            // ------------------------------------------------------ Protected Methods
1098:
1099:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.