Skip to content

Commit

Permalink
Another block of cleanups in DOL
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 762513e commit 2e2f15f
Show file tree
Hide file tree
Showing 42 changed files with 941 additions and 986 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,9 +17,8 @@

package org.glassfish.apf.context;

import java.util.Stack;
import java.lang.reflect.AnnotatedElement;
import java.lang.annotation.ElementType;
import java.lang.reflect.AnnotatedElement;

import org.glassfish.apf.AnnotatedElementHandler;
import org.glassfish.apf.AnnotationProcessorException;
Expand All @@ -32,27 +32,30 @@
*/
public class AnnotationContext implements AnnotatedElementHandler {

ProcessingContext processingContext;
private ProcessingContext processingContext;

/** Creates a new instance of AnnotationContext */
public AnnotationContext() {
}


public void setProcessingContext(ProcessingContext processingContext) {
this.processingContext = processingContext;
}


public ProcessingContext getProcessingContext() {
return processingContext;
}

public void startElement(ElementType type, AnnotatedElement element)
throws AnnotationProcessorException {
}

public void endElement(ElementType type, AnnotatedElement element)
throws AnnotationProcessorException {
@Override
public void startElement(ElementType type, AnnotatedElement element) throws AnnotationProcessorException {
}


@Override
public void endElement(ElementType type, AnnotatedElement element) throws AnnotationProcessorException {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public int getAuthMechVal(String value) {
} else if (value.trim().equals(ConnectorTagNames.DD_KERBEROS)) {
authMechVal = AuthMechanism.KERBV5;
} else {
throw new IllegalArgumentException("Invalid auth-mech-type");// put this in localStrings...
throw new IllegalArgumentException("Invalid auth-mech-type");
}
return authMechVal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ public void createConnectorConnectionPool(ConnectorConnectionPool ccp,
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Wrong parameters for pool creation ");
}
String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create");
String i18nMsg = I18N.getString("ccp_adm.wrong_params_for_create");
throw new ConnectorRuntimeException(i18nMsg);
}
ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo();
ConnectorDescriptor connectorDescriptor = _registry.getDescriptor(rarName);
if (connectorDescriptor == null) {
String i18nMsg = localStrings.getString("ccp_adm.no_conn_pool_obj", rarName);
String i18nMsg = I18N.getString("ccp_adm.no_conn_pool_obj", rarName);
ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_notfound_registry", rarName);
_logger.log(Level.SEVERE, "", cre);
Expand Down Expand Up @@ -238,7 +238,7 @@ public void createConnectorConnectionPool(
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Wrong parameters for pool creation ");
}
String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create");
String i18nMsg = I18N.getString("ccp_adm.wrong_params_for_create");
throw new ConnectorRuntimeException(i18nMsg);
}
String moduleName =
Expand All @@ -251,7 +251,7 @@ public void createConnectorConnectionPool(
_registry.getDescriptor(moduleName);
if (connectorDescriptor == null) {
String i18nMsg = localStrings.getString("ccp_adm.null_connector_desc", moduleName);
String i18nMsg = I18N.getString("ccp_adm.null_connector_desc", moduleName);
ConnectorRuntimeException cre = new
ConnectorRuntimeException(i18nMsg);
_logger.log(Level.SEVERE, "rardeployment.null_mcf_in_registry", moduleName);
Expand Down Expand Up @@ -566,7 +566,7 @@ protected ManagedConnectionFactory getManagedConnectionFactory(String poolName)
logFine("getUnpooledConnection:: " +
"done obtainManagedConnectionFactory again");
} catch (ConnectorRuntimeException creAgain) {
String l10nMsg = localStrings.getString(
String l10nMsg = I18N.getString(
"pingpool.cannot_obtain_mcf", poolName);
_logger.log(Level.WARNING, "jdbc.pool_not_reachable",
l10nMsg);
Expand All @@ -577,7 +577,7 @@ protected ManagedConnectionFactory getManagedConnectionFactory(String poolName)
} else {
_logger.log(Level.WARNING, "jdbc.pool_not_reachable",
cre.getMessage());
String l10nMsg = localStrings.getString(
String l10nMsg = I18N.getString(
"pingpool.cannot_obtain_mcf", poolName);
ResourceException e = new ResourceException(l10nMsg);
e.initCause(cre);
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public void createConnectorConnectionPool(ConnectorConnectionPool ccp,
connectorDescriptor = _runtime.getConnectorDescriptor(rarName);
}
if (connectorDescriptor == null) {
String i18nMsg = localStrings.getString(
String i18nMsg = I18N.getString(
"ccp_adm.no_conn_pool_obj", rarName);
ConnectorRuntimeException cre = new ConnectorRuntimeException(
i18nMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class RARUtils {
public static Map getRABeanProperties (String pathToDeployableUnit) throws ConnectorRuntimeException {
File f = new File(pathToDeployableUnit);
if (!f.exists()){
String i18nMsg = localStrings.getString(
String i18nMsg = I18N.getString(
"rar_archive_not_found", pathToDeployableUnit);
throw new ConnectorRuntimeException( i18nMsg );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public DeferredResourceConfig getDeferredResourceConfig(Object resource, Object
return null;
}
} catch (Exception e) {
String message = localStrings.getString(
String message = I18N.getString(
"error.finding.resources.references",
resourceInfo);
_logger.log(Level.WARNING, message + e.getMessage());
Expand Down Expand Up @@ -322,7 +322,7 @@ public DeferredResourceConfig getDeferredResourceConfig(Object resource, Object
}
}
} catch (Exception e) {
String message = localStrings.getString("error.finding.resources.references", resourceInfo);
String message = I18N.getString("error.finding.resources.references", resourceInfo);
_logger.log(Level.WARNING, message + e.getMessage());
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,message + e.getMessage(), e);
Expand Down Expand Up @@ -378,7 +378,7 @@ public DeferredResourceConfig getDeferredResourceConfig(Object resource, Object
return null;
}
} catch (Exception e) {
String message = localStrings.getString(
String message = I18N.getString(
"error.finding.resources.references",
resourceInfo);
_logger.log(Level.WARNING, message + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* This provides a context for Application Client.
*
* @Author Shing Wai Chan
* @author Shing Wai Chan
*/
public class AppClientContext extends ResourceContainerContextImpl {

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) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -19,11 +20,12 @@
/**
* This interface provides an abstraction for component.
*
* @Author Shing Wai Chan
* @author Shing Wai Chan
*/
public interface ComponentContext {

/**
* @return the component java class name
*/
public String getComponentClassName();
String getComponentClassName();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,28 +15,22 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/*
* EjbBundleContext.java
*
* Created on January 12, 2005, 10:20 AM
*/

package com.sun.enterprise.deployment.annotation.context;

import com.sun.enterprise.deployment.EjbBundleDescriptor;
import com.sun.enterprise.deployment.EjbDescriptor;
import com.sun.enterprise.deployment.EjbInterceptor;
import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
import com.sun.enterprise.deployment.WebServiceEndpoint;
import com.sun.enterprise.deployment.core.*;
import com.sun.enterprise.deployment.types.HandlerChainContainer;
import com.sun.enterprise.deployment.types.ServiceReferenceContainer;
import org.glassfish.apf.AnnotatedElementHandler;

import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.List;

import org.glassfish.apf.AnnotatedElementHandler;

/**
* This ClientContext implementation holds a top level reference
* to the DOL EJB BundleDescriptor which will be used to populate
Expand All @@ -50,18 +45,19 @@ public EjbBundleContext(EjbBundleDescriptor descriptor) {
super(descriptor);
}


public EjbBundleDescriptor getDescriptor() {
return (EjbBundleDescriptor)descriptor;
return (EjbBundleDescriptor) descriptor;
}


/**
* This methods create a context for Ejb(s) by using descriptor(s)
* associated to given ejbClassName.
* Return null if corresponding descriptor is not found.
*/
public AnnotatedElementHandler createContextForEjb() {
Class ejbClass = (Class)this.getProcessingContext().getProcessor(
).getLastAnnotatedElement(ElementType.TYPE);
Class<?> ejbClass = (Class<?>) getProcessingContext().getProcessor().getLastAnnotatedElement(ElementType.TYPE);
EjbDescriptor[] ejbDescs = null;
String ejbClassName = null;
if (ejbClass != null) {
Expand All @@ -78,59 +74,54 @@ public AnnotatedElementHandler createContextForEjb() {

if (aeHandler != null) {
// push a EjbContext to stack
this.getProcessingContext().pushHandler(aeHandler);
getProcessingContext().pushHandler(aeHandler);
}
return aeHandler;
}

public HandlerChainContainer[]
getHandlerChainContainers(boolean serviceSideHandlerChain, Class declaringClass) {
if(serviceSideHandlerChain) {

@Override
public HandlerChainContainer[] getHandlerChainContainers(boolean serviceSideHandlerChain, Class declaringClass) {
if (serviceSideHandlerChain) {
EjbDescriptor[] ejbs;
if(declaringClass.isInterface()) {
if (declaringClass.isInterface()) {
ejbs = getDescriptor().getEjbBySEIName(declaringClass.getName());
} else {
ejbs = getDescriptor().getEjbByClassName(declaringClass.getName());
}
List<WebServiceEndpoint> result = new ArrayList<WebServiceEndpoint>();
List<WebServiceEndpoint> result = new ArrayList<>();
for (EjbDescriptor ejb : ejbs) {
result.addAll(getDescriptor().getWebServices().getEndpointsImplementedBy(ejb));
}
return(result.toArray(new HandlerChainContainer[result.size()]));
} else {
List<ServiceReferenceDescriptor> result = new ArrayList<ServiceReferenceDescriptor>();
result.addAll(getDescriptor().getEjbServiceReferenceDescriptors());
return(result.toArray(new HandlerChainContainer[result.size()]));
return (result.toArray(new HandlerChainContainer[result.size()]));
}
List<ServiceReferenceDescriptor> result = new ArrayList<>();
result.addAll(getDescriptor().getEjbServiceReferenceDescriptors());
return result.toArray(new HandlerChainContainer[result.size()]);
}


@Override
public ServiceReferenceContainer[] getServiceRefContainers() {
ServiceReferenceContainer[] container =
new ServiceReferenceContainer[getDescriptor().getEjbs().size()];
ServiceReferenceContainer[] ret =
(ServiceReferenceContainer[])getDescriptor().getEjbs().toArray(container);
return ret;
ServiceReferenceContainer[] container = new ServiceReferenceContainer[getDescriptor().getEjbs().size()];
return getDescriptor().getEjbs().toArray(container);
}


/**
* This methods create a context for EjbInterceptor associated to
* given className.
* This methods create a context for EjbInterceptor associated to given className.
* Return null if corresponding descriptor is not found.
*/
public AnnotatedElementHandler createContextForEjbInterceptor() {
Class interceptorClass =
(Class)this.getProcessingContext().getProcessor(
).getLastAnnotatedElement(ElementType.TYPE);
EjbInterceptor ejbInterceptor =
this.getDescriptor().getInterceptorByClassName(
interceptorClass.getName());

AnnotatedElementHandler aeHandler = null;
if (ejbInterceptor != null) {
aeHandler = new EjbInterceptorContext(ejbInterceptor);
// push a EjbInterceptorContext to stack
this.getProcessingContext().pushHandler(aeHandler);
Class<?> interceptorClass = (Class<?>) getProcessingContext().getProcessor()
.getLastAnnotatedElement(ElementType.TYPE);
EjbInterceptor ejbInterceptor = getDescriptor().getInterceptorByClassName(interceptorClass.getName());
if (ejbInterceptor == null) {
return null;
}
EjbInterceptorContext aeHandler = new EjbInterceptorContext(ejbInterceptor);
// push a EjbInterceptorContext to stack
getProcessingContext().pushHandler(aeHandler);
return aeHandler;
}
}

0 comments on commit 2e2f15f

Please sign in to comment.