Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
SCA4J Copyright (c) 2009 - 2099 Service Symphony Ltd Licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the license is included in this distrubtion or you may obtain a copy at http://www.opensource.org/licenses/apache2.0.php 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. This project contains code licensed from the Apache Software Foundation under the Apache License, Version 2.0 and original code from project contributors. Original Codehaus Header Copyright (c) 2007 - 2008 fabric3 project contributors Licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. A copy of the license is included in this distrubtion or you may obtain a copy at http://www.opensource.org/licenses/apache2.0.php 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. This project contains code licensed from the Apache Software Foundation under the Apache License, Version 2.0 and original code from project contributors. Original Apache Header Copyright (c) 2005 - 2006 The Apache Software Foundation Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. This product includes software developed by The Apache Software Foundation (http://www.apache.org/).
 
 package org.sca4j.web.control;
 
 import java.net.URI;
 import java.util.Map;
 
 
 import static org.sca4j.container.web.spi.WebApplicationActivator.CONTEXT_ATTRIBUTE;
 import static org.sca4j.web.provision.WebConstants.SERVLET_CONTEXT_SITE;
 import static org.sca4j.web.provision.WebConstants.SESSION_CONTEXT_SITE;
 import static org.sca4j.web.provision.WebContextInjectionSite.ContextType.SERVLET_CONTEXT;
 import static org.sca4j.web.provision.WebContextInjectionSite.ContextType.SESSION_CONTEXT;

Generates commands to provision a web component.

Version:
$Rev: 2931 $ $Date: 2008-02-28 04:49:35 -0800 (Thu, 28 Feb 2008) $
    private HostInfo info;
        this. = info;
        this. = encoder;
        registry.register(WebImplementation.classthis);
    }
        ComponentDefinition<WebImplementationdefinition = component.getDefinition();
        WebComponentType componentType = definition.getImplementation().getComponentType();
        URI componentId = component.getUri();
        // the context URL for the web application is derived from the component name relative to the domain
        String contextUrl = .getDomain().relativize(componentId).toString();
        WebComponentDefinition physical = new WebComponentDefinition();
        physical.setComponentId(componentId);
        physical.setContextUrl(contextUrl);
        physical.setGroupId(component.getParent().getUri());
        Map<StringMap<StringInjectionSite>> sites = generateInjectionMapping(componentType);
        physical.setInjectionMappings(sites);
        processPropertyValues(componentphysical);
        URI classLoaderId = component.getClassLoaderId();
        physical.setClassLoaderId(classLoaderId);
        if (component.getRuntimeId() == null) {
            physical.setContributionUri(definition.getContributionUri());
        } else {
            URI encoded;
            try {
                encoded = .encode(definition.getContributionUri());
            } catch (URISyntaxException e) {
                throw new GenerationException(e);
            }
            physical.setContributionUri(encoded);
        }
        return physical;
    }
            throws GenerationException {
        WebComponentWireSourceDefinition sourceDefinition = new WebComponentWireSourceDefinition();
        sourceDefinition.setUri(reference.getUri());
        if (reference.getDefinition().getServiceContract().isConversational()) {
            sourceDefinition.setInteractionType(.);
        }
        return sourceDefinition;
    }
                                                                   ServiceContract<?> serviceContract,
                                                                   Policy policythrows GenerationException {
        throw new UnsupportedOperationException();
    }
            throws GenerationException {
        return null;
    }
            throws GenerationException {
        return null;
    }
        Map<StringMap<StringInjectionSite>> mappings = new HashMap<StringMap<StringInjectionSite>>();
        for (ReferenceDefinition definition : type.getReferences().values()) {
            generateReferenceInjectionMapping(definitiontypemappings);
        }
        for (Property property : type.getProperties().values()) {
            generatePropertyInjectionMapping(propertymappings);
        }
        generateContextInjectionMapping(typemappings);
        return mappings;
    }
    private void generateReferenceInjectionMapping(ReferenceDefinition definition,
                                                   WebComponentType type,
                                                   Map<StringMap<StringInjectionSite>> mappings) {
        Map<StringInjectionSitemapping = mappings.get(definition.getName());
        if (mapping == null) {
            mapping = new HashMap<StringInjectionSite>();
            mappings.put(definition.getName(), mapping);
        }
        for (Map.Entry<StringMap<InjectionSiteInjectableAttribute>> entry : type.getInjectionSites().entrySet()) {
            for (Map.Entry<InjectionSiteInjectableAttributesiteMap : entry.getValue().entrySet()) {
                if (siteMap.getValue().getName().equals(definition.getName())) {
                    mapping.put(entry.getKey(), siteMap.getKey());
                }
            }
        }
        ServiceContract<?> contract = definition.getServiceContract();
        String interfaceClass = contract.getQualifiedInterfaceName();
        // inject the reference into the session context
        WebContextInjectionSite site = new WebContextInjectionSite(interfaceClass);
        mapping.put(site);
        if (!contract.isConversational()) {
            // if the target service is non-conversational, also inject the reference into the servlet context
            WebContextInjectionSite servletContextsite = new WebContextInjectionSite(interfaceClass);
            mapping.put(servletContextsite);
        }
    }
    private void generatePropertyInjectionMapping(Property propertyMap<StringMap<StringInjectionSite>> mappings) {
        Map<StringInjectionSitemapping = mappings.get(property.getName());
        if (mapping == null) {
            mapping = new HashMap<StringInjectionSite>();
            mappings.put(property.getName(), mapping);
        }
        // inject the property into the session context
        // we don't need to do the type mappings from schema to Java so set Object as the type
        mapping.put(site);
    }
    private void generateContextInjectionMapping(WebComponentType typeMap<StringMap<StringInjectionSite>> mappings) {
        Map<StringInjectionSitemapping = mappings.get();
        if (mapping == null) {
            mapping = new HashMap<StringInjectionSite>();
            WebContextInjectionSite site =
                    new WebContextInjectionSite(ComponentContext.class.getName(), );
            mapping.put(site);
            mappings.put(mapping);
        }
        for (Map.Entry<StringMap<InjectionSiteInjectableAttribute>> entry : type.getInjectionSites().entrySet()) {
            for (Map.Entry<InjectionSiteInjectableAttributesiteMap : entry.getValue().entrySet()) {
                if (siteMap.getValue().equals(.)) {
                    mapping.put(entry.getKey(), siteMap.getKey());
                }
            }
        }
    }
    private void processPropertyValues(LogicalComponent<?> componentWebComponentDefinition physical) {
        for (Map.Entry<StringDocumententry : component.getPropertyValues().entrySet()) {
            String name = entry.getKey();
            Document value = entry.getValue();
            if (value != null) {
                physical.setPropertyValue(namevalue);
            }
        }
    }
New to GrepCode? Check out our FAQ X