Skip to content

Commit

Permalink
Using org.glassfish.hk2.api.PopulatorPostProcessor instead of depreca…
Browse files Browse the repository at this point in the history
…ted copy

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Dec 7, 2022
1 parent c9c98f2 commit 764c431
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.oracle.hk2.devtest.cdi.ejb1.ppp;

import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.bootstrap.PopulatorPostProcessor;
import org.glassfish.hk2.api.PopulatorPostProcessor;
import org.glassfish.hk2.utilities.DescriptorImpl;

import com.oracle.hk2.devtest.cdi.ejb1.scoped.HK2Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,8 +20,8 @@
import org.glassfish.admin.restconnector.ProxyRestCommandAdapter;
import org.glassfish.admin.restconnector.ProxyRestManagementAdapter;
import org.glassfish.admin.restconnector.ProxyRestMonitoringAdapter;
import org.glassfish.hk2.api.PopulatorPostProcessor;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.bootstrap.PopulatorPostProcessor;
import org.glassfish.hk2.utilities.DescriptorImpl;

/**
Expand All @@ -29,30 +30,16 @@
* @author Jerome Dochez
*/
public class EmbeddedInhabitantsParser implements PopulatorPostProcessor {
public String getName() {
return "Embedded";
}

// public void decorate(InhabitantsParser inhabitantsParser) {
// inhabitantsParser.drop(RestService.class);
// inhabitantsParser.drop(ProxyRestManagementAdapter.class);
// inhabitantsParser.drop(ProxyRestMonitoringAdapter.class);
// inhabitantsParser.drop(ProxyRestAdminAdapter.class);
// }

@Override
public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl) {

boolean skip = RestService.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestManagementAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestMonitoringAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestCommandAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation());

if (!skip) {
return descriptorImpl;
if (RestService.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestManagementAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestMonitoringAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| ProxyRestCommandAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())) {
return null;
}

return null;

return descriptorImpl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public class EmbeddedInhabitantsParser implements PopulatorPostProcessor {
@Inject
private ServiceLocator serviceLocator;

public String getName() {
return "Embedded";
}


@Override
public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,10 +17,6 @@

package org.glassfish.kernel.embedded;

import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.bootstrap.PopulatorPostProcessor;
import org.glassfish.hk2.utilities.DescriptorImpl;

import com.sun.enterprise.server.logging.LogManagerService;
import com.sun.enterprise.v3.admin.PrivateAdminAdapter;
import com.sun.enterprise.v3.admin.PublicAdminAdapter;
Expand All @@ -29,6 +26,10 @@

import jakarta.inject.Inject;

import org.glassfish.hk2.api.PopulatorPostProcessor;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.DescriptorImpl;

/**
* Kernel's decoration for embedded environment.
*
Expand All @@ -39,31 +40,6 @@ public class EmbeddedInhabitantsParser implements PopulatorPostProcessor {
@Inject
private ServiceLocator serviceLocator;

public EmbeddedInhabitantsParser() {
}


public String getName() {
return "Embedded";
}

// private void decorate(InhabitantsParser parser) {
//
// // we don't want to reconfigure the loggers.
//
// parser.drop(AdminConsoleAdapter.class);
//
// String enableCLI = System.getenv("GF_EMBEDDED_ENABLE_CLI");
// if (enableCLI == null || !enableCLI.equalsIgnoreCase("true")) {
// parser.drop(PublicAdminAdapter.class);
// parser.drop(LogManagerService.class);
// parser.drop(PrivateAdminAdapter.class);
// }
// parser.replace(GFDomainXml.class, EmbeddedDomainXml.class);
//
// parser.replace(DomainXmlPersistence.class, EmbeddedDomainPersistence.class);
//
// }

@Override
public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl) {
Expand All @@ -72,34 +48,26 @@ public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl desc

boolean skip = false;

if (AdminConsoleAdapter.class.getCanonicalName().equals(
descriptorImpl.getImplementation())) {
if (AdminConsoleAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())) {
skip = true;
}

String enableCLI = System.getenv("GF_EMBEDDED_ENABLE_CLI");
if (enableCLI == null || !enableCLI.equalsIgnoreCase("true")) {

if (PublicAdminAdapter.class.getCanonicalName().equals(
descriptorImpl.getImplementation())
|| LogManagerService.class.getCanonicalName().equals(
descriptorImpl.getImplementation())
|| PrivateAdminAdapter.class.getCanonicalName().equals(
descriptorImpl.getImplementation())) {
if (PublicAdminAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| LogManagerService.class.getCanonicalName().equals(descriptorImpl.getImplementation())
|| PrivateAdminAdapter.class.getCanonicalName().equals(descriptorImpl.getImplementation())) {
skip = true;
}
}

if (GFDomainXml.class.getCanonicalName().equals(
descriptorImpl.getImplementation())) {
descriptorImpl.setImplementation(EmbeddedDomainXml.class
.getCanonicalName());
if (GFDomainXml.class.getCanonicalName().equals(descriptorImpl.getImplementation())) {
descriptorImpl.setImplementation(EmbeddedDomainXml.class.getCanonicalName());
}

if (DomainXmlPersistence.class.getCanonicalName().equals(
descriptorImpl.getImplementation())) {
descriptorImpl.setImplementation(EmbeddedDomainPersistence.class
.getCanonicalName());
if (DomainXmlPersistence.class.getCanonicalName().equals(descriptorImpl.getImplementation())) {
descriptorImpl.setImplementation(EmbeddedDomainPersistence.class.getCanonicalName());
}

if (!skip) {
Expand Down

0 comments on commit 764c431

Please sign in to comment.