Author: remy.maucherat(a)jboss.com
Date: 2009-05-11 13:10:57 -0400 (Mon, 11 May 2009)
New Revision: 1047
Added:
trunk/java/org/apache/catalina/core/ServerJarRepository.java
trunk/java/org/apache/catalina/startup/OrderingResolver.java
trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java
Removed:
trunk/java/org/apache/catalina/ContextScanner.java
trunk/java/org/apache/catalina/startup/BaseContextScanner.java
trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
trunk/java/org/apache/catalina/startup/JavassistContextScanner.java
Modified:
trunk/java/org/apache/catalina/deploy/WebOrdering.java
trunk/java/org/apache/catalina/loader/WebappClassLoader.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/LocalStrings.properties
trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
trunk/java/org/apache/naming/resources/ProxyDirContext.java
Log:
- Ongoing work with the ordering.
- Also add a DirContext facade for possible use.
- Remove ContextScanner, and add a stub ServerJarRepository.
Deleted: trunk/java/org/apache/catalina/ContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/ContextScanner.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/ContextScanner.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-
-package org.apache.catalina;
-
-import org.apache.tomcat.WarComponents;
-
-public interface ContextScanner extends WarComponents {
-
- /**
- * Scan the given context's default locations for annotations, overlays
- * and web.xml fragments.
- *
- * @param context
- */
- public void scan(Context context);
-
-
-}
Added: trunk/java/org/apache/catalina/core/ServerJarRepository.java
===================================================================
--- trunk/java/org/apache/catalina/core/ServerJarRepository.java
(rev 0)
+++ trunk/java/org/apache/catalina/core/ServerJarRepository.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -0,0 +1,403 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.catalina.core;
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.jar.JarFile;
+
+import javax.naming.Binding;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.servlet.ServletContext;
+
+import org.apache.catalina.Contained;
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
+import org.apache.catalina.JarRepository;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.util.IOTools;
+import org.apache.catalina.util.LifecycleSupport;
+import org.apache.catalina.util.StringManager;
+import org.apache.naming.resources.Resource;
+import org.jboss.logging.Logger;
+
+
+/**
+ * Server specific implementation for a JAR repository, which will manage
+ * shared JARs which may contain descriptors.
+ *
+ * FIXME: Stub impl
+ * @author Remy Maucherat
+ */
+public class ServerJarRepository
+ implements JarRepository, Contained, Lifecycle {
+
+ private static Logger log = Logger.getLogger(ServerJarRepository.class);
+
+ /**
+ * Names of JARs that are known not to contain any descriptors or annotations.
+ */
+ protected static HashSet<String> skipJars;
+
+ /**
+ * Initializes the set of JARs that are known not to contain any descriptors.
+ */
+ static {
+ skipJars = new HashSet<String>();
+ // Bootstrap JARs
+ skipJars.add("bootstrap.jar");
+ skipJars.add("commons-daemon.jar");
+ skipJars.add("tomcat-juli.jar");
+ // Main JARs
+ skipJars.add("annotations-api.jar");
+ skipJars.add("catalina.jar");
+ skipJars.add("catalina-ant.jar");
+ skipJars.add("el-api.jar");
+ skipJars.add("jasper.jar");
+ skipJars.add("jasper-el.jar");
+ skipJars.add("jasper-jdt.jar");
+ skipJars.add("jsp-api.jar");
+ skipJars.add("servlet-api.jar");
+ skipJars.add("tomcat-coyote.jar");
+ skipJars.add("tomcat-dbcp.jar");
+ // i18n JARs
+ skipJars.add("tomcat-i18n-en.jar");
+ skipJars.add("tomcat-i18n-es.jar");
+ skipJars.add("tomcat-i18n-fr.jar");
+ skipJars.add("tomcat-i18n-ja.jar");
+ // Misc JARs not included with Tomcat
+ skipJars.add("ant.jar");
+ skipJars.add("commons-dbcp.jar");
+ skipJars.add("commons-beanutils.jar");
+ skipJars.add("commons-fileupload-1.0.jar");
+ skipJars.add("commons-pool.jar");
+ skipJars.add("commons-digester.jar");
+ skipJars.add("commons-logging.jar");
+ skipJars.add("commons-collections.jar");
+ skipJars.add("jmx.jar");
+ skipJars.add("jmx-tools.jar");
+ skipJars.add("xercesImpl.jar");
+ skipJars.add("xmlParserAPIs.jar");
+ skipJars.add("xml-apis.jar");
+ // JARs from J2SE runtime
+ skipJars.add("sunjce_provider.jar");
+ skipJars.add("ldapsec.jar");
+ skipJars.add("localedata.jar");
+ skipJars.add("dnsns.jar");
+ skipJars.add("tools.jar");
+ skipJars.add("sunpkcs11.jar");
+ }
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Construct a new ContextJarRepository instance with no associated Container.
+ */
+ public ServerJarRepository() {
+
+ this(null);
+
+ }
+
+
+ /**
+ * Construct a new ContextJarRepository instance that is associated with the
+ * specified Container.
+ *
+ * @param container The container we should be associated with
+ */
+ public ServerJarRepository(Container container) {
+
+ super();
+ setContainer(container);
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The Container with which this Pipeline is associated.
+ */
+ protected Container container = null;
+
+
+ /**
+ * Descriptive information about this implementation.
+ */
+ protected String info =
"org.apache.catalina.core.ServerJarRepository/1.0";
+
+
+ /**
+ * The lifecycle event support for this component.
+ */
+ protected LifecycleSupport lifecycle = new LifecycleSupport(this);
+
+
+ /**
+ * The string manager for this package.
+ */
+ protected static StringManager sm =
+ StringManager.getManager(Constants.Package);
+
+
+ /**
+ * Has this component been started yet?
+ */
+ protected boolean started = false;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return descriptive information about this implementation class.
+ */
+ public String getInfo() {
+
+ return (this.info);
+
+ }
+
+
+ // ------------------------------------------------------ Contained Methods
+
+
+ /**
+ * Return the Container with which this Pipeline is associated.
+ */
+ public Container getContainer() {
+
+ return (this.container);
+
+ }
+
+
+ /**
+ * Set the Container with which this Pipeline is associated.
+ *
+ * @param container The new associated container
+ */
+ public void setContainer(Container container) {
+
+ this.container = container;
+
+ }
+
+
+ // ------------------------------------------------------ Lifecycle Methods
+
+
+ /**
+ * Add a lifecycle event listener to this component.
+ *
+ * @param listener The listener to add
+ */
+ public void addLifecycleListener(LifecycleListener listener) {
+
+ lifecycle.addLifecycleListener(listener);
+
+ }
+
+
+ /**
+ * Get the lifecycle listeners associated with this lifecycle. If this
+ * Lifecycle has no listeners registered, a zero-length array is returned.
+ */
+ public LifecycleListener[] findLifecycleListeners() {
+
+ return lifecycle.findLifecycleListeners();
+
+ }
+
+
+ /**
+ * Remove a lifecycle event listener from this component.
+ *
+ * @param listener The listener to remove
+ */
+ public void removeLifecycleListener(LifecycleListener listener) {
+
+ lifecycle.removeLifecycleListener(listener);
+
+ }
+
+ /**
+ * Prepare for active use of the public methods of this Component.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents it from being started
+ */
+ public synchronized void start() throws LifecycleException {
+
+ // Validate and update our current component state
+ if (started) {
+ if(log.isDebugEnabled())
+
log.debug(sm.getString("contextJarRepository.alreadyStarted"));
+ return;
+ }
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
+
+ started = true;
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(START_EVENT, null);
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
+
+ }
+
+
+ /**
+ * Gracefully shut down active use of the public methods of this Component.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that needs to be reported
+ */
+ public synchronized void stop() throws LifecycleException {
+
+ // Validate and update our current component state
+ if (!started) {
+ if(log.isDebugEnabled())
+ log.debug(sm.getString("contextJarRepository.notStarted"));
+ return;
+ }
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(STOP_EVENT, null);
+ started = false;
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
+ }
+
+
+ // -------------------------------------------------- JarRepository Methods
+
+
+ /**
+ * Execute a periodic task, such as reloading, etc. This method will be
+ * invoked inside the classloading context of this container. Unexpected
+ * throwables will be caught and logged.
+ */
+ public void backgroundProcess() {
+
+ }
+
+
+ /**
+ * Get the JarFile map.
+ *
+ * @return the JarFile map, associating logical name with JarFile
+ */
+ public Map<String, JarFile> getJars() {
+ return null;
+ }
+
+
+ /**
+ * Find the JarFile corresponding to the path.
+ *
+ * @return the JarFile, or null if not found
+ */
+ public JarFile findJar(String path) {
+ return null;
+ }
+
+
+ /**
+ * Find all JarFile managed by the JARRepository.
+ *
+ * @return All JarFile
+ */
+ public JarFile[] findJars() {
+ return null;
+ }
+
+
+ /**
+ * Get the exploded Jar map.
+ *
+ * @return the Jar map, associating logical name with File
+ */
+ public Map<String, File> getExplodedJars() {
+ return null;
+ }
+
+
+ /**
+ * Find all exploded Jars managed by the JARRepository.
+ *
+ * @return All exploded File
+ */
+ public File[] findExplodedJars() {
+ return null;
+ }
+
+
+}
Modified: trunk/java/org/apache/catalina/deploy/WebOrdering.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/WebOrdering.java 2009-05-11 09:35:06 UTC (rev
1046)
+++ trunk/java/org/apache/catalina/deploy/WebOrdering.java 2009-05-11 17:10:57 UTC (rev
1047)
@@ -28,14 +28,19 @@
public class WebOrdering implements Serializable {
+ private static final long serialVersionUID = 5603203103871892211L;
+
protected String jar = null;
protected String name = null;
protected List<String> after = new ArrayList<String>();
protected List<String> before = new ArrayList<String>();
-
+ protected boolean afterOthers = false;
+ protected boolean beforeOthers = false;
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
@@ -55,11 +60,29 @@
public void addBefore(String name) {
before.add(name);
}
+
public String getJar() {
return jar;
}
+
public void setJar(String jar) {
this.jar = jar;
}
+
+ public boolean isAfterOthers() {
+ return afterOthers;
+ }
+
+ public void setAfterOthers(boolean afterOthers) {
+ this.afterOthers = afterOthers;
+ }
+
+ public boolean isBeforeOthers() {
+ return beforeOthers;
+ }
+
+ public void setBeforeOthers(boolean beforeOthers) {
+ this.beforeOthers = beforeOthers;
+ }
}
Modified: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-11 09:35:06 UTC
(rev 1046)
+++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -741,7 +741,7 @@
if (getJarPath() != null) {
try {
- NamingEnumeration enumeration = resources.listBindings(getJarPath());
+ NamingEnumeration enumeration = resources.list(getJarPath());
int i = 0;
while (enumeration.hasMoreElements() && (i < length)) {
NameClassPair ncPair = (NameClassPair) enumeration.nextElement();
Deleted: trunk/java/org/apache/catalina/startup/BaseContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-11 09:35:06 UTC
(rev 1046)
+++ trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -1,400 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-
-package org.apache.catalina.startup;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.servlet.annotation.HandlesTypes;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.ContextScanner;
-import org.apache.catalina.Globals;
-import org.apache.catalina.JarRepository;
-
-public abstract class BaseContextScanner
- implements ContextScanner {
-
-
- /**
- * Names of JARs that are known not to contain any descriptors or annotations.
- */
- protected static HashSet<String> skipJars;
-
- /**
- * Initializes the set of JARs that are known not to contain any descriptors.
- */
- static {
- skipJars = new HashSet<String>();
- // Bootstrap JARs
- skipJars.add("bootstrap.jar");
- skipJars.add("commons-daemon.jar");
- skipJars.add("tomcat-juli.jar");
- // Main JARs
- skipJars.add("annotations-api.jar");
- skipJars.add("catalina.jar");
- skipJars.add("catalina-ant.jar");
- skipJars.add("el-api.jar");
- skipJars.add("jasper.jar");
- skipJars.add("jasper-el.jar");
- skipJars.add("jasper-jdt.jar");
- skipJars.add("jsp-api.jar");
- skipJars.add("servlet-api.jar");
- skipJars.add("tomcat-coyote.jar");
- skipJars.add("tomcat-dbcp.jar");
- // i18n JARs
- skipJars.add("tomcat-i18n-en.jar");
- skipJars.add("tomcat-i18n-es.jar");
- skipJars.add("tomcat-i18n-fr.jar");
- skipJars.add("tomcat-i18n-ja.jar");
- // Misc JARs not included with Tomcat
- skipJars.add("ant.jar");
- skipJars.add("commons-dbcp.jar");
- skipJars.add("commons-beanutils.jar");
- skipJars.add("commons-fileupload-1.0.jar");
- skipJars.add("commons-pool.jar");
- skipJars.add("commons-digester.jar");
- skipJars.add("commons-logging.jar");
- skipJars.add("commons-collections.jar");
- skipJars.add("jmx.jar");
- skipJars.add("jmx-tools.jar");
- skipJars.add("xercesImpl.jar");
- skipJars.add("xmlParserAPIs.jar");
- skipJars.add("xml-apis.jar");
- // JARs from J2SE runtime
- skipJars.add("sunjce_provider.jar");
- skipJars.add("ldapsec.jar");
- skipJars.add("localedata.jar");
- skipJars.add("dnsns.jar");
- skipJars.add("tools.jar");
- skipJars.add("sunpkcs11.jar");
- }
-
-
- protected ArrayList<Class<?>> annotatedClasses = new
ArrayList<Class<?>>();
- protected ArrayList<String> overlays = new ArrayList<String>();
- protected ArrayList<String> webFragments = new ArrayList<String>();
- protected Map<String, Set<String>> TLDs = new HashMap<String,
Set<String>>();
- protected Map<String, ServletContainerInitializerInfo>
servletContainerInitializerInfos =
- new HashMap<String, ServletContainerInitializerInfo>();
-
- /**
- * Used to speed up scanning for the services interest classes.
- */
- protected Class<?>[] handlesTypesArray = null;
- protected Map<Class<?>, ServletContainerInitializerInfoImpl> handlesTypes
=
- new HashMap<Class<?>, ServletContainerInitializerInfoImpl>();
-
-
- public Iterator<Class<?>> getAnnotatedClasses() {
- return annotatedClasses.iterator();
- }
-
-
- public Iterator<String> getOverlays() {
- return overlays.iterator();
- }
-
-
- public Iterator<String> getWebFragments() {
- return webFragments.iterator();
- }
-
-
- public Map<String, Set<String>> getTLDs() {
- return TLDs;
- }
-
-
- public Map<String, ServletContainerInitializerInfo>
getServletContainerInitializerInfo() {
- return servletContainerInitializerInfos;
- }
-
-
- /**
- * Scan the given context's default locations for annotations.
- *
- * @param context
- */
- public void scan(Context context) {
- JarRepository jarRepository = context.getJarRepository();
- if (jarRepository != null) {
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- scanJar(context, jars[i]);
- }
- File[] explodedJars = jarRepository.findExplodedJars();
- for (int i = 0; i < explodedJars.length; i++) {
- scanClasses(context, explodedJars[i], "");
- }
- }
- // Do the same for the context parent
- jarRepository = context.getParent().getJarRepository();
- if (jarRepository != null) {
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- // FIXME: maybe add an option to do the full scan
- scanSharedJar(context, jars[i]);
- }
- File[] explodedJars = jarRepository.findExplodedJars();
- for (int i = 0; i < explodedJars.length; i++) {
- // FIXME: maybe add an option to do the full scan
- // scanClasses(context, explodedJars[i], "");
- }
- }
-
- HashSet<String> warTLDs = new HashSet<String>();
-
- // Find any TLD file in /WEB-INF
- DirContext resources = context.getResources();
- if (resources != null) {
- tldScanResourcePathsWebInf(resources, "/WEB-INF", warTLDs);
- }
- TLDs.put("", warTLDs);
-
- }
-
-
- /**
- * Scans the web application's subdirectory identified by rootPath,
- * along with its subdirectories, for TLDs.
- *
- * Initially, rootPath equals /WEB-INF. The /WEB-INF/classes and
- * /WEB-INF/lib subdirectories are excluded from the search, as per the
- * JSP 2.0 spec.
- *
- * @param resources The web application's resources
- * @param rootPath The path whose subdirectories are to be searched for
- * TLDs
- * @param tldPaths The set of TLD resource paths to add to
- */
- protected void tldScanResourcePathsWebInf(DirContext resources,
- String rootPath,
- HashSet<String> tldPaths) {
- try {
- NamingEnumeration<NameClassPair> items = resources.list(rootPath);
- while (items.hasMoreElements()) {
- NameClassPair item = items.nextElement();
- String resourcePath = rootPath + "/" + item.getName();
- if (!resourcePath.endsWith(".tld")
- &&
(resourcePath.startsWith("/WEB-INF/classes")
- || resourcePath.startsWith("/WEB-INF/lib"))) {
- continue;
- }
- if (resourcePath.endsWith(".tld")) {
- tldPaths.add(resourcePath);
- } else {
- tldScanResourcePathsWebInf(resources, resourcePath,
- tldPaths);
- }
- }
- } catch (NamingException e) {
- ; // Silent catch: it's valid that no /WEB-INF directory exists
- }
- }
-
-
- /**
- * Scan folder containing class files.
- */
- public void scanClasses(Context context, File folder, String path) {
- String[] files = folder.list();
- for (int i = 0; i < files.length; i++) {
- File file = new File(folder, files[i]);
- if (file.isDirectory()) {
- scanClasses(context, file, path + "/" + files[i]);
- } else if (files[i].endsWith(".class")) {
- String className = getClassName(path + "/" + files[i]);
- Class<?> annotated = scanClass(context, className, file, null);
- if (annotated != null) {
- annotatedClasses.add(annotated);
- }
- }
- }
- }
-
-
- /**
- * Scan all class files in the given shared JAR (shared JARs are not scanned for
annotations, overlays,
- * etc, as this would be a serious security risk).
- */
- public void scanSharedJar(Context context, JarFile file) {
- // Find ServletContainerInitializer services
- JarEntry servletContainerInitializerEntry =
file.getJarEntry(Globals.SERVLET_CONTAINER_INITIALIZER_SERVICE_PATH);
- String servletContainerInitializerClassName = null;
- if (servletContainerInitializerEntry != null) {
- // Read Servlet container initializer service file
- InputStream is = null;
- try {
- is = file.getInputStream(servletContainerInitializerEntry);
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- servletContainerInitializerClassName = reader.readLine();
- int pos = servletContainerInitializerClassName.indexOf('#');
- if (pos > 0) {
- servletContainerInitializerClassName =
servletContainerInitializerClassName.substring(0, pos);
- }
- servletContainerInitializerClassName =
servletContainerInitializerClassName.trim();
- } catch (Exception e) {
- // FIXME: error message or exception
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- // Ignore
- }
- }
- // Load Servlet container initializer class and read HandlesTypes annotation
- Class<?> servletContainerInitializerClass = null;
- Class<?>[] typesArray = null;
- if (servletContainerInitializerClassName != null) {
- try {
- servletContainerInitializerClass =
context.getLoader().getClassLoader()
- .loadClass(servletContainerInitializerClassName);
- if
(servletContainerInitializerClass.isAnnotationPresent(HandlesTypes.class)) {
- HandlesTypes handlesTypes =
servletContainerInitializerClass.getAnnotation(HandlesTypes.class);
- typesArray = handlesTypes.value();
- }
- } catch (Throwable t) {
- // FIXME: error message or exception
- }
- }
- // Add in jarService map, and add in the local map used to speed up lookups
- ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
- new ServletContainerInitializerInfoImpl(servletContainerInitializerClass,
handlesTypesArray);
- servletContainerInitializerInfos.put(file.getName(),
jarServletContainerInitializerService);
- if (typesArray != null) {
- ArrayList<Class<?>> handlesTypesList = new
ArrayList<Class<?>>();
- if (handlesTypesArray != null) {
- for (int i = 0; i < handlesTypesArray.length; i++) {
- handlesTypesList.add(handlesTypesArray[i]);
- }
- }
- for (int i = 0; i < typesArray.length; i++) {
- handlesTypesList.add(typesArray[i]);
- handlesTypes.put(typesArray[i],
jarServletContainerInitializerService);
- }
- handlesTypesArray = handlesTypesList.toArray(handlesTypesArray);
- }
- }
- }
-
-
- /**
- * Scan all class files in the given JAR.
- */
- public void scanJar(Context context, JarFile file) {
- // Find webapp descriptor fragments
- if (file.getEntry(Globals.WEB_FRAGMENT_PATH) != null) {
- webFragments.add(file.getName());
- }
- // Find webapp overlays
- if (file.getEntry(Globals.OVERLAY_PATH) != null) {
- overlays.add(file.getName());
- }
- // Find ServletContainerInitializer services
- scanSharedJar(context, file);
- // Find tag library descriptors
- HashSet<String> jarTLDs = new HashSet<String>();
- Enumeration<JarEntry> entries = file.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- String name = entry.getName();
- if (!context.getIgnoreAnnotations() &&
name.endsWith(".class")) {
- Class<?> annotated = scanClass(context,
getClassName(entry.getName()), null, entry);
- if (annotated != null) {
- annotatedClasses.add(annotated);
- }
- } else if (name.startsWith("META-INF/") &&
name.endsWith(".tld")) {
- jarTLDs.add(name);
- }
- }
- if (jarTLDs.size() > 0) {
- TLDs.put(file.getName(), jarTLDs);
- }
- }
-
-
- /**
- * Get class name given a path to a classfile.
- * /my/class/MyClass.class -> my.class.MyClass
- */
- public String getClassName(String filePath) {
- if (filePath.startsWith("/")) {
- filePath = filePath.substring(1);
- }
- if (filePath.endsWith(".class")) {
- filePath = filePath.substring(0, filePath.length() -
".class".length());
- }
- return filePath.replace('/', '.');
- }
-
-
- /**
- * Scan class for interesting annotations.
- */
- public abstract Class<?> scanClass(Context context, String className, File
file, JarEntry entry);
-
-
- protected class ServletContainerInitializerInfoImpl implements
ServletContainerInitializerInfo {
- protected Class<?> servletContainerInitializer = null;
- protected Class<?>[] interestClasses = null;
- protected HashSet<Class<?>> startupNotifySet = new
HashSet<Class<?>>();
- protected ServletContainerInitializerInfoImpl(Class<?>
servletContainerInitializer, Class<?>[] interestClasses) {
- this.servletContainerInitializer = servletContainerInitializer;
- this.interestClasses = interestClasses;
- }
- public Class<?> getServletContainerInitializer() {
- return servletContainerInitializer;
- }
- public Class<?>[] getInterestClasses() {
- return interestClasses;
- }
- protected void addStartupNotifyClass(Class<?> clazz) {
- startupNotifySet.add(clazz);
- }
- public Set<Class<?>> getStartupNotifySet() {
- return startupNotifySet;
- }
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-11
09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-11
17:10:57 UTC (rev 1047)
@@ -1,65 +0,0 @@
-/*
- * 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.catalina.startup;
-
-import java.io.File;
-import java.util.jar.JarEntry;
-
-import javax.servlet.annotation.MultipartConfig;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.annotation.WebInitParam;
-import javax.servlet.annotation.WebListener;
-import javax.servlet.annotation.WebServlet;
-
-import org.apache.catalina.Context;
-
-public class ClassLoadingContextScanner
- extends BaseContextScanner {
-
- /**
- * Scan class for interesting annotations.
- */
- public Class<?> scanClass(Context context, String className, File file,
JarEntry entry) {
- // Load the class using the classloader, and see if it implements one of the web
annotations
- try {
- Class<?> clazz =
context.getLoader().getClassLoader().loadClass(className);
- if (handlesTypesArray != null) {
- for (int i = 0; i < handlesTypesArray.length; i++) {
- if (handlesTypesArray[i].isAssignableFrom(clazz)) {
- ServletContainerInitializerInfoImpl
jarServletContainerInitializerService =
- handlesTypes.get(handlesTypesArray[i]);
-
jarServletContainerInitializerService.addStartupNotifyClass(clazz);
- }
- }
- }
- if (clazz.isAnnotationPresent(MultipartConfig.class)
- || clazz.isAnnotationPresent(WebFilter.class)
- || clazz.isAnnotationPresent(WebInitParam.class)
- || clazz.isAnnotationPresent(WebListener.class)
- || clazz.isAnnotationPresent(WebServlet.class)) {
- return clazz;
- }
- } catch (Throwable t) {
- // Ignore classloading errors here
- }
- return null;
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 09:35:06 UTC (rev
1046)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 17:10:57 UTC (rev
1047)
@@ -108,10 +108,8 @@
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.WebOrdering;
-import
org.apache.catalina.startup.BaseContextScanner.ServletContainerInitializerInfoImpl;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.WarComponents;
-import org.apache.tomcat.WarComponents.ServletContainerInitializerInfo;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
import org.xml.sax.ErrorHandler;
@@ -1084,8 +1082,8 @@
order.addAll(otherPos, jarsSet);
}
} else if (orderings.size() > 0) {
- // FIXME: Use the ordering specified by the fragments
-
+ // Resolve relative ordering
+ OrderingResolver.resolveOrder(orderings, order);
} else {
// No order specified
order.addAll(jarsSet);
@@ -1095,6 +1093,21 @@
/**
+ * Get the jar name corresponding to the ordering name.
+ */
+ protected String getJarName(List<WebOrdering> orderings, String name) {
+ Iterator<WebOrdering> orderingsIterator = orderings.iterator();
+ while (orderingsIterator.hasNext()) {
+ WebOrdering ordering = orderingsIterator.next();
+ if (name.equals(ordering.getName())) {
+ return ordering.getJar();
+ }
+ }
+ return null;
+ }
+
+
+ /**
* Process additional descriptors: TLDs, web fragments, and map overlays.
*/
protected void applicationExtraDescriptorsConfig() {
@@ -1746,15 +1759,13 @@
}
// Scan all Servlet API related annotations
if (ok && !context.getIgnoreAnnotations()) {
- // FIXME: It is likely this should be moved to after running all listeners,
- // as they can add servlets or filters
+ // FIXME: Moved to after running all listeners, as they can add servlets or
filters
WebAnnotationSet.loadApplicationAnnotations(context);
}
if (ok) {
validateSecurityRoles();
}
- // FIXME: See about order
// Find webapp overlays
if (ok) {
JarRepository jarRepository = context.getJarRepository();
@@ -1777,7 +1788,6 @@
(ServletContainerInitializer)
service.getServletContainerInitializer().newInstance();
servletContainerInitializer.onStartup(service.getStartupNotifySet(),
context.getServletContext());
} catch (Throwable t) {
- // FIXME: error message
log.error(sm.getString("contextConfig.servletContainerInitializer",
service.getServletContainerInitializer()), t);
ok = false;
Deleted: trunk/java/org/apache/catalina/startup/JavassistContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/JavassistContextScanner.java 2009-05-11
09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/JavassistContextScanner.java 2009-05-11
17:10:57 UTC (rev 1047)
@@ -1,38 +0,0 @@
-/*
- * 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.catalina.startup;
-
-import java.io.File;
-import java.util.jar.JarEntry;
-
-import org.apache.catalina.Context;
-
-public class JavassistContextScanner
- extends BaseContextScanner {
-
- /**
- * Scan class for interesting annotations.
- */
- public Class<?> scanClass(Context context, String className, File file,
JarEntry entry) {
- // FIXME: Javassist impl
- return null;
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-11 09:35:06 UTC
(rev 1046)
+++ trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -28,6 +28,7 @@
contextConfig.role.link=WARNING: Security role name {0} used in a <role-link>
without being defined in a <security-role>
contextConfig.role.runas=WARNING: Security role name {0} used in a <run-as> without
being defined in a <security-role>
contextConfig.scan=Error scanning context resources
+contextConfig.servletContainerInitializer=Error running Servlet container initializer
{0}
contextConfig.start=ContextConfig: Processing START
contextConfig.stop=ContextConfig: Processing STOP
contextConfig.tldEntryException=Exception processing TLD {0} in JAR at resource path {1}
in context {2}
Added: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java
(rev 0)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+
+package org.apache.catalina.startup;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.catalina.deploy.WebOrdering;
+
+/**
+ * Resolves the relative ordering of web fragments. This is in a separate class
+ * because of the relative complexity.
+ *
+ * @author Remy Maucherat
+ */
+public class OrderingResolver {
+
+ protected class Ordering {
+ protected WebOrdering ordering;
+ protected List<WebOrdering> after = new ArrayList<WebOrdering>();
+ protected List<WebOrdering> before = new ArrayList<WebOrdering>();
+ protected boolean afterOthers = false;
+ protected boolean beforeOthers = false;
+ }
+
+ /**
+ * Generate the Jar processing order.
+ *
+ * @param webOrderings The list of orderings, as parsed from the fragments
+ * @param order The generated order list
+ */
+ public static void resolveOrder(List<WebOrdering> webOrderings,
List<String> order) {
+
+ }
+
+}
Modified: trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2009-05-11 09:35:06 UTC
(rev 1046)
+++ trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -99,24 +99,24 @@
digester.addCallMethod(prefix + "web-app/ordering/before/name",
"addBefore", 0);
digester.addRule(prefix + "web-app/ordering/after/others",
- new AddOthersAfterRule());
+ new SetAfterOthersRule());
digester.addRule(prefix + "web-app/ordering/before/others",
- new AddOthersBeforeRule());
+ new SetBeforeOthersRule());
}
- final class AddOthersAfterRule extends Rule {
+ final class SetAfterOthersRule extends Rule {
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.addAfter("*");
+ ordering.setAfterOthers(true);
}
}
- final class AddOthersBeforeRule extends Rule {
+ final class SetBeforeOthersRule extends Rule {
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.addBefore("*");
+ ordering.setBeforeOthers(true);
}
}
}
Modified: trunk/java/org/apache/naming/resources/ProxyDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-11 09:35:06 UTC
(rev 1046)
+++ trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-11 17:10:57 UTC
(rev 1047)
@@ -1559,6 +1559,7 @@
if (object instanceof InputStream) {
entry.resource = new Resource((InputStream) object);
} else if (object instanceof DirContext) {
+ //entry.context = new ProxyDirContextFacade(this, name);
entry.context = (DirContext) object;
} else if (object instanceof Resource) {
entry.resource = (Resource) object;
Added: trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java
(rev 0)
+++ trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java 2009-05-11 17:10:57
UTC (rev 1047)
@@ -0,0 +1,1165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.naming.resources;
+
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.AttributeModificationException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributesException;
+import javax.naming.directory.InvalidSearchControlsException;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+/**
+ * Proxy Directory Context facade implementation. Used to cache nested contexts
+ * access.
+ *
+ * @author Remy Maucherat
+ * @version $Revision: 793 $ $Date: 2008-09-27 19:44:11 +0200 (Sat, 27 Sep 2008) $
+ */
+
+public class ProxyDirContextFacade implements DirContext {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Builds a proxy directory context using the given environment.
+ */
+ public ProxyDirContextFacade(ProxyDirContext dirContext, String path) {
+ this.dirContext = dirContext;
+ this.path = path;
+ try {
+ pathName = new CompositeName(path);
+ } catch (InvalidNameException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * Associated DirContext.
+ */
+ protected ProxyDirContext dirContext;
+
+
+ /**
+ * Path.
+ */
+ protected String path;
+
+
+ /**
+ * Path as name.
+ */
+ protected Name pathName;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return the actual directory context we are wrapping.
+ */
+ public ProxyDirContext getDirContext() {
+ return this.dirContext;
+ }
+
+
+ // -------------------------------------------------------- Context Methods
+
+
+ /**
+ * Retrieves the named object. If name is empty, returns a new instance
+ * of this context (which represents the same naming context as this
+ * context, but its environment may be modified independently and it may
+ * be accessed concurrently).
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookup(Name name)
+ throws NamingException {
+ return dirContext.lookup(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the named object.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookup(String name)
+ throws NamingException {
+ return dirContext.lookup(composeName(name, path));
+ }
+
+
+ /**
+ * Binds a name to an object. All intermediate contexts and the target
+ * context (that named by all but terminal atomic component of the name)
+ * must already exist.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(Name name, Object obj)
+ throws NamingException {
+ dirContext.bind(composeName(name, pathName), obj);
+ }
+
+
+ /**
+ * Binds a name to an object.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(String name, Object obj)
+ throws NamingException {
+ dirContext.bind(composeName(name, path), obj);
+ }
+
+
+ /**
+ * Binds a name to an object, overwriting any existing binding. All
+ * intermediate contexts and the target context (that named by all but
+ * terminal atomic component of the name) must already exist.
+ * <p>
+ * If the object is a DirContext, any existing attributes associated with
+ * the name are replaced with those of the object. Otherwise, any
+ * existing attributes associated with the name remain unchanged.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(Name name, Object obj)
+ throws NamingException {
+ dirContext.rebind(composeName(name, pathName), obj);
+ }
+
+
+ /**
+ * Binds a name to an object, overwriting any existing binding.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(String name, Object obj)
+ throws NamingException {
+ dirContext.rebind(composeName(name, path), obj);
+ }
+
+
+ /**
+ * Unbinds the named object. Removes the terminal atomic name in name
+ * from the target context--that named by all but the terminal atomic
+ * part of name.
+ * <p>
+ * This method is idempotent. It succeeds even if the terminal atomic
+ * name is not bound in the target context, but throws
+ * NameNotFoundException if any of the intermediate contexts do not exist.
+ *
+ * @param name the name to bind; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void unbind(Name name)
+ throws NamingException {
+ dirContext.unbind(composeName(name, pathName));
+ }
+
+
+ /**
+ * Unbinds the named object.
+ *
+ * @param name the name to bind; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void unbind(String name)
+ throws NamingException {
+ dirContext.unbind(composeName(name, path));
+ }
+
+
+ /**
+ * Binds a new name to the object bound to an old name, and unbinds the
+ * old name. Both names are relative to this context. Any attributes
+ * associated with the old name become associated with the new name.
+ * Intermediate contexts of the old name are not changed.
+ *
+ * @param oldName the name of the existing binding; may not be empty
+ * @param newName the name of the new binding; may not be empty
+ * @exception NameAlreadyBoundException if newName is already bound
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rename(Name oldName, Name newName)
+ throws NamingException {
+ dirContext.rename(composeName(oldName, pathName), composeName(newName,
pathName));
+ }
+
+
+ /**
+ * Binds a new name to the object bound to an old name, and unbinds the
+ * old name.
+ *
+ * @param oldName the name of the existing binding; may not be empty
+ * @param newName the name of the new binding; may not be empty
+ * @exception NameAlreadyBoundException if newName is already bound
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rename(String oldName, String newName)
+ throws NamingException {
+ dirContext.rename(composeName(oldName, path), composeName(newName, path));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the class
+ * names of objects bound to them. The contents of any subcontexts are
+ * not included.
+ * <p>
+ * If a binding is added to or removed from this context, its effect on
+ * an enumeration previously returned is undefined.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the names and class names of the bindings in
+ * this context. Each element of the enumeration is of type NameClassPair.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
+ return dirContext.list(composeName(name, pathName));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the class
+ * names of objects bound to them.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the names and class names of the bindings in
+ * this context. Each element of the enumeration is of type NameClassPair.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
+ return dirContext.list(composeName(name, path));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the
+ * objects bound to them. The contents of any subcontexts are not
+ * included.
+ * <p>
+ * If a binding is added to or removed from this context, its effect on
+ * an enumeration previously returned is undefined.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the bindings in this context.
+ * Each element of the enumeration is of type Binding.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
+ return dirContext.listBindings(composeName(name, pathName));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the
+ * objects bound to them.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the bindings in this context.
+ * Each element of the enumeration is of type Binding.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
+ return dirContext.listBindings(composeName(name, path));
+ }
+
+
+ /**
+ * Destroys the named context and removes it from the namespace. Any
+ * attributes associated with the name are also removed. Intermediate
+ * contexts are not destroyed.
+ * <p>
+ * This method is idempotent. It succeeds even if the terminal atomic
+ * name is not bound in the target context, but throws
+ * NameNotFoundException if any of the intermediate contexts do not exist.
+ *
+ * In a federated naming system, a context from one naming system may be
+ * bound to a name in another. One can subsequently look up and perform
+ * operations on the foreign context using a composite name. However, an
+ * attempt destroy the context using this composite name will fail with
+ * NotContextException, because the foreign context is not a "subcontext"
+ * of the context in which it is bound. Instead, use unbind() to remove
+ * the binding of the foreign context. Destroying the foreign context
+ * requires that the destroySubcontext() be performed on a context from
+ * the foreign context's "native" naming system.
+ *
+ * @param name the name of the context to be destroyed; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NotContextException if the name is bound but does not name
+ * a context, or does not name a context of the appropriate type
+ */
+ public void destroySubcontext(Name name)
+ throws NamingException {
+ dirContext.destroySubcontext(composeName(name, pathName));
+ }
+
+
+ /**
+ * Destroys the named context and removes it from the namespace.
+ *
+ * @param name the name of the context to be destroyed; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NotContextException if the name is bound but does not name
+ * a context, or does not name a context of the appropriate type
+ */
+ public void destroySubcontext(String name)
+ throws NamingException {
+ dirContext.destroySubcontext(composeName(name, path));
+ }
+
+
+ /**
+ * Creates and binds a new context. Creates a new context with the given
+ * name and binds it in the target context (that named by all but
+ * terminal atomic component of the name). All intermediate contexts and
+ * the target context must already exist.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if creation of the subcontext
+ * requires specification of mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Context createSubcontext(Name name)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, pathName));
+ }
+
+
+ /**
+ * Creates and binds a new context.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if creation of the subcontext
+ * requires specification of mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Context createSubcontext(String name)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves the named object, following links except for the terminal
+ * atomic component of the name. If the object bound to name is not a
+ * link, returns the object itself.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name, not following the terminal link
+ * (if any).
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookupLink(Name name)
+ throws NamingException {
+ return dirContext.lookupLink(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the named object, following links except for the terminal
+ * atomic component of the name.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name, not following the terminal link
+ * (if any).
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookupLink(String name)
+ throws NamingException {
+ return dirContext.lookupLink(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves the parser associated with the named context. In a
+ * federation of namespaces, different naming systems will parse names
+ * differently. This method allows an application to get a parser for
+ * parsing names into their atomic components using the naming convention
+ * of a particular naming system. Within any single naming system,
+ * NameParser objects returned by this method must be equal (using the
+ * equals() test).
+ *
+ * @param name the name of the context from which to get the parser
+ * @return a name parser that can parse compound names into their atomic
+ * components
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NameParser getNameParser(Name name)
+ throws NamingException {
+ return dirContext.getNameParser(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the parser associated with the named context.
+ *
+ * @param name the name of the context from which to get the parser
+ * @return a name parser that can parse compound names into their atomic
+ * components
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NameParser getNameParser(String name)
+ throws NamingException {
+ return dirContext.getNameParser(composeName(name, path));
+ }
+
+
+ /**
+ * Composes the name of this context with a name relative to this context.
+ * <p>
+ * Given a name (name) relative to this context, and the name (prefix)
+ * of this context relative to one of its ancestors, this method returns
+ * the composition of the two names using the syntax appropriate for the
+ * naming system(s) involved. That is, if name names an object relative
+ * to this context, the result is the name of the same object, but
+ * relative to the ancestor context. None of the names may be null.
+ *
+ * @param name a name relative to this context
+ * @param prefix the name of this context relative to one of its ancestors
+ * @return the composition of prefix and name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Name composeName(Name name, Name prefix)
+ throws NamingException {
+ prefix = (Name) prefix.clone();
+ return prefix.addAll(name);
+ }
+
+
+ /**
+ * Composes the name of this context with a name relative to this context.
+ *
+ * @param name a name relative to this context
+ * @param prefix the name of this context relative to one of its ancestors
+ * @return the composition of prefix and name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public String composeName(String name, String prefix)
+ throws NamingException {
+ return prefix + "/" + name;
+ }
+
+
+ /**
+ * Adds a new environment property to the environment of this context. If
+ * the property already exists, its value is overwritten.
+ *
+ * @param propName the name of the environment property to add; may not
+ * be null
+ * @param propVal the value of the property to add; may not be null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object addToEnvironment(String propName, Object propVal)
+ throws NamingException {
+ return dirContext.addToEnvironment(propName, propVal);
+ }
+
+
+ /**
+ * Removes an environment property from the environment of this context.
+ *
+ * @param propName the name of the environment property to remove;
+ * may not be null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object removeFromEnvironment(String propName)
+ throws NamingException {
+ return dirContext.removeFromEnvironment(propName);
+ }
+
+
+ /**
+ * Retrieves the environment in effect for this context. See class
+ * description for more details on environment properties.
+ * The caller should not make any changes to the object returned: their
+ * effect on the context is undefined. The environment of this context
+ * may be changed using addToEnvironment() and removeFromEnvironment().
+ *
+ * @return the environment of this context; never null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Hashtable<?,?> getEnvironment()
+ throws NamingException {
+ return dirContext.getEnvironment();
+ }
+
+
+ /**
+ * Closes this context. This method releases this context's resources
+ * immediately, instead of waiting for them to be released automatically
+ * by the garbage collector.
+ * This method is idempotent: invoking it on a context that has already
+ * been closed has no effect. Invoking any other method on a closed
+ * context is not allowed, and results in undefined behaviour.
+ *
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void close()
+ throws NamingException {
+ }
+
+
+ /**
+ * Retrieves the full name of this context within its own namespace.
+ * <p>
+ * Many naming services have a notion of a "full name" for objects in
+ * their respective namespaces. For example, an LDAP entry has a
+ * distinguished name, and a DNS record has a fully qualified name. This
+ * method allows the client application to retrieve this name. The string
+ * returned by this method is not a JNDI composite name and should not be
+ * passed directly to context methods. In naming systems for which the
+ * notion of full name does not make sense,
+ * OperationNotSupportedException is thrown.
+ *
+ * @return this context's name in its own namespace; never null
+ * @exception OperationNotSupportedException if the naming system does
+ * not have the notion of a full name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public String getNameInNamespace()
+ throws NamingException {
+ return dirContext.getNameInNamespace();
+ }
+
+
+ // ----------------------------------------------------- DirContext Methods
+
+
+ /**
+ * Retrieves all of the attributes associated with a named object.
+ *
+ * @return the set of attributes associated with name.
+ * Returns an empty attribute set if name has no attributes; never null.
+ * @param name the name of the object from which to retrieve attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(Name name)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves all of the attributes associated with a named object.
+ *
+ * @return the set of attributes associated with name
+ * @param name the name of the object from which to retrieve attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(String name)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves selected attributes associated with a named object.
+ * See the class description regarding attribute models, attribute type
+ * names, and operational attributes.
+ *
+ * @return the requested attributes; never null
+ * @param name the name of the object from which to retrieve attributes
+ * @param attrIds the identifiers of the attributes to retrieve. null
+ * indicates that all attributes should be retrieved; an empty array
+ * indicates that none should be retrieved
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(Name name, String[] attrIds)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, pathName), attrIds);
+ }
+
+
+ /**
+ * Retrieves selected attributes associated with a named object.
+ *
+ * @return the requested attributes; never null
+ * @param name the name of the object from which to retrieve attributes
+ * @param attrIds the identifiers of the attributes to retrieve. null
+ * indicates that all attributes should be retrieved; an empty array
+ * indicates that none should be retrieved
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(String name, String[] attrIds)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, path), attrIds);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object. The order of
+ * the modifications is not specified. Where possible, the modifications
+ * are performed atomically.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mod_op the modification operation, one of: ADD_ATTRIBUTE,
+ * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
+ * @param attrs the attributes to be used for the modification; may not
+ * be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(Name name, int mod_op, Attributes attrs)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, pathName), mod_op, attrs);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mod_op the modification operation, one of: ADD_ATTRIBUTE,
+ * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
+ * @param attrs the attributes to be used for the modification; may not
+ * be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(String name, int mod_op, Attributes attrs)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, path), mod_op, attrs);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object using an an
+ * ordered list of modifications. The modifications are performed in the
+ * order specified. Each modification specifies a modification operation
+ * code and an attribute on which to operate. Where possible, the
+ * modifications are performed atomically.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mods an ordered sequence of modifications to be performed; may
+ * not be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(Name name, ModificationItem[] mods)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, pathName), mods);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object using an an
+ * ordered list of modifications.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mods an ordered sequence of modifications to be performed; may
+ * not be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(String name, ModificationItem[] mods)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, path), mods);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes. If attrs
+ * is null, the resulting binding will have the attributes associated
+ * with obj if obj is a DirContext, and no attributes otherwise. If attrs
+ * is non-null, the resulting binding will have attrs as its attributes;
+ * any attributes associated with obj are ignored.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(Name name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.bind(composeName(name, pathName), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(String name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.bind(composeName(name, path), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes,
+ * overwriting any existing binding. If attrs is null and obj is a
+ * DirContext, the attributes from obj are used. If attrs is null and obj
+ * is not a DirContext, any existing attributes associated with the object
+ * already bound in the directory remain unchanged. If attrs is non-null,
+ * any existing attributes associated with the object already bound in
+ * the directory are removed and attrs is associated with the named
+ * object. If obj is a DirContext and attrs is non-null, the attributes
+ * of obj are ignored.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(Name name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.rebind(composeName(name, pathName), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes,
+ * overwriting any existing binding.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(String name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.rebind(composeName(name, path), obj, attrs);
+ }
+
+
+ /**
+ * Creates and binds a new context, along with associated attributes.
+ * This method creates a new subcontext with the given name, binds it in
+ * the target context (that named by all but terminal atomic component of
+ * the name), and associates the supplied attributes with the newly
+ * created object. All intermediate and target contexts must already
+ * exist. If attrs is null, this method is equivalent to
+ * Context.createSubcontext().
+ *
+ * @param name the name of the context to create; may not be empty
+ * @param attrs the attributes to associate with the newly created context
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if the name is already bound
+ * @exception InvalidAttributesException if attrs does not contain all
+ * the mandatory attributes required for creation
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext createSubcontext(Name name, Attributes attrs)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, pathName), attrs);
+ }
+
+
+ /**
+ * Creates and binds a new context, along with associated attributes.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @param attrs the attributes to associate with the newly created context
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if the name is already bound
+ * @exception InvalidAttributesException if attrs does not contain all
+ * the mandatory attributes required for creation
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext createSubcontext(String name, Attributes attrs)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, path), attrs);
+ }
+
+
+ /**
+ * Retrieves the schema associated with the named object. The schema
+ * describes rules regarding the structure of the namespace and the
+ * attributes stored within it. The schema specifies what types of
+ * objects can be added to the directory and where they can be added;
+ * what mandatory and optional attributes an object can have. The range
+ * of support for schemas is directory-specific.
+ *
+ * @param name the name of the object whose schema is to be retrieved
+ * @return the schema associated with the context; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchema(Name name)
+ throws NamingException {
+ return dirContext.getSchema(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the schema associated with the named object.
+ *
+ * @param name the name of the object whose schema is to be retrieved
+ * @return the schema associated with the context; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchema(String name)
+ throws NamingException {
+ return dirContext.getSchema(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves a context containing the schema objects of the named
+ * object's class definitions.
+ *
+ * @param name the name of the object whose object class definition is to
+ * be retrieved
+ * @return the DirContext containing the named object's class
+ * definitions; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchemaClassDefinition(Name name)
+ throws NamingException {
+ return dirContext.getSchemaClassDefinition(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves a context containing the schema objects of the named
+ * object's class definitions.
+ *
+ * @param name the name of the object whose object class definition is to
+ * be retrieved
+ * @return the DirContext containing the named object's class
+ * definitions; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchemaClassDefinition(String name)
+ throws NamingException {
+ return dirContext.getSchemaClassDefinition(composeName(name, path));
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes, and retrieves selected attributes. The search is
+ * performed using the default SearchControls settings.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @param attributesToReturn the attributes to return. null indicates
+ * that all attributes are to be returned; an empty array indicates that
+ * none are to be returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, Attributes
matchingAttributes,
+ String[] attributesToReturn)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), matchingAttributes,
+ attributesToReturn);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes, and retrieves selected attributes.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @param attributesToReturn the attributes to return. null indicates
+ * that all attributes are to be returned; an empty array indicates that
+ * none are to be returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, Attributes
matchingAttributes,
+ String[] attributesToReturn)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), matchingAttributes,
+ attributesToReturn);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes. This method returns all the attributes of such objects.
+ * It is equivalent to supplying null as the atributesToReturn parameter
+ * to the method search(Name, Attributes, String[]).
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, Attributes
matchingAttributes)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), matchingAttributes);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, Attributes
matchingAttributes)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), matchingAttributes);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filter the filter expression to use for the search; may not be
+ * null
+ * @param cons the search controls that control the search. If null,
+ * the default search controls are used (equivalent to
+ * (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisfy
+ * the filter; never null
+ * @exception InvalidSearchFilterException if the search filter specified
+ * is not supported or understood by the underlying directory
+ * @exception InvalidSearchControlsException if the search controls
+ * contain invalid settings
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, String filter,
+ SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), filter, cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filter the filter expression to use for the search; may not be
+ * null
+ * @param cons the search controls that control the search. If null,
+ * the default search controls are used (equivalent to
+ * (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisfy
+ * the filter; never null
+ * @exception InvalidSearchFilterException if the search filter
+ * specified is not supported or understood by the underlying directory
+ * @exception InvalidSearchControlsException if the search controls
+ * contain invalid settings
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, String filter,
+ SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), filter, cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filterExpr the filter expression to use for the search.
+ * The expression may contain variables of the form "{i}" where i is a
+ * nonnegative integer. May not be null.
+ * @param filterArgs the array of arguments to substitute for the
+ * variables in filterExpr. The value of filterArgs[i] will replace each
+ * occurrence of "{i}". If null, equivalent to an empty array.
+ * @param cons the search controls that control the search. If null, the
+ * default search controls are used (equivalent to (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisy the
+ * filter; never null
+ * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * expressions where i is outside the bounds of the array filterArgs
+ * @exception InvalidSearchControlsException if cons contains invalid
+ * settings
+ * @exception InvalidSearchFilterException if filterExpr with filterArgs
+ * represents an invalid search filter
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
+ Object[] filterArgs, SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), filterExpr, filterArgs,
+ cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filterExpr the filter expression to use for the search.
+ * The expression may contain variables of the form "{i}" where i is a
+ * nonnegative integer. May not be null.
+ * @param filterArgs the array of arguments to substitute for the
+ * variables in filterExpr. The value of filterArgs[i] will replace each
+ * occurrence of "{i}". If null, equivalent to an empty array.
+ * @param cons the search controls that control the search. If null, the
+ * default search controls are used (equivalent to (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisy the
+ * filter; never null
+ * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * expressions where i is outside the bounds of the array filterArgs
+ * @exception InvalidSearchControlsException if cons contains invalid
+ * settings
+ * @exception InvalidSearchFilterException if filterExpr with filterArgs
+ * represents an invalid search filter
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, String filterExpr,
+ Object[] filterArgs, SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), filterExpr, filterArgs,
+ cons);
+ }
+
+
+}
+