Grails JMS Plugin to WebLogic JMS Server - grails

Has anyone configured Grails 2.x JMS Plugin to send/receive messages to a remote WebLogic JMS Server? I've tried resources.groovy configurations like this with no luck:
jmsConnectionFactory(InitialContext, [
"INITIAL_CONTEXT_FACTORY": "weblogic.jndi.WLInitialContextFactory",
"PROVIDER_URL": "t3://remote-host:7001",
"SECURITY_PRINCIPAL": "weblogic",
"SECURITY_CREDENTIALS": "weblogic"])

Not much resources with complete answers are on net about sending/receiving JMS in Grails with remote Weblogic server, so I figured out 2-3 years ago a working solution, without need of any plugins.
Make sure that at least Weblogic wlthint3client.jar is in lib directory.
Setting up JMS listener:
in conf/spring/resources.groovy:
// Weblogic's JMS setup on Grails
jndiTemplate(org.springframework.jndi.JndiTemplate) {
environment = [
"java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory",
"java.naming.provider.url" : "t3://host.name.mustbe.same.as.configured.on.server.side:port_number",
"java.naming.security.principal" : "wlsadmin",
"java.naming.security.credentials": "password"
]
}
//
// listener
//
jmsListenerConnectionFactory(org.springframework.jndi.JndiObjectFactoryBean) {
jndiTemplate = ref(jndiTemplate)
jndiName = "jms.checkonserver.QueueConnectionFactory"
}
jmsListenerDestinationResolver(org.springframework.jms.support.destination.JndiDestinationResolver) {
jndiTemplate = ref(jndiTemplate)
cache = false
}
userListenerCredentialsConnectionFactory(org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter){
targetConnectionFactory = ref(jmsListenerConnectionFactory)
}
standardListenerJmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = ref(userListenerCredentialsConnectionFactory)
destinationResolver = ref(jmsListenerDestinationResolver)
}
jmsListenerMessageListener(org.springframework.jms.listener.adapter.MessageListenerAdapter, ref("myListenerService")) {
defaultListenerMethod = "onMessage"
}
standardListenerJmsListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
connectionFactory = ref(jmsListenerConnectionFactory)
destinationResolver = ref(jmsListenerDestinationResolver)
messageListener = jmsListenerMessageListener
destinationName = "jms.checkonserver.MessagesQueue"
}
in services/myListenerService.groovy:
package app
class MyListenerService {
static transactional = false
static scope = "prototype"
def onMessage(msg) {
log.info "JMS msg received."
try {
String txtmsg = new String(msg as String)
log.info txtmsg
} catch (e) {
log.error e
}
}
}
Setting up JMS sender :
in conf/spring/resources.groovy:
jmsSenderConnectionFactory( org.springframework.jndi.JndiObjectFactoryBean) {
jndiTemplate = ref(jndiTemplate)
jndiName = "jms.checkonseerver.QueueConnectionFactory"
}
jmsSenderDestinationResolver(org.springframework.jms.support.destination.JndiDestinationResolver) {
jndiTemplate = ref(jndiTemplate)
cache = false
}
userSenderCredentialsConnectionFactory(org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter){
targetConnectionFactory = ref(jmsSenderConnectionFactory)
}
standardSenderJmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = ref(userSenderCredentialsConnectionFactory) //
destinationResolver = ref(jmsSenderDestinationResolver)
}
in service/myJmsSenderService.groovy:
package app
import org.springframework.jms.core.MessageCreator
import javax.jms.JMSException
import javax.jms.Message
import javax.jms.Session
class MyJmsSenderService {
static transactional = false
static scope = "prototype"
def standardSenderJmsTemplate
def sendMessage(txt) {
MessageCreator messageCreator = new MessageCreator() {
public Message createMessage(Session session) throws
JMSException {
return session.createTextMessage(txt)
}
}
standardSenderJmsTemplate.send( "jms.checkonserver.SendingQueue", messageCreator)
log.info "JMS message send: ${txt}"
}
}

Related

How to properly update Android BillingFlowParams sku() to setSkuDetails()

here is the code can anyone tell how can I setSkuDetails()
as I was using vision one now I update it to 4
However, setSku and setType seem to be deprecated in the BillingFlowParams.Builder class. Instead, we should be using setSkuDetails(SkuDetails).
private void BillingFunction() {
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
// Establish connection to billing client
mBillingClient = BillingClient.newBuilder(MainActivity.this).setListener(MainActivity.this).build();
mBillingClient.startConnection(new BillingClientStateListener() {
#Override
public void onBillingSetupFinished(#NonNull BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// The billing client is ready. You can query purchases here.
getPricesMonthlyTime();
getPricesYearlyTime();
getPricesONeTime();
}
}
#Override
public void onBillingServiceDisconnected() {
//TODO implement your own retry policy
Toast.makeText(MainActivity.this, getResources().getString(R.string.billing_connection_failure), Toast.LENGTH_SHORT);
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
continue_button.setOnClickListener(view -> {
if (select_radio_one.getVisibility() == View.VISIBLE) {
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails()
.build();
BillingResult responseCode = mBillingClient.launchBillingFlow(MainActivity.this, flowParams);
brandDialogInAppPurchase.dismiss();
} else if (select_radio_two.getVisibility() == View.VISIBLE) {
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails()
.build();
BillingResult responseCode = mBillingClient.launchBillingFlow(MainActivity.this, flowParams);
brandDialogInAppPurchase.dismiss();
} else if (select_radio_three.getVisibility() == View.VISIBLE) {
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails()
.build();
BillingResult responseCode = mBillingClient.launchBillingFlow(MainActivity.this, flowParams);
brandDialogInAppPurchase.dismiss();
} else {
Toast.makeText(MainActivity.this, "Nothing selected", Toast.LENGTH_SHORT).show();
}
});
// queryPrefPurchases();
queryPurchases();
}
You should send the object skuDetail.
To do so you need to retrieve it by calling querySkuDetailsAsync().
fun querySkuDetails() {
val skuList = ArrayList<String>()
skuList.add("premium_upgrade")
skuList.add("gas")
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(SkuType.INAPP)
// leverage querySkuDetails Kotlin extension function
val skuDetailsResult = withContext(Dispatchers.IO) {
billingClient.querySkuDetails(params.build())
}
// Process the result.
}

How to replace Servlet Filters already defined (replacing legacy doWithWebDescriptor with doWithSpring)

I'm trying to upgrade a Grails plugin from version 2.3.4 to 4.0.11. It uses a syntax that is no longer supported to replace filters with names sitemesh and urlMapping with its own filters.
The code below uses a DSL for xml. It replaces xml nodes in the final generated web.xml.
def doWithWebDescriptor = { xml ->
def pageFilter = xml.filter.find { it.'filter-name'.text() == 'sitemesh' }
def urlMappingFilter = xml.filter.find { it.'filter-name'.text() == 'urlMapping' }
def grailsVersion = GrailsUtil.grailsVersion
// Grails 1.3.x & Grails 2.0.x
def pageFilterClass = "org.zkoss.zk.grails.web.ZKGrailsPageFilter"
def urlMappingFilterClass = "org.zkoss.zk.grails.web.ZULUrlMappingsFilter"
if(grailsVersion.startsWith("2")) {
pageFilter.'filter-class'.replaceNode {
'filter-class'(pageFilterClass)
}
urlMappingFilter.'filter-class'.replaceNode {
'filter-class'(urlMappingFilterClass)
}
//
// Require a legacy config for servlet version
//
if(application.metadata.getServletVersion() >= '3.0') {
pageFilter.'filter-class' + {
'async-supported'('true')
}
urlMappingFilter.'filter-class' + {
'async-supported'('true')
}
}
} else {
pageFilter.'filter-class'.replaceBody(pageFilterClass)
urlMappingFilter.'filter-class'.replaceBody(urlMappingFilterClass)
}
}
What I tried so far
The code below uses Grails plugin configuration to register filters with spring's FilterRegistrationBean. I'm following Grails official documentation.
Closure doWithSpring() { { ->
boolean supportsAsync = this.grailsApplication.metadata.getServletVersion() >= "3.0"
pageFilter(FilterRegistrationBean) {
name = "sitemesh"
filter = bean(org.zkoss.zk.grails.web.ZKGrailsPageFilter)
urlPatterns = ["/*"]
order = Ordered.HIGHEST_PRECEDENCE
asyncSupported = supportsAsync
}
urlMappingFilter(FilterRegistrationBean) {
name = "urlMapping"
filter = bean(org.zkoss.zk.grails.web.ZULUrlMappingsFilter)
urlPatterns = ["/*"]
order = Ordered.HIGHEST_PRECEDENCE
asyncSupported = supportsAsync
}
}}
How can I replicate the legacy code with RegistrationBeans?
Also, I don't know if any of these filters got deprecated by Grails. I would like to know if there are any other replacements, if possible.
Here's the project in case anyone wants more context.
Debugging the older version of the plugin I came up with the following:
pageFilter(FilterRegistrationBean) {
name = "sitemesh"
filter = bean(ZKGrailsPageFilter)
urlPatterns = ["/*"]
order = OrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER + 50
asyncSupported = supportsAsync
dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR)
}
urlMappingFilter(FilterRegistrationBean) {
name = "urlMapping"
filter = bean(ZULUrlMappingsFilter)
urlPatterns = ["/*"]
order = OrderedFilter.REQUEST_WRAPPER_FILTER_MAX_ORDER + 60
asyncSupported = supportsAsync
dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD)
}
Added the dispatcherTypes and changed the order assuming these would be the last filters where the 'pageFilter' should be placed before the 'urlMappingFilter' in the filter chain.

Installing Umbraco programmatically

I'm trying to install Umbraco without using the visual interface, in order to increase my productivity.
Currently my code looks like this:
var installApiController = new InstallApiController();
var installSetup = installApiController.GetSetup();
var instructions = new Dictionary<string, JToken>();
var databaseModel = new DatabaseModel
{
DatabaseType = DatabaseType.SqlCe
};
var userModel = new UserModel
{
Email = "my#email.com",
Name = "My name",
Password = "somepassword",
SubscribeToNewsLetter = false
};
foreach (var step in installSetup.Steps)
{
if (step.StepType == typeof(DatabaseModel))
{
instructions.Add(step.Name, JToken.FromObject(databaseModel));
}
else if (step.StepType == typeof(UserModel))
{
instructions.Add(step.Name, JToken.FromObject(userModel));
}
}
var installInstructions = new InstallInstructions
{
InstallId = installSetup.InstallId,
Instructions = instructions
};
InstallProgressResultModel progressInfo = null;
do
{
string stepName = "";
if (progressInfo != null)
{
stepName = progressInfo.NextStep;
}
try
{
progressInfo = installApiController.PostPerformInstall(installInstructions);
}
catch (Exception e)
{
throw new Exception(stepName, e);
}
}
while (progressInfo.ProcessComplete == false);
The code fails at this line: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7.8/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs#L47, and I believe it's because the ApplicationContext isnt updated for each of the installation steps (e.g. not updated after the database is created).
Is it possible to update the ApplicationContext manually after each step in the installation progress, or do I have to trigger all installation steps in separate HTTP requests?
The code works, if I run each step in separate HTTP requests.

Xtext project JDT Independence

I created editor with Xtext 2.9.1 and now I want to make it independent of JDT. I followed this guide https://eclipse.org/Xtext/documentation/307_special_languages.html
but it does not seem to work. This is my ErrmsgUiModule.xtend
#FinalFieldsConstructor
class ErrmsgUiModule extends AbstractErrmsgUiModule {
override configure(Binder binder) {
super.configure(binder);
binder.bind(DefaultHighlightingConfiguration).to(ErrMsgHighlightingConfiguration);
binder.bind(DefaultSemanticHighlightingCalculator).to(ErrorSemanticHighlightingCalculator);
}
override bindIResourceForEditorInputFactory() {
return ResourceForIEditorInputFactory
}
override bindIResourceSetProvider() {
return SimpleResourceSetProvider
}
override provideIAllContainersState() {
return Access.getWorkspaceProjectsState()
}
}
I checked every overwritten method with debugger and all 3 methods are called. I did not created my own project wizard so this should be enough.
But still after plugin installating the Java project wizard becomes available...
/Edit:
To provide more information, this is project's mwe2 file
module com.xxx.lang.errmsg.GenerateErrmsg
import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*
import org.eclipse.xtext.ui.generator.*
var rootPath = ".."
Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "com.xxx.lang.errmsg"
rootPath = rootPath
runtimeTest = {
enabled = true
}
eclipsePlugin = {
enabled = true
}
eclipsePluginTest = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "windows-1250"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "com.xxx.lang.errmsg.Errmsg"
fileExtensions = "msg"
fragment = formatting.Formatter2Fragment2 auto-inject {}
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
}
}
}
and this is list of Dependencies from plugin.xml for various projects:
project com.xxx.lang.errmsg
org.eclipse.xtext,
org.eclipse.xtext.xbase,
org.eclipse.equinox.common;bundle-version="3.5.0",
org.eclipse.emf.ecore,
org.eclipse.xtext.xbase.lib,
org.antlr.runtime,
org.eclipse.xtext.util,
org.eclipse.xtend.lib,
org.eclipse.emf.common,
org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional,
org.eclipse.xtext.ui
project com.xxx.lang.errmsg.ui
com.xxx.lang.errmsg,
com.xxx.lang.errmsg.ide,
org.eclipse.xtext.ui,
org.eclipse.xtext.ui.shared,
org.eclipse.xtext.ui.codetemplates.ui,
org.eclipse.ui.editors;bundle-version="3.5.0",
org.eclipse.ui.ide;bundle-version="3.5.0",
org.eclipse.ui,
org.eclipse.compare,
org.eclipse.xtext.builder,
org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtext.xbase.ui
/Edit2: According to this topic https://bugs.eclipse.org/bugs/show_bug.cgi?id=336217, I also tried to disable all org.eclipse.jdt* plugins in run configuration. This is what i get http://pastebin.com/Wi0gzceM
You have to remove the dependencies on org.eclipse.xtext.xbase and org.eclipse.xtext.xbase.ui from your runtime and UI project.
Make sure if you open the Plug-in Dependencies in the Package Explorer that you do not see org.eclipse.jdt.core in the list. If so, there is another plug-in having a (transitive) dependency. Find out which and remove.

I writng custom Agile Tab for JIRA server 7.0.2 with JIRA Agile 6.7.11

I writng custom Agile Tab for JIRA server 7.0.2 with JIRA Agile 6.7.11.
That I want list all Spitns to this Tab.
StringBuffer outputProjects = new StringBuffer();
ServiceOutcome<Collection<Sprint>> allsprints = sprintManager.getAllSprints();
Collection<Sprint> allsprintscollection = allsprints.getValue();
outputProjects.append("");
for (Iterator<Sprint> iterator = allsprintscollection.iterator(); iterator.hasNext();) {
Sprint sprint = iterator.next();
outputProjects.append("<tr>");
outputProjects.append("<td>"+sprint.getName()+"</td>");
outputProjects.append("<td>"+sprint.getId()+"</td>");
outputProjects.append("<td></td>");
outputProjects.append("<td></td>");
outputProjects.append("<td></td>");
outputProjects.append("</tr>");
}
Plugin plugin = pluginAccesor.getEnabledPlugin("com.i4ware.plugin.timesheet.timesheet");
PluginInformation pluginInformation = plugin.getPluginInformation();
String version = pluginInformation.getVersion();
tmpParams.put("sprintsHtml", outputProjects.toString());
tmpParams.put("project", context.getProject().getKey());
tmpParams.put("baseUrl",applicationProperties.getBaseUrl());
tmpParams.put("version",version);
return descriptor.getHtml("view",tmpParams);
But I got with error message log file:
2015-12-02 10:31:55,455 http-nio-8181-exec-12 WARN admin 631x1578x1 xhcbd 80.222.144.149,37.48.78.137 /projects/AD [c.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of 'java.lang.NullPointerException - null'.
Okay I found a solution my self by help of Atlassian Developer Community.
Class:
import com.atlassian.greenhopper.service.sprint.SprintManager;
Is a privete so it must be loeded first like this:
import com.atlassian.greenhopper.service.sprint.SprintManager;
import com.atlassian.greenhopper.service.sprint.Sprint;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.greenhopper.service.ServiceOutcome;
import org.springframework.context.ApplicationContext;
import org.osgi.framework.InvalidSyntaxException;
import com.atlassian.plugin.osgi.container.OsgiContainerManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import com.atlassian.greenhopper.web.rapid.view.JqlHelper;
public class LoadSprintsForGanttServlet extends HttpServlet
{
private String jqlQuery;
private SprintManager getSprintManager() throws InvalidSyntaxException {
ApplicationContext appCtx = (ApplicationContext) getGreenHopperAppCtx();
if ( appCtx !=null ) {
return (SprintManager) appCtx.getBean( "sprintManagerImpl" );
}
return null;
}
private JqlHelper getJqlHelper() throws InvalidSyntaxException {
ApplicationContext appCtx = (ApplicationContext) getGreenHopperAppCtx();
if ( appCtx !=null ) {
return (JqlHelper) appCtx.getBean( "jqlHelper" );
}
return null;
}
private Object getGreenHopperAppCtx() throws InvalidSyntaxException {
OsgiContainerManager osgi = ComponentAccessor.getComponentOfType(OsgiContainerManager.class);
if ( osgi==null ) {
java.lang.System.out.println("OSGI Not Found");
return null;
}
Bundle[] bundles = osgi.getBundles();
for(int i=0;i<bundles.length;i++) {
Bundle bundle = bundles[i];
if ( "com.pyxis.greenhopper.jira".equals( bundle.getSymbolicName() ) ) {
BundleContext bctx = bundle.getBundleContext();
ServiceReference[] refs = bctx.getAllServiceReferences(null,null);
if ( refs!=null ) {
for(int j=0; j<refs.length;j++) {
Object prop = refs[j].getProperty("org.springframework.context.service.name");
if ( "com.pyxis.greenhopper.jira".equals(prop) ) {
return bctx.getService( refs[j] );
}
}
}
}
}
return null;
}
And it can be iterated like this:
try {
ServiceOutcome<Collection<Sprint>> allSprints = getSprintManager().getAllSprints();
sprints = allSprints.getValue();
pages = sprints.size();
}
catch (InvalidSyntaxException e)
{
System.out.println("Got an SearchException: " + e.getCause());
}
for (Iterator iteratorSprints = sprints.iterator(); iteratorSprints.hasNext();) {
Sprint sprint = (Sprint) iteratorSprints.next();
//your code here
}

Resources