当前位置: 首页>>代码示例>>Java>>正文


Java HTTPContext.add方法代码示例

本文整理汇总了Java中org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext.add方法的典型用法代码示例。如果您正苦于以下问题:Java HTTPContext.add方法的具体用法?Java HTTPContext.add怎么用?Java HTTPContext.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext的用法示例。


在下文中一共展示了HTTPContext.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractWebArchiveContexts

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
private void extractWebArchiveContexts(HTTPContext context, String deploymentName, ModelNode deploymentNode) {
    if (deploymentNode.hasDefined(SUBSYSTEM)) {
        ModelNode subsystem = deploymentNode.get(SUBSYSTEM);
        if (subsystem.hasDefined(UNDERTOW)) {
            ModelNode webSubSystem = subsystem.get(UNDERTOW);
            if (webSubSystem.isDefined() && webSubSystem.hasDefined("context-root")) {
                final String contextName = webSubSystem.get("context-root").asString();
                if (webSubSystem.hasDefined(SERVLET)) {
                    for (final ModelNode servletNode : webSubSystem.get(SERVLET).asList()) {
                        for (final String servletName : servletNode.keys()) {
                            context.add(new Servlet(servletName, toContextName(contextName)));
                        }
                    }
                }
                /*
                 * This is a WebApp, it has some form of webcontext whether it has a Servlet or not. AS7 does not expose jsp
                 * / default servlet in mgm api
                 */
                context.add(new Servlet("default", toContextName(contextName)));
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:24,代码来源:ManagementClient.java

示例2: extractWebArchiveContexts

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
private void extractWebArchiveContexts(HTTPContext context, ModelNode deploymentNode) {
    if (deploymentNode.hasDefined(SUBSYSTEM)) {
        ModelNode subsystem = deploymentNode.get(SUBSYSTEM);
        if (subsystem.hasDefined(UNDERTOW)) {
            ModelNode webSubSystem = subsystem.get(UNDERTOW);
            if (webSubSystem.isDefined() && webSubSystem.hasDefined("context-root")) {
                final String contextName = toContextName(webSubSystem.get("context-root").asString());
                if (webSubSystem.hasDefined(SERVLET)) {
                    for (final ModelNode servletNode : webSubSystem.get(SERVLET).asList()) {
                        for (final String servletName : servletNode.keys()) {
                            context.add(new Servlet(servletName, contextName));
                        }
                    }
                }
                /*
                 * This is a WebApp, it has some form of webcontext whether it has a
                 * Servlet or not. AS7 does not expose jsp / default servlet in mgm api
                 */
                context.add(new Servlet("default", contextName));
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:24,代码来源:ManagementClient.java

示例3: addArquillianServlet

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
protected void addArquillianServlet(final Archive<?> archive, final AppInfo appInfo,
                                  final String archiveName, final HTTPContext httpContext) {
    // Avoids "inconvertible types" error in windows build
    if (archiveName.endsWith(".war")) {
        httpContext.add(new Servlet("ArquillianServletRunner", "/" + getArchiveNameWithoutExtension(archive)));
    } else if (archiveName.endsWith(".ear") && appInfo.webApps.size() > 0) {
        final String contextRoot = System.getProperty("tomee.arquillian.ear.context", configuration.getWebContextToUseWithEars());
        if (contextRoot != null) {
            httpContext.add(new Servlet("ArquillianServletRunner", ("/" + contextRoot).replace("//", "/")));
        } else {
            for (final WebAppInfo web : appInfo.webApps) { // normally a single webapp is supported cause of arquillian resolution
                httpContext.add(new Servlet("ArquillianServletRunner", ("/" + web.contextRoot).replace("//", "/")));
            }
        }
    } else {
        httpContext.add(new Servlet("ArquillianServletRunner", "/arquillian-protocol")); // needs another jar to add the fake webapp
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:TomEEContainer.java

示例4: addServlets

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
public void addServlets(final HTTPContext httpContext, final AppInfo appInfo) {
    for (final WebAppInfo webApps : appInfo.webApps) {
        for (final ServletInfo servlet : webApps.servlets) {
            // weird but arquillian url doesn't match the servlet url but its context
            String clazz = servlet.servletClass;
            if (clazz == null) {
                clazz = servlet.servletName;
                if (clazz == null) {
                    continue;
                }
            }

            httpContext.add(new Servlet(clazz, webApps.contextRoot));
            /*
            for (String mapping : servlet.mappings) {
                httpContext.add(new Servlet(servlet.servletClass, startWithSlash(uniqueSlash(webApps.contextRoot, mapping))));

            }
            */
        }
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:23,代码来源:TomEEContainer.java

示例5: registerDeploymentInfo

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
private HTTPContext registerDeploymentInfo(Archive<?> archive) {
    UndertowWebArchive servletBuilder = (UndertowWebArchive) archive;

    final DeploymentInfo deploymentInfo = servletBuilder
        .getDeploymentInfo();
    deploymentManager = defaultContainer().addDeployment(
        deploymentInfo);
    deploymentManager.deploy();

    try {
        this.undertow = createUndertow(deploymentManager.start());
        this.undertow.start();
    } catch (ServletException e) {
        throw new IllegalArgumentException(e);
    }

    HTTPContext httpContext = new HTTPContext(
        configuration.getBindAddress(), configuration.getBindHttpPort());

    final Map<String, ServletInfo> servlets = deploymentInfo.getServlets();

    final Collection<ServletInfo> servletsInfo = servlets.values();

    for (ServletInfo servletInfo : servletsInfo) {
        httpContext.add(new Servlet(servletInfo.getName(),
            deploymentManager.getDeployment().getDeploymentInfo()
                .getContextPath()));
    }
    return httpContext;
}
 
开发者ID:arquillian,项目名称:arquillian-container-undertow,代码行数:31,代码来源:EmbeddedUndertowContainer.java

示例6: addArquillianTestServlet

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
private void addArquillianTestServlet(Archive<?> deployment, HTTPContext httpContext) {
    httpContext.add(new Servlet("ArquillianServletRunner", extractContextName(deployment)));
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:4,代码来源:ContainerlessDockerDeployableContainer.java

示例7: update

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
public void update(@Observes EventContext<ProtocolMetaData> eventContext, Container container,
    CubeRegistry registry) {

    ProtocolMetaData originalMetaData = eventContext.getEvent();
    ProtocolMetaData updatedMetaData = new ProtocolMetaData();
    boolean updated = false;

    try {
        Cube<?> cube = registry.getCube(ContainerUtil.getCubeIDForContainer(container));
        if (cube == null) {
            return;
        }
        HasPortBindings portBindings = cube.getMetadata(HasPortBindings.class);
        if (portBindings == null) {
            return;
        }
        for (Object contextObj : originalMetaData.getContexts()) {
            if (contextObj instanceof HTTPContext) {
                HTTPContext context = (HTTPContext) contextObj;
                String ip = context.getHost();
                int port = context.getPort();
                final PortAddress mappedPort = portBindings.getMappedAddress(port);
                final String bindingIp;
                final Integer bindingPort;
                if (mappedPort != null) {
                    bindingIp = mappedPort.getIP();
                    bindingPort = mappedPort.getPort();
                } else {
                    continue;
                }
                if (bindingPort != null && port != bindingPort) {
                    updated = true;
                    port = bindingPort;
                }
                if (bindingIp != null && !bindingIp.equals(ip)) {
                    updated = true;
                    ip = bindingIp;
                }
                if (updated) {
                    HTTPContext newContext = new HTTPContext(ip, port);
                    for (Servlet servlet : context.getServlets()) {
                        newContext.add(servlet);
                    }
                    updatedMetaData.addContext(newContext);
                }
            } else {
                updatedMetaData.addContext(contextObj);
            }
        }
    } finally {
        if (updated) {
            protocolMetaDataProducer.set(updatedMetaData);
        } else {
            eventContext.proceed();
        }
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:58,代码来源:ProtocolMetadataUpdater.java

示例8: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    final DeploymentInfo info;
    try {
        final Closeables cl = new Closeables();
        closeablesProducer.set(cl);
        info = quickDeploy(archive, testClass.get(), cl);

        // try to switch module context jndi to let test use java:module naming
        // we could put the managed bean in the war but then test class should respect all the
        // container rules (CDI) which is not the case with this solution
        if (archive.getName().endsWith(".war")) {
            final List<BeanContext> beanContexts = info.appCtx.getBeanContexts();
            if (beanContexts.size() > 1) {
                final Iterator<BeanContext> it = beanContexts.iterator();
                while (it.hasNext()) {
                    final BeanContext next = it.next();
                    if (ModuleTestContext.class.isInstance(next.getModuleContext()) && BeanContext.Comp.class != next.getBeanClass()) {
                        for (final BeanContext b : beanContexts) {
                            if (b.getModuleContext() != next.getModuleContext()) {
                                ModuleTestContext.class.cast(next.getModuleContext())
                                        .setModuleJndiContextOverride(b.getModuleContext().getModuleJndiContext());
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }

        servletContextProducer.set(info.appServletContext);
        sessionProducer.set(info.appSession);
        appInfoProducer.set(info.appInfo);
        appContextProducer.set(info.appCtx);
        final ClassLoader loader = info.appCtx.getWebContexts().isEmpty() ? info.appCtx.getClassLoader() : info.appCtx.getWebContexts().iterator().next().getClassLoader();
        final ClassLoader classLoader = loader == null ? info.appCtx.getClassLoader() : loader;

        TestObserver.ClassLoaders classLoaders = this.classLoader.get();
        if (classLoaders == null) {
            classLoaders = new TestObserver.ClassLoaders();
            this.classLoader.set(classLoaders);
        }
        classLoaders.register(archive.getName(), classLoader);
    } catch (final Exception e) {
        throw new DeploymentException("can't deploy " + archive.getName(), e);
    }

    // if service manager is started allow @ArquillianResource URL injection
    if (PROPERTIES.containsKey(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE)) {
        final ProtocolMetaData metaData = ServiceManagers.protocolMetaData(appInfoProducer.get());
        HTTPContext http = null;
        for (final WebAppInfo webapp : info.appInfo.webApps) {
            for (final ServletInfo servletInfo : webapp.servlets) {
                if (http == null) {
                    http = HTTPContext.class.cast(metaData.getContexts().iterator().next());
                    http.add(new Servlet(servletInfo.servletName, webapp.contextRoot));
                }
            }
            for (final ClassListInfo classListInfo : webapp.webAnnotatedClasses) {
                for (final String path : classListInfo.list) {
                    if (!path.contains("!")) {
                        continue;
                    }
                    if (http == null) {
                        http = HTTPContext.class.cast(metaData.getContexts().iterator().next());
                    }
                    http.add(new Servlet(path.substring(path.lastIndexOf('!') + 2).replace(".class", "").replace("/", "."), webapp.contextRoot));
                }
            }
        }
        if (metaData != null) {
            return metaData;
        }
    }
    return new ProtocolMetaData();
}
 
开发者ID:apache,项目名称:tomee,代码行数:78,代码来源:OpenEJBDeployableContainer.java

示例9: newHttpProtocolMetaData

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
private static ProtocolMetaData newHttpProtocolMetaData(final ServerService ss, final String contextRoot) {
    final HTTPContext httpContext = new HTTPContext(ss.getIP(), ss.getPort());
    httpContext.add(new Servlet("ArquillianServletRunner", contextRoot));
    return new ProtocolMetaData().addContext(httpContext);
}
 
开发者ID:apache,项目名称:tomee,代码行数:6,代码来源:ServiceManagers.java

示例10: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
    try {
        /* don't do it since it should be configurable
        final File tempDir = Files.createTempDir();
        final File file = new File(tempDir, name);
        */
        final String name = archive.getName();
        final Dump dump = this.dumpFile(archive);
        final File file = dump.getFile();

        if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(name)) {
            ARCHIVES.put(archive, file);
            final Thread current = Thread.currentThread();
            final ClassLoader loader = current.getContextClassLoader();
            current.setContextClassLoader(ParentClassLoaderFinder.Helper.get()); // multiple deployments, don't leak a loader
            try {
                this.container.deploy(name, file);
            } finally {
                current.setContextClassLoader(loader);
            }
        }

        final AppInfo info = this.container.getInfo(name);
        final String context = this.getArchiveNameWithoutExtension(archive);

        final HTTPContext httpContext = new HTTPContext(this.configuration.getHost(), this.configuration.getHttpPort());
        httpContext.add(new Servlet("ArquillianServletRunner", "/" + context));
        this.addServlets(httpContext, info);

        startCdiContexts(name); // ensure tests can use request/session scopes even if we don't have a request

        TestObserver.ClassLoaders classLoaders = this.classLoader.get();
        if (classLoaders == null) {
            classLoaders = new TestObserver.ClassLoaders();
            this.classLoader.set(classLoaders);
        }
        classLoaders.register(archive.getName(), SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(info.appId).getClassLoader());

        return new ProtocolMetaData().addContext(httpContext);
    } catch (final Exception e) {
        throw new DeploymentException("Unable to deploy", e);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:45,代码来源:EmbeddedTomEEContainer.java


注:本文中的org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。