9.4. 애플리케이션 클라이언트 마이그레이션


이 섹션에서는 클라이언트 애플리케이션을 Elytron으로 마이그레이션하는 방법에 대한 정보를 제공합니다.

이름 지정 클라이언트 구성을 Elytron으로 마이그레이션

이 섹션에서는 org.jboss.naming.remote.client.InitialContext 클래스에서 지원하는 org.jboss.naming.remote.client .InitialContext Factory 클래스를 사용하여 원격 JNDI 조회를 수행하는 클라이언트 애플리케이션을 Elytron으로 마이그레이션하는 방법을 설명합니다.

다음 예제에서는 사용자 자격 증명 및 연결하는 이름 지정 공급자의 URL에 대한 속성을 지정하여 InitialContextFactory 클래스를 생성한다고 가정합니다.

예: InitialContext 코드 이전 릴리스에서 사용됨

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL,"http-remoting://127.0.0.1:8080");
properties.put(Context.SECURITY_PRINCIPAL, "bob");
properties.put(Context.SECURITY_CREDENTIALS, "secret");
InitialContext context = new InitialContext(properties);
Bar bar = (Bar) context.lookup("foo/bar");
...

다음 마이그레이션 방법 중 하나를 선택할 수 있습니다.

구성 접근 방식을 사용하여 이름 지정 클라이언트를 Elytron으로 마이그레이션합니다.

프로세스

  1. 클라이언트 애플리케이션 META-INF/ 디렉터리에 wildfly-config.xml 파일을 생성합니다. 파일에는 이름 지정 공급자에 대한 연결을 설정할 때 사용할 사용자 자격 증명이 포함되어야 합니다.

    예: wildfly-config.xml 파일

    <configuration>
      <authentication-client xmlns="urn:elytron:client:1.7">
        <authentication-rules>
          <rule use-configuration="namingConfig">
            <match-host name="127.0.0.1"/>
          </rule>
        </authentication-rules>
        <authentication-configurations>
          <configuration name="namingConfig">
            <set-user-name name="bob"/>
            <credentials>
              <clear-password password="secret"/>
            </credentials>
          </configuration>
        </authentication-configurations>
      </authentication-client>
    </configuration>

  2. 다음 예와 같이 InitialContext 를 생성합니다. InitialContextorg.wildfly.naming.client.wildFlyInitialContextFactory 클래스에서 지원합니다.

    예: InitialContext 코드

    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.wildfly.naming.client.WildFlyInitialContextFactory");
    properties.put(Context.PROVIDER_URL,"remote+http://127.0.0.1:8080");
    InitialContext context = new InitialContext(properties);
    Bar bar = (Bar) context.lookup("foo/bar");
    ...

이 방법을 사용하면 애플리케이션 코드에서 직접 이름 지정 공급자에 대한 연결을 설정하는 데 사용되는 사용자 자격 증명을 제공합니다.

예: 프로그래밍 방식의 접근 방식을 사용하는 코드

// Create the authentication configuration
AuthenticationConfiguration namingConfig = AuthenticationConfiguration.empty().useName("bob").usePassword("secret");

// Create the authentication context
AuthenticationContext context = AuthenticationContext.empty().with(MatchRule.ALL.matchHost("127.0.0.1"), namingConfig);

// Create a callable that creates and uses an InitialContext
Callable<Void> callable = () -> {
    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.wildfly.naming.client.WildFlyInitialContextFactory");
    properties.put(Context.PROVIDER_URL,"remote+http://127.0.0.1:8080");
    InitialContext context = new InitialContext(properties);
    Bar bar = (Bar) context.lookup("foo/bar");
    ...
    return null;
};

// Use the authentication context to run the callable
context.runCallable(callable);

9.4.3. Jakarta Enterprise Cryostats 클라이언트를 Elytron으로 마이그레이션

이 마이그레이션 예제에서는 jboss- Cryostat-client.properties 파일을 사용하여 원격 서버에 배포된 Jakarta Enterprise Cryostat를 호출하도록 클라이언트 애플리케이션이 구성되어 있다고 가정합니다. 클라이언트 애플리케이션 META-INF/ 디렉터리에 있는 이 파일에는 원격 서버에 연결하는 데 필요한 다음 정보가 포함되어 있습니다.

예: jboss- Cryostat-client.properties 파일

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port = 8080
remote.connection.default.username=bob
remote.connection.default.password=secret

클라이언트는 자카르타 Enterprise Cryostat를 조회하고 다음 예제와 유사한 코드를 사용하여 메서드 중 하나를 호출합니다.

예: 원격 Jakarta Enterprise Cryostat를 호출하는 클라이언트 코드

// Create an InitialContext
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext context = new InitialContext(properties);

// Look up the Jakarta Enterprise Beans and invoke one of its methods
RemoteCalculator statelessRemoteCalculator = (RemoteCalculator) context.lookup(
    "ejb:/ejb-remote-server-side//CalculatorBean!" + RemoteCalculator.class.getName());
int sum = statelessRemoteCalculator.add(101, 202);

다음 마이그레이션 방법 중 하나를 선택할 수 있습니다.

구성 접근 방식을 사용하여 이름 지정 클라이언트를 Elytron으로 마이그레이션하려면 다음 단계를 따르십시오.

프로세스

  1. 클라이언트 애플리케이션 META-INF/ 디렉터리에 wildfly-config.xml 파일을 구성합니다. 파일에는 이름 지정 공급자에 대한 연결을 설정할 때 사용할 사용자 자격 증명이 포함되어야 합니다.

    예: wildfly-config.xml 파일

    <configuration>
      <authentication-client xmlns="urn:elytron:client:1.7">
        <authentication-rules>
          <rule use-configuration="ejbConfig">
            <match-host name="127.0.0.1"/>
          </rule>
        </authentication-rules>
        <authentication-configurations>
          <configuration name="ejbConfig">
            <set-user-name name="bob"/>
            <credentials>
              <clear-password password="secret"/>
            </credentials>
          </configuration>
        </authentication-configurations>
      </authentication-client>
      <jboss-ejb-client xmlns="urn:jboss:wildfly-client-ejb:3.0">
        <connections>
          <connection uri="remote+http://127.0.0.1:8080" />
        </connections>
      </jboss-ejb-client>
    </configuration>

  2. 다음 예와 같이 InitialContext 를 생성합니다. InitialContextorg.wildfly.naming.client.wildFlyInitialContextFactory 클래스에서 지원합니다.

    예: InitialContext 코드

    // Create an InitialContext
    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.wildfly.naming.client.WildFlyInitialContextFactory");
    InitialContext context = new InitialContext(properties);
    
    // Look up an Jakarta Enterprise Beans and invoke one of its methods
    // Note that this code is the same as before
    RemoteCalculator statelessRemoteCalculator = (RemoteCalculator) context.lookup(
        "ejb:/ejb-remote-server-side//CalculatorBean!" + RemoteCalculator.class.getName());
    int sum = statelessRemoteCalculator.add(101, 202);----

  3. 이제 해당 파일이 더 이상 필요하지 않으므로 더 이상 사용되지 않는 jboss- Cryostat-client.properties 파일을 삭제할 수 있습니다.

다음 단계를 사용하여 프로그래밍 방식으로 Jakarta Enterprise Cryostats 클라이언트를 마이그레이션합니다.

프로세스

  • 애플리케이션 코드에서 원격 서버에 직접 연결하는 데 필요한 정보를 제공합니다.

예: 프로그래밍 방식을 사용하는 코드

// Create the authentication configuration
AuthenticationConfiguration ejbConfig = AuthenticationConfiguration.empty().useName("bob").usePassword("secret");

// Create the authentication context
AuthenticationContext context = AuthenticationContext.empty().with(MatchRule.ALL.matchHost("127.0.0.1"), ejbConfig);

// Create a callable that invokes the Jakarta Enterprise Beans
Callable<Void> callable = () -> {

    // Create an InitialContext
    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
    properties.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");
    InitialContext context = new InitialContext(properties);

    // Look up the Jakarta Enterprise Beans and invoke one of its methods
    // Note that this code is the same as before
    RemoteCalculator statelessRemoteCalculator = (RemoteCalculator) context.lookup(
        "ejb:/ejb-remote-server-side//CalculatorBean!" + RemoteCalculator.class.getName());
    int sum = statelessRemoteCalculator.add(101, 202);
    ...
    return null;
};

// Use the authentication context to run the callable
context.runCallable(callable);

이제 해당 파일이 더 이상 필요하지 않으므로 더 이상 사용되지 않는 jboss- Cryostat-client.properties 파일을 삭제할 수 있습니다.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동