Factory Patterns with Generics

I am trying to combine the good old factory pattern with generics and could use some advice.
I have the following
//Base class from which all my things extend
public abstract class Thing {
//one kind of thing
public class ThingOne extends Thing {
//another kind of thing
public class ThingTwo extends Thing {
//interface for my factory
public interface ThingFactory<T> {
public T create(long id);
//a factory for thingones
public class ThingOneFactory<T> implements ThingFactory<T> {
public T create(long id) {
return (T) new ThingOne();
public class TestClass{
public <T extends Thing> T getThing(ThingFactory<T> tf){
//do a bunch of generic stuff to figure out id to call create
ThingFactory<T> instance = tf;
return (T) instance.create(Long id);
}My calling code would know what kind of thing it needs but necessarily the things id. Which can be computed in a generic way.
TestClass gt = new TestClass();
gt.getThing(new ThingOneFactory<ThingOne>());This all seems to work properly but I am getting "Type safety: Unchecked cast from ThingOne to T" in my ThingOneFactory
My T's will always extend Thing, what am I missing? Is there a better way to do this?
Edited by: nedry on Dec 29, 2009 5:39 PM

I thought of that after I posted. But that just moves my unsafe cast warning into TestClass.Why?
return (T) instance.create(Long id);That can't have ever compiled. What is the exact code? And why did you have to cast (what was the warning/error)?

Similar Messages

  • Factory Design Pattern with Java generics

    I was wondering if it was possible to implement the factory pattern using a generic like sintax with java5. Something like:
    IFactory factory = new ConcreteFactory();
    Car c=factory.CreateObject<Car>();
    I saw this article the other day http://weblogs.asp.net/pgielens/archive/2004/07/01/171183.aspx
    done in C# for the framework 2.0 and tryed to re-implement it with java5 however I was less then fortunate, can someone do a functional conversion?

    I had to change the signature a bit but this is the best I came with:
    (I don't like I have to write Type.class but if someone has a better idea please share, I deliberatly used classes are return types but you can easily program to the interfaces as well)
    use:
    ConcreteFactory cf=new ConcreteFactory();
    Car c=cf.Create(Car.class);
    public interface Vehicle {
    String getName();
    public class Plane implements Vehicle {
    String name="Mig 29";
    public String getName() {
    return name;
    public class Car implements Vehicle {
    String name="Volvo";
    public String getName() {
    return name;
    public interface IFactory{
    <T> T Create(Class<T> type);
    public class ConcreteFactory implements IFactory {
    public <T extends Vehicle> T Create(Class<T> type) {
    try {
    return type.newInstance();
    } catch (InstantiationException e) {
    return null;
    } catch (IllegalAccessException e) {
    return null;
    }

  • Problems with Factory pattern

    Sorry... I know this topic has been done to death but I still have some questions.
    In my development, I keep encountering a recurring problem that I believe should be solved by the 'factory pattern'. (Note: I'm not a patterns nut so I am only guessing about the correct pattern).
    Here is the problem:
    I develop an abstract base class. I extend the base class with several subclasses. Exterior objects use the instances via a base class reference and I don't want to them to have to know which is the correct subclass or how to create the instance.
    My solution is to make a create(param, param,...) method in the base class and using the param(s) construct the instance something like:static Foo create(int type)
    Foo instance = null;
    String className = "com.myco.foos.DefaultFoo";
    if(CONST_A == type)
      className = "com.myco.foos.FooA";
    else if(CONST_B == type)
      className = "com.myco.foos.FooB";
    {on and on...}
    {using reflection create a new instance from the className String}
    return instance;
    }The obvious problem with the create() method is that it becomes a maintenence point and I don't like the idea of a base class knowing about subclasses.
    Anyone know better a solution? Comments?
    Thanks in advance.

    Yes, that is the Factory pattern you describe. The client programs are going to call your createFoo() method and get back an instance of a subclass of Foo. Typically this pattern is used where there is some external entity that determines what subclass will be returned -- for example a system property -- and the client programs call createFoo() with no arguments. In this case reflection is used to create the instance, and your base class does not need to know anything about any subclasses.
    However, if your client programs can influence the choice of subclass, then they will have to pass some kind of parameter into createFoo(). At this point, createFoo() requires some decision logic that says "create this, or that, depending on the input parameter". And if that parameter is simply a code that enables the client programs to say "Give me a ChocolateFoo instance", then returning "new ChocolateFoo()" is the most straightforward design. But in this case, why can't the client program do that?
    If you don't like the base class having to know about subclasses (and you shouldn't be happy if it does), then you could have a helper class -- FooFactory -- that contains only the static method createFoo(). This class would know about Foo, and about any of its subclasses that it can produce instances of. It's still a maintenance point, no avoiding that, but at least it is off by itself somewhere.

  • Need a little help with this factory pattern thing..

    Evening all,
    I have an assignment to do over easter, before i start i will say i dont want any code or anything so this isnt 'cheating' or whatever..
    This was the brief:
    A vending machine dispenses tea and coffee, to which may be added milk, and 0, 1 or 2 doses of sugar. When the machine is loaded it initially contains 100 doses of tea, 100 doses of coffee 50 doses of milk and 70 doses of sugar. After it has been in use for a while it may run out one or more items. For example, it may run out of sugar, in which case it would continue to vend tea, coffee, tea with milk, and coffee with milk. Periodically, an attendant recharges the machine to full capacity with doses of coffee, tea, milk and sugar. A user selects the required beverage, selects the required amount of sugar, and selects milk if required. The machine responds with a message telling the user the cost of the drink (coffee is 30P, tea 20P, milk 10P, and sugar 5P per dose). The user inserts coins (the machine accepts 10P and 5P coins), and when the required sum or more has been inserted, the machine dispenses the beverage, and possibly some change.
    You are to write a program that simulates the above vending machine. Your solution must use the class factory pattern, and make use of the code templates provided. The user interface should be constructed with a Swing JFrame object.
    We were suppled with code for all of the classes required except for the JFrame.. They are as follows:
    public abstract class Beverage
      int sugar;
      boolean milk;
      public String getMessage()
        String name = this.getClass().getName();
        String sugarMessage = "";
        if (sugar == 1) sugarMessage = "one sugar";
        if (sugar == 2) sugarMessage = "two sugars";
        if (sugar == 0) sugarMessage = "";
        return  "Vended 1 " + name  +  (milk ? " with milk " : "") + (sugar==1 || sugar == 2 ? (milk ? "and " + sugarMessage : " with " + sugarMessage) : "");
    public class Coffee extends Beverage
      public Coffee( int sugar, boolean milk)
        this.sugar = sugar;
        this.milk = milk;
    public class Tea extends Beverage
      public Tea(int sugar, boolean milk)
        this.sugar = sugar;
        this.milk = milk;
    public class SugarButtonsGroup
      private JRadioButton jRadioButton0Sugar = new JRadioButton();
      private JRadioButton jRadioButton1Sugar = new JRadioButton();
      private JRadioButton jRadioButton2Sugar = new JRadioButton();
      private ButtonGroup sugarButtons = new ButtonGroup();
      public SugarButtonsGroup()
        jRadioButton0Sugar.setText("No sugar");
        jRadioButton1Sugar.setText("1 sugar");
        jRadioButton2Sugar.setText("2 sugars");
        sugarButtons.add(this.jRadioButton0Sugar);
        sugarButtons.add(this.jRadioButton1Sugar);
        sugarButtons.add(this.jRadioButton2Sugar);
      public int numberOfSugars()
        if (this.jRadioButton1Sugar.isSelected()) return 1;
        if (this.jRadioButton2Sugar.isSelected()) return 2;
        return 0;
      public ButtonGroup getButtonGroup()
        return sugarButtons;
      public JRadioButton getJRadioButton0Sugar()
        return jRadioButton0Sugar;
      public JRadioButton getJRadioButton1Sugar()
        return jRadioButton1Sugar;
      public JRadioButton getJRadioButton2Sugar()
        return jRadioButton2Sugar;
    public class BeverageButtonsGroup
      private JRadioButton jRadioButtonTea = new JRadioButton();
      private JRadioButton jRadioButtonCoffee = new JRadioButton();
      private ButtonGroup buttonGroup = new ButtonGroup();
      public BeverageButtonsGroup()
        buttonGroup.add(jRadioButtonTea);
        buttonGroup.add(jRadioButtonCoffee);
        jRadioButtonTea.setText("Tea");
        jRadioButtonCoffee.setText("Coffee");
        jRadioButtonCoffee.setSelected(true);
      public String getBeverageName()
        if (jRadioButtonTea.isSelected()) return "tea";
        if (jRadioButtonCoffee.isSelected()) return "coffee";
        return "";
      public ButtonGroup getBeverageButtonGroup()
        return buttonGroup;
      public JRadioButton getJRadioButtonTea()
        return jRadioButtonTea;
       public JRadioButton getJRadioButtonCoffee()
        return jRadioButtonCoffee;
    public class MilkCheck
      private JCheckBox jCheckBoxMilk = new JCheckBox();
      public MilkCheck()
        this.jCheckBoxMilk.setText("Milk");
      public JCheckBox getJCheckBoxMilk()
        return jCheckBoxMilk;
      public boolean withMilk()
        return this.jCheckBoxMilk.isSelected();
    public class CoinMechanism
      private JButton jButton5P = new JButton();
      private JButton jButton10P = new JButton();
      private JTextField jTextFieldTotal = new JTextField();
      private BeverageFactory b;
      public CoinMechanism (BeverageFactory b)
        this.b = b;
        reset();
        jTextFieldTotal.setEditable(false);
        jButton5P.setText("Insert 5 pence");
        jButton5P.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
              jButton5P_actionPerformed(e);
        jButton10P.setText("Insert 10 pence");
        jButton10P.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
              jButton10P_actionPerformed(e);
      private void jButton5P_actionPerformed(ActionEvent e)
        // to be completed
      private void jButton10P_actionPerformed(ActionEvent e)
        // to be completed
      private void notifyVend()
        b.getCoinCurrentTotal(jTextFieldTotal.getText());
      public void reset()
         this.jTextFieldTotal.setText("0");
      public JButton getJButton5P()
        return this.jButton5P;
      public JButton getJButton10P()
        return this.jButton10P;
      public JTextField getJTextFieldTotal()
        return this.jTextFieldTotal;
    public class BeverageFactory
      private int coffees;
      private int teas;
      private int milks;
      private int sugars;
      public BeverageButtonsGroup beverageButtons = new BeverageButtonsGroup();
      public SugarButtonsGroup sugarButtons = new SugarButtonsGroup();
      public MilkCheck milkCheck = new MilkCheck();
      public CoinMechanism slots = new CoinMechanism(this);
      public void setUIState()
        // sets the states of the widgets on the frame accoording to the
        // quantities of supplies in the machine
        // to be finished
      public void getCoinCurrentTotal (String o)
        // this is should be executed whenever a user puts a coin into the machine
        int foo = Integer.parseInt(o);
        // to be finished
      private int cost()
        // returns the cost of the currently selected beverage
        // to be finished
      public BeverageFactory( int coffees, int teas, int milks, int sugars)
        this.coffees = coffees;
        this.teas = teas;
        this.milks = milks;
        this.sugars = sugars;
      public void refill(int coffees, int teas, int milks, int sugars)
        // to be completed
      public Beverage makeBeverage(String name, boolean milk, int sugar)
        if (name.compareTo("coffee") == 0)
          coffees--;
          if (milk) milks--;
          sugars = sugars - sugar;
          return new Coffee(sugar,milk);
        if (name.compareTo("tea") == 0)
          teas--;
          if (milk) milks--;
          sugars = sugars - sugar;
          return new Tea(sugar, milk);
        return null;
    }Okay, well if you read through all that, blimey thanks a lot!.
    My question relates to this method in the BeverageFactory class:
    public void getCoinCurrentTotal (String o)
        // this is should be executed whenever a user puts a coin into the machine
        int foo = Integer.parseInt(o);
        // to be finished
      }I don't understand what the heck its supposed to be for..
    I can obtain the current amount of coins inserted from the textbox in the CoinMechanism class. The only thing i could think of, would be for this to enable the 'Vend' button, but it doesnt have access anyway..
    Any suggestions would be hugely appreciated, I have tried to contact the lecturer but he isnt around over easter i guess..
    Many thanks.

    I'm not going to read all that, and I don't do GUIs, so this is just a guess, but it looks like the CoinMechanism class is intended to be just a dumb processor to accept coins and determine what each coin's value is, but no to keep a running total.
    That in itself is an arguably acceptable design--one class, one job and all that. But I don't know that it makes sense to have the BeverageFactory keep the running total.
    Overall, I gotta say, I'm not impressed with your instructor's framework. Maybe it's just because I didn't look at it closely enough, or maybe it's more of a naming problem than a design problem, but it seems to me he's mixing up GUI code with business logic.
    Good luck.

  • BlazeDS and Abstract Factory Pattern

    Hi All,
    I was trying to extend my application using the Factory Method. But, I identified that I need to use an abstract Factory pattern to meet my design requirements. In other words I need to create a FactoryInstance based on a input. Will that be possible.
    Any help?????
    -Ram V

    The Factory pattern is meant to give you the ability to generically construct objects (rather than explicitly declare what you want to create via the "new" keyword you defer to a factory and take what it gives you) The Abstract Factory pattern is meant to give you the ability to generically construct Factories. So, for instance, say you want to create widgets with a certain look and feel. You could use the Factory pattern and ask a ButtonFactory to make buttons and a TextArea factory to make TextAreas, but since you want the same look and feel for all widgets you could just ask the WidgetFactory to give you a WidgetFactory for a given Look and Feel and then ask it to make Buttons and TextAreas and whatever else, knowing that it has handled which kind of button and whatever else you need.
    Hope that made sense, good luck
    Lee

  • Help building an executable that uses a factory pattern

    Hello,
    I'm trying to build an .exe from a VI that uses the factory pattern. The VI gives me the error that it can't find the classes to load and is looking outside the .exe file to find them. The specific error is:
    "Get LV Class Default Value.vi<APPEND>
    <b>Complete call chain:</b>
         Get LV Class Default Value.vi
         Main.vi
    <b>LabVIEW attempted to load the class at this path:</b>
    C:\ATE\Experiments\Build Testing\Builds\Virtual Classes\High Class\High Class.lvclass"
    I thought those classes were bundled into the .exe when it was built? I have included the class folders in the "Always Included" window of the build script.
    Any help would be appreciated. I'm fairly new to classes and I haven't built an .exe with an app using the factory pattern.
    Thanks,
    Simon
    Attachments:
    Build Testing.zip ‏491 KB

    This might be the answer.  I found the following checklist on Building Executables.  It really is referencing things other than Objects, but maybe Object folders also need to be properly located ...
    Bob Schor  [the stuff I found is below this line ...]
    Ensure paths generate correctly.
    Details
    If a VI loads other VIs dynamically using VI Server or calls a dynamically loaded VI through a Call By Reference node, make sure the application or source distribution creates the paths for the VIs correctly. To ensure paths generate correctly, use relative paths to load the VIs. The following table depicts the relative paths for a top-level VI, foo.vi, which calls a.vi and b.vi. C:\..\Application.exe represents the path to the application.
    Path to source files
    Path to files in application
    C:\Source\foo.vi
    C:\..\Application.exe\foo.vi
    C:\Source\xxx\a.vi
    C:\..\Application.exe\xxx\a.vi
    C:\Source\yyy\b.vi
    C:\..\Application.exe\yyy\b.vi
    If you use the LabVIEW 8.x file layout and you include dynamically loaded VIs in the application, the paths to the VIs change. For example, if you build b.vi into an application, its path is C:\..\Application.exe\b.vi whereC:\..\Application.exe represents the path to the application and its filename.

  • LVOOP Factory Pattern

    Factory Pattern..
    I am using factory pattern for its advantage of loading classes into memory when it is called dynamically.
    But I am able to see all the classes loaded into memory by looking into LabVIEW Class Hierarchy window and VI Hierarchy window.
    Where this not happen. Please suggest solution for this query.
    nilesh
    Attachments:
    Factory Pattern.zip ‏136 KB

    I'll reply but I am no OOPer expert.
    THe factory pattern as implemented in LV is just anum driven case structure where each case can have a different instance of a class constant. All of the Class constants exit through the same tunnel that LV cast as the common ancestor class of all of the constants in the case structre.
    The exiting wire can be wired to any method available for the common parent class.
    So it is a code construct that lets you choose the type of data on the wire.
    The Actor Frame work is another fancy term for a generic barckground task.
    Actors can be instaciated using using teh Factory Pattern to choose the "flavor" of background task.
    Re: All in memory
    If the classes are in the project and the project is open then all of the classes are loaded to make sure they are healty.
    In an exe that is not always the case as is the situation when the classes are not part of the project or the project is closed.
    This image (and the others in that album) show a method I used to find and use compatable classes to create the background task (Active Object).
    Active Object (as I understand them) are instances of a Class that function indepenently once created and provided a method to allow other objects to invoke its exposed methods.
    Example DAQ_Collector
    Child of an I/O class that runs in the background and acepts commands(invoked methods) like "Start", Stop, Exit.
    I will now step back to let those who know more correct what I havge posted.
    Have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • RMI & Factory Patterns

    Hey,
    I'm developing a Chat RMI app for a college assignment. One of the features that's required is to use the Factory Pattern(FP). I've read about Factory patterns and have a bit of an understanding of them but I'm not sure what I developed actually implements a FP. Would the code below be considered a Factory Pattern?
    I've created an interface class called ChatServer and a class which implements this interface called ChatServerImpl. The server with the main method is as follows:
    public class Server {
      public static void main(String[] args) {
        if (System.getSecurityManager() == null) {
          System.setSecurityManager(new RMISecurityManager());
        try {
          ChatServerImpl server = new ChatServerImpl();
          Naming.rebind("DSChat",server);
          System.out.println("DSChat bound in registry");
        catch (RemoteException remoteExc) {
          remoteExc.printStackTrace();
        catch(MalformedURLException malformedURLExc){
          malformedURLExc.printStackTrace();
      }I have a ChatServer, the interface class, object in the Client UI class that calls the server methods, e.g.
    ClientUI
    public class ClientUI extends JApplet implements ActionListener, ClientMonitor
         ChatServer server;
         public void init()
              try
                   server = (ChatServer) Naming.lookup("//" + getCodeBase().getHost()
                             + "/" + serviceName);
              catch (NotBoundException notBoundExc)
                   notBoundExc.printStackTrace();
              catch (MalformedURLException malformedURLExc)
                   malformedURLExc.printStackTrace();
              catch (RemoteException remoteExc)
                   remoteExc.printStackTrace();
         public void start()
              try
                   authenticate = server.authenticate(sessionUser);
              catch (RemoteException remoteExc)
                   remoteExc.printStackTrace();
              if (authenticate)
                   this.componentInit();
                   this.layoutComponents();
                   try
                        UnicastRemoteObject.exportObject(this); // Allow server to
                        // connect.
                        server.registerClient(this);
                   catch (RemoteException remoteExc)
                        remoteExc.printStackTrace();
              else
                   String errMsg = "Sorry you are already logged on to this chat room";
                   JOptionPane.showMessageDialog(this, errMsg, "You're already here",
                             JOptionPane.OK_OPTION);
                   server = null;
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == btnSend)
              {//Checks if textbox is empty
              if (txtInput.getText().compareTo("") != 0)
                   String input = txtInput.getText();
                   txtInput.setText(""); // Clear text field.
                   txtInput.requestFocus();
                   Message msg = new Message(input);
                   server.sendMessage(msg);               
         public void receiveMessage(Message msg)
              // Display received message.
              txtMessages.setText(txtMessages.getText() + "\n" + msg.toString());
              txtMessages.setCaretPosition(txtMessages.getText().length());
    ChatServer Interface
    //Interface
    public interface ChatServer extends Remote{
      public void sendMessage(Message msg) throws RemoteException;
      public boolean authenticate(ChatUser usr) throws RemoteException;
    ChatServerImpl
    public class ChatServerImpl extends UnicastRemoteObject implements ChatServer
         public ChatServerImpl() throws RemoteException
              super();
         public boolean authenticate(ChatUser usr) throws RemoteException
              ClientMonitor client = registeredUsersTMap.get(usr.getUsername());
              if (client == null)
                   return true;
              return false;
          * ChatServer interface method implementation. Sends messages between two
          * users.
         public void sendMessage(Message msg) throws RemoteException
              //Thread sends message to client
              SendMessageThread sendMessage = new SendMessageThread(
                        this.roomUsersHMap, this.registeredUsersTMap, msg);
              Thread tSendMsg = new Thread(sendMessage);
              tSendMsg.run();
    }Any help would be appreciated.

    Question: Does the code compile and run properly?
    Since the Gang of Four published their pattern book, everyone is obsessed with patterns.
    A factory basically creates and returns a new object. The following does that and technically could be called a factory.
    public MyObject createA() {};Just what object does your code create and return to the caller?

  • Difference between Builder Pattern and Factory Pattern

    difference between Builder Pattern and Factory Pattern

    You are right Both of these patterns are creational design patterns Purpose of these two patterns is very different as Abstract Factory Patterns (which is commonly known as Factory pattern ) is used to create a object in a scenario when you have a product & there is a possibility of many vandors providing implementation for it. So it is good to come up with a abastract factory which provides create method for the product. Each vendor can implement you abstract factory & provide a concrete implementation which will return a product of Vendor implementation.
    Builder patter is used in case you have a very complex object creation process involved & you realy want to abstract the client from doing all those complex steps. In such situation you create a builder class which takes care of all complex steps & client just needs to use this builder class to create your complex object.
    Hope it clarifies your doubts.

  • On my ipod touch, i can't seem to get the imessage app.. I have updated my itunes and even restored the ipod to factory settings with the latest update. Maybe the ipod is too old? Help

    On my ipod touch, i can't seem to get the imessage app.. I have updated my itunes and even restored the ipod to factory settings with the latest update. Maybe the ipod is too old? Is that even a thing? Is there another app I can download to have access to my contacts with imessage?

    That comes with iOS 5 (Settings>General>About>Version) and only the 3G abd later iPods can go to iOS 5 or later
    Identifying iPod models

  • Error in Extraction with Generic Datasource via Function Module

    Dear Gurus,
    Iam working for BI-HR module.We are extracting data with generic data source via function module. The client some more extra fields in already existing DS. So we made a copy of that Function module and tried to create new generic DS, we got error while extraction like "Error occured during the extraction process". Can you please help in resolving this issue, your valuable suggestion would be highly appreciated.
    Thanks and regards
    Arun S

    Hi,
    Which structure are you using??
    Are you using the same old structure for this function module as well.
    Have you enhanced the structure with new required fields.
    New extrac fields needs to be added to existing structure if you are using the same or create a new one and make sure that you have all the fields in the structure which you are going to use in the data source.
    You need to take care for the append as well and the issue could be in the code as well.
    Make sure you have written the proper code and just for the new fields done an append
    Thanks
    Ajeet

  • After upgrading to IOS 8 on my iPad I constantly get a temperature warning despite the fact it is cool. Did not happen with IOS 7. I have restored the iPad to factory settings with the problem not resolved.

    After upgrading to IOS 8 on my iPad I constantly get a temperature warning despite the fact it is cool. Did not happen with IOS 7. I have restored the iPad to factory settings with the problem not resolved.

    Hey, I've got the same problem. Did you find any help or solution by now?

  • Import from database an internal table with generic Type : Web Dynpro ABAP

    Hi everyone,
    i have a requirement in which i'm asked to transfer data flow between two frameworks, from WD Component to another. The problem is that i have to transfer internal tables with generic types. i used the import/ export from database approache but in that way i get an error message saying "Object references and data references not yet supported".
    Here is my code to extract a generic internal table from memory.
        DATA l_table_f4 TYPE TABLE OF REF TO data.
      FIELD-SYMBOLS: <l_table_f4> TYPE STANDARD TABLE.
      DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
      DATA: ls_indx TYPE indx.
      lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
      lo_componentcontroller->fire_vh_search_action_evt( ).
      ASSIGN l_table_f4 TO <l_table_f4>.
    *-- Import table for Help F4
      IMPORT l_table_f4 TO <l_table_f4> FROM DATABASE indx(v1) TO ls_indx ID 'table_help_f4_ID'.
    The error message is desplayed when last instruction is executed " IMPORT l_table_f4...".
    I saw another post facing the same problem but never solved "Generic Type for import Database".
    Please can anyone help ?
    Thanks & Kind regards.

    hi KIan,
    go:
    general type
    TYPE : BEGIN OF ty_itab,
               field1 TYPE ztab-field1,
               field2 TYPE ztab-field2,
    *your own fields here:
               field TYPE i,
               field(30) TYPE c,
               END OF ty_itab.
    work area
    DATA : gw_itab TYPE ty_itab.
    internal table
    DATA : gt_itab TYPE TABLE OF ty_itab.
    hope this helps
    ec

  • Error 500 with generic Apache

    Hi,
    I am trying to user Apex Listener 1.0.2 on OC4J fronted with generic Apache 2.0. I configured mod_oc4j and the combination seems to work.
    When i ran apex/listenerConfigure the configuration page shows up. But when I try to Apply changes I constantly get
    500 Internal Server Error
    Servlet error: An exception occurred. The current application deployment descriptors do not allow for including it in this response. Please consult the application log for details.
    Any idea what would be the cause?
    Janis

    Thank you for the answer. This is the log. I hope it helps
    10/10/27 12:39:04.951 apex: 10.1.3.5.0 Started
    10/10/27 12:56:51.975 apex: Servlet error
    java.lang.NoSuchMethodError: java.lang.String.getBytes(Ljava/nio/charset/Charset;)[B
         at oracle.dbtools.apex.utilities.Text.getBytes(Text.java:31)
         at oracle.dbtools.apex.ModApex.notifyNotConfigured(ModApex.java:257)
         at oracle.dbtools.apex.ModApex.doConfig(ModApex.java:98)
         at oracle.dbtools.apex.ModApex.doGet(ModApex.java:92)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    10/10/27 12:59:11.662 apex: Servlet error
    java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
         at oracle.dbtools.apex.admin.AdminManager.validConnection(AdminManager.java:337)
         at oracle.dbtools.apex.admin.AdminManager.validateInfo(AdminManager.java:168)
         at oracle.dbtools.apex.admin.AdminManager.processAdministration(AdminManager.java:81)
         at oracle.dbtools.apex.admin.Admin.doPost(Admin.java:87)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:734)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:391)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:908)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:458)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.5.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Not able to put data selection condition in data selection tab of infopakag

    I was loading data from data source as data mart ( export data sauce from ODS) to other ODS. when I tried to do delta Initialization with data transfer , I am not able to put data selection condition in data selection tab of infopakage. when I choose

  • File-XI-RFC, archiving file only when system ack ok. Is it possible?

    Hi ! We have a File-XI-RFC scenario. We need the file adapter to archive the input file ONLY if the message was delivered ok to the RFC. Should this work, using a BPM with this steps ???? 1) Receive (file message type) 2) Block 2a) Send (ASYNC to the

  • Problem with FX5200 it hangs the computer!

    Hi every one. i have a problem with my FX5200 T-128, it hangs my computer. My system is Moderboard: AK75-ec from dfi.com Cpu: Amd athlon 1300Mhz memory: 512 sdram Some time the FX5200 works good, but many times it hangs when i am trying to play some

  • "LayoutTagLibrary" tag error in JSP file .

    Dear All, I am trying to implement Custom Framework Page in SAP NW Portal 7.3 with the help of the [DOCUMENT|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/001bfa1a-958e-2e10-c2be-d914f673e21e?QuickLink=index&overridelayout=true]

  • How to create an input template/sheet to a summary spreadsheet

    I've done this type of sheet in excel and access years ago, but have no clue on how to do it in numbers. Example, I have a spreadsheet that summarizes specific actions for specific individuals in a specific event over the course of many events. What