Access remote bean with JNDI from remote system
by Karsten Ohme
Hi,
I want to access a Bean remotely (with JNDI). So I thought I could
access in on the client with:
Properties env = new Properties();
env.put(Context.PROVIDER_URL, "jnp://myserver:1099");
Context jndiContext = new InitialContext(env);
jndiContext.lookup(...);
If I do a port scan on "myserver" the JNDI port 1099 does not show up. I
thought this is the default port. What do I have to do the get access
the remote bean?
Is there somewhere a documentation how to access JNDI resources from
another system?
Regards,
Karsten
16Â years, 8Â months
[JBoss Seam] - Re: Using EL in backend Java code?
by samdoyle
The only thing I see that resembles what I am looking for is some Test based examples which have no indication on how to do it in a Session Bean
| @Test
| public void testSayHello() throws Exception {
| new FacesRequest("/hello.jsp") {
| @Override
| protected void updateModelValues() throws Exception {
| setValue("#{person.name}","Michael Yuan");
| }
| @Override
| protected void invokeApplication() {
| assert getValue ("#{person.name}").equals("Michael Yuan");
| assert invokeMethod("#{manager.sayHello}") == null;
| assert getValue ("#{person.name}") == null;
| }
| @Override
| protected void renderResponse() {
| List<Person> fans =
| (List<Person>) getValue("#{fans}");
| assert fans!=null;
| assert fans.get(fans.size()-1)
| .getName().equals("Michael Yuan");
| }
| }.run();
| }
| TestNG-based
| The entire JSF lifecycle
| as well as database session
| are mocked
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100898#4100898
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100898
17Â years, 1Â month
[JBoss Seam] - Factory pattern and CRUD operations
by asookazian
So one of the tables/entities is being updated in the table after I submit my use case for a particular employee/row.
I have not coded any explicit calls to the DAO methods. The submit() method in my SFSB simply has a log4j output statement.
So how is the update transaction actually happening? This app was reverse-engineering using JPA reverse engineering (via MyEclipse). So is this a feature of EJB3 (I saw in the server.log that the SFSB was being serialized at one point)? The only reference to ".merge" in my entire project were commented in the submit() method below. Only references to "update" are in the DAO classes.
so what's the explanation here for the save/update?
here's the entire SFSB:
package com.cox.beans.session;
|
| import java.util.ArrayList;
| import java.util.List;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.faces.model.SelectItem;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.apache.log4j.Logger;
| import org.jboss.seam.annotations.AutoCreate;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
| import org.jboss.seam.security.Identity;
|
| import com.cox.beans.entity.TblSecurityAuditNote;
| import com.cox.beans.entity.User;
|
|
|
| @Stateful
| //@Restrict("#{identity.loggedIn}")
| @Name("securityAuditAction")
| public class SecurityAuditAction implements SecurityAuditLocal {
|
| @PersistenceContext(unitName="boIcomsSecurityAudit")
| private EntityManager em;
|
| private String currentEmployeeName = "";
|
| @In(required=false) @Out
| private User user;
|
| @In
| private Identity identity;
|
| @In
| private TblSecurityAuditNote myNotes[][];
|
| @In(create=true)
| private NoteLocal noteAction;
|
| Logger log = Logger.getLogger(this.getClass());
|
| private List<SelectItem> myRadioButtonList;
|
| @DataModel
| private List myAuditList;
|
| @DataModelSelection
| private Object myAuditListSelection;
|
| public SecurityAuditAction() {
| log.info("in SecurityAuditAction()");
| }
|
| @Factory("myAuditList")
| public void findAuditList()
| {
|
| log.info("in getAuditList(): user.getUserId() = " + user.getUserId());
| log.info("in getAuditList(): user.getBillingId() = " + user.getBillingId());
|
| int employeeId;
|
| String networkId = noteAction.getNetworkId()==null?"":noteAction.getNetworkId();
|
| if (!networkId.equals("")) { //user entered a networkId from UI to run for another person, so get new guy's billingId
|
| List myList = em.createQuery("from User u where u.networkId = :networkId").setParameter("networkId", networkId).getResultList();
| User newUser = (User)myList.get(0);
|
| employeeId = newUser.getEmployeeId().intValue();
|
| myAuditList = em.createQuery("SELECT gem, tsaw "+
| "FROM TblSecurityAuditWorking tsaw, "+
| "GlobalEmployeeMaster gem "+
| "WHERE tsaw.id.siteId = gem.id.siteId "+
| "AND tsaw.id.employeeNumber = gem.id.employeeNumber "+
| "AND tsaw.reportToId = :employeeId")
| .setParameter("employeeId", employeeId)
| .getResultList();
| }
| else {
|
| List myList = em.createQuery("from User u where u.networkId = :networkId").setParameter("networkId", identity.getUsername()).getResultList();
| User user = (User)myList.get(0);
|
| employeeId = user.getEmployeeId().intValue();
|
| myAuditList = em.createQuery("SELECT gem, tsaw "+
| "FROM TblSecurityAuditWorking tsaw, "+
| "GlobalEmployeeMaster gem "+
| "WHERE tsaw.id.siteId = gem.id.siteId "+
| "AND tsaw.id.employeeNumber = gem.id.employeeNumber "+
| "AND tsaw.reportToId = :employeeId")
| .setParameter("employeeId", employeeId)
| .getResultList();
| }
|
| log.info("in find(): myAuditList.size() = " + myAuditList.size());
|
| }
|
| public List<SelectItem> getSecurityAuditRadioButtons() {
| myRadioButtonList = new ArrayList<SelectItem>();
| myRadioButtonList.add(new SelectItem("true", "Yes", "Yes it is"));
| myRadioButtonList.add(new SelectItem("false", "No", "No it isn't"));
| return myRadioButtonList;
| }
|
| public void test() {
| log.info("in test()");
|
| }
|
| public String getHeader() {
| log.info("in getHeader()");
| return "Please enter your note for the associate";
| //return "Please enter your note for " + currentEmployeeName;
| }
|
|
| public void submit() {
|
|
| log.info("in submit()");
|
| /*
|
| Iterator it = myAuditList.iterator();
|
| while (it.hasNext()) {
| Object[] result = (Object[])it.next();
| TblSecurityAuditSnapshot tblSecurityAuditSnapshot = (TblSecurityAuditSnapshot)result[0];
| em.merge(tblSecurityAuditSnapshot);
| //why was I updating GlobalEmployeeMaster view?
| //GlobalEmployeeMaster globalEmployeeMaster = (GlobalEmployeeMaster)result[1];
| //em.merge(globalEmployeeMaster);
| }
|
| for (int i = 0; i < myNotes.length; i++) {
| log.info("i = " + i);
| for (int j = 0; j < myNotes.length; j++) {
| log.info("j = " + j);
| em.persist(myNotes[j]);
| }
| }
| */
|
| }
|
| //moved networkId methods to the NoteAction SLSB for now...
|
| /*public String getNetworkId() {
| if (networkId.equals(""))
| return identity.getUsername();
| else
| return networkId;
| }
|
| public void setNetworkId(String networkId) {
| log.info("in setNetworkId(): networkId = " + networkId);
| this.networkId = networkId;
| }*/
|
| public void setCurrentEmployeeName(String employeeName) {
| log.info("in setCurrentEmployeeName: employeeName = " + employeeName);
| currentEmployeeName = employeeName;
| }
|
|
|
| @Remove @Destroy
| public void destroy() {
| log.info("in destroy()");
| }
|
|
|
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100896#4100896
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100896
17Â years, 1Â month