Skip to content

Commit

Permalink
Added module-info files + resolved dependency on LogFacade of glassfi…
Browse files Browse the repository at this point in the history
…sh.jar

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Oct 11, 2024
1 parent 28e9e9e commit 1b18869
Show file tree
Hide file tree
Showing 21 changed files with 295 additions and 224 deletions.
2 changes: 1 addition & 1 deletion appserver/extras/embedded/common/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<excludes>META-INF/**</excludes>
<excludes>META-INF/**,module-info.class</excludes>
</artifactItem>
<artifactItem>
<groupId>org.glassfish.main.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void listLoggers() {
assertThat(result, asadminOK());
String[] lines = substringBefore(result.getStdOut(), "Command list-loggers executed successfully.").split("\n");
assertAll(
() -> assertThat(lines, arrayWithSize(equalTo(61))),
() -> assertThat(lines, arrayWithSize(equalTo(62))),
() -> assertThat(lines[0], matchesPattern("Logger Name[ ]+Subsystem[ ]+Logger Description[ ]+"))
);
Map<String, String[]> loggers = Arrays.stream(lines).skip(1).map(line -> line.split("\\s{2,}"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2008, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -25,10 +25,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.osgi.framework.BundleException;

/**
* Tools for obtaining readable information from the {@link BundleException}
* Tools for obtaining readable information from the {@link org.osgi.framework.BundleException}
*/
public class FelixPrettyPrinter {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/**
* @author David Matejcek
*/
module org.glassfish.main.jdke {

requires java.base;

exports org.glassfish.main.jdke.cl;
exports org.glassfish.main.jdke.i18n;
}
27 changes: 27 additions & 0 deletions nucleus/common/simple-glassfish-api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/**
* @author David Matejcek
*/
module org.glassfish.main.api.simple {

requires java.base;
requires java.logging;

exports org.glassfish.embeddable;
exports org.glassfish.embeddable.spi;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.glassfish.main.boot.embedded;

import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys;
import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;
import com.sun.enterprise.module.ModulesRegistry;
import com.sun.enterprise.module.bootstrap.Main;
import com.sun.enterprise.module.bootstrap.ModuleStartup;
Expand Down Expand Up @@ -46,6 +45,7 @@
import org.glassfish.embeddable.GlassFishRuntime;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.DuplicatePostProcessor;
import org.glassfish.main.boot.log.LogFacade;

import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.AUTO_DELETE;
import static java.util.logging.Level.FINER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys;
import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform;
import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles;
import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;
import com.sun.enterprise.module.ModulesRegistry;
import com.sun.enterprise.module.common_impl.AbstractFactory;

Expand All @@ -37,6 +36,7 @@
import org.glassfish.embeddable.GlassFishException;
import org.glassfish.embeddable.GlassFishRuntime;
import org.glassfish.embeddable.spi.RuntimeBuilder;
import org.glassfish.main.boot.log.LogFacade;
import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

package org.glassfish.main.boot.embedded;

import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.hk2.api.PerLookup;
import org.glassfish.hk2.api.PopulatorPostProcessor;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.DescriptorImpl;
import org.glassfish.main.boot.log.LogFacade;

/**
* Kernel's decoration for embedded environment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.glassfish.main.boot.embedded;

import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand All @@ -29,6 +27,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.main.boot.log.LogFacade;

/**
* Most part is copied from com.sun.appserv.connectors.internal.api.ConnectorsUtil
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package org.glassfish.main.boot.embedded;

import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;
import com.sun.enterprise.module.ModuleDefinition;
import com.sun.enterprise.module.ModulesRegistry;
import com.sun.enterprise.module.common_impl.AbstractFactory;
import com.sun.enterprise.module.common_impl.ModuleId;
import com.sun.enterprise.module.single.SingleModulesRegistry;

import org.glassfish.main.boot.log.LogFacade;

/**
* Factory which provides SingleModulesRegistry
* This should actually be in HK2 workspace.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.main.boot.log;

import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

import org.glassfish.logging.annotation.LogMessageInfo;
import org.glassfish.logging.annotation.LogMessagesResourceBundle;
import org.glassfish.logging.annotation.LoggerInfo;

public class LogFacade {

@LoggerInfo(subsystem = "BOOTSTRAP", description="Main bootstrap logger.")
public static final String BOOTSTRAP_LOGGER_NAME = "jakarta.enterprise.bootstrap";

@LogMessagesResourceBundle
public static final String RB_NAME = "org.glassfish.main.boot.log.LogMessages";

public static final Logger BOOTSTRAP_LOGGER = Logger.getLogger(BOOTSTRAP_LOGGER_NAME, RB_NAME);

@LogMessageInfo(
message = "Can not start bundle {0} because it is not contained in the list of installed bundles.",
level = "WARNING")
public static final String CANT_START_BUNDLE = "NCLS-BOOTSTRAP-00005";

@LogMessageInfo(
message = "Failed to start {0}.",
level = "WARNING")
public static final String BUNDLE_START_FAILED = "NCLS-BOOTSTRAP-00006";

@LogMessageInfo(
message = "Can't uninstall bundle = {0} as it's already uninstalled.",
level = "WARNING")
public static final String BUNDLE_ALREADY_UNINSTALED = "NCLS-BOOTSTRAP-00007";

@LogMessageInfo(
message = "Uninstalled bundle {0} installed from {1}.",
level = "INFO")
public static final String UNINSTALLED_BUNDLE = "NCLS-BOOTSTRAP-00008";

@LogMessageInfo(
message = "Can't update bundle = {0} as it's already uninstalled.",
level = "WARNING")
public static final String CANT_UPDATE_ALREADY_INSTALLED = "NCLS-BOOTSTRAP-00009";

@LogMessageInfo(
message = "Updated bundle {0} from {1}.",
level = "INFO")
public static final String BUNDLE_UPDATED = "NCLS-BOOTSTRAP-00010";

@LogMessageInfo(
message = "Failed to uninstall bundle {0}.",
level = "WARNING")
public static final String BUNDLE_UNINSTALL_FAILED = "NCLS-BOOTSTRAP-00011";

@LogMessageInfo(
message = "Failed to update {0}.",
level = "WARNING")
public static final String UPDATE_FAILED = "NCLS-BOOTSTRAP-00012";

@LogMessageInfo(
message = "Failed to install {0}.",
level = "WARNING")
public static final String INSTALL_FAILED = "NCLS-BOOTSTRAP-00013";

@LogMessageInfo(
message = "Can not set the start level for {0} to {2} as it is already set to {1}.",
level = "WARNING")
public static final String CANT_SET_START_LEVEL = "NCLS-BOOTSTRAP-00014";

@LogMessageInfo(
message = "Skipping entry {0} because it is not an absolute URI.",
level = "WARNING")
public static final String ENTRY_SKIPPED = "NCLS-BOOTSTRAP-00015";

@LogMessageInfo(
message = "Skipping entry {0} due to exception: ",
level = "WARNING")
public static final String ENTRY_SKIPPED_DUE_TO = "NCLS-BOOTSTRAP-00016";

@LogMessageInfo(
message = "Create bundle provisioner {0}.",
level = "CONFIG")
public static final String CREATE_BUNDLE_PROVISIONER = "NCLS-BOOTSTRAP-00026";

@LogMessageInfo(
message = "Registered {0} as OSGi service registration: {1}.",
level = "CONFIG")
public static final String SERVICE_REGISTERED = "NCLS-BOOTSTRAP-00027";

@LogMessageInfo(
message = "Unregistered {0} from service registry.",
level = "CONFIG")
public static final String SERVICE_UNREGISTERED = "NCLS-BOOTSTRAP-00028";

@LogMessageInfo(
message = "Exception while unregistering: ",
level = "WARNING")
public static final String SERVICE_UNREGISTRATION_EXCEPTION = "NCLS-BOOTSTRAP-00029";

@LogMessageInfo(
message = "installLocations = {0}.",
level = "INFO")
public static final String SHOW_INSTALL_LOCATIONS = "NCLS-BOOTSTRAP-00030";

@LogMessageInfo(
message = "Unable to determine if {0} is a fragment or not due to ",
level = "INFO")
public static final String CANT_TELL_IF_FRAGMENT = "NCLS-BOOTSTRAP-00031";

@LogMessageInfo(
message = "Skipping starting of bundles bundles have been provisioned already.",
level = "INFO")
public static final String SKIP_STARTING_ALREADY_PROVISIONED_BUNDLES = "NCLS-BOOTSTRAP-00032";

@LogMessageInfo(
message = "{0} : latest file in installation location = {1} and latest installed bundle = {2} ",
level = "INFO")
public static final String LATEST_FILE_IN_INSTALL_LOCATION = "NCLS-BOOTSTRAP-00033";

@LogMessageInfo(
message = "Updating system bundle.",
level = "INFO")
public static final String UPDATING_SYSTEM_BUNDLE = "NCLS-BOOTSTRAP-00034";

@LogMessageInfo(
message = "Provisioning options have changed, recreating the framework with a clean OSGi storage(aka cache).",
level = "INFO")
public static final String PROVISIONING_OPTIONS_CHANGED = "NCLS-BOOTSTRAP-00035";

@LogMessageInfo(
message = "Storage support not available in framework bundle, so can't store bundle ids. This may lead to slower start up time.",
level = "WARNING")
public static final String CANT_STORE_BUNDLEIDS = "NCLS-BOOTSTRAP-00037";

@LogMessageInfo(
message = "Storage support not available in framework bundle, so can't store provisioning options. This may lead to slower start up time.",
level = "WARNING")
public static final String CANT_STORE_PROVISIONING_OPTIONS = "NCLS-BOOTSTRAP-00038";

@LogMessageInfo(
message = "Got an unexpected exception.",
level = "WARNING")
public static final String CAUGHT_EXCEPTION = "NCLS-BOOTSTRAP-00039";

/**
* This helper method is duplicated from org.glassfish.api.logging.LogHelper to avoid adding
* dependency on the glassfish-api bundle.
* Logs a message with the given level, message, parameters and <code>Throwable</code>.
*
* @param logger the <code>Logger</code> object to be used for logging the message.
* @param level the <code>Level</code> of the message to be logged.
* @param messageId the key in the resource bundle of the <code>Logger</code> containing the localized text.
* @param thrown the <code>Throwable</code> associated with the message to be logged.
* @param params the parameters to the localized text.
*/
public static void log(Logger logger, Level level, String messageId, Throwable thrown, Object... params) {
LogRecord rec = new LogRecord(level, messageId);
rec.setLoggerName(logger.getName());
rec.setResourceBundleName(logger.getResourceBundleName());
rec.setResourceBundle(logger.getResourceBundle());
rec.setParameters(params);
rec.setThrown(thrown);
logger.log(rec);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.glassfish.main.boot.osgi;

import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;

import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -31,6 +29,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.main.boot.log.LogFacade;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.glassfish.main.boot.osgi;

import com.sun.enterprise.glassfish.bootstrap.log.LogFacade;

import java.io.File;
import java.io.FileFilter;
import java.net.URI;
Expand All @@ -33,6 +31,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.glassfish.main.boot.log.LogFacade;
import org.osgi.framework.Bundle;

import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.AUTO_INSTALL_PROP;
Expand Down
Loading

0 comments on commit 1b18869

Please sign in to comment.