I'm developing in eclipse (java 6) and working with websphere server.
How can I automate a dynamic modification of some small parts of the code (mock-like) for my local development only? I don't want to share my own adjustments with other developers... That could create bad expectations including them thinking it should be working in a certain way that is not correct or even outside communications not happening as they should.
I'm not using any java framework, that is what has been decided for the project.
I have already looked at ASM and BCEL but I can't find any good source on how to get them working in an automated way for this kind of thing... If they are capable of it.
The changes I need can all be achieved by intercepting values of parameters of some specific methods (some are static and other are not static) when they are called.
Anything that can be automated to get that result without changing any of the code shared between the other developers can do. It doesn't need to automatically adapt to new code.
I have already been called to attention of my own adjustments being sent to the repository and I want to avoid it at my best capability.
It’s quite unclear what you are trying to achieve but it sounds like you want local modifications to the code? If so, modify the code, commit the changes to a branch that you never publish. Merge incoming changes into this branch every now and then.
Related
I'm looking for a lightweight way of embedding some GUI-based object inspection facilities in a Java application.
Ideally it would be something like the variable inspector in the Eclipse debugger, which lets you see all the fields of a given object instance, and drill down to inspect fields contained within these. Doesn't have to be pretty, just needs to have a way to inspect the value of all fields
I don't just want to use a debugger: this idea is that the facility can be used on the application at runtime, allowing for quick diagnostics without restarting the application.
It needs to be pretty lightweight: since this is meant to be embedded in a deployed application, I don't want to pull in a whole load of extra dependencies. So Swing would be OK, but pulling in a whole native widget library would be out of the question (sorry, no SWT....)
It needs to be able to inspect an arbitrary Java/JVM object (presumably via reflection)
Does anyone know a tool like this?
I do not know "ready" framework but can recommend you to either use JDPA directly or use one of libraries that are using byte code engineering done at runtime. For example take a look on java-interceptor that can help you if you can control the code you want to interspect.
There is ReflectionUI.
By default it will only present you the public getter/setter properties but you could customize it to access the private/protected fields for your debugging purposes.
I started using dependency injection with roboguice and created an interface like DataProvider. I have an implementation which retrieves the data from some WebServer located in the WebServerDataProvider class. In Order to eliminate the waiting for the webserver i added a DummyDataProvider.
Where would i put such class? I don't like that it is in /src/main/java/my/package/providers/ since it is not real part of the application, but still i need it for development.
Typically you would use such a class in your unit tests. Roboguice works well with Robolectric , which allows you to mock things like http access. If you do that you would put your code in src/test/java/...
You could put it into the main project if you want to use it for fiddling around with the application without bothering the server each time and deactivate it with some constant for deployment, e.g.
if (DEBUG) {
setDataProvider(new MockDataProvider());
}
Proguard should be smart enough to remove this unused class if you remember to reset your variable (you might have to fiddle around with the settings there).
I'm a new person in this area (plugin developing) and I want to create some kind of plugin for my app:
I've developed an android application and now I need to make a toolkit for the students for future work on this app. The idea is:
1) to make a manual for that app, so that students can read about classes and structure not in separate .doc file but inside Eclipse IDE, probably with some links to the code.
2) to make a supervise of the app's functions (so that students can check if all features (performance-UI design, connection to the external server/API's, etc) of the app are working properly, in case if they will change something). All these data should be in separate frame (looks like a toolkit). (I found information related to this here http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-jfeature/section5.html, but I'm not sure if it's gonna work for my idea)
I will be glad to get some links of tutorials that are related to my task as well as your suggestions for the set of the toolkit features (but also with links how to make it).
Thank you very much in advance! Hope to get your help :)
The thing for the manual is Javadoc, you can use it in eclipse with java as well as in android.
here are some links, first:
http://en.wikipedia.org/wiki/Javadoc
Then I can quickly explain why javadoc can be useful for you, first of all it allows to create a real manual (java API are created with javadoc) with (in my opinion) the easiest way you can imagine.
You have to use a special comment tag that is:
/**
*
**/
When you put this before any declaration (methods, class, interfaces, fields etc) it will be included in the javadoc.
You have standard things that can be added for example you can specify a description of the method, what it #return what #params it need and many other things, being very careful and precise you can link javadoc with each other, and create very complex and precise documentation.
In eclipse javadoc is useful because eclipse itself allows the user to interact with javadoc by default. For example if you want to know what a method do, just simply hang the mouse over the name of the method and a little yellow dialog will appear. If you also use ctrl-space you can have some tips also in it. Pressing ctrl-space shows for example all avaible public methods, with javadoc for each method you have the yellow description dialog. If you are instantiating a new object you can see how many (and what kind of parameters they have) constructor are definited and so on, I think it is very useful and important.
For the second things if I understand what you want probably something like JUnit (a unit for the testing) can be ok for you.
http://www.junit.org
JUnit is a unit for testing the code, can be fully integrated with eclipse.
In few word, for each part of the code you should write one or more test to check if its behaviour is correct. Once you've written some test you can run them automatically with an user-friendly interface that tell you how many test are failed, how many passed and what kind of error there are.
Why is useful to test each little (stupid?) thing of my code?
Imagine you have a working code (your code).
Imagine you have someone working on it (your students).
How can a user be sure that any change he/she do it's ok with the existing code?
He/she should run the program and check each functionality one by one in order to find an error.
You understand that this is impossible. so JUnit do it for you with just one click (and if you want also in background).
So the student can add the code, and run the tests in order to see if the pre-existing code is still working.
The students can also write his own test to test automatically if all is ok. JUnit in facts allow you to test each part of the code without depending from the other, in this way, you can also test an internet connection without being connected to the net just "mocking" the connection.
I let this part without explanation because It is a long and complicated part. I gave you that "input" to stimulate you to read about testing and XP programming.
Ah, and welcome to stackoverflow! if you like this answer and think that answer correct to your question you can check it with the little check on the left.
I am currently developing a simple plugin that retrieves results from a Jenkins build. I am extending Notifier and using build.getResults() to get the information. However, when I upload my plugin, I can't set it as a post-build action.
When I run my builds, they break on build.getResults() since I am trying to get the results while the build is still running.
What can I do to properly get the build result ?
Best thing is to look at existing plugins which use Notifier extension point (click to expand implementing plugins list).
Check that you have the Descriptor implemenation (inner) class, as well as config.jelly. Also check jenkins.out and jenkins.err logs for any exceptions (such as malformed config.jelly).
Edit: Actually, Notifier subclass of this plugin looks really simple as Notifiers go: https://wiki.jenkins-ci.org/display/JENKINS/The+Continuous+Integration+Game+plugin , see especially its GamePublisher.java and corresponding config.jelly, and it's GameDescriptor.java, which has been made a full outer class (often descriptor is inner class). Also if you want options into Jenkins' Global configuration, you need a global.jelly, but if you don't have such options, that is something you can just leave out (unlike config.jelly, which you must have for Notifier even if it is empty, like here).
As a general note, it can be really annoying when things do not work, and you do not get any error, your stuff simply is just not displayed by Jenkins... If you just want to get things to work for you, using Groovy build step might be easier, but if you want to get things to work for others, then doing a decent full plugin reduces support requests.
Since this sounds so simple, are you sure you need a plugin ? Take a look at using a Groovy Postbuild step instead; they're much easier to write. There are some good usage examples in the link. If you decide you really need a plugin, see if you can extend an existing one rather than writing your own; it's an easier way to understand the ins and outs of Jenkins plugin writing.
I need advice on how to rewrite a java GUI. Ultimate goal is easier to maintain & enhance.
What I have built is a Java Applet Client interface that acts and behave similar to Eclipse. developer can design their data entry forms without using a single line of code (drag and drop), and define its attribute. This part is pretty well iron out. however, i am left with more than 40,000 lines of codes that is very difficult to maintain.
Each time a bug is occur or a new enhancement, i normally cant program in a more direct way. more than half the time, i need to workaround the problem and that adds up the lines of code.
Consideration:
-Java Web Applet (because it runs on any browser with J2RE installed)
-runs on slow machine
-deployment of around 200 nodes and growing
Problems that i currently have:
-Listeners are all over the place. sometimes is inside the element.AddListener(new listener..). Sometimes is outside of the class, could be in another package that contain all the rest of listener.
Question: is it always good idea to put all listener in another package? if that is that case, i cant use "this." to get the reference i need.
-JTable this is a killer to me :( the problem i had on Cannot access the Jtable column data after set invisible still persist. Imagine i have JTable with 3 column. First column is a dropDown, second and third column is a textfield. Whenever a value choose from dropdown, i need to base on the selected value, and update to the second column and third column. the problem is, if the user click and it click on other row very fast, it will update to a column that is in the wrong row.
-Currently the program is coded in the sense of it is single thread. whenever the user does a http connection to the server side, reading a file, writing a file and etc, i need to make it as asynchronous process so it doenst feel like "program hang". what is the best way to do this?
Really appreciate help here! Thanks!
Lots of questions here and I'm not sure where to start but I can sympathize with you one this one. Unless you have a well seasoned team that has already gone through the pains of Swing application development things can quickly become out of control and unmanageable.
Before you adventure into re-writing a project I would start with defining some simple standards for development. Like package structures and listeners. I would also recommend splitting the application up into well unit tested modules or sub projects.
Also, ask yourself if you really need to re-write the application or does it just need some TLC. As a consultant and Director of IT I see developers always wanting to re-write applications just because they've learned something new or don't think it's up to par. When they come to me and tell me that it's junk and needs to be re-written I usually send them back and ask them to come up with alternative solutions to a re-write and the impact of each solution including - doing nothing. In a lot of cases we didn't write the application at all.
[UPDATE]
Lastly, If you are going to re-write I would use a Domain Driven Design and MVC approach. Yes, I said MVC for desktop applications!. We've had great success with these methodologies. It keeps a good separation of concern and makes things easily re-usable. It also provides the structure to easily switch out the presentation layer. Most importantly it's easy to unit test and any developer that understands MVC can understand the basics of your project without knowing the details.
I have some more thoughts but i'll leave it at that for now. ;)
use dsl for gui:
swinghtmltemplate
swixml
yaml
there are some more of them
this will remove the need to describe listeners, allow binding in dsl manner
Why dont you just reuse the eclipse framework to build your own gui instead of writing it from scratch in Swing ?