Skip to content

Commit

Permalink
Refactoring in DOL + consequences
Browse files Browse the repository at this point in the history
- main target: generic collections, cleanup

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 6ac8d0f commit 36a75ce
Show file tree
Hide file tree
Showing 94 changed files with 2,181 additions and 2,084 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Contributors to Eclipse Foundation.
* Copyright (c) 2021, 2022 Contributors to 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
Expand All @@ -17,18 +17,6 @@

package org.glassfish.appclient.client.acc;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.naming.NamingException;

import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.manager.api.WeldManager;
import org.jvnet.hk2.annotations.Service;

import com.sun.enterprise.container.common.spi.CDIService;
import com.sun.enterprise.container.common.spi.InterceptorInvoker;
import com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilder;
Expand All @@ -46,6 +34,18 @@
import jakarta.inject.Inject;
import jakarta.servlet.ServletContext;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.naming.NamingException;

import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
import org.jboss.weld.manager.api.WeldManager;
import org.jvnet.hk2.annotations.Service;

/**
* @author <a href="mailto:phil.zampino@oracle.com">Phil Zampino</a>
*/
Expand Down Expand Up @@ -107,7 +107,6 @@ private <T> T createEEManagedObject(ManagedBeanDescriptor managedBeanDescriptor)
}

@Override
@SuppressWarnings("unchecked")
public CDIInjectionContext createManagedObject(Class managedClass, BundleDescriptor bundle, boolean invokePostConstruct) {
Object managedObject = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import com.sun.enterprise.deployment.BundleDescriptor;
import com.sun.enterprise.deployment.EjbBundleDescriptor;
import com.sun.enterprise.deployment.EjbDescriptor;
import com.sun.enterprise.deployment.InterceptorDescriptor;
import com.sun.enterprise.deployment.JndiNameEnvironment;
import com.sun.enterprise.deployment.ManagedBeanDescriptor;
import com.sun.enterprise.deployment.WebBundleDescriptor;
Expand Down Expand Up @@ -199,7 +200,7 @@ public void loadManagedBeans(Application app) {
interceptorInfo.setHasTargetClassAroundInvoke(true);
}

Map<Method, List> interceptorChains = new HashMap<>();
Map<Method, List<InterceptorDescriptor>> interceptorChains = new HashMap<>();
for (Method targetMethod : targetClass.getMethods()) {
interceptorChains.put(targetMethod, managedBeanDescriptor.getAroundInvokeInterceptors(targetMethod));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/**
* Provides an abstraction for invoking jakarta.interceptor callbacks and around invoke methods on a target instance.
*/

public interface JavaEEInterceptorBuilder {

InterceptorInvoker createInvoker(Object targetInstance) throws Exception;
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,9 +20,13 @@

import com.sun.enterprise.deployment.InterceptorDescriptor;

import java.util.*;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
*/
Expand All @@ -32,17 +37,17 @@ public class InterceptorInfo {
private List postConstructInterceptors = new LinkedList();
private List preDestroyInterceptors = new LinkedList();

private Map<Method, List> aroundInvokeChains = new HashMap<Method, List>();
private Map<Method, List<InterceptorDescriptor>> aroundInvokeChains = new HashMap<>();

private Set<String> interceptorClassNames = new HashSet<String>();
private Set<String> interceptorClassNames = new HashSet<>();

// True if a system interceptor needs to be added dynamically
private boolean supportRuntimeDelegate;

private Object targetObjectInstance;
private Class targetClass;
private Class<?> targetClass;

private boolean hasTargetClassAroundInvoke = false;
private boolean hasTargetClassAroundInvoke;

public void setTargetObjectInstance(Object instance) {
targetObjectInstance = instance;
Expand All @@ -52,11 +57,11 @@ public Object getTargetObjectInstance() {
return targetObjectInstance;
}

public void setTargetClass(Class targetClass) {
public void setTargetClass(Class<?> targetClass) {
this.targetClass = targetClass;
}

public Class getTargetClass() {
public Class<?> getTargetClass() {
return this.targetClass;
}

Expand Down Expand Up @@ -85,15 +90,15 @@ public List getPreDestroyInterceptors() {
}

public void setInterceptorClassNames(Set<String> names) {
interceptorClassNames = new HashSet<String>(names);
interceptorClassNames = new HashSet<>(names);
}

public Set<String> getInterceptorClassNames() {
return interceptorClassNames;
}

public void setAroundInvokeInterceptorChains(Map<Method, List> chains) {
aroundInvokeChains = new HashMap<Method, List>(chains);
public void setAroundInvokeInterceptorChains(Map<Method, List<InterceptorDescriptor>> chains) {
aroundInvokeChains = new HashMap<>(chains);
}


Expand All @@ -106,8 +111,7 @@ public boolean getHasTargetClassAroundInvoke() {
}


public List getAroundInvokeInterceptors(Method m) {

public List<InterceptorDescriptor> getAroundInvokeInterceptors(Method m) {
return aroundInvokeChains.get(m);
}

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, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,29 +17,31 @@

package com.sun.enterprise.resource.allocator;

import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.PoolingException;
import com.sun.enterprise.connectors.ConnectorRuntime;
import com.sun.enterprise.deployment.ConnectorDescriptor;
import com.sun.enterprise.resource.AssocWithThreadResourceHandle;
import com.sun.enterprise.resource.ClientSecurityInfo;
import com.sun.enterprise.resource.ResourceHandle;
import com.sun.enterprise.resource.ResourceSpec;
import com.sun.enterprise.resource.AssocWithThreadResourceHandle;
import com.sun.enterprise.resource.pool.PoolManager;
import com.sun.enterprise.connectors.ConnectorRuntime;
import com.sun.appserv.connectors.internal.api.PoolingException;
import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.logging.LogDomains;

import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.ManagedConnectionFactory;
import jakarta.resource.spi.ValidatingManagedConnectionFactory;
import javax.security.auth.Subject;

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

import javax.security.auth.Subject;


/**
* An abstract implementation of the <code>ResourceAllocator</code> interface
Expand Down Expand Up @@ -81,6 +84,7 @@ public AbstractConnectorAllocator(PoolManager poolMgr,

}

@Override
public Set getInvalidConnections(Set connectionSet)
throws ResourceException {
if (mcf instanceof ValidatingManagedConnectionFactory) {
Expand All @@ -90,9 +94,10 @@ public Set getInvalidConnections(Set connectionSet)
return null;
}

@Override
public boolean isConnectionValid(ResourceHandle h) {
HashSet conn = new HashSet();
conn.add(h.getResource());
HashSet<ManagedConnection> conn = new HashSet<>();
conn.add((ManagedConnection) h.getResource());
Set invalids = null;
try {
invalids = getInvalidConnections(conn);
Expand All @@ -118,21 +123,25 @@ public boolean isConnectionValid(ResourceHandle h) {
return true;
}

@Override
public void destroyResource(ResourceHandle resourceHandle)
throws PoolingException {
throw new UnsupportedOperationException();
}

@Override
public void fillInResourceObjects(ResourceHandle resourceHandle)
throws PoolingException {
throw new UnsupportedOperationException();
}


@Override
public boolean isTransactional() {
return true;
}

@Override
public void cleanup(ResourceHandle h) throws PoolingException {
try {
ManagedConnection mc = (ManagedConnection) h.getResource();
Expand All @@ -143,18 +152,19 @@ public void cleanup(ResourceHandle h) throws PoolingException {
}
}

@Override
public boolean matchConnection(ResourceHandle h) {
Set set = new HashSet();
set.add(h.getResource());
Set<ManagedConnection> set = new HashSet<>();
set.add((ManagedConnection) h.getResource());
try {
ManagedConnection mc =
mcf.matchManagedConnections(set, subject, reqInfo);
return (mc != null);
ManagedConnection mc = mcf.matchManagedConnections(set, subject, reqInfo);
return mc != null;
} catch (ResourceException ex) {
return false;
}
}

@Override
public void closeUserConnection(ResourceHandle resource) throws PoolingException {

try {
Expand All @@ -165,10 +175,12 @@ public void closeUserConnection(ResourceHandle resource) throws PoolingException
}
}

@Override
public boolean shareableWithinComponent() {
return false;
}

@Override
public Object getSharedConnection(ResourceHandle h)
throws PoolingException {
throw new UnsupportedOperationException();
Expand All @@ -190,6 +202,7 @@ protected ResourceHandle createResourceHandle(Object resource, ResourceSpec spec
}
}

@Override
public boolean hasValidatingMCF() {
return mcf instanceof ValidatingManagedConnectionFactory;
}
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, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,45 +17,40 @@

package com.sun.enterprise.resource.allocator;

import com.sun.enterprise.resource.ResourceHandle;
import com.sun.appserv.connectors.internal.api.PoolingException;
import com.sun.enterprise.resource.ResourceHandle;

import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnection;

import java.util.Set;

/**
* @author Tony Ng
*/
public interface ResourceAllocator {

public ResourceHandle createResource()
throws PoolingException;

public void fillInResourceObjects(ResourceHandle resource)
throws PoolingException;
ResourceHandle createResource() throws PoolingException;

public void closeUserConnection(ResourceHandle resource)
throws PoolingException;
void fillInResourceObjects(ResourceHandle resource) throws PoolingException;

public void destroyResource(ResourceHandle resource)
throws PoolingException;
void closeUserConnection(ResourceHandle resource) throws PoolingException;

public boolean matchConnection(ResourceHandle h);
void destroyResource(ResourceHandle resource) throws PoolingException;

boolean matchConnection(ResourceHandle h);

public boolean isTransactional();
boolean isTransactional();

public void cleanup(ResourceHandle resource) throws PoolingException;
void cleanup(ResourceHandle resource) throws PoolingException;

public boolean shareableWithinComponent();
boolean shareableWithinComponent();

public Object getSharedConnection(ResourceHandle h)
throws PoolingException;
Object getSharedConnection(ResourceHandle h) throws PoolingException;

public Set getInvalidConnections(Set connectionSet)
throws ResourceException;
Set<ManagedConnection> getInvalidConnections(Set<ManagedConnection> connectionSet) throws ResourceException;

public boolean isConnectionValid(ResourceHandle resource);
boolean isConnectionValid(ResourceHandle resource);

public boolean hasValidatingMCF();
boolean hasValidatingMCF();
}

0 comments on commit 36a75ce

Please sign in to comment.