-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- more concrete API Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Loading branch information
Showing
32 changed files
with
1,016 additions
and
1,865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...ent-impl/src/main/java/org/glassfish/concurrent/runtime/deployer/ConcurrencyDeployer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* Copyright (c) 2022 Eclipse Foundation 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.concurrent.runtime.deployer; | ||
|
||
import com.sun.appserv.connectors.internal.api.ConnectorsUtil; | ||
import com.sun.enterprise.config.serverbeans.Application; | ||
import com.sun.enterprise.config.serverbeans.Resource; | ||
import com.sun.enterprise.config.serverbeans.Resources; | ||
import com.sun.enterprise.deployment.ResourceDescriptor; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import java.util.Collection; | ||
|
||
import org.glassfish.api.invocation.ComponentInvocation; | ||
import org.glassfish.api.invocation.InvocationManager; | ||
import org.glassfish.deployment.common.JavaEEResourceType; | ||
import org.glassfish.resourcebase.resources.api.ResourceConflictException; | ||
import org.glassfish.resourcebase.resources.api.ResourceDeployer; | ||
import org.glassfish.resourcebase.resources.api.ResourceInfo; | ||
|
||
import static com.sun.appserv.connectors.internal.api.ConnectorsUtil.deriveResourceName; | ||
|
||
/** | ||
* @param <D> {@link ResourceDescriptor} managed by this class. | ||
* | ||
* @author David Matejcek | ||
*/ | ||
public abstract class ConcurrencyDeployer<D extends ResourceDescriptor> implements ResourceDeployer<D> { | ||
|
||
@Inject | ||
private InvocationManager invocationManager; | ||
|
||
/** | ||
* Returns false - cannot be deployed before application. | ||
*/ | ||
@Override | ||
public final boolean canDeploy(boolean postApplicationDeployment, Collection<Resource> allResources, Resource resource) { | ||
return false; | ||
} | ||
|
||
|
||
/** | ||
* Does nothing | ||
*/ | ||
@Override | ||
public final void validatePreservedResource(Application oldApp, Application newApp, Resource resource, | ||
Resources allResources) throws ResourceConflictException { | ||
// FIXME: remove finals | ||
} | ||
|
||
|
||
/** | ||
* Same as {@link #deployResource(Object)} | ||
*/ | ||
@Override | ||
public final void enableResource(D resource) throws Exception { | ||
deployResource(resource); | ||
} | ||
|
||
|
||
/** | ||
* Same as {@link #undeployResource(Object)} | ||
*/ | ||
@Override | ||
public final void disableResource(D resource) throws Exception { | ||
undeployResource(resource); | ||
} | ||
|
||
|
||
/** | ||
* Create {@link ResourceInfo} instance. | ||
* Resource name is resolved by {@link ConnectorsUtil#deriveResourceName(String, String, JavaEEResourceType)} | ||
* | ||
* @param descriptor | ||
* @param applicatioName | ||
* @param moduleName | ||
* @return {@link ResourceInfo} | ||
*/ | ||
protected ResourceInfo toResourceInfo(final D descriptor, String applicatioName, String moduleName) { | ||
return new ResourceInfo(toResourceName(descriptor), applicatioName, moduleName); | ||
} | ||
|
||
|
||
/** | ||
* Create {@link ResourceInfo} instance. | ||
* Resource name is resolved by {@link ConnectorsUtil#deriveResourceName(String, String, JavaEEResourceType)} | ||
* | ||
* @param descriptor | ||
* @return {@link ResourceInfo} | ||
*/ | ||
protected ResourceInfo toResourceInfo(final D descriptor) { | ||
ComponentInvocation invocation = invocationManager.getCurrentInvocation(); | ||
return new ResourceInfo(toResourceName(descriptor), invocation.getAppName(), invocation.getModuleName()); | ||
} | ||
|
||
|
||
protected String toResourceName(D descriptor) { | ||
return deriveResourceName(descriptor.getResourceId(), descriptor.getJndiName(), descriptor.getResourceType()); | ||
} | ||
} |
Oops, something went wrong.