Last use of RMI object instance
I have an RMI object with instance variables. As clients of this
remote object method make calls on it, these instance variables
are used and modified. My question is; Is there a way where I can
check when the last call from the client where made using a certain
instance?
Do I have to have separate timer methods for each instance to track
the time elapsed since last use?
Any answers are appreciated.
/Mats
Perhaps you could post something describing what you are trying to do. (Sounds like you want to keep track of last-used-time on a bunch of data elements?)
Similar Messages
-
Create an object instance without calling its constructor?
Hi,
Sometimes it's useful to create object instances without calling their constructor. When? For example object deserialization.
By default when deserializating an object, the instance in the VM is created by calling the default constructor of the first non Serializable super-class (if you don't have such you're in trouble). I think that the db4o object database don't even call any constructor you may have written.
So such thing exists, but how is this possible? I fugured out that sun's deserialization mechanism first finds the constructor of the first non Serializable super-class and then:
cons = reflFactory.newConstructorForSerialization(cl, cons); Here I'm stuck.
Here's the source of the method for finding serializable constructor:
* Returns subclass-accessible no-arg constructor of first non-serializable
* superclass, or null if none found. Access checks are disabled on the
* returned constructor (if any).
private static Constructor getSerializableConstructor(Class cl) {
Class initCl = cl;
while (Serializable.class.isAssignableFrom(initCl)) {
if ((initCl = initCl.getSuperclass()) == null) {
return null;
try {
Constructor cons = initCl.getDeclaredConstructor(new Class[0]);
int mods = cons.getModifiers();
if ((mods & Modifier.PRIVATE) != 0 ||
((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
!packageEquals(cl, initCl)))
return null;
cons = reflFactory.newConstructorForSerialization(cl, cons);
cons.setAccessible(true);
return cons;
} catch (NoSuchMethodException ex) {
return null;
}So any info about this ReflectionFactory, and the problem as a whole?
Thanks.So the question is how to create object instance without initializing it (calling the constructor)? And if you have any info about ReflectionFactory it will be useful too.
When serializing an object you save all its fields and some extra info. When you deserialize it you have to reconstruct it, by copying the fields back, but not to reinitialize.
import java.lang.reflect.*;
import java.io.Serializable;
import java.security.AccessController;
import sun.reflect.ReflectionFactory;
public class Test0 implements Serializable {
public Test0() {
System.out.println("Test0");
public static void main(String[] args) throws Exception {
Constructor<Test0> constr = reflectionFactory.newConstructorForSerialization(Test0.class, Object.class.getConstructor(new Class[0]));
System.out.println(constr.newInstance(new Object[0]).getClass());
private static final ReflectionFactory reflectionFactory = (ReflectionFactory)
AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction());
}When you execute this piece you get:
class Test0 -
How to use RMI objects in a servlet
Hi,
I have just run the example RMI program in the java tutorial in my linux pc. Also I have another method to just echo a string back. It works fine when calling from command line.
Now I want to write a servlet that get a string when POSTed and call the RMI objects echo method and display the returned string.
I use Tomcat-5.0 which is installed in /usr/local. I moved the remote object interface jar to the common/lib folder and import the interface in my Servlet. I use the following statements inside the servlet to get the RMI object reference.
Registry registry = LocateRegistry.getRegistry("localhost");
Rser comp = (Rser) registry.lookup("rmiser");When i use this in my servlet the tomcat stops working.
Also I don't know how to specify the code base and security policy which I use in command prompt when calling RMI object.
Pls suggest me what to do and also specify any resources that explain this task step by step.
Thanks.restarted the system and caught the following exception while calling the servlet.
Apr 30, 2009 12:24:15 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3861 ms
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
at java.net.Socket.connect(Socket.java:513)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at RequestParamExample1.doGet(RequestParamExample1.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at filters.ExampleFilter.doFilter(ExampleFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
Apr 30, 2009 12:25:19 PM org.apache.coyote.tomcat5.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.Thread.setContextClassLoader(Thread.java:1351)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.security.AccessControlException: access denied (java.lang.RuntimePermission setContextClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.Thread.setContextClassLoader(Thread.java:1351)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1623)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608)
at java.lang.Thread.run(Thread.java:619)
Hope u can find it now.
the line
at RequestParamExample1.doGet(RequestParamExample1.java:94)
is the file I am editing and using to call RMI.
Edited by: itsraja on Apr 30, 2009 12:06 AM -
I need to run multiple external programs concurrently using RMI objects.
have a web based solutiion which uses a backend machine for some processing. I have a RMI based Java proram running on the backend machine and the web server talks with this backend machine through RMI. Now, on this backend machine, I need to call some external program using Process s = Runtime.getRuntime().exec(....). Since this is a web application, multiple clients will connect at the same time and I need to run this external program for multiple clients at the same time.
Here is what I do. I have a separate RMI object bound to registry for each client that connects to the web server. This RMI object implements runnable interface, since I can't extend this class from Thread (it already extends from UnicastRemoteObject). So each time I call upon a method from this object, only one process gets started and other objects need to wait till this process finishes.
I need to start multiple processes at the sametime so that other clients don't have to wait for this thread to finish.
Please let me know if anybody has any other solution than installing an application server on this backend machine.
Here is my code.
public class iLinkOnlineSession extends UnicastRemoteObject implements Session, Serializable, Runnable
public iLinkOnlineSession(String sessName, String sessId, String rootLogs, String rootWrks) throws RemoteException
setSessionId(sessId);
setName(sessName);
ROOT_LOGS = rootLogs;
ROOT_WORKSPACE = rootWrks;
searchKeys_ = new Vector();
searchObjects_ = new Hashtable();
Thread s = new Thread(this);
s.start();
public void run()
System.out.println("running");
public String checkLogin(String user, String passwd)
String msg = "";
String cmd = "iLinkOnlineLogin";
cmd += " param "+ user + " param " + passwd;
System.out.println("cmd: " + cmd);
try
Runtime run = Runtime.getRuntime();
Process proc = run.exec(cmd); // Call to the external program.
InputStream in = proc.getInputStream();
Reader inp = new InputStreamReader(in);
BufferedReader rd = new BufferedReader(inp);
String line = rd.readLine();
while(line != null)
System.out.println(line);
msg += line;
line = rd.readLine();
int res = proc.waitFor();
}catch(Exception e)
e.printStackTrace();
System.out.println("Msg: " + msg);
return msg;
public String searchObject(String user, String passwd, String param1, String paramVal1, String param2, String paramVal2, String param3, String paramVal3, String relLev, String mfgLoc)
String cmd = "iLinkOnlineSearch";
cmd += " param " + user + " param " + passwd + " param " + getSessionId() + " param " + logFile_ + " param " + param1 + " param " + paramVal1 +
" param " + param2 + " param " + paramVal2 + " param " + param3 + " param " + paramVal3 + " param "
+ relLev + " param " + mfgLoc;
System.out.println("cmd: " + cmd);
try
Runtime run = Runtime.getRuntime();
Process proc = run.exec(cmd); // External program.
InputStream in = proc.getInputStream();
Reader inp = new InputStreamReader(in);
BufferedReader rd = new BufferedReader(inp);
FileWriter out = new FileWriter(resultFile_);
System.out.println("Filename: "+resultFile_);
BufferedWriter wout = new BufferedWriter(out);
String line = rd.readLine();
while(line != null)
System.out.println(line);
wout.write(line);
wout.newLine();
wout.flush();
line = rd.readLine();
int res = proc.waitFor();
wout.close();
if(res == 0)
boolean ret = createResultTable();
if(ret == true)
return GlobalConstants.SUCCESS_MSG;
else
return GlobalConstants.ERROR_MSG;
}catch(Exception e)
e.printStackTrace();
System.out.println("getting results");
return GlobalConstants.ERROR_MSG;
}I guess I don't get it.
RMI servers are inherently multi-threaded, so why are you running separate servers for every client? -
How to register RMI object with runnign Weblogic Server instance?
I need to write some RMI objects(non EJB) and register it with the already running weblogic server so that I can access them from a RMI client.
Can some help me with this?So more precisely the way I am doing it is
I have a remote interface
package com.myserv.rmi;
public interface NSPQueryExecutionService extends java.rmi.Remote
public void getQueryExecutionDelegate();
I have the Implementation as
package com.myserv.rmi;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class NSPQueryExecutionServiceImpl
implements NSPQueryExecutionService
public static final void main (String[] arg) {
try {
Properties properties = null;
properties = new Properties();
properties.put (Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Context context = new InitialContext(properties);
context.bind("QueryExecutionService", new NSPQueryExecutionServiceImpl());
System.out.println("================================> QueryExecutionService Bound");
} catch (Exception ex){
ex.printStackTrace();
System.out.println("Unable to start QueryExecutionService");
public NSPQueryExecutionServiceImpl()
public void getQueryExecutionDelegate()
System.out.println("inside remote");
I compile these classes and I do a weblogic.rmic as
java weblogic.rmic com.myserv.rmi.NSPQueryExecutionServiceImpl
I run the NSPQueryExecutionServiceImpl class to bind the RMIObject with the weblogic server.
Finally when I try to access this from my client it is able to access the object but when I invoke an operation on it gives the exception that RJVM is already shutdown.
Edited by kuldeep.sharma at 02/15/2007 9:37 AM -
Trouble in storing and retrieving RMI object in Weblogic 7 JNDI tree.
I have created a simple server (BankImpl), implementing a RMI interface
called Bank. A stub class (BankImpl_Stub.class) is generated from BankImpl
class using
"rmic -v1.2". Then I bind an instance of the BankImpl class to the JNDI tree
in Weblogic
server 7 under the name of "PeopleBank".
After the binding, I can see the stub class in the JNDI tree, but with a
different name: BankImpl_WLStub.class). when a
client program is trying to lookup the stub associated with "PeopleBank", it
failed with a puzzling message:
java.io.NotSerializableException: BankImpl_WLStub
Why a stub of a RMI object is not serializable? Does Weblogic needs a
different rmic to generate RMI stubs?
Thanks,
LianI have created a simple server (BankImpl), implementing a RMI interface
called Bank. A stub class (BankImpl_Stub.class) is generated from BankImpl
class using
"rmic -v1.2". Then I bind an instance of the BankImpl class to the JNDI tree
in Weblogic
server 7 under the name of "PeopleBank".
After the binding, I can see the stub class in the JNDI tree, but with a
different name: BankImpl_WLStub.class). when a
client program is trying to lookup the stub associated with "PeopleBank", it
failed with a puzzling message:
java.io.NotSerializableException: BankImpl_WLStub
Why a stub of a RMI object is not serializable? Does Weblogic needs a
different rmic to generate RMI stubs?
Thanks,
Lian -
Unable to retreive RMI object bound to JNDI
Hi
I am trying to retrieve an rmi object that appears to have been sucessfully
deployed to the weblogic server. Upon startup the nt command console shows
the message below and the class name appears in the Distributed objects/rmi
area in the Weblogic console.
Invoking main-style startup Guid xxxxxx.GuidImpl
However if I try to write a test client using either one of the following
calls I get a NameNotFoundException.
I have tried both the name Guid (which is what is in the startup entry) and
the fully qualified name. They all have the same results.
Sample calls:
Naming.lookup("Guid");
or
getInitialContext();
jndiContext.lookup("Guid");
In my weblogic properties files I have the following entry:
weblogic.system.startupClass.Guid=xxx.GuidImpl
in the main of GuidImpl class I have the following entry:
Naming.bind("xxx.Guid");
any ideas as to what might be wrong?
ThanksHi, all:
Currently I evaluate BEA Weblogic 6.1 server. I've read the "Programming
WebLogic JNDI" section of the documentation for Weblogic server 6.1.
However, I couldn't find the answer for my question. What problem I have
now is that
(1): How I can create a object in the Java VM when the Weblogic server
startup? Note:
This class need to read a property files and
store all of properties information into its instance for the
client program to lookup it later.
(2): How can the previous created object to be bound in the Weblogic
JDNI server and the bounded
object can be shown up in the JDNI tree in the Weblogic server's
console?
(3): How do I code my servlet to lookup that object I
just created in the step1? What configuration settings need to be
done before Weblogic server is started?
Because I am stopped by this problem, if anyone can give me the example
code or some explanation of the solution ASAP,
it would be very appreciated....Thanks in advance.......
Merry Christmas
Long -
Reusing a variable from a new object instance
I'm developing a stock list array for an assignment I'm currently working on. I've got most of it done, and it seems to be working for the most part, but I'm having trouble getting an array to accept individual variable entries created by new object instances in TestQ3.java.
I think problem is because the variable itemCode in CraftItem.java is being overwritten by the creation of a new object instance in the TestQ3.java file. I've tested it and believe this to be true.
I can add a String of my own choosing by using testArray.addCraftItemToStock(itemCode); line but I want to get the program to reuse the itemCode values that have already been created by the four new object instances in TestQ3.java. For example, I want to be able to add more instances of them to the testArray.
As I'm still relatively new to Java programming, I'm wondering how to do this. I've tried several solutions but I'm not getting anywhere. I'd appreciate it if anyone has any ideas?
Here's my code:
TestQ3.java
public class TestQ3 {
public static void main(String args[]) {
// creating a new StockItem array
CraftStock testArray = new CraftStock(CraftStock.initialStockCapacity);
// creating new object instance for Glue
Glue gluePVA = new Glue("PVA Glue",250,"789012",2.50);
// adds gluePVA item code to the testArray list
// testArray.addCraftItemToStock(gluePVA.getItemCode());
// creating new object instance for Card
Card colouredCard = new Card ("Coloured Card","A3","654321",1.25);
// adds coloured card item code to the testArray list
// testArray.addCraftItemToStock(colouredCard.getItemCode());
// creating new object instance for Glue
Glue superGlue = new Glue ("Super Glue",25,"210987",1.50);
// adds superGlue item code to the testArray list
// testArray.addCraftItemToStock(superGlue.getItemCode());
// creating new object instance for Card
Card whiteCard = new Card ("White Card","A4","123456",0.50);
// adds superGlue item code to the testArray list
// testArray.addCraftItemToStock(whiteCard.getItemCode());
// display complete stocklist
testArray.displayCraftStockList();
// this adds the itemCode from gluePVA to the array but
// it comes out as the last itemCode entry 123456 rather than 789012
// when I run the code. The problem may lie with variable itemCode
testArray.addCraftItemToStock(gluePVA.getItemCode());
// display complete stocklist
testArray.displayCraftStockList();
CraftItem.java
public class CraftItem {
// instance variables
public static String itemCode;
private double price;
//private int stockCount;
// constructor
public CraftItem(String itemCodeValue, double itemPriceValue){
itemCode = itemCodeValue;
price = itemPriceValue;
//CraftStock.addCraftItemToStock(itemCode);
//stockCount++;
// getter for itemCode
public String getItemCode() {
return itemCode;
// getter for price
public double getPrice() {
return price;
// setter for itemCode
public void setItemCode(String itemCodeValue) {
itemCode = itemCodeValue;
// setter for price
public void setPrice(double itemPriceValue) {
price = itemPriceValue;
// toString() value
public String toString() {
return "Item code is " + itemCode + " and costs " + price + " pounds.";
Glue.java
public class Glue extends CraftItem{
// Instance variables
private String glueType;
private double glueVolume;
// Constructor
public Glue(String glueType, double glueVolume,
String itemCodeValue, double itemPriceValue) {
super(itemCodeValue, itemPriceValue);
glueType = glueType;
glueVolume = glueVolume;
// getter
public String getGlueType() {
return glueType;
// getter
public double getGlueVolume() {
return glueVolume;
// setter
public void setGlueType(String glueTypeValue) {
glueType = glueTypeValue;
public void setGlueVolume(double glueVolumeValue) {
glueVolume = glueVolumeValue;
// toString
public String toString() {
return glueType + ", " + glueVolume + "ml, item code is "
+ super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
Card.java
public class Card extends CraftItem{
// instance variables
private String cardType;
private String cardSize;
// Constructor
// added super(itemCodeValue, itemPriceValue) to call on CraftItem
public Card(String cardTypeValue, String cardSizeValue,
String itemCodeValue, double itemPriceValue) {
super(itemCodeValue, itemPriceValue);
cardType = cardTypeValue;
cardSize = cardSizeValue;
// getter
public String getCardType() {
return cardType;
// getter
public String getCardSize() {
return cardSize;
// setter
public void setCardType(String cardTypeValue) {
cardType = cardTypeValue;
// setter
public void setCardSize(String cardSizeValue) {
cardSize = cardSizeValue;
// toString
// using super. to call on methods from superclass CraftItem
public String toString() {
return cardType + ", size " + cardSize + ", item code is "
+ super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
CraftStock.java
public class CraftStock {
public static int currentStockLevel;
public static String[] craftStock;
public static int initialStockCapacity = 10;
public CraftStock(int initialStockCapacity) {
currentStockLevel = 0;
craftStock = new String[initialStockCapacity];
public int currentStockLevel() {
return currentStockLevel;
public static void addCraftItemToStock(String itemCodeValue) {
if(currentStockLevel == 10){
System.out.println("Stock list full: cannot add new item code." +
"\nPlease remove an item if you want to add a new one.");
else{
craftStock[currentStockLevel] = itemCodeValue;
currentStockLevel++;
System.out.println("Item added");
public void removeCraftItemFromStock(String itemCode){
findStockItem(itemCode);
int i = -1;
do {
i++;
} while (!craftStock.equals(itemCode));
for (int j = i; j < currentStockLevel - 1; j++) {
craftStock[j] = craftStock[j + 1];
currentStockLevel--;
System.out.println("Item removed");
private int findStockItem(String itemCode){
int index = 0;
for(int i = 0; i < currentStockLevel; i++){
if(craftStock[i].equals(itemCode)){
index = i;
break;
else{
index = -1;
return index;
public void displayCraftStockList() {
if(currentStockLevel == 0){
System.out.println("There are no items in the stock list");
else{
for(int i = 0; i < currentStockLevel; i++){
System.out.println("Item at " + (i + 1) + " is " + craftStock[i]);
Message was edited by:
NikariusAn instance variable relates to an object. If you require a variable to be available across multiple objects of the same class then I suggest you declare a class variable using the static keyword in your declaration.
HTH -
How to Use Transient View Objects to Store Session-level Global Variables
hi
Please consider section "40.8.5 How to Use Transient View Objects to Store Session-level Global Variables"
at http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm#ADFFD19610
Based on this documentation I created the example application
at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.01.zip
It behaves as show in the screencast at http://screencast.com/t/qDvSQCgpvYdd
Its Application Module has a Transient View Object instance "MyEmployeesContextVOVI", as master for the child View Object instance "EmpInCtxJobVI".
On rollback the Transient View Object instance keeps its row and attribute values.
Also when passivation and activation is forced (using jbo.ampool.doampooling=false ) the Transient View Object instance seems to keep its row and attribute values.
questions:
- (q1) Why does the expression #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty} evaluate as true when a Transient View Object instance attribute value is changed (as shown in screencast at http://screencast.com/t/qDvSQCgpvYdd )?
- (q2) What would be a robust approach to make a Transient View Object instance more self-contained, and manage itself to have only one single row (per instance) at all times (and as such removing the dependency on the Application Module prepareSession() as documented in "5. Create an empty row in the view object when a new user begins using the application module.")?
many thanks
Jan VerveckenThanks for your reply Frank.
q1) Does sample 90 help ? http://blogs.oracle.com/smuenchadf/examples/
Yes, the sample from Steve Muench does help, "90. Avoiding Dirtying the ADF Model Transaction When Transient Attributes are Set [10.1.3] "
at http://blogs.oracle.com/smuenchadf/examples/#90
It does point out a difference in marking transactions dirty by different layers of the framework, "... When any attribute's value is changed through an ADFM binding, the ADFM-layer transaction is marked as dirty. ...".
This can be illustrate with a small change in the example application
at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.02.zip
It now shows the result of both these expressions on the page ...
#{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty}
#{bindings.MyEmployeesContextVOVIIterator.dataControl.dataProvider.transaction.dirty}... where one can be true and the other false respectively.
See also the screencast at http://screencast.com/t/k8vgNqdKgD
Similar to the sample from Steve Muench, another modification to the example application introduces MyCustomADFBCDataControl
at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.03.zip
public class MyCustomADFBCDataControl
extends JUApplication
@Override
public void setTransactionModified()
ApplicationModule vApplicationModule = (ApplicationModule)getDataProvider();
Transaction vTransaction = vApplicationModule.getTransaction();
if (vTransaction.isDirty())
super.setTransactionModified();
}Resulting in what seems to be more consistent/expected transaction (dirty) information,
see also the screencast at http://screencast.com/t/756yCs1L1
Any feedback on why the ADF Model layer is so eager to mark a transaction dirty is always welcome.
Currently, question (q2) remains.
regards
Jan -
Object instance 1200 does not exist (while executing task SWUS)
hello all,
i have created a workflow class and two methods (constructor, display) and 1 attribute PLANT (instance,public) in it.
i am using this class and display method in task t code PFTC.
While executing this task from SWUS , i am getting this error.Object instance 1000 does not exist.
As i was going through this blog. i have created everything exactly just like it is mentioned there.
But still i am getting this error. please guide me to detect where i am mistaken.
http://scn.sap.com/community/bpm/business-workflow/blog/2006/07/25/using-abap-oo-methods-in-workflow-tasks
this is class screen-shot and error i am facing while executing the task.
The methods which are implemented using the interface are emtpy(don't contain any source code lines).sorry i forgot to mention that input value 1000 does exist in our system.
i have also tried F4 help. it is showing all existing plants in our system, but still it is not accepting values select from f4 help.
Also to add information,
I have executed class using F8 option in class builder, and it is working perfect.
source code of display method.(i am trying to view plant in display method just like in blog).
method DISPLAY.
break-point.
data: ls_vt001w type v_t001w.
CLEAR ls_vT001W.
ls_VT001W-MANDT = SY-MANDT.
ls_VT001W-WERKS = me->PLANT.
CALL FUNCTION 'VIEW_MAINTENANCE_SINGLE_ENTRY'
EXPORTING
ACTION = 'SHOW'
VIEW_NAME = 'V_T001W'
CHANGING
ENTRY = ls_vT001W.
endmethod. -
Need Ideas for creating and using Custom Business Object
Hello Guys,
I am developing an application which uses a Request->Approve->Create approach for creating Purchase documents.
Now I am a little puzzled about how to make use of the Business Object BUS2014.
The application I am developing has its own unique 'Request Number' (say REQID) which will point to the Request for Creation of a purchase order.
Whenever a Request is created (from a Z-Tcode) a workflow needs to be initiated and it has to be sent to the approver.
The Purchase Document will be created once the approver approves.
Now my confusion here is, if I use BUS2014, the object will be instantiated only during the final step of the workflow. But I need an instance during the beginning of the Requestor ->Approver negotiations as I am playing with events. These events needs an Object_key.
How should I proceed here?
Should I create a new logical Business Object like ZPOREQ where I have the above mentioned REQID as the key?
And should I have an attribute of type BUS2014 inside the custom BO?
How will I make use of the methods like BUS2014.Create etc which I may need to create the purchase document?
Any small direction will be a huge help for me to get used to this wilderness.Hi,
You should continue with the ABAP class idea. The business objects are kind of "obsolete" already, and if there is a need to create a new "object", ABAP classes are the way to go. Business objects are still useful, but I normally use them only when an existing standard business object fulfills the requirements (possibly with slight additions) which is almost never.
From my point of view you can use the existing class. Depending on the circumstances I normally have just one class that I use for both workflow and the possible other functionality that is required, but you have to understand that I have this goal in my mind already when starting the development process. As your class most probably has many useful features already (such as you have the header and item data as attributes etc. (if I understood correctly?), these are also useful in in workflow (class attributes will be available in WF container etc.).
If you are hesitant to use the same class directly in your workflow, you could also create a new class ZCL_REQUEST_FOR_WF (with the workflow interface), and then simply add your existing class ZCL_WF_REQUEST as an attribute to this new class. Then this new workflow class could include the pure workflow stuff, and your existing class the non-workflow stuff. But this most probably will not make much sense - just implement the if_workflow interface in your existing class (this is just one possibility that you might consider.)
Regards,
Karri -
How to invoke BPM object instance variable from interactive activity?
I have a screenflow with an automatic activity "A" followed by an interactive activity "B". "B" calls a BPM object "X" and uses a JSP presentation to show its attributes. Is there a way to use another BPM object, say type "Y", create an instance variable of that type inside "A", and get its attributes values from the JSP page associated to "B"?
Edited by: user6473912 on 20/07/2010 03:37 PMTry this. It assumes you have:
<li> a user named "auto"
<li> a project variable named "customerType"
<li> an instance variable named "orderAmount" that is a decimal
<li> an instance variable named "order" that is a BPM Object that has attributes named "customerName" and "amount"
ps as ProcessService
xmlObject as Fuego.Xml.XMLObject
do
connectTo ps
using url = Fuego.Server.directoryURL,
user = "auto",
password = "auto"
instF as InstanceFilter
create(instF, processService : ps)
addAttributeTo(instF, variable : "customerType", comparator : IS, value : "Gold")
instF.searchScope = SearchScope(participantScope : ParticipantScope.ALL, statusScope : StatusScope.ONLY_INPROCESS)
for each inst in getInstancesByFilter(ps, filter : instF) do
// here's how to get the value inside a primitive instance variable
orderAmtObj as Object = getVar(inst, var : "orderAmount")
// here's how to get the value of attributes inside a complex BPM Object instance variable
// - in this case this is an "order" object with two attributes (customerName and amount)
orderObj as Object = (getVar(inst, var : "order"))
xmlObject = Fuego.Xml.XMLObject(createXmlTextFor(DynamicXml, object : orderObj, topLevelTag : "xsi"))
logMessage "The value of the order object's customer name is: " +
selectString(xmlObject, xpath : "customerName")
logMessage "The value of the order object's order amount is: " +
selectNumber(xmlObject, xpath : "amount")
// here's a rather uninspired way to retrieve who the participant is that was assigned the instance
logMessage "The participant assigned to this instance is: " + inst.participantId
end
on exit
disconnectFrom ps
endDan -
OIM - Task Assignment Adapter - How to get the object instance key?
Hello experts,
I'm trying to use a task assignment adapter to assign an approval task dynamically. Basically, the user can request a resource like "CustomApp Profiles" and we create an object form to let them choose the profile that he needs. Each profile has an owner, which is populate in a Lookup (Owner is the code and Profile is the decode).
So, in the approval task, I need to get the profile selected by user in the object form and search into the lookup who is the owner of that profile. But I don't know how can I get the object instance key using the parameters that can be mapped to a task assignment adapter.
Looking into the OIM documents, I believe that the easier way is using the request key, because the REQ_KEY is a foreign key in OBI table.
Did anyone knows how can I get the object instance key using the request key? Can I use some API or should I execute a SQL statement directly in OIM database?
Best Regards,
NittoTo retry a task that is in a rejected state, you use the SCH_KEY which is the task key. In OIM, all rejected tasks are listed in the OTI table. It contains all the important information about a rejected or pending task.
You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
-Kevin -
How can i have a refrence of a java class object instance in my c++ project
Hi!
How can i have a refrence of a java class object instance in my c++ project. Is there a way?hahaxia wrote:
The second question is the big one. The first question is half of the problem of "c++ to java" invocation and access. But the other half which is "java to c++ " invocation and access is still not solved. jni only provide the "java to c++ " DLL invocation Wrong,
Using JNI your java classes can have methods implemented in C/C++.
Using JNI you can call java classes.
There is no other possible interaction between C++ and java, so it does it all. -
is there a way to tell if a plugin is no longer needed. In other words is there a way to tell when it was last used to determine if it should be deleted. for instance iphoto6,
the 4-5th digits of the serial number indicate week of production
ie 82327 = week 27 of the year.
Maybe you are looking for
-
Is there a way to create actions in Photoshop Elements 7
Is there a way to create actions in (or for, other than Photoshop, CS3, 4, 5) Photoshop Elements 7?
-
Moved music, now itunes can't locate songs
I moved my music to a second internal hard drive hard drive. Now Itunes can't find the songs even though I have changed the music file location. Each song title has an Exclamation point next to it in the itunes library window. Any suggestions?
-
"best practice to maintain the SAP OM Org Structure"
Hi SAP Experts, My client want to have an best practice or an safe process to update, better and maintain their existing SAP HCM Organizational Structure. In one way you can say that i am doing an process oriented job. Our client system is not up-to-
-
How do I uninstall the MSI DOT program.
HI, I'd like to know how I uninstall the DOT program that comes with MSI VGA drivers. If I just uninstall the MSI driver, then install a nvidia driver, the DOT part of the old msi driver comes back. how do I remove this? Ive tried using the driver cl
-
If the mouse is moved inside a Firefox window, everything resumes, so long as the mouse keeps moving. Keypresses while Firefox has the input focus also get it going (holding shift down works as well). If the task manager is open and the mouse is stat