Package org.apache.naming.resources

Examples of org.apache.naming.resources.Resource


        int jarFilesLength = jarFiles.length;
        int repositoriesLength = repositories.length;

        int i;

        Resource resource = null;

        boolean fileNeedConvert = false;

        for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
            try {

                String fullPath = repositories[i] + path;

                Object lookupResult = resources.lookup(fullPath);
                if (lookupResult instanceof Resource) {
                    resource = (Resource) lookupResult;
                }

                // Note : Not getting an exception here means the resource was
                // found

                ResourceAttributes attributes =
                    (ResourceAttributes) resources.getAttributes(fullPath);
                contentLength = (int) attributes.getContentLength();
                String canonicalPath = attributes.getCanonicalPath();
                if (canonicalPath != null) {
                    // we create the ResourceEntry based on the information returned
                    // by the DirContext rather than just using the path to the
                    // repository. This allows to have smart DirContext implementations
                    // that "virtualize" the docbase (e.g. Eclipse WTP)
                    entry = findResourceInternal(new File(canonicalPath), "");
                } else {
                    // probably a resource not in the filesystem (e.g. in a
                    // packaged war)
                    entry = findResourceInternal(files[i], path);
                }
                entry.lastModified = attributes.getLastModified();

                if (resource != null) {


                    try {
                        binaryStream = resource.streamContent();
                    } catch (IOException e) {
                        return null;
                    }

                    if (needConvert) {
View Full Code Here


        int jarFilesLength = jarFiles.length;
        int repositoriesLength = repositories.length;

        int i;

        Resource resource = null;

        boolean fileNeedConvert = false;

        for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
            try {

                String fullPath = repositories[i] + path;

                Object lookupResult = resources.lookup(fullPath);
                if (lookupResult instanceof Resource) {
                    resource = (Resource) lookupResult;
                }

                // Note : Not getting an exception here means the resource was
                // found

                ResourceAttributes attributes =
                    (ResourceAttributes) resources.getAttributes(fullPath);
                contentLength = (int) attributes.getContentLength();
                String canonicalPath = attributes.getCanonicalPath();
                if (canonicalPath != null) {
                    // we create the ResourceEntry based on the information returned
                    // by the DirContext rather than just using the path to the
                    // repository. This allows to have smart DirContext implementations
                    // that "virtualize" the docbase (e.g. Eclipse WTP)
                    entry = findResourceInternal(new File(canonicalPath), "");
                } else {
                    // probably a resource not in the filesystem (e.g. in a
                    // packaged war)
                    entry = findResourceInternal(files[i], path);
                }
                entry.lastModified = attributes.getLastModified();

                if (resource != null) {


                    try {
                        binaryStream = resource.streamContent();
                    } catch (IOException e) {
                        return null;
                    }

                    if (needConvert) {
View Full Code Here

          if (log.isDebugEnabled())
            log.debug(sm.getString("webappLoader.jarDeploy", filename,
                destFile.getAbsolutePath()));

          Resource jarResource = (Resource) binding.getObject();
          if (copyJars) {
            if (!copy(jarResource.streamContent(), new FileOutputStream(
                destFile)))
              continue;
          }

          try {
View Full Code Here

                @Override
                public Object lookup(String name) throws NamingException {
                   
                    try {
                        final URL url = new URL(TomcatDefaultServlet.this.documentRoot + name);
                        return new Resource() {
                            @Override
                            public InputStream streamContent() throws IOException {
                                URLConnection connection = url.openConnection();
                                connection.setUseCaches(false);
                                return connection.getInputStream();
View Full Code Here

        } else {
            resourceInputStream = req.getInputStream();
        }

        try {
            Resource newResource = new Resource(resourceInputStream);
            // FIXME: Add attributes
            if (exists) {
                resources.rebind(path, newResource);
            } else {
                resources.bind(path, newResource);
View Full Code Here

        }

        RandomAccessFile randAccessContentFile =
            new RandomAccessFile(contentFile, "rw");

        Resource oldResource = null;
        try {
            Object obj = getResources().lookup(path);
            if (obj instanceof Resource)
                oldResource = (Resource) obj;
        } catch (NamingException e) {
        }

        // Copy data in oldRevisionContent to contentFile
        if (oldResource != null) {
            BufferedInputStream bufOldRevStream =
                new BufferedInputStream(oldResource.streamContent(),
                                        BUFFER_SIZE);

            int numBytesRead;
            byte[] copyBuffer = new byte[BUFFER_SIZE];
            while ((numBytesRead = bufOldRevStream.read(copyBuffer)) != -1) {
View Full Code Here

        int jarFilesLength = jarFiles.length;
        int repositoriesLength = repositories.length;

        int i;

        Resource resource = null;

        for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
            try {

                String fullPath = repositories[i] + path;

                Object lookupResult = resources.lookup(fullPath);
                if (lookupResult instanceof Resource) {
                    resource = (Resource) lookupResult;
                }

                // Note : Not getting an exception here means the resource was
                // found

                entry = new ResourceEntry();
                try {
                    entry.source = getURL(new File(files[i], path));
                    entry.codeBase = entry.source;
                } catch (MalformedURLException e) {
                    return null;
                }
                ResourceAttributes attributes =
                    (ResourceAttributes) resources.getAttributes(fullPath);
                contentLength = (int) attributes.getContentLength();
                entry.lastModified = attributes.getLastModified();

                if (resource != null) {

                    try {
                        binaryStream = resource.streamContent();
                    } catch (IOException e) {
                        return null;
                    }

                    // Register the full path for modification checking
View Full Code Here

        } else {
            resourceInputStream = req.getInputStream();
        }

        try {
            Resource newResource = new Resource(resourceInputStream);
            // FIXME: Add attributes
            if (exists) {
                resources.rebind(path, newResource);
            } else {
                resources.bind(path, newResource);
View Full Code Here

        }

        RandomAccessFile randAccessContentFile =
            new RandomAccessFile(contentFile, "rw");

        Resource oldResource = null;
        try {
            Object obj = getResources().lookup(path);
            if (obj instanceof Resource)
                oldResource = (Resource) obj;
        } catch (NamingException e) {
        }

        // Copy data in oldRevisionContent to contentFile
        if (oldResource != null) {
            BufferedInputStream bufOldRevStream =
                new BufferedInputStream(oldResource.streamContent(),
                                        BUFFER_SIZE);

            int numBytesRead;
            byte[] copyBuffer = new byte[BUFFER_SIZE];
            while ((numBytesRead = bufOldRevStream.read(copyBuffer)) != -1) {
View Full Code Here

        int jarFilesLength = jarFiles.length;
        int repositoriesLength = repositories.length;

        int i;

        Resource resource = null;

        boolean fileNeedConvert = false;

        for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
            try {

                String fullPath = repositories[i] + path;

                Object lookupResult = resources.lookup(fullPath);
                if (lookupResult instanceof Resource) {
                    resource = (Resource) lookupResult;
                }

                // Note : Not getting an exception here means the resource was
                // found

                ResourceAttributes attributes =
                    (ResourceAttributes) resources.getAttributes(fullPath);
                contentLength = (int) attributes.getContentLength();
                String canonicalPath = attributes.getCanonicalPath();
                if (canonicalPath != null) {
                    // we create the ResourceEntry based on the information returned
                    // by the DirContext rather than just using the path to the
                    // repository. This allows to have smart DirContext implementations
                    // that "virtualize" the docbase (e.g. Eclipse WTP)
                    entry = findResourceInternal(new File(canonicalPath), "");
                } else {
                    // probably a resource not in the filesystem (e.g. in a
                    // packaged war)
                    entry = findResourceInternal(files[i], path);
                }
                entry.lastModified = attributes.getLastModified();

                if (resource != null) {


                    try {
                        binaryStream = resource.streamContent();
                    } catch (IOException e) {
                        return null;
                    }

                    if (needConvert) {
View Full Code Here

TOP

Related Classes of org.apache.naming.resources.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.