w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to Create CustomEndpoint which called some groovy script method , and return the xml as response
Follow the steps given in the official pages - http://camel.apache.org/creating-a-new-camel-component.html http://camel.apache.org/writing-components.html

Categories : Apache

Spring AOP: Aspect not working on called method
This is not possible with your current setup. With Spring's AOP features, your class InvalidSessionIdHandler will get created as a bean and then scanned for annotations/method signatures/etc. relevant to your MyAspect class. It will find method2() and therefore create a proxy wrapping the bean it's already created. The proxy will have the behavior from your advice. Spring will the inject this (proxy) bean where you need it. For example: public class MyClass { @Autowired private MyAspect aspect; public void callMethod2() { aspect.method2(); } } In this case, the MyClass object has a reference to the proxy. When it calls aspect.method2(), the added behavior will be executed. In your code, however, you're expecting to call method2() within method1() public void me

Categories : Java

write method in spring batch not called
I tried your config with latest version of batch (2.2.1.RELEASE), spring (3.2.3.RELEASE) and quartz (2.2.0) and all works fine substituting file:input/report.csv with file:${user.dir}/src/main/java/input/report.csv. Are you sure file exists and doesn't throw a IllegalStateException: Input resource must exist (reader is in 'strict' mode): URL [file:input/report.csv] You can try use classpath:input/report.csv or build the real path of file (or check if your file is not empty...)

Categories : Spring

Groovy mixin on Spring-MVC controller
When you map requests with annotations, what happens is that once the container is started, it scans the classpath, looks for annotated classes and methods, and builds the map internally, instead of you manually writing the deployment descriptor. The scanner reads methods and annotations from the compiled .class files. Maybe Groovy mixins are implemented in such a way that they are resolved at runtime, so the scanner software can't find them in the compiled bytecode. To solve this problem, you have to find a way to statically mixin code at compile time, so that the annotated method is actually written to the class file.

Categories : Spring

How to Spring Inject My Controller layer from Groovy
Ok, So i have something thats working. Taken from answer 5 How to programmatically create bean definition with injected properties? public class AppContextExtendingBean implements ApplicationContextAware{ @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{ AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory(); version1(beanFactory); } private void version1(AutowireCapableBeanFactory beanFactory){ IUser userController= (UserController) beanFactory.createBean(UserController,AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true); beanFactory.initializeBean(userController, "user"); User testuser = userController.getUser(3); } } ApplicationContext ctx = new Clas

Categories : Java

In java, if I call, from a subclass, a superclass method that calls an overriden method, which class' method will be called?
Because the method MyPrMethod() is overridden in the subclass, the subclass implementation will be called. The actual method that gets called depends on the object on which it gets called.

Categories : Java

How to PROPERLY inject Grails services using Spring resource.groovy
Beans declared in resources.groovy are normal Spring beans and do not by default participate in autowiring. You can do so by setting the autowire property on them explicitly: aBean(BeanClass) { bean -> bean.autowire = 'byName' } In your specific case, you don't need to define the testService bean in your resources.groovy, merely set up a reference to it from your jmsContainer bean like so: jmsContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) { connectionFactory = jmsConnectionFactory destinationName = "Test" messageListener = ref('testService') // <- runtime reference to Grails artefact autoStartup = true } This is documented in the "Grails and Spring" section of the Grails Documentation under "Referencing Existing Beans".

Categories : Spring

rails 3 'undefined method' when a method is called inside another method
When you call your method search Ruby don't know what min_latitude means here @sql=a.search(min_latitude,max_latitude,min_longitude,max_longitude,sql)

Categories : Ruby On Rails

Groovy CodeVisitorSupport Call Method
The AST transform wouldn't typically generate a where-clause directly. Instead, it would generate program code that when executed generates a where-clause. This would also mean that the MethodCallExpression can stay as-is.

Categories : Java

What is the difference between a Method and MetaMethod in Groovy?
I can't find the reference, but i think i read somewhere they use Reflectors.

Categories : Java

Groovy method with optional parameters
Can't be done as it stands... The code def myMethod(pParm1='1', pParm2='2'){ println "${pParm1}${pParm2}" } Basically makes groovy create the following methods: Object myMethod( pParm1, pParm2 ) { println "$pParm1$pParm2" } Object myMethod( pParm1 ) { this.myMethod( pParm1, '2' ) } Object myMethod() { this.myMethod( '1', '2' ) } One alternative would be to have an optional Map as the first param: def myMethod( Map map = [:], String mandatory1, String mandatory2 ){ println "${mandatory1} ${mandatory2} ${map.parm1 ?: '1'} ${map.parm2 ?: '2'}" } myMethod( 'a', 'b' ) // prints 'a b 1 2' myMethod( 'a', 'b', parm1:'value' ) // prints 'a b value 2' myMethod( 'a', 'b', parm2:'2nd') // prints 'a b 1 2nd' Obviously, documenting this so other people

Categories : Groovy

Javascript, groovy like invoke method?
The obvious answer is to simply call invoke in your getName method. If, for whatever reason, you don't wanna do that, you can proxy the methods of klass afterwards: // loop through all properties of klass for (var i in klass) { // skip if it's not a custom property, not a function or the invoke function // (to prevent infinite nested calls) if(!klass.hasOwnProperty(i) || typeof klass[i] !== 'function' || i === 'invoke') { continue; } // add the invoke() method as a proxy to the current method var old = klass[i]; klass[i] = function () { klass.invoke.apply(this, arguments); return old.apply(this, arguments); }; } You can also put everything together neatly like this: var klass = (function () { this.invoke = functi

Categories : Javascript

Difference in groovy between calling a method
In a Groovy class, a property access service.defects becomes a call to service.getProperty("defects"), the default implementation of which will ultimately delegate to service.getDefects(). So working up that stack trace from the bottom, IncidentController calls getProperty("incidents") on the service object, which is a Spring AOP proxy. at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at com.test.service.$Proxy27.getProperty(Unknown Source) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:47) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227) at com.test.

Categories : Spring

Groovy each method on list of arrays
I guess it's a feature rather than a bug :p Object[] in a closure declaration has a special semantic for variable argument: From http://groovy.codehaus.org/Closures+-+Formal+Definition: Groovy has special support for excess arguments. A closure may be declared with its last argument of type Object[]. If the developer does this, any excess arguments at invocation time are placed in this array. This can be used as a form of support for variable numbers of arguments. In your example, the argument passed to the closure will be wrapped again with a new Object array, containing list as the only element. As an example: def list = [ [2, "foo"].toArray(), [4, "bar"].toArray() ] def c = {Object[] args -> println args} c(list) Output: [[[2, foo], [4, bar]]]

Categories : Arrays

Spring/REST Application with HOT Deployment: Groovy script does not load dynamically from applicationContext.xml on tomcat startup at runtime
Try creating the controller with Java/Groovy that is compiled and let it get injected the Groovy 'script' as a dependency to do the actual work. I seem to remember doing this before and it might be the annotations or the way Spring loads controllers that makes the 'script' not work for you properly.

Categories : Rest

Method being called 9 times, should be called once
Each time that cellForRowAtIndexPath calls the currentDataValues method, the dictionary inside that method is created and therefore windDirection called. You should create that dictionary once, for example in viewDidLoad and store it in a property or instance variable of the table view controller.

Categories : Objective C

how to fix groovy.lang.MissingMethodException: No signature of method:
Because you are passing three arguments to a four arguments method. Also, you are not using the passed closure. If you want to specify the operations to be made on top of the source contents, then use a closure. It would be something like this: def copyAndReplaceText(source, dest, closure){ dest.write(closure( source.text )) } // And you can keep your usage as: copyAndReplaceText(source, dest){ it.replaceAll('Visa', 'Passport!!!!') } If you will always swap strings, pass both, as your method signature already states: def copyAndReplaceText(source, dest, targetText, replaceText){ dest.write(source.text.replaceAll(targetText, replaceText)) } copyAndReplaceText(source, dest, 'Visa', 'Passport!!!!')

Categories : Groovy

performance issues with groovy getProperty() method
We can test it to find out using GBench... I came up with 4 different methods: @Grab( 'org.gperfutils:gbench:0.4.2-groovy-2.1' ) // Your 'version 1' method def method1( object, String propertyName ) { original = propertyName prefix = original.substring(0,1).toUpperCase() suffix = original.substring(1,original.length()) methodName = new StringBuilder('get').append(prefix).append(suffix).toString() assert 'tim' == object.metaClass.invokeMethod(object,methodName,null) } // Your 'version 2' method def method2( object, String propertyName ) { assert 'tim' == object.getProperty( propertyName ) } // The same as method 1, but more Groovy def method3( object, String propertyName ) { assert 'tim' == object.metaClass.invokeMethod( object, "get${propertyName.capitalize

Categories : Groovy

Indentation of groovy style method parameters in emacs
Groovy mode is treating these types of parameters as labels, like case statement labels and the rarely used feature inherited from Java that allows break statements to specify a target. You can override the indentation by adding this to your hook: (add-hook 'groovy-mode-hook (lambda () (c-set-offset 'label 4)))

Categories : Emacs

Call closure's delegate method from a function in Groovy?
You can declare the closure first, set its delegate, resolveStrategy and then pass it to each: def addAllFilesMatching(pattern, delegate) { def closure = { addFile file: it } closure.delegate = delegate closure.resolveStrategy = Closure.DELEGATE_FIRST foundFiles = ["a.txt", "b.txt", "c.txt", "d.txt"] foundFiles.each closure }

Categories : Groovy

Using python's mock patch.object to change the return value of a method called within another method
It can be done with something like this: #foo.py class Foo: def method_1(): results = uses_some_other_method() #testing.py form mock import patch @patch('Foo.uses_some_other_method'): def test_some_other_method(mock_some_other_method): mock_some_other_method.return_value = "specific_value" foo = Foo() the_value = foo.method_1() assert name == "specific_value" Here's a source that you can read: Patching in the wrong place

Categories : Python

if java wait() is called on a Thread, the method exits also on run() method termination
It is documented since Java 7, in the documentation of the join() method: As a thread terminates the this.notifyAll method is invoked. It is recommended that applications not use wait, notify, or notifyAll on Thread instances.

Categories : Java

Why I'm getting 'Non-static method should not be called statically' when invoking a method in a Eloquent model?
You defined your method as non-static and you are trying to invoke it as static. That said... ... if you want to invoke a static method, you should use the :: and define your method as static. // Defining a static method in a Foo class. public static function getAll() { /* code */ } // Invoking that static method Foo::getAll(); ... otherwise, if you want to invoke an instance method you should instance your class, use ->. // Defining a non-static method in a Foo class. public function getAll() { /* code */ } // Invoking that non-static method. $foo = new Foo(); $foo->getAll(); Note: In Laravel, almost all Eloquent methods return an instance of your model, allowing you to chain methods as shown below: $foos = Foo::all()->take(10)->get(); In that code we are static

Categories : PHP

How to mock the return of a public method called in a private method inSpring
If you are trying to test Service, then you have to mock oracleDao as well and make its getSubjectOracle() method return the String you want. I'm assuming you aren't testing getSubject() but a method that calls getSubject().

Categories : Java

How to call a method inside the operator> method if the methord called needs to change data members?
Just make your method const: int Region::findSmallestCity() const { ... } this lets the compiler know that you don't intend to change the Region, so it is safe to use with const Region objects.

Categories : C++

Cancelling method calls when the same method is called multiple time
What you need is called debouncing. You should check the jQuery Throttle/Debounce plugin (which is btw totally independent of jQuery except for using the same namespace). What you need is covered by the debounce part: Using jQuery throttle / debounce, you can pass a delay and function to $.debounce to get a new function, that when called repetitively, executes the original function just once per “bunch” of calls, effectively coalescing multiple sequential calls into a single execution at either the beginning or end. Underscore.js has the same method: _.debounce(function, wait, [immediate]) Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was inv

Categories : Java

WebService Method request in console of debugger disappears while the method is called on client click event of asp:button
1) For the 1st part if you're using Firebug , you can view the 'Net' tab for all the XHR requests and if you need them to persist even after redirecting or posting. Select 'persist' button at the left hand side. 2) Ideally the id should have come even if it is hidden ,incase the element is not deleted.

Categories : Jquery

Soapui Groovy - No Signature of Method error on ProWsdlTestSuitePanelBuilder.buildDesktopPanel
Okay, so this falls under the newbie catagory. I wasn't paying attention to the fact that buildDesktopPanel was static. However, I managed to work around that and create the final product: // Create a UISupport container for all the panels we'll be showing def UIDesktop = new com.eviware.soapui.support.UISupport(); // Basic environment information def properties = new com.eviware.soapui.support.types.StringToObjectMap(); def currentProject = testRunner.getTestCase().testSuite.getProject(); def workspace = currentProject.getWorkspace(); // Get the various Projects we'll be using def OtherProject = workspace.getProjectByName('Other Project'); // Get the various TestSuites we'll be running def OtherTestSuite = OtherProject.getTestSuiteByName('Other Test Suite'); // Generate the Pane

Categories : Groovy

Grails / Groovy log4j - Log line numbers, method name and class name
Please take a look at Grails logging - Is there any existing solution to be able to log the File + Line where the call actually occured? So, you need to use a custom appender...

Categories : Grails

Groovy/grails how to call controller method from view using jquery
Looks like you might have a bug in the params section of your code. Try: var newData = ${remoteFunction(controller: 'my', action: 'updateData', params: '[string_from_form]')};

Categories : Jquery

Groovy: Determining the expected return type dynamically from within method?
Groovy allows you to declare a variable without the type, using the def keyword. So you can write either: def foo = query("FROM Foo"); // "foo" will contain a List<Foo> or: def foo = query("FROM Foo f WHERE f.id = 1"); // "foo" will contain a Foo object That said, is up to you to make it work the proper way. To do that the easy way, I would suggest you to return always a collection, which may contain only one item. As a rule of thumb, if you expect different return types, you probably need two different behaviours to deal with them, so it's fine to have two methods.

Categories : Groovy

Groovy Global Closure not working in nested method call
That's because you're running it in a script. Groovy converts the above into: class Script { def run() { def benchmark = {name,closure -> ... nested() } def nested() { benchmark('doesnt_work'){print("hello")} } } So as you can see, the Closure is local to the implicit run method, but the nested method belongs to the class... I believe you have 3 options: Make nested a Closure, and they will both exist in the same scope def benchmark = {name,closure -> start = System.currentTimeMillis() ret = closure.call() now = System.currentTimeMillis() println(name + " took: " + (now - start)) ret } def nested = { benchmark('doesnt_work'){print("hello")} } nested() Write a proper class and control the scoping yourself cl

Categories : Groovy

In groovy when comparing this and a reference passed in a method: same instance, different metaclass
You can implement methodMissing in the class as below to answer your last question: class Greeter { def sayHello() { //this.metaClass.greeting = { System.out.println "Hello!" } greeting() goodNight() } def methodMissing(String name, args){ if(name == 'greeting'){ println "Hello!" } else println "Good Night" } } new Greeter().sayHello() Also note that == in groovy actually means equals() (that is value comparison) if you want to compare identity then is() can be used like a.is(b) //Corresponds to == in Java a == b //Corresponds to equals() in Java UPDATE Can use metaClass as below Greeter.metaClass.greeting = { println "Hello"} def greet = new Greeter() //or //greet.metaClass.greeting = { println "Hel

Categories : Groovy

Can changes in the order of the method parameters be called method overloading?
Yes, that's absolutely method overloading. From section 8.4.9 of the JLS: If two methods of a class (whether both declared in the same class, or both inherited by a class, or one declared and one inherited) have the same name but signatures that are not override-equivalent, then the method name is said to be overloaded. "Override-equivalent" is described in section 8.4.2: Two methods have the same signature if they have the same name and argument types. [ ... Details on "same argument types ... ] The signature of a method m1 is a subsignature of the signature of a method m2 if either: m2 has the same signature as m1, or the signature of m1 is the same as the erasure (§4.6) of the signature of m2. Two method signatures m1 and m2 are override-equivalen

Categories : Java

Method error when method called, but not as single line
Your unless needs its own end: if ... unless stat.nil? stat.delete end end You only get to omit the end when you use the x unless y form: if ... stat.delete unless stat.nil? end (The method itself is lacking an end, but I assume you've just omitted that part from your code).

Categories : Ruby

self::method() call uses parent method instead of called class
Late Static Binding: use static::createFile(); instead of self::createFile();

Categories : PHP

Get classtype of class where method is called in async method
Thanks to the comment by JonSkeet, a few changes to the way I was handeling my logs and the information I found in this article, I was able to solve my problem! Since my Log method that supported formating had an overload of object arguments, I was unable to pass the CallerMemberName / CallerFilePath that way. I solved this by making the Log method require the LogMessage to be passed directly (and handle formating there), and the method and class added in that method. Many thanks to JonSkeet for pointing me in the right direction! Log method: public static async void Log(LogMessage logMessage, [CallerMemberName]string method = "", [CallerFilePath]string path = "") { logMessage.SetCaller(method, path); await AddLogToCollection(logMessage); } SetCaller me

Categories : C#

Why can an instance method be called as a module method after include?
You're including A into Object. module A def self.included(base) puts base.inspect #Object end def foo :bar end end include A puts A.foo # :bar puts 2.foo # :bar #puts BasicObject.new.foo #this will fail Also note that the top level object main is special; it's both an instance of Object and a sort of delegator to Object. See http://banisterfiend.wordpress.com/2010/11/23/what-is-the-ruby-top-level/

Categories : Ruby

Java: Query a method from a class that the method was called from
Currently, the map knows about the start place, but the place doesn't know anything about the map containing it. So if you really must implement a method such as isStartPlace(), you'll have to also set a relation from place to map: public class Place { private Map containingMap; ... public boolean isSTartPlace() { return this.equals(containingMap.getStartPlace()); } } public class Map{ public void setStartPlace(Place p) { this.startPlace = p; p.setContainingMap(this); } ... }

Categories : Java

Spring AOP advice is not getting called
You need to read the documentation about proxies here. Basically, because of the way proxies are generated, a instance method call within another instance method will not trigger an aspect (or proxy behavior). Given: class FooBar { // advised method public void foo() { bar(); } // would've been advised public void bar() { // ... do something } } Say an instance of FooBar was proxied, a call to foo() will trigger the aspect because from outside you have a reference to the proxy object. When you call bar() internally, you have access to this (equivalent to this.bar()) which is a reference to the target instance, the actual object, so there is no added behavior. There are a few ways to solve this problem, but probably not the way you want. See th

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.