use of org.jvnet.hk2.annotations.Service in project Payara by payara.
the class WebServiceRefHandler method processAWsRef.
protected HandlerProcessingResult processAWsRef(AnnotationInfo annInfo, WebServiceRef annotation) throws AnnotationProcessorException {
AnnotatedElementHandler annCtx = annInfo.getProcessingContext().getHandler();
AnnotatedElement annElem = annInfo.getAnnotatedElement();
Class annotatedType = null;
Class declaringClass = null;
InjectionTarget target = null;
String defaultServiceRefName = null;
if (annInfo.getElementType().equals(ElementType.FIELD)) {
// this is a field injection
Field annotatedField = (Field) annElem;
// check this is a valid field
if (annCtx instanceof AppClientContext) {
if (!Modifier.isStatic(annotatedField.getModifiers())) {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.injectionfieldnotstatic", "Injection fields for application clients must be declared STATIC"), annInfo);
}
}
annotatedType = annotatedField.getType();
declaringClass = annotatedField.getDeclaringClass();
defaultServiceRefName = declaringClass.getName() + "/" + annotatedField.getName();
target = new InjectionTarget();
target.setFieldName(annotatedField.getName());
target.setClassName(annotatedField.getDeclaringClass().getName());
} else if (annInfo.getElementType().equals(ElementType.METHOD)) {
// this is a method injection
Method annotatedMethod = (Method) annElem;
validateInjectionMethod(annotatedMethod, annInfo);
if (annCtx instanceof AppClientContext) {
if (!Modifier.isStatic(annotatedMethod.getModifiers())) {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.injectionmethodnotstatic", "Injection methods for application clients must be declared STATIC"), annInfo);
}
}
annotatedType = annotatedMethod.getParameterTypes()[0];
declaringClass = annotatedMethod.getDeclaringClass();
// Derive javabean property name.
String propertyName = getInjectionMethodPropertyName(annotatedMethod, annInfo);
// prefixing with fully qualified type name
defaultServiceRefName = declaringClass.getName() + "/" + propertyName;
target = new InjectionTarget();
target.setMethodName(annotatedMethod.getName());
target.setClassName(annotatedMethod.getDeclaringClass().getName());
} else if (annInfo.getElementType().equals(ElementType.TYPE)) {
// name must be specified.
if (!ok(annotation.name())) {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.nonametypelevel", "TYPE-Level annotation must specify name member."), annInfo);
}
// this is a dependency declaration, we need the service interface
// to be specified
annotatedType = annotation.type();
if (annotatedType == null || annotatedType == Object.class) {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.typenotfound", "TYPE-level annotation symbol must specify type member."), annInfo);
}
declaringClass = (Class) annElem;
} else {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.invalidtype", "annotation not allowed on this element."), annInfo);
}
MTOM mtom = null;
Addressing addressing = null;
RespectBinding respectBinding = null;
// Other annotations like SchemaValidation etc to be passed on to
// ServiceReferenceDescriptor
Map<Class<? extends Annotation>, Annotation> otherAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation a : annElem.getAnnotations()) {
if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class)))
continue;
if (a instanceof MTOM) {
mtom = (MTOM) a;
} else if (a instanceof Addressing) {
addressing = (Addressing) a;
} else if (a instanceof RespectBinding) {
respectBinding = (RespectBinding) a;
} else {
if (!otherAnnotations.containsKey(a.getClass())) {
otherAnnotations.put(a.getClass(), a);
}
}
}
String serviceRefName = !ok(annotation.name()) ? defaultServiceRefName : annotation.name();
ServiceReferenceContainer[] containers = null;
if (annCtx instanceof ServiceReferenceContainerContext) {
containers = ((ServiceReferenceContainerContext) annCtx).getServiceRefContainers();
}
if (containers == null || containers.length == 0) {
annInfo.getProcessingContext().getErrorHandler().fine(new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.invalidannotationforthisclass", "Illegal annotation symbol for this class will be ignored"), annInfo));
return HandlerProcessingResultImpl.getDefaultResult(getAnnotationType(), ResultType.PROCESSED);
}
// now process the annotation for all the containers.
for (ServiceReferenceContainer container : containers) {
ServiceReferenceDescriptor aRef = null;
try {
aRef = container.getServiceReferenceByName(serviceRefName);
}// ignore
catch (Throwable t) {
}
if (aRef == null) {
// time to create it...
aRef = new ServiceReferenceDescriptor();
aRef.setName(serviceRefName);
container.addServiceReferenceDescriptor(aRef);
}
// merge other annotations
Map<Class<? extends Annotation>, Annotation> oa = aRef.getOtherAnnotations();
if (oa == null)
aRef.setOtherAnnotations(otherAnnotations);
else {
for (Map.Entry<Class<? extends Annotation>, Annotation> entry : otherAnnotations.entrySet()) {
if (!oa.containsKey(entry.getKey()))
oa.put(entry.getKey(), entry.getValue());
}
}
// merge wsdlLocation
if (!ok(aRef.getWsdlFileUri()) && ok(annotation.wsdlLocation()))
aRef.setWsdlFileUri(annotation.wsdlLocation());
if (!aRef.hasMtomEnabled() && mtom != null) {
aRef.setMtomEnabled(mtom.enabled());
aRef.setMtomThreshold(mtom.threshold());
}
// check Addressing annotation
if (aRef.getAddressing() == null && addressing != null) {
aRef.setAddressing(new com.sun.enterprise.deployment.Addressing(addressing.enabled(), addressing.required(), addressing.responses().toString()));
}
// check RespectBinding annotation
if (aRef.getRespectBinding() == null && respectBinding != null) {
aRef.setRespectBinding(new com.sun.enterprise.deployment.RespectBinding(respectBinding.enabled()));
}
// Store mapped name that is specified
if (!ok(aRef.getMappedName()) && ok(annotation.mappedName()))
aRef.setMappedName(annotation.mappedName());
// Store lookup name that is specified
if (!aRef.hasLookupName() && ok(getLookupValue(annotation, annInfo)))
aRef.setLookupName(getLookupValue(annotation, annInfo));
aRef.setInjectResourceType("javax.jws.WebServiceRef");
if (target != null)
aRef.addInjectionTarget(target);
// Read the WebServiceClient annotation for the service name space
// uri and wsdl (if required)
WebServiceClient wsclientAnn;
// of these default values.
if (!Object.class.equals(annotation.value()) && (!javax.xml.ws.Service.class.equals(annotation.value()))) {
// port.
if (aRef.getServiceInterface() == null) {
aRef.setServiceInterface(annotation.value().getName());
}
if (aRef.getPortInfoBySEI(annotatedType.getName()) == null) {
ServiceRefPortInfo portInfo = new ServiceRefPortInfo();
portInfo.setServiceEndpointInterface(annotatedType.getName());
aRef.addPortInfo(portInfo);
}
// set the port type requested for injection
if (aRef.getInjectionTargetType() == null) {
aRef.setInjectionTargetType(annotatedType.getName());
}
wsclientAnn = (WebServiceClient) annotation.value().getAnnotation(WebServiceClient.class);
} else {
// no value provided in the annotation
wsclientAnn = (WebServiceClient) annotatedType.getAnnotation(WebServiceClient.class);
}
if (wsclientAnn == null) {
throw new AnnotationProcessorException(localStrings.getLocalString("enterprise.deployment.annotation.handlers.classnotannotated", "Class must be annotated with a {1} annotation\n symbol : {1}\n location: {0}", new Object[] { annotatedType.toString(), WebServiceClient.class.toString() }));
}
// annotation, get it from WebServiceClient annotation
if (aRef.getWsdlFileUri() == null) {
aRef.setWsdlFileUri(wsclientAnn.wsdlLocation());
}
// Set service name space URI and service local part
if (aRef.getServiceName() == null) {
aRef.setServiceNamespaceUri(wsclientAnn.targetNamespace());
aRef.setServiceLocalPart(wsclientAnn.name());
}
if (aRef.getServiceInterface() == null) {
aRef.setServiceInterface(annotatedType.getName());
}
}
// have @HandlerChain but the SEI has one specified through JAXWS customization
if (annElem.getAnnotation(javax.jws.HandlerChain.class) == null) {
return (new HandlerChainHandler()).processHandlerChainAnnotation(annInfo, annCtx, annotatedType, declaringClass, false);
}
return HandlerProcessingResultImpl.getDefaultResult(getAnnotationType(), ResultType.PROCESSED);
}
use of org.jvnet.hk2.annotations.Service in project Payara by payara.
the class RealmsManager method setDefaultDigestAlgorithm.
private void setDefaultDigestAlgorithm() {
SecurityService service = config.getSecurityService();
if (service == null) {
return;
}
List<Property> props = service.getProperty();
if (props == null) {
return;
}
Iterator<Property> propsIterator = props.iterator();
while (propsIterator != null && propsIterator.hasNext()) {
Property prop = propsIterator.next();
if (prop != null && DEFAULT_DIGEST_ALGORITHM.equals(prop.getName())) {
defaultDigestAlgorithm = prop.getValue();
break;
}
}
}
use of org.jvnet.hk2.annotations.Service in project Payara by payara.
the class EJBTimerServiceConfigListener method changed.
/**
*************************************************************************
*/
/**
* Implementation of org.jvnet.hk2.config.ConfigListener ********************
*/
/**
*************************************************************************
*/
public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
// Events that we can't process now because they require server restart.
List<UnprocessedChangeEvent> unprocessedEvents = new ArrayList<UnprocessedChangeEvent>();
for (PropertyChangeEvent event : events) {
if (event.getSource() instanceof EjbTimerService) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Got EjbTimerService change event ==== " + event.getSource() + " " + event.getPropertyName() + " " + oldValue + " " + newValue);
}
if (oldValue != null && oldValue.equals(newValue)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Event " + event.getPropertyName() + " did not change existing value of " + oldValue);
}
} else {
unprocessedEvents.add(new UnprocessedChangeEvent(event, "Restart required to reconfigure EJB Timer Service"));
}
}
}
return (unprocessedEvents.size() > 0) ? new UnprocessedChangeEvents(unprocessedEvents) : null;
}
use of org.jvnet.hk2.annotations.Service in project Payara by payara.
the class ConfigureJMSCluster method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
// Server targetServer = domain.getServerNamed(target);
// String configRef = targetServer.getConfigRef();
Cluster cluster = domain.getClusterNamed(clusterName);
if (cluster == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName", "No Cluster by this name has been configured"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
List instances = cluster.getInstances();
String warning = null;
if (instances.size() > 0) {
ActionReport listReport = habitat.getService(ActionReport.class);
ParameterMap parameters = new ParameterMap();
parameters.set("DEFAULT", clusterName);
commandRunner.getCommandInvocation("list-instances", listReport, context.getSubject()).parameters(parameters).execute();
if (ActionReport.ExitCode.FAILURE.equals(listReport.getActionExitCode())) {
warning = localStrings.getLocalString("configure.jms.cluster.clusterWithInstances", "Warning: Please make sure running this command with all cluster instances stopped, otherwise it may lead to inconsistent JMS behavior and corruption of configuration and message stores.");
} else {
String result = listReport.getMessage();
String fixedResult = result.replaceAll("not running", "stopped");
if (fixedResult.indexOf("running") > -1) {
warning = localStrings.getLocalString("configure.jms.cluster.clusterWithInstances", "Warning: Please make sure running this command with all cluster instances stopped, otherwise it may lead to inconsistent JMS behavior and corruption of configuration and message stores.");
warning = warning + "\r\n" + result + "\r\n";
}
}
}
Config config = domain.getConfigNamed(cluster.getConfigRef());
JmsService jmsService = config.getExtensionByType(JmsService.class);
if (jmsService == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.nojmsservice", "No JMS Service element in config"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (!CONVENTIONAL.equalsIgnoreCase(clusterType) && !ENHANCED.equalsIgnoreCase(clusterType)) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongClusterType", "Invalid option sepecified for clustertype. Valid options are conventional and enhanced"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (CONVENTIONAL.equalsIgnoreCase(clusterType) && !MASTER_BROKER.equalsIgnoreCase(configStoreType) && !SHARED_DB.equalsIgnoreCase(configStoreType)) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongConfigStoreType", "Invalid option sepecified for configstoretype. Valid options are masterbroker and shareddb"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (ENHANCED.equalsIgnoreCase(clusterType) && configStoreType != null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongStoreType", "configstoretype option is not configurable for Enhanced clusters."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (CONVENTIONAL.equalsIgnoreCase(clusterType) && !MASTER_BROKER.equalsIgnoreCase(configStoreType) && !FILE.equalsIgnoreCase(messageStoreType) && !JDBC.equalsIgnoreCase(messageStoreType)) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongMessageStoreType", "Invalid option sepecified for messagestoretype. Valid options are file and jdbc"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (ENHANCED.equalsIgnoreCase(clusterType) && messageStoreType != null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongmsgStoreType", "messagestoretype option is not configurable for Enhanced clusters."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
String integrationMode = jmsService.getType();
if (REMOTE.equalsIgnoreCase(integrationMode)) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.remoteMode", "JMS integration mode should be either EMBEDDED or LOCAL to run this command. Please use the asadmin.set command to change the integration mode"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
String changeIntegrationMode = null;
if (EMBEDDED.equalsIgnoreCase(integrationMode) && ENHANCED.equalsIgnoreCase(clusterType)) {
try {
ConfigSupport.apply(new SingleConfigCode<JmsService>() {
public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
param.setType(LOCAL);
return param;
}
}, jmsService);
changeIntegrationMode = localStrings.getLocalString("configure.jms.cluster.integrationModeChanged", "WARNING: JMS integration mode has been changed from EMBEDDED to LOCAL automatically.");
} catch (TransactionFailure tfe) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.cannotChangeIntegrationMode", "Unable to change the JMS integration mode to LOCAL for Enhanced cluster {0}.", clusterName) + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
return;
}
}
if (MASTER_BROKER.equalsIgnoreCase(configStoreType) && FILE.equals(messageStoreType)) {
if (dbvendor != null || dburl != null || dbuser != null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidDboptions", "Database options should not be specified for this configuration"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
if (!MASTER_BROKER.equalsIgnoreCase(configStoreType) || ENHANCED.equalsIgnoreCase(clusterType) || JDBC.equalsIgnoreCase(messageStoreType)) {
if (dbvendor == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.nodbvendor", "No DataBase vendor specified"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
} else if (dburl == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.nojdbcurl", "No JDBC URL specified"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
} else if (!isSupportedDbVendor()) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.invaliddbvendor", "Invalid DB Vednor specified"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
}
if (CONVENTIONAL.equalsIgnoreCase(clusterType) && configStoreType == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.noConfigStoreType", "No configstoretype specified. Using the default value - masterbroker"));
configStoreType = "masterbroker";
}
if (CONVENTIONAL.equalsIgnoreCase(clusterType) && messageStoreType == null) {
report.setMessage(localStrings.getLocalString("configure.jms.cluster.noMessagetoreType", "No messagestoretype specified. Using the default value - file"));
messageStoreType = "file";
}
config = domain.getConfigNamed(cluster.getConfigRef());
JmsAvailability jmsAvailability = config.getAvailabilityService().getExtensionByType(JmsAvailability.class);
final Boolean availabilityEnabled = Boolean.valueOf(ENHANCED.equalsIgnoreCase(clusterType));
try {
ConfigSupport.apply(new SingleConfigCode<JmsAvailability>() {
public Object run(JmsAvailability param) throws PropertyVetoException, TransactionFailure {
param.setAvailabilityEnabled(availabilityEnabled.toString());
if (availabilityEnabled.booleanValue()) {
param.setMessageStoreType(JDBC);
} else {
param.setConfigStoreType(configStoreType.toLowerCase(Locale.ENGLISH));
param.setMessageStoreType(messageStoreType.toLowerCase(Locale.ENGLISH));
}
param.setDbVendor(dbvendor);
param.setDbUsername(dbuser);
param.setDbPassword(jmsDbPassword);
param.setDbUrl(dburl);
if (props != null) {
for (Map.Entry e : props.entrySet()) {
Property prop = param.createChild(Property.class);
prop.setName((String) e.getKey());
prop.setValue((String) e.getValue());
param.getProperty().add(prop);
}
}
return param;
}
}, jmsAvailability);
/* //update the useMasterBroker flag on the JmsService only if availabiltyEnabled is false
if(!availabilityEnabled.booleanValue()){
ConfigSupport.apply(new SingleConfigCode<JmsService>() {
public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
param.setUseMasterBroker(useMasterBroker.toString());
return param;
}
}, jmsservice);
}*/
} catch (TransactionFailure tfe) {
report.setMessage((changeIntegrationMode == null ? "" : changeIntegrationMode + "\n") + localStrings.getLocalString("configure.jms.cluster.fail", "Unable to Configure JMS Cluster for cluster {0}.", clusterName) + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
report.setMessage((warning == null ? "" : warning + "\n") + (changeIntegrationMode == null ? "" : changeIntegrationMode + "\n") + localStrings.getLocalString("configure.jms.cluster.success", "JMS Cluster Configuration updated for Cluster {0}.", clusterName));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.jvnet.hk2.annotations.Service in project Payara by payara.
the class ChangeMasterBrokerCommand method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
final String newMB = newMasterBroker;
Server newMBServer = domain.getServerNamed(newMasterBroker);
if (newMBServer == null) {
report.setMessage(localStrings.getLocalString("change.master.broker.invalidServerName", "Invalid server name specified. There is no server by this name"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// domain.getClusterNamed(clusterName);
Cluster cluster = newMBServer.getCluster();
if (cluster == null) {
report.setMessage(localStrings.getLocalString("change.master.broker.invalidClusterName", "The server specified is not associated with a cluster. The server assocaited with the master broker has to be a part of the cluster"));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
/*if(!cluster.getName().equals(newMBServer.getCluster().getName()))
{
report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName",
"{0} does not belong to the specified cluster", newMasterBroker));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
} */
Nodes nodes = domain.getNodes();
config = domain.getConfigNamed(cluster.getConfigRef());
JmsService jmsservice = config.getExtensionByType(JmsService.class);
Server oldMBServer = null;
// Else use the first configured instance in the cluster list
if (jmsservice.getMasterBroker() != null) {
oldMBServer = domain.getServerNamed(jmsservice.getMasterBroker());
} else {
List<Server> serverList = cluster.getInstances();
// if(serverList == null || serverList.size() == 0){
// report.setMessage(localStrings.getLocalString("change.master.broker.invalidCluster",
// "No servers configured in cluster {0}", clusterName));
// report.setActionExitCode(ActionReport.ExitCode.FAILURE);
// return;
// }
oldMBServer = serverList.get(0);
}
String oldMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(oldMBServer);
if (oldMasterBrokerPort == null) {
SystemProperty sp = config.getSystemProperty("JMS_PROVIDER_PORT");
if (sp != null)
oldMasterBrokerPort = sp.getValue();
}
if (oldMasterBrokerPort == null)
oldMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
String oldMasterBrokerHost = nodes.getNode(oldMBServer.getNodeRef()).getNodeHost();
String newMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(newMBServer);
if (newMasterBrokerPort == null)
newMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
String newMasterBrokerHost = nodes.getNode(newMBServer.getNodeRef()).getNodeHost();
String oldMasterBroker = oldMasterBrokerHost + ":" + oldMasterBrokerPort;
String newMasterBroker = newMasterBrokerHost + ":" + newMasterBrokerPort;
// System.out.println("1: IN deleteinstanceCheck supplimental oldMasterBroker = " + oldMasterBroker + " newmasterBroker " + newMasterBroker);
try {
CompositeData result = updateMasterBroker(oldMBServer.getName(), oldMasterBroker, newMasterBroker);
boolean success = ((Boolean) result.get("Success")).booleanValue();
if (!success) {
int statusCode = ((Integer) result.get("StatusCode")).intValue();
String detailMessage = (String) result.get("DetailMessage");
String msg = " " + detailMessage;
if (BrokerStatusCode.BAD_REQUEST.getCode() == statusCode || BrokerStatusCode.NOT_ALLOWED.getCode() == statusCode || BrokerStatusCode.UNAVAILABLE.getCode() == statusCode || BrokerStatusCode.PRECONDITION_FAILED.getCode() == statusCode) {
msg = localStrings.getLocalString("change.master.broker.errorMsg", "{0}. But it didn't affect current master broker configuration.", msg);
} else {
msg = msg + ". " + localStrings.getLocalString("change.master.broker.otherErrorMsg", "The cluster should be shutdown and configured with the new master broker then restarts.");
}
report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB", "Unable to change master broker.{0}", msg));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB", "Unable to change master broker.{0}", ""));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
/*String setCommandStr = cluster.getConfigRef() + "." + "jms-service" + "." +"master-Broker";
ParameterMap parameters = new ParameterMap();
parameters.set(setCommandStr, newMB );
ActionReport subReport = report.addSubActionsReport();
commandRunner.getCommandInvocation("set", subReport, context.getSubject()).parameters(parameters).execute();
if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){
report.setMessage(localStrings.getLocalString("create.jms.resource.cannotCreateConnectionPool",
"Unable to create connection pool."));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}*/
ConfigSupport.apply(new SingleConfigCode<JmsService>() {
public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
param.setMasterBroker(newMB);
return param;
}
}, jmsservice);
} catch (Exception tfe) {
report.setMessage(localStrings.getLocalString("change.master.broker.fail", "Unable to update the domain.xml with the new master broker") + " " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
}
report.setMessage(localStrings.getLocalString("change.master.broker.success", "Master broker change has executed successfully for Cluster {0}.", cluster.getName()));
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Aggregations