Package org.wso2.carbon.application.deployer.config

Examples of org.wso2.carbon.application.deployer.config.Artifact


                    + cacheKey);
        }

        // look up cache
        Object prop = cfgCtx.getPropertyNonReplicable(CachingConstants.CACHE_MANAGER);
        CacheManager cacheManager;
        if (prop != null && prop instanceof CacheManager) {
            cacheManager = (CacheManager) prop;
        } else {
            synchronized (cfgCtx) {
                // check again after taking the lock to make sure no one else did it before us
                prop = cfgCtx.getPropertyNonReplicable(CachingConstants.CACHE_MANAGER);
                if (prop != null && prop instanceof CacheManager) {
                    cacheManager = (CacheManager) prop;

                } else {
                    synLog.traceOrDebug("Creating/recreating the cache object");
                    cacheManager = new CacheManager();
                    cfgCtx.setProperty(CachingConstants.CACHE_MANAGER, cacheManager);
                }
            }
        }
View Full Code Here


            if (synLog.isTraceOrDebugEnabled()) {
                synLog.traceOrDebug("Storing the response message into the cache at scope : " +
                    scope + " with ID : " + cacheKey + " for request hash : " + requestHash);
            }

            CachedObject cachedObj = cacheManager.getResponseForKey(cacheKey, requestHash, cfgCtx);
            if (cachedObj != null) {

                if (synLog.isTraceOrDebugEnabled()) {
                    synLog.traceOrDebug("Storing the response for the message with ID : " +
                        synCtx.getMessageID() + " with request hash ID : " +
                        cachedObj.getRequestHash() + " in the cache : " + cacheKey);
                }

                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                try {
                    MessageHelper.cloneSOAPEnvelope(synCtx.getEnvelope()).serialize(outStream);
                    cachedObj.setResponseEnvelope(outStream.toByteArray());
                } catch (XMLStreamException e) {
                    handleException("Unable to set the response to the Cache", e, synCtx);
                }

                /* this is not required yet, can commented this for perf improvements
                   in the future there can be a situation where user sends the request
                   with the response hash (if client side caching is on) in which case
                   we can compare that response hash with the given response hash and
                   respond with not-modified http header */
                // cachedObj.setResponseHash(cache.getGenerator().getDigest(
                //     ((Axis2MessageContext) synCtx).getAxis2MessageContext()));

                if (cachedObj.getTimeout() > 0) {
                    cachedObj.setExpireTimeMillis(System.currentTimeMillis() + cachedObj.getTimeout());
                }

                cfgCtx.setProperty(CachingConstants.CACHE_MANAGER, cacheManager);
//                Replicator.replicate(cfgCtx, new String[]{cacheManagerKey});
                Replicator.replicate(cfgCtx);
View Full Code Here

        if (cacheManager.containsKey(cacheKey, requestHash) &&
            cacheManager.getResponseForKey(cacheKey, requestHash, cfgCtx) != null) {

            // get the response from the cache and attach to the context and change the
            // direction of the message
            CachedObject cachedObj = cacheManager.getResponseForKey(cacheKey, requestHash, cfgCtx);

            if (!cachedObj.isExpired() && cachedObj.getResponseEnvelope() != null) {

                if (synLog.isTraceOrDebugEnabled()) {
                    synLog.traceOrDebug("Cache-hit for message ID : " + synCtx.getMessageID());
                }

                // mark as a response and replace envelope from cache
                synCtx.setResponse(true);
                try {
                    SOAPEnvelope omSOAPEnv = SOAPMessageHelper.buildSOAPEnvelopeFromBytes(
                            cachedObj.getResponseEnvelope());

                    // todo: if there is a WSA messageID in the response, is that need to be unique on each and every resp

                    synCtx.setEnvelope(omSOAPEnv);
                } catch (AxisFault axisFault) {
                    handleException("Error setting response envelope from cache : "
                        + cacheKey, synCtx);
                } catch (IOException ioe) {
                    handleException("Error setting response envelope from cache : "
                        + cacheKey, ioe, synCtx);
                } catch (SOAPException soape) {
                    handleException("Error setting response envelope from cache : "
                        + cacheKey, soape, synCtx);
                }

                // take specified action on cache hit
                if (onCacheHitSequence != null) {
                    // if there is an onCacheHit use that for the mediation
                    synLog.traceOrDebug("Delegating message to the onCachingHit "
                            + "Anonymous sequence");
                    onCacheHitSequence.mediate(synCtx);

                } else if (onCacheHitRef != null) {

                    if (synLog.isTraceOrDebugEnabled()) {
                        synLog.traceOrDebug("Delegating message to the onCachingHit " +
                            "sequence : " + onCacheHitRef);
                    }
                    synCtx.getSequence(onCacheHitRef).mediate(synCtx);

                } else {

                    if (synLog.isTraceOrDebugEnabled()) {
                        synLog.traceOrDebug("Request message " + synCtx.getMessageID() +
                            " was served from the cache : " + cacheKey);
                    }
                    // send the response back if there is not onCacheHit is specified
                    synCtx.setTo(null);
                    Axis2Sender.sendBack(synCtx);
                }
                // stop any following mediators from executing
                return false;

            } else {
                // cache exists, but has expired...
                cachedObj.expire();
                cachedObj.setTimeout(timeout);
                synLog.traceOrDebug("Existing cached response has expired. Reset cache element");

                cfgCtx.setProperty(CachingConstants.CACHE_MANAGER, cacheManager);
//                Replicator.replicate(cfgCtx, new String[]{cacheManagerKey});
                Replicator.replicate(cfgCtx);
View Full Code Here

     * @throws ClusteringFault if there is an error in replicating the cfgCtx
     */
    private void storeRequestToCache(ConfigurationContext cfgCtx,
        String requestHash, CacheManager cacheManager) throws ClusteringFault {

        CachedObject cachedObj = new CachedObject();
        cachedObj.setRequestHash(requestHash);
        // this does not set the expiretime but just sets the timeout and the espiretime will
        // be set when the response is availabel
        cachedObj.setTimeout(timeout);
        cacheManager.addResponseWithKey(cacheKey, requestHash, cachedObj, cfgCtx);

        cfgCtx.setProperty(CachingConstants.CACHE_MANAGER, cacheManager);
//        Replicator.replicate(cfgCtx, new String[]{cacheManagerKey});
        Replicator.replicate(cfgCtx);
View Full Code Here

                .getDependencies();

        String repo = axisConfig.getRepository().getPath();
        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }
            if (BPELAppDeployer.BPEL_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + BPELAppDeployer.BPEL_DIR;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error("A BPEL workflow must have a single file. But " +
                        files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = destPath + File.separator + fileName;
            File artifactFile = new File(artifactPath);
            if (artifactFile.exists() && !artifactFile.delete()) {
                log.warn("Couldn't delete App artifact file : " + artifactPath);
            }
View Full Code Here

        String repo = axisConfig.getRepository().getPath();

        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }

            if (!isAccepted(artifact.getType())) {
                log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " +
                        artifact.getType() + ". Required features are not installed in the system");
                continue;
            }

            if (BPEL_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + BPEL_DIR;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error("BPEL workflows must have a single file to " +
                        "be deployed. But " + files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            AppDeployerUtils.createDir(destPath);
            AppDeployerUtils.copyFile(artifactPath, destPath + File.separator + fileName);
        }
    }
View Full Code Here

        String repo = axisConfig.getRepository().getPath();

        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }

            if (!isAccepted(artifact.getType())) {
                log.warn("Can't deploy artifact : " + artifact.getName() + " of type : " +
                        artifact.getType() + ". Required features are not installed in the system");
                continue;
            }

            if (GADGET_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + GADGET_DIR;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error("Gadgets must have a single .gar file to " +
                        "be deployed. But " + files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            AppDeployerUtils.createDir(destPath);
            AppDeployerUtils.copyFile(artifactPath, destPath + File.separator + fileName);
        }
    }
View Full Code Here

                .getDependencies();

        String repo = axisConfig.getRepository().getPath();
        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }
            if (GadgetAppDeployer.GADGET_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + GadgetAppDeployer.GADGET_DIR;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error("A Gadget must have a single .gar file. But " +
                        files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = destPath + File.separator + fileName;
            File artifactFile = new File(artifactPath);
            if (artifactFile.exists() && !artifactFile.delete()) {
                log.warn("Couldn't delete Gadget artifact file : " + artifactPath);
            }
View Full Code Here

        String repo = axisConfig.getRepository().getPath();

        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }

            String artifactName = artifact.getName();
            if (!isAccepted(artifact.getType())) {
                log.warn("Can't deploy artifact : " + artifactName + " of type : " +
                        artifact.getType() + ". Required features are not installed in the system");
                continue;
            }

            if (MASHUP_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + MASHUP_DIR + File.separator + MASHUP_CONTEXT;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error(
                        "Mashups must have a single file to " + "be deployed. But " + files.size() +
                                " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            try {
                archiveManipulator.extract(artifactPath, destPath);
            } catch (IOException e) {
                log.error("Unable to copy the Mashup : " + artifactName, e);
            }
View Full Code Here

        ArchiveManipulator archiveManipulator = new ArchiveManipulator();

        String repo = axisConfig.getRepository().getPath();
        String artifactPath, destPath;
        for (Artifact.Dependency dep : artifacts) {
            Artifact artifact = dep.getArtifact();
            if (artifact == null) {
                continue;
            }
            if (MashupAppDeployer.MASHUP_TYPE.equals(artifact.getType())) {
                destPath = repo + File.separator + MashupAppDeployer.MASHUP_DIR + File.separator +
                        MashupAppDeployer.MASHUP_CONTEXT;
            } else {
                continue;
            }

            List<CappFile> files = artifact.getFiles();
            if (files.size() != 1) {
                log.error(
                        "A Mashup must have a single file. But " + files.size() + " files found.");
                continue;
            }
            String fileName = artifact.getFiles().get(0).getName();
            artifactPath = artifact.getExtractedPath() + File.separator + fileName;
            File artifactInRepo;
            if (new File(artifactPath).exists()) {
                try {
                    String[] filesInZip = archiveManipulator.check(artifactPath);
                    File jsFile = null;
                    for (String file : filesInZip) {
                        String artifactRepoPath = destPath + File.separator + file;
                        if (file.indexOf("/") == -1) {
                            String extension = file.substring(file.indexOf(".") + 1);
                            if ("js".equals(extension)) {
                                jsFile = new File(destPath + File.separator + file);
                            } else {
                                artifactInRepo = new File(artifactRepoPath);
                                if (artifactInRepo.exists() && artifactInRepo.delete()) {
                                    log.warn("Couldn't delete Mashup artifact file : " + artifactPath);
                                }
                            }
                        }
                    }
                    if (jsFile != null && jsFile.exists() && !jsFile.delete()) {
                        log.warn("Couldn't delete Mashup artifact file : " + artifactPath);
                    }
                } catch (IOException e) {
                    log.error("Error reading the content of the artifact : " + artifact.getName(), e);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.application.deployer.config.Artifact

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.