Search Results

Search found 1594 results on 64 pages for 'initialization'.

Page 11/64 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • What should I use for the .SWF path in FlowPlayer's configuration if I'm developing from my desktop?

    - by codeninja
    I'm having an extremely difficulty time getting the flowplayer to show up and the worst part is I have no idea what is wrong because I'm not getting any error messages! I have an external javascript file: C:/desktop/mysite/js/jq/plugins.js calling $f() from: C:/desktop/mysite/thirdparty/flowplayer/flowplayer.js the swf files also live there... I'm working on file/desktop (no localhost or webserver) $(video.id).flowplayer("thirdparty/flowplayer/flowplayer-3.1.15.swf", { clip:{ .... }, // min Flash version version:[9,115], // older versions will see a custom message onFail:function(){ alert("Failed!"); }, onError:function(errCode,errMsg){ alert(errCode+errMsg); } }); I don't know what path to use for the SWFs to get them to load, is the path relative to the javascript (plugins.js) that calls $f() or is it relative to the path of the flowplayer.js ?? bangs head on wall

    Read the article

  • Why do I get a NullPointerException when initializing Spring

    - by niklassaers
    Hi guys, I've got a problem running a batch job on my server, whereas it runs fine from Eclipse on my development workstation. I've got my Spring environment set up using Roo, made an entity, and make a batch that does some work, and test it well on my develompent box. I initialize my context and do the work, but when I run my batch on the server, the context isn't initialized properly. Here's the code: public class TestBatch { private static ApplicationContext context; @SuppressWarnings("unchecked") public static void main(final String[] args) { context = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml"); try { @SuppressWarnings("unused") TestBatch app = new TestBatch(); } catch (Exception ex) { ex.printStackTrace(); } } public void TestBatch() { /** Do Something using the context **/ } } And here's the log and exception: 2010-02-16 11:54:16,072 [main] INFO org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6037fb1e: startup date [Tue Feb 16 11:54:16 CET 2010]; root of context hierarchy Exception in thread "main" java.lang.ExceptionInInitializerError at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:194) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:127) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:458) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:388) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at tld.mydomain.myproject.batch.TestBatch.main(TestBatch.java:51) Caused by: java.lang.NullPointerException at org.springframework.beans.factory.support.DefaultListableBeanFactory.<clinit>(DefaultListableBeanFactory.java:103) ... 7 more Any idea or hints as to what's going on? My classpath is set to $PROJECTHOME/target/classes, and all my dependencies are in $PROJECTHOME/target/lib, and I execute using "export CLASSPATH=$PROJECTHOME/target/classes; java -Djava.endorsed.dirs=$PROJECTHOME/target/lib tld.mydomain.myproject.batch.TestBatch" Is there anything in my setup that looks very wrong? When I run this from Eclipse, no problems, but when I deploy it on the server where I want to run it and run it as described above, I get this problem. Because it runs from Eclipse, I believe my config files are all right, but how can I debug what's causing this? Perhaps I have some config errors or a mismatch between the server and the development workstation after all? Or is this a really weird way of saying file not found, and if so, how do I make sure it finds the correct file?? I'm really looking forward to hearing your suggestions as to how to tackle this problem. Cheers Nik

    Read the article

  • Java: why is declaration not sufficient in interface?

    - by HH
    Big class contains Format-interfcase and Format-class. The Format-class contains the methods and the interface has the values of the fields. I could have the fields in the class Format but the goal is with Interface. So do I just create dummy-vars to get the errors away, design issue or something ELSE? KEY: Declaration VS Initialisation Explain by the terms, why you have to init in interface. What is the logic behind it? To which kind of problems it leads the use of interface? Sample Code having the init-interface-problem import java.util.*; import java.io.*; public class FormatBig { private static class Format implements Format { private static long getSize(File f){return f.length();} private static long getTime(File f){return f.lastModified();} private static boolean isFile(File f){if(f.isFile()){return true;}} private static boolean isBinary(File f){return Match.isBinary(f);} private static char getType(File f){return Match.getTypes(f);} private static String getPath(File f){return getNoErrPath(f);} //Java API: isHidden, --- SYSTEM DEPENDED: toURI, toURL Format(File f) { // PUZZLE 0: would Stack<Object> be easier? size=getSize(f); time=getTime(f); isfile=isFile(f); isBinary=isBinary(f); type=getType(f); path=getPath(f); //PUZZLE 1: how can simplify the assignment? values.push(size); values.push(time); values.push(isfile); values.push(isBinary); values.push(type); values.push(path); } } public static String getNoErrPath(File f) { try{return f.getCanonicalPath(); }catch(Exception e){e.printStackTrace();} } public static final interface Format { //ERR: IT REQUIRES "=" public long size; public long time; public boolean isFile=true; //ERROR goes away if I initialise wit DUMMY public boolean isBinary; public char type; public String path; Stack<Object> values=new Stack<Object>(); } public static void main(String[] args) { Format fm=new Format(new File(".")); for(Object o:values){System.out.println(o);} } }

    Read the article

  • 'Set = new HashSet' or 'HashSet = new Hashset'?

    - by Pureferret
    I'm intialising a HashSet like so in my program: Set<String> namesFilter = new HashSet<String>(); Is this functionally any different if I initilise like so? HashSet<String> namesFilter = new HashSet<String>(); I've read this about the collections interface, and I understand interfaces (well, except their use here). I've read this excerpt from Effective Java, and I've read this SO question, but I feel none the wiser. Is there a best practice in Java, and if so, why? My intuition is that it makes casting to a different type of Set easier in my first example. But then again, you'd only be casting to something that was a collection, and you could convert it by re-constructing it.

    Read the article

  • How do I intiailize the vector I have defined in my header file?

    - by FrankTheTank
    I have the following in my Puzzle.h class Puzzle { private: vector<int> puzzle; public: Puzzle() : puzzle (16) {} bool isSolved(); void shuffle(vector<int>& ); }; and then my Puzzle.cpp looks like: Puzzle::Puzzle() { // Initialize the puzzle (0,1,2,3,...,14,15) for(int i = 0; i <= puzzle.size(); i++) { puzzle[i] = i; } } // ... other methods Am I using the initiailizer list wrong in my header file? I would like to define a vector of ints and initialize its size to that of 16. How should I do this? G++ Output: Puzzle.cpp:16: error: expected unqualified-id before ')' token Puzzle.cpp: In constructor `Puzzle::Puzzle()': Puzzle.cpp:16: error: expected `)' at end of input Puzzle.cpp:16: error: expected `{' at end of input Puzzle.cpp: At global scope: Puzzle.cpp:24: error: redefinition of `Puzzle::Puzzle()' Puzzle.cpp:16: error: `Puzzle::Puzzle()' previously defined here

    Read the article

  • Init modules in apache2

    - by user306963
    Hello, I used to write apache modules in apache 1.3, but these days I am willing to pass to apache2. The module that I am writing at the moment has is own binary data, not a database, for performance purposes. I need to load this data in shared memory, so every child can access it without making his own copy, and it would be practical to load/create the binary data at startup, as I was used to do with apache 1.3. Problem is that I don't find an init event in apache2, in 1.3 in the module struct, immediatly after STANDARD_MODULE_STUFF you find a place for a /** module initializer */, in which you can put a function that will be executed early. Body of the function I used to write is something like: if ( getppid == 1 ) { // Load global data here // this is the parent process void* data = loadGlobalData( someFilePath ); setGlobalData( config, data ); } else { // this is the init of a child process // do nothing } I am looking for a place in apache2 in where I can put a similar function. Can you help? Thanks Benvenuto

    Read the article

  • AES Cipher not picking up IV

    - by timothyjc
    I am trying to use an IV with AES so that the encrypted text is unpredictable. However, the encrypted hex string is always the same. I have actually tried a few methods of attempting to add some randomness by passing some additional parameters to the cipher init call: 1) Manual IV generation byte[] iv = generateIv(); IvParameterSpec ivspec = new IvParameterSpec(iv); 2) Asking cipher to generate IV AlgorithmParameters params = cipher.getParameters(); params.getParameterSpec(IvParameterSpec.class); 3) Using a PBEParameterSpec byte[] encryptionSalt = generateSalt(); PBEParameterSpec pbeParamSpec = new PBEParameterSpec(encryptionSalt, 1000); All of these seem to have no influence on the encrypted text.... help!!! My code: package com.citc.testencryption; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Main extends Activity { public static final int SALT_LENGTH = 20; public static final int PBE_ITERATION_COUNT = 1000; private static final String RANDOM_ALGORITHM = "SHA1PRNG"; private static final String PBE_ALGORITHM = "PBEWithSHA256And256BitAES-CBC-BC"; private static final String CIPHER_ALGORITHM = "PBEWithSHA256And256BitAES-CBC-BC"; private static final String TAG = Main.class.getSimpleName(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { String password = "password"; String plainText = "plaintext message to be encrypted"; // byte[] salt = generateSalt(); byte[] salt = "dfghjklpoiuytgftgyhj".getBytes(); Log.i(TAG, "Salt: " + salt.length + " " + HexEncoder.toHex(salt)); PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(), salt, PBE_ITERATION_COUNT); SecretKeyFactory keyFac = SecretKeyFactory.getInstance(PBE_ALGORITHM); SecretKey secretKey = keyFac.generateSecret(pbeKeySpec); byte[] key = secretKey.getEncoded(); Log.i(TAG, "Key: " + HexEncoder.toHex(key)); // PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, ITERATION_COUNT); Cipher encryptionCipher = Cipher.getInstance(CIPHER_ALGORITHM); // byte[] encryptionSalt = generateSalt(); // Log.i(TAG, "Encrypted Salt: " + encryptionSalt.length + " " + HexEncoder.toHex(encryptionSalt)); // PBEParameterSpec pbeParamSpec = new PBEParameterSpec(encryptionSalt, 1000); // byte[] iv = params.getParameterSpec(IvParameterSpec.class).getIV(); // Log.i(TAG, encryptionCipher.getParameters() + " "); byte[] iv = generateIv(); IvParameterSpec ivspec = new IvParameterSpec(iv); encryptionCipher.init(Cipher.ENCRYPT_MODE, secretKey, ivspec); byte[] encryptedText = encryptionCipher.doFinal(plainText.getBytes()); Log.i(TAG, "Encrypted: " + HexEncoder.toHex(encryptedText)); // <== Why is this always the same :( Cipher decryptionCipher = Cipher.getInstance(CIPHER_ALGORITHM); decryptionCipher.init(Cipher.DECRYPT_MODE, secretKey, ivspec); byte[] decryptedText = decryptionCipher.doFinal(encryptedText); Log.i(TAG, "Decrypted: " + new String(decryptedText)); } catch (Exception e) { e.printStackTrace(); } } private byte[] generateSalt() throws NoSuchAlgorithmException { SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM); byte[] salt = new byte[SALT_LENGTH]; random.nextBytes(salt); return salt; } private byte[] generateIv() throws NoSuchAlgorithmException { SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM); byte[] iv = new byte[16]; random.nextBytes(iv); return iv; } }

    Read the article

  • How to set global variables to use everywhere in my application?

    - by user502052
    I am using Ruby on Rails 3 and I would like to set some global variable to use those everywhere in my application. In particular, the domain name. If, for example, my website URL is http://subname.domain.com I would like to set or retrieve the subname.domain.com value in order to use that in my application like this request_uri = "http://#{sub_domain_name}" Where and how I have to state\initialize the sub_domain_name variable or other variables at all?

    Read the article

  • Java: how to initialize int without assigning a value?

    - by HH
    $ javac InitInt.java InitInt.java:9: '[' expected right = new int; ^ InitInt.java:9: ']' expected right = new int; ^ InitInt.java:13: ';' expected } ^ InitInt.java:14: ';' expected public int getRight(){return right;} ^ InitInt.java:15: reached end of file while parsing } ^ 5 errors $ cat InitInt.java import java.util.*; import java.io.*; public class InitInt { private final int right; public static void main(String[] args) { // I don't want to assign any value. // just initialize it, how? right = new int; // later assiging a value } public int getRight(){return right;} }

    Read the article

  • C# Initialize Subclass based on Parent object

    - by ctrlShiftBryan
    So basically I have this public class Ticket{ public TicketNumber {get; set;} ..a bunch more properties... } I want to add some properties using a subclass like this using subsumption instead of composition. public class TicketViewModel(Ticket ticket){ //set each property from value of Ticket passed in this.TicketNumber = ticket.TicketNumber; ...a bunch more lines of code.. //additional VM properties public SelectList TicketTypes {get; private set;} } How do I instantiate the properties without having to write all the lines like this this.TicketNumber = ticket.TicketNumber; Is there some kind of shortcut? Something like in the subclass constructor? this = ticket; Obviously this doesn't work but is their some way so I don't have to modify my subclass if addng/removing a property to the parent class? Or something?

    Read the article

  • Please explain this python behavior

    - by StackUnderflow
    class SomeClass(object): def __init__(self, key_text_pairs = None): ..... for key, text in key_text_pairs: ...... ...... x = SomeClass([1, 2, 3]) The value of key_text_pairs inside the init is None even if I pass a list as in the above statement. Why is it so?? I want to write a generic init which can take all iterator objects... Thanks

    Read the article

  • main vs initialize in Ruby

    - by Dave
    Okay, so I've looked through a couple of my ruby books and done some googling to no avail. What is the difference between main and initialize in Ruby? I've seen code that uses class Blahblah def main some logic here end #more methods... end and then calls it using Blahblah.new. Isn't new reserved only for initialize? if not, then what's the difference between the two?

    Read the article

  • How to initialize a web app?

    - by Gatis
    My Web App will be deployed as a WAR package in a Jetty instance. It needs to perform a lot of caching before serving requests. How do I call the caching method before anything else? is the a static void main() in the web app standard?

    Read the article

  • Managing Instances in Python

    - by BeensTheGreat
    Hello, I am new to Python and this is my first time asking a stackOverflow question, but a long time reader. I am working on a simple card based game but am having trouble managing instances of my Hand class. If you look below you can see that the hand class is a simple container for cards(which are just int values) and each Player class contains a hand class. However, whenever I create multiple instances of my Player class they all seem to manipulate a single instance of the Hand class. From my experience in C and Java it seems that I am somehow making my Hand class static. If anyone could help with this problem I would appreciate it greatly. Thank you, Thad To clarify: An example of this situation would be p = player.Player() p1 = player.Player() p.recieveCard(15) p1.recieveCard(21) p.viewHand() which would result in: [15,21] even though only one card was added to p Hand class: class Hand: index = 0 cards = [] #Collections of cards #Constructor def __init__(self): self.index self.cards def addCard(self, card): """Adds a card to current hand""" self.cards.append(card) return card def discardCard(self, card): """Discards a card from current hand""" self.cards.remove(card) return card def viewCards(self): """Returns a collection of cards""" return self.cards def fold(self): """Folds the current hand""" temp = self.cards self.cards = [] return temp Player Class import hand class Player: name = "" position = 0 chips = 0 dealer = 0 pHand = [] def __init__ (self, nm, pos, buyIn, deal): self.name = nm self.position = pos self.chips = buyIn self.dealer = deal self.pHand = hand.Hand() return def recieveCard(self, card): """Recieve card from the dealer""" self.pHand.addCard(card) return card def discardCard(self, card): """Throw away a card""" self.pHand.discardCard(card) return card def viewHand(self): """View the players hand""" return self.pHand.viewCards() def getChips(self): """Get the number of chips the player currently holds""" return self.chips def setChips(self, chip): """Sets the number of chips the player holds""" self.chips = chip return def makeDealer(self): """Makes this player the dealer""" self.dealer = 1 return def notDealer(self): """Makes this player not the dealer""" self.dealer = 0 return def isDealer(self): """Returns flag wether this player is the dealer""" return self.dealer def getPosition(self): """Returns position of the player""" return self.position def getName(self): """Returns name of the player""" return self.name

    Read the article

  • Reinitialize the current month name, when i click button

    - by EswaraMoorthyNEC
    Hi,In my richCalendar.jsp page, first time i click the showCurrentMonth button and display the current month using rich:calendar. i select some other month i click SelectedMonth button. I show the selected month name. My problem is : I go to any other page. then i come visit the richCalendar.jsp and again click showCurrentMonth button, this time the rich:calendar show the already selected month instead of current month . Each time, i want to show current month when i click showCurrentMonth. richCalendar.jsp <body> <h:form id="calendarForm" binding="#{CalenderBean.initForm}"> <rich:panel> <a4j:outputPanel id="calendarOutputPanel"> <h:panelGrid> <a4j:commandButton value="showCurrentMonth" action="#{CalenderBean.showCurrentMonthAction}" reRender="monthlyPanelGridId,monthlyCalendarId,calendarOutputPanel"/> <h:panelGrid id="monthlyPanelGridId" rendered="#{CalenderBean.monthlyCalendarRendered}" > <rich:calendar boundaryDatesMode="scroll" id="monthlyCalendarId" showWeekDaysBar="false" oncurrentdateselected="event.rich.component.selectDate(event.rich.date)" showFooter="false" popup="false" value="#{CalenderBean.selectedMonth}"/> </h:panelGrid> <h:panelGrid id = "SearchButtonGrid"> <a4j:commandButton id="SelectedMonth" value="SelectedMonth" action="#{CalenderBean.selectedMonthButtonAction}" reRender="calendarOutputPanel"/> <h:outputText value="#{CalenderBean.selectedMonthName}" /> </h:panelGrid> </h:panelGrid> </a4j:outputPanel> <rich:panel></h:form></body> CalenderBean.java import java.util.Calendar; import java.util.Date; import javax.faces.component.html.HtmlForm; public class CalenderBean { private HtmlForm initForm; private boolean monthlyCalendarRendered; private Date selectedMonth; private String selectedMonthName; public CalenderBean() { } public String showCurrentMonthAction() { monthlyCalendarRendered = true; Calendar calendar = Calendar.getInstance(); int startingDate = calendar.getActualMinimum(Calendar.DAY_OF_MONTH); calendar.set(Calendar.DATE, startingDate); selectedMonth = calendar.getTime(); return ""; } public String selectedMonthButtonAction() { selectedMonthName = selectedMonth.toString(); return ""; } public HtmlForm getInitForm() { selectedMonth = null; monthlyCalendarRendered = false; return initForm; } public void setInitForm(HtmlForm initForm){ this.initForm = initForm; } public boolean isMonthlyCalendarRendered(){ return monthlyCalendarRendered; } public void setMonthlyCalendarRendered(boolean monthlyCalendarRendered){ this.monthlyCalendarRendered = monthlyCalendarRendered; } public Date getSelectedMonth(){ return selectedMonth; } public void setSelectedMonth(Date selectedMonth){ this.selectedMonth = selectedMonth; } public String getSelectedMonthName(){ return selectedMonthName; } public void setSelectedMonthName(String selectedMonthName){ this.selectedMonthName = selectedMonthName; } } First time i visit this page perfectly show the current month. Then i go to any othe page and then come to see this page, click showCurrentMonth button not show the current month. Help me. Thanks in advance.

    Read the article

  • Java: 2-assignments-2-initializations inside for-loop not allowed?

    - by HH
    $ javac MatchTest.java MatchTest.java:7: ')' expected for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) ^ MatchTest.java:7: ';' expected for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) ^ MatchTest.java:7: ';' expected for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) ^ MatchTest.java:7: not a statement for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) ^ MatchTest.java:7: illegal start of expression for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) ^ 5 errors $ cat MatchTest.java import java.util.*; import java.io.*; public class MatchTest { public static void main(String[] args){ String text = "hello0123456789hello0123456789hello1234567890hello3423243423232"; for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);) System.out.println(i); } }

    Read the article

  • - Default value of variables at the time of declaration -

    - by gotye
    Hey guys, I was wondering what was the default values of variables before I intialize them .. For example, if I do : //myClass.h BOOL myBOOL; // default value ? NSArray *myArray; // default value ? NSUInteger myInteger; // default value ? Some more examples here : //myClass.m // myArray is not initialized, only declared in .h file if ([myArray count] == 0) { // TRUE or FALSE ? // do whatever } More generally, what is returned when I do : [myObjectOnlyDeclaredAndNotInitialized myCustomFunction]; Thank you for your answers. Gotye.

    Read the article

  • initialising a 2-dim Array in Scala

    - by Stefan W.
    (Scala 2.7.7:) I don't get used to 2d-Arrays. Arrays are mutable, but how do I specify a 2d-Array which is - let's say of size 3x4. The dimension (2D) is fixed, but the size per dimension shall be initializable. I tried this: class Field (val rows: Int, val cols: Int, sc: java.util.Scanner) { var field = new Array [Char](rows)(cols) for (r <- (1 to rows)) { val line = sc.nextLine () val spl = line.split (" ") field (r) = spl.map (_.charAt (0)) } def put (val rows: Int, val cols: Int, c: Char) = todo () } I get this error: :11: error: value update is not a member of Char field (r) = spl.map (_.charAt (0)) If it would be Java, it would be much more code, but I would know how to do it, so I show what I mean: public class Field { private char[][] field; public Field (int rows, int cols, java.util.Scanner sc) { field = new char [rows][cols]; for (int r = 0; r < rows; ++r) { String line = sc.nextLine (); String[] spl = line.split (" "); for (int c = 0; c < cols; ++c) field [r][c] = spl[c].charAt (0); } } public static void main (String args[]) { new Field (3, 4, new java.util.Scanner ("fraese.fld")); } } and fraese.fld would look, for example, like that: M M M M . M I get some steps wide with val field = new Array Array [Char] but how would I then implement 'put'? Or is there a better way to implement the 2D-Array. Yes, I could use a one-dim-Array, and work with put (y, x, c) = field (y * width + x) = c but I would prefer a notation which looks more 2d-ish.

    Read the article

  • Initialize window code Mac OS X

    - by Jarle
    I'm currently reading "the red book" for learning OpenGL properly, and in one of the first examples, the author writes a line that says "InitializeAWindowPlease();" as a place holder for the code that will make a window to draw the OpenGL content in. Since I'm using Xcode for my programing, I know that I "get" a window to work with automatically (and that I have to make my own OpenGL view in interfacebuilder). How can I make this with pure code? I'm trying to learn programming, and I'm not to happy about taking "shortcuts" all the time. How can I make a window to draw my openGL stuff in? With Objective-C and C code I would love to see it. My goal is that I can make it without opening interface builder at all:)

    Read the article

  • iPhone init method return type

    - by William Jockusch
    Suppose we are writing a class (let's call it Class) in an iPhone program. In all the samples out there, the init methods are typically declared like this: -(id) initWithFoo: (Foo *) foo My question is: would it be more logical to do the following? Why or why not? -(Class *) initWithFoo: (Foo *) foo

    Read the article

  • Java: Initializing a public static field in superclass that needs a different value in every subclas

    - by BinaryMuse
    Good evening, I am developing a set of Java classes so that a container class Box contains a List of a contained class Widget. A Widget needs to be able to specify relationships with other Widgets. I figured a good way to do this would be to do something like this: public abstract class Widget { public static class WidgetID { // implementation stolen from Google's GWT private static int nextHashCode; private final int index; public WidgetID() { index = ++nextHashCode; } public final int hashCode() { return index; } } public abstract WidgetID getWidgetID(); } so sublcasses of Widget could: public class BlueWidget extends Widget { public static final WidgetID WIDGETID = new WidgetID(); @Override public WidgetID getWidgetID() { return WIDGETID; } } Now, BlueWidget can do getBox().addWidgetRelationship(RelationshipTypes.SomeType, RedWidget.WIDGETID, and Box can iterate through it's list comparing the second parameter to iter.next().getWidgetID(). Now, all this works great so far. What I'm trying to do is keep from having to declare the public static final WidgetID WIDGETID in all the subclasses and implement it instead in the parent Widget class. The problem is, if I move that line of code into Widget, then every instance of a subclass of Widget appears to get the same static final WidgetID for their Subclassname.WIDGETID. However, making it non-static means I can no longer even call Subclassname.WIDGETID. So: how do I create a static WidgetID in the parent Widget class while ensuring it is different for every instance of Widget and subclasses of Widget? Or am I using the wrong tool for the job here? Thanks!

    Read the article

  • log4net initialisation

    - by Ruben Bartelink
    I've looked hard for duplicates but have to ask the following, no matter how basic it may seem, to get it clear once and for all! In a fresh Console app using log4net version 1.2.10.0 on VS28KSP1 on 64 bit W7, I have the following code:- using log4net; using log4net.Config; namespace ConsoleApplication1 { class Program { static readonly ILog _log = LogManager.GetLogger(typeof(Program)); static void Main(string[] args) { _log.Info("Ran"); } } } In my app.config, I have: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> <log4net> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="Program.log" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="1MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="[%username] %date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <root> <level value="DEBUG" /> <appender-ref ref="RollingFileAppender" /> </root> </log4net> </configuration> This doesnt write anything, unless I either add an attribute: [ assembly:XmlConfigurator ] Or explicitly initialise it in Main(): _log.Info("This will not go to the log"); XmlConfigurator.Configure(); _log.Info("Ran"); This raises the following questions: I'm almost certain I've seen it working somewhere on some version of log4net without the addition of the assembly attribute or call in Main. Can someone assure me I'm not imagining that? Can someone please point me to where in the doc it explicitly states that both the config section and the initialisation hook are required - hopefully with an explanation of when this changed, if it did? I can easily imagine why this might be the policy -- having the initialisation step explicit to avoid surprises etc., it's just that I seem to recall this not always being the case... (And normally I have the config in a separate file, which generally takes configsections out of the picture)

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >