Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2017-2021] [Payara Foundation and/or its affiliates]
package com.sun.enterprise.resource.deployer;
import com.sun.appserv.connectors.internal.api.ConnectorConstants;
import com.sun.appserv.connectors.internal.api.ConnectorsUtil;
import com.sun.enterprise.config.serverbeans.Resource;
import com.sun.enterprise.config.serverbeans.Resources;
import com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor;
import com.sun.logging.LogDomains;
import org.glassfish.connectors.config.AdminObjectResource;
import org.glassfish.resourcebase.resources.api.ResourceConflictException;
import org.glassfish.resourcebase.resources.api.ResourceDeployer;
import org.glassfish.resourcebase.resources.api.ResourceDeployerInfo;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.config.ConfigBeanProxy;
import org.jvnet.hk2.config.TransactionFailure;
import org.jvnet.hk2.config.types.Property;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.config.support.TranslatedConfigView;
@Service
@ResourceDeployerInfo(JMSDestinationDefinitionDescriptor.class)
public class JMSDestinationDefinitionDeployer implements ResourceDeployer {
@Inject
private Provider resourceManagerFactoryProvider;
private static Logger _logger = LogDomains.getLogger(JMSDestinationDefinitionDeployer.class, LogDomains.RSR_LOGGER);
final static String PROPERTY_PREFIX = "org.glassfish.jms-destination.";
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
//TODO ASR
}
public void deployResource(Object resource) throws Exception {
final JMSDestinationDefinitionDescriptor desc = (JMSDestinationDefinitionDescriptor) resource;
String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), desc.getResourceType());
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "JMSDestinationDefinitionDeployer.deployResource() : resource-name [" + resourceName + "]");
}
//deploy resource
MyJMSDestinationResource jmsDestinationResource = new MyJMSDestinationResource(desc, resourceName);
getDeployer(jmsDestinationResource).deployResource(jmsDestinationResource);
}
/**
* {@inheritDoc}
*/
public boolean canDeploy(boolean postApplicationDeployment, Collection allResources, Resource resource) {
if (handles(resource)) {
if (!postApplicationDeployment) {
return true;
}
}
return false;
}
/**
* {@inheritDoc}
*/
public void validatePreservedResource(com.sun.enterprise.config.serverbeans.Application oldApp,
com.sun.enterprise.config.serverbeans.Application newApp,
Resource resource,
Resources allResources)
throws ResourceConflictException {
//do nothing.
}
private ResourceDeployer getDeployer(Object resource) {
return resourceManagerFactoryProvider.get().getResourceDeployer(resource);
}
private JMSDestinationProperty convertProperty(String name, String value) {
return new JMSDestinationProperty(name, value);
}
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
//TODO ASR
}
public void undeployResource(Object resource) throws Exception {
final JMSDestinationDefinitionDescriptor desc = (JMSDestinationDefinitionDescriptor)resource;
String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(),desc.getResourceType());
if(_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "JMSDestinationDefinitionDeployer.undeployResource() : resource-name [" + resourceName + "]");
}
//undeploy resource
MyJMSDestinationResource jmsDestinationResource = new MyJMSDestinationResource(desc, resourceName);
getDeployer(jmsDestinationResource).undeployResource(jmsDestinationResource);
}
public void redeployResource(Object resource) throws Exception {
throw new UnsupportedOperationException("redeploy() not supported for jms-destination-definition type");
}
public void enableResource(Object resource) throws Exception {
throw new UnsupportedOperationException("enable() not supported for jms-destination-definition type");
}
public void disableResource(Object resource) throws Exception {
throw new UnsupportedOperationException("disable() not supported for jms-destination-definition type");
}
public boolean handles(Object resource) {
return resource instanceof JMSDestinationDefinitionDescriptor;
}
/**
* @inheritDoc
*/
public boolean supportsDynamicReconfiguration() {
return false;
}
/**
* @inheritDoc
*/
@SuppressWarnings("rawtypes")
public Class[] getProxyClassesForDynamicReconfiguration() {
return new Class[0];
}
abstract class FakeConfigBean implements ConfigBeanProxy {
public ConfigBeanProxy deepCopy(ConfigBeanProxy parent) {
throw new UnsupportedOperationException();
}
public ConfigBeanProxy getParent() {
return null;
}
public T getParent(Class tClass) {
return null;
}
public T createChild(Class tClass) throws TransactionFailure {
return null;
}
}
class JMSDestinationProperty extends FakeConfigBean implements Property {
private String name;
private String value;
private String description;
JMSDestinationProperty(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String value) throws PropertyVetoException {
this.name = value;
}
public String getValue() {
return TranslatedConfigView.expandValue(value);
}
public void setValue(String value) throws PropertyVetoException {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String value) throws PropertyVetoException {
this.description = value;
}
public void injectedInto(Object o) {
//do nothing
}
}
class MyJMSDestinationResource extends FakeConfigBean implements AdminObjectResource {
private JMSDestinationDefinitionDescriptor desc;
private String name;
public MyJMSDestinationResource(JMSDestinationDefinitionDescriptor desc, String name) {
this.desc = desc;
this.name = name;
}
@Override
public String getObjectType() {
return "user"; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void setObjectType(String value) throws PropertyVetoException {
//To change body of implemented methods use File | Settings | File Templates.
}
public String getIdentity() {
return name;
}
public String getResAdapter() {
String resourceAdapter = desc.getResourceAdapter();
if (resourceAdapter != null && !resourceAdapter.equals("")) {
return resourceAdapter;
}
return ConnectorConstants.DEFAULT_JMS_ADAPTER;
}
public void setResAdapter(String value) throws PropertyVetoException {
//do nothing
}
public String getDescription() {
return desc.getDescription();
}
public void setDescription(String value) throws PropertyVetoException {
//do nothing
}
@Override
public String getJndiName() {
return name;
}
@Override
public void setJndiName(String value) throws PropertyVetoException {
//do nothing
}
@Override
public String getResType() {
return desc.getInterfaceName();
}
@Override
public void setResType(String value) throws PropertyVetoException {
//do nothing
}
@Override
public String getClassName() {
return desc.getClassName();
}
@Override
public void setClassName(String value) throws PropertyVetoException {
//do nothing
}
@Override
public String getEnabled() {
return "true";
}
@Override
public void setEnabled(String value) throws PropertyVetoException {
//do nothing
}
public List getProperty() {
String destinationName = desc.getDestinationName();
boolean destinationNameSet = false;
List jmsDestinationProperties = new ArrayList();
if (destinationName != null && !destinationName.equals("")) {
JMSDestinationProperty dp = convertProperty("Name", destinationName);
jmsDestinationProperties.add(dp);
destinationNameSet = true;
}
Properties p = desc.getProperties();
for (Entry