Creating ejb project - eclipse

I am trying to learn ejb by reading MasteringEJB by ED Roman. It stated there that we need to create the interface first. For example, we need to create
1.Remote interface for Hello.java
2.Local interface for HelloLocal.java
3.Home interface for HelloHome.java
4.Local Home interface for HelloLocalHome.java
5.and we need to create interface for our bean class, HelloBean.java
6.and we need to have deployment descriptor
and lastly we need to package all this file together in EJB-jar file.
so my question is , I do not know which one to choose?
like go to File>New> --which one should i choose? is it file?interface? java project? ejb?
Could anyone help me ?

Have you tried taking a look at the source code that goes with the book:
http://media.techtarget.com/tss/static/books/wiley/masteringEJB/downloads/3eCode.zip

Related

How to distinguish wizards in Eclipse RCP?

We have an Eclipse IDE application on 3.x that uses various newWizards to allow the user to create different files. Although these files differ slightly contentwise, the structure of the wizards is quite similar.
Thus, a sound object-oriented approach would be to instantiate different wizards from the same class and initialize them with different data.
Problem:
To decide what wizard needs which data we need a way to distinguish the different already instantiated wizards (e.g during the call to the init method of the wizard).
Is there any way to do so? It would e.g. help if somebody knows a way to get the wizard's id defined in the extension point from within the instantiated wizard.
If your wizard implements IExecutableExtension, it will be passed the configuration element that represents the extension for which it is created.
You can also use extension factories in that you specify a type that implements IExecutableExtensionFactory.
The interface allows you to control how the instances provided to extension-points (wizards in your case) are created.
Extension example:
<extension point="org.eclipse.ui.wizards">
<newWizard
name="..."
class="com.example.WizardFactory">
</newWizard>
Note that the extension factory may also implement IExecutableExtension to gain access to extension attributes before creating the extension's executable class.

user spcific packages with gwt client side

I am a newbie at GWT and I have the following query.
I have a scenario where I am trying to develop a web interface(using GWT) for an existing application.
In the client side class file I would like to invoke a user specific class file, i understand that this is due to the fact that i am trying to invoke classes other than the ones http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html
I would like to know how this code can be called from the client side of the ui.
Thanks and Regards,
Bhavya
If you have a source code for the class you want to use and it is using only the supported Java classes, you can simply add your specific classes to client packages. If this is a reusable code, you can create a new GWT module and inherit it in your application. You can also simply move those classes to your client packages OR add a new client folder in you .gwt.xml file (add one more <source> tag)
If your class is not compilable by GWT, then I think you need to use it through RPC service.
If the code is translatable into JavaScript, you could for example put your individual class files into a jar and add it to the Build Path - as you would do in a 'regular' Java Project.

Programmatically configure ActiveRecordFacility for multiple databases

I'm trying to build a small application (ASP.NET MVC) that uses the plugin architecture. Along with Castle ActiveRecord Integration Facility. And I wish to let each plugin configure its own ActiveRecord behaviors. Like database connection string, proxy, etc..
However, I couldn't find a way to set multiple configurations without the use of web.config. The idea is to make this programmatically.
My goal is for each plugin in this system, if it defines its own ActiveRecord settings, the main application can set up next to ActiveRecordFacility these behaviors.
has someone do something like that?
P.S.: sorry, bad grammar...google translate...;P
You can set up the ActiveRecord configuration programmatically using InPlaceConfigurationSource (lots of examples around), then after initializing ActiveRecord (in your own code), call the ActiveRecordFacility with the skipARInitialization flag. e.g.:
container.AddFacility("ar", new ActiveRecordFacility(true));
This tells the facility not to try to initialize ActiveRecord, so it picks up the existing configuration.
Ok...the example in Lostechies works great. (link text)
Mauricio, thanks for the tip!

Netbeans: using GUI Builder on regular Java class file

I'm using Netbeans. When I create a Java class, I sometimes want to change it to be a GUI component so that I can visually edit it using the GUI Builder.
What is the necessary step to transform a regular Java class to a GUI component so that Netbeans would recognize it and allow me to use GUI Builder ? (i.e. switch between Source and Design)
NetBeans' Gui builder, Matisse, works off a .form xml file located adjacent to the source file. Matisse creates and maintains the .form file and the code generator creates/updates methods in the java source to reflect changes to the form.
Unfortunately, there is no support in NetBeans for free-form GUI construction.
The closest I've seen is FormGenerator. It's a contributed NetBeans module that adds a right click action to .java files that will attempt to generate a .form file from the .java source. It's very limited, but it's better than nothing. It works best if you've followed the coding style employed by Matisse.
http://netbeans.org/projects/contrib/downloads/download/Readme.txt
http://netbeans.org/projects/contrib/downloads/download/FormGeneratorModule.zip
To add a class to the Palette, all that's needed is for your class to conform to the Java Beans model. That is, your class must:
be serializable
have a public, no-argument constructor.
All fields that have getter and setter methods that are named properly, i.e.:
int count
int getCount()
void setCount(int c)
should by default be recognized as a property.
For a finer control of what properties should and should not be exposed to the GUI Builder, you can associate your class with an implementation of the BeanInfo interface. See this Sun tutorial for more details.
However, NetBeans has several tools to help you in designing a custom bean. You can create new beans using the built-in templates available in the new file dialog, under the "JavaBeans Objects" folder.
This tutorial will guide you through creating an Image Bean.
What you could do is create one from scratch, design it as you wish, and then look at the generated code to understand how you can modify your existing class.
Try to use properties (Java bean!) for properties which should be changed from the ui designer and look here for more info.

GWT with JPA

I'm trying to build database application using GWT 1.5.3. I use JPA annotations with my objects. It seems in hosted mode GWT's RPC works fine. But when I try to compile my app using GWT-compiler I get errors like: "The import javax.persistence cannot be resolved", "Entity cannot be resolved to a type". toplink-essentials.jar is already included in my project path. What settings else do I need to solve this problem?
You can use Gilead (http://sourceforge.net/projects/gilead/) library to seamlessly manage JPA entities with GWT.
Regards
You need to include the source code for the JPA annotations in the build path for your GWT project. See here for more details:
http://code.google.com/p/google-web-toolkit/issues/detail?id=1830&can=1&q=jpa
Specifically this jar file which will fix your problem:
http://google-web-toolkit.googlecode.com/issues/attachment?aid=1475633892125294312&name=jpa-annotations-source.jar
The general problem of the JPA and GWT is that GWT itself doesn't support fancy JPA classes, so you just do simple POJO persistent entities DTO that implements the java.io.Serializable and have simple JPA resource annotations. You need to create the entity classes in the scope of the GWT client either have it under the yourproject.client package or add them with
source path="client"
source path="folderOfYourEntities"
in the GWT project's YouProject.gwt.xml file. This will include the entity objects in the GWT client so they can used them on client side of the RPC as well. The DAO must be on the server side and can contain anything that you container supports.
The problem you have now is that when compiling, GWT compiler saids that it desn't know what those imports for JPA annonations are in the entity DTO classes. That is why you need the javax.persistence class and source codes. The jpa-annotation-source.jar reference by Rustmyself works. It is just the javax.persistence compiled class files and source codes files plus a Persistence.gwt.xml. It is a simple GWT module for the javax.persistence package. If you know how to make your own GWT module, you should have problem making all this work. By the way, the official source for the Java EE can be found on the glassfish dev site's build section wiki.glassfish.java.net
There are many other solutions that wrap your fancy PU entities to simple objects automatically using proxy or to lazy load them at run time. They work, but not optimal solutions. The best practice is to make things simple and robust from the start by having POJO JPA DTO entities on the GWT client context and full blown DAO on the server.
GWTPersistence Example
I have added an actual working example on how to make GWT and JPA work seamlessly. It is a NetBean project with source codes and deployment file. See GWTPersistence on NingZhang.info
Ok, I've found what I was missing. I needed to include jpa-annotations-source.jar in my GWT-compiler path in myapp-compile.cmd script (or in ant build file). By the way can anyone tell me the origin of this jpa-annotations-source.jar file?
I am also working with JPA <--> GWT data transformation etc.
In an effort to eliminate the DTO layer I used Gilead too.
My objection here is about translating javax.persistence. To avoid this I used XML JPA mapping declarations (orm.xml)
Simply, keep another version of your Entities but without the annotations!
Rebounding on synergetic's comment, you now (from GWT 1.5) only need to add
<source path='javax.persistence'/>
to your Module.gwt.xml